summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-07-20 00:58:11 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-07-20 00:58:11 (GMT)
commitbabb3bb4bb0de6cd2129d29fd6a90695bcbd53e2 (patch)
treec0a44c57e54e77dd31e2a68959e03256124cdfbd /src/declarative
parent45cbfefe9d68152841beb6474c94eece0a085eb5 (diff)
parent1dc2e92b4630a0c19d1d2bdf5a05cd18003c566a (diff)
downloadQt-babb3bb4bb0de6cd2129d29fd6a90695bcbd53e2.zip
Qt-babb3bb4bb0de6cd2129d29fd6a90695bcbd53e2.tar.gz
Qt-babb3bb4bb0de6cd2129d29fd6a90695bcbd53e2.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/canvas/canvas.pri19
-rw-r--r--src/declarative/canvas/qsimplecanvas.cpp1034
-rw-r--r--src/declarative/canvas/qsimplecanvas.h173
-rw-r--r--src/declarative/canvas/qsimplecanvas_graphicsview.cpp219
-rw-r--r--src/declarative/canvas/qsimplecanvas_opengl.cpp680
-rw-r--r--src/declarative/canvas/qsimplecanvas_opengl1.cpp401
-rw-r--r--src/declarative/canvas/qsimplecanvas_p.h207
-rw-r--r--src/declarative/canvas/qsimplecanvas_software.cpp232
-rw-r--r--src/declarative/canvas/qsimplecanvasdebugplugin.cpp155
-rw-r--r--src/declarative/canvas/qsimplecanvasdebugplugin_p.h85
-rw-r--r--src/declarative/canvas/qsimplecanvasfilter.cpp323
-rw-r--r--src/declarative/canvas/qsimplecanvasfilter.h113
-rw-r--r--src/declarative/canvas/qsimplecanvasfilter_p.h70
-rw-r--r--src/declarative/canvas/qsimplecanvasitem.cpp1885
-rw-r--r--src/declarative/canvas/qsimplecanvasitem.h335
-rw-r--r--src/declarative/canvas/qsimplecanvasitem_p.h270
-rw-r--r--src/declarative/declarative.pro5
-rw-r--r--src/declarative/extra/extra.pri2
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.h2
-rw-r--r--src/declarative/extra/qfxblendedimage.cpp308
-rw-r--r--src/declarative/extra/qfxblendedimage.h111
-rw-r--r--src/declarative/extra/qfxparticles.cpp150
-rw-r--r--src/declarative/extra/qfxparticles.h11
-rw-r--r--src/declarative/extra/qmlbehaviour.cpp26
-rw-r--r--src/declarative/extra/qmlbehaviour.h8
-rw-r--r--src/declarative/extra/qmlfolderlistmodel.cpp4
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp3
-rw-r--r--src/declarative/extra/qmlxmllistmodel.h2
-rw-r--r--src/declarative/fx/fx.pri21
-rw-r--r--src/declarative/fx/qfxanchors.cpp14
-rw-r--r--src/declarative/fx/qfxblurfilter.cpp467
-rw-r--r--src/declarative/fx/qfxblurfilter.h83
-rw-r--r--src/declarative/fx/qfxcomponentinstance.h2
-rw-r--r--src/declarative/fx/qfxflickable.cpp5
-rw-r--r--src/declarative/fx/qfxflickable.h2
-rw-r--r--src/declarative/fx/qfxflipable.cpp24
-rw-r--r--src/declarative/fx/qfxflipable.h7
-rw-r--r--src/declarative/fx/qfxfocuspanel.h81
-rw-r--r--src/declarative/fx/qfxgraphicsobjectcontainer.cpp (renamed from src/declarative/fx/qfxfocuspanel.cpp)68
-rw-r--r--src/declarative/fx/qfxgraphicsobjectcontainer.h (renamed from src/declarative/fx/qfxwidgetcontainer.h)28
-rw-r--r--src/declarative/fx/qfxgridview.cpp4
-rw-r--r--src/declarative/fx/qfxgridview.h2
-rw-r--r--src/declarative/fx/qfxhighlightfilter.cpp320
-rw-r--r--src/declarative/fx/qfxhighlightfilter.h99
-rw-r--r--src/declarative/fx/qfximage.cpp456
-rw-r--r--src/declarative/fx/qfximage.h17
-rw-r--r--src/declarative/fx/qfximage_p.h22
-rw-r--r--src/declarative/fx/qfxitem.cpp712
-rw-r--r--src/declarative/fx/qfxitem.h162
-rw-r--r--src/declarative/fx/qfxitem_p.h48
-rw-r--r--src/declarative/fx/qfxkeyactions.cpp2
-rw-r--r--src/declarative/fx/qfxkeyproxy.cpp120
-rw-r--r--src/declarative/fx/qfxkeyproxy.h2
-rw-r--r--src/declarative/fx/qfxlayouts.cpp24
-rw-r--r--src/declarative/fx/qfxlayouts.h2
-rw-r--r--src/declarative/fx/qfxlineedit.cpp518
-rw-r--r--src/declarative/fx/qfxlineedit.h188
-rw-r--r--src/declarative/fx/qfxlineedit_p.h (renamed from src/declarative/opengl/glsave.h)95
-rw-r--r--src/declarative/fx/qfxlistview.cpp3
-rw-r--r--src/declarative/fx/qfxlistview.h2
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp52
-rw-r--r--src/declarative/fx/qfxmouseregion.h4
-rw-r--r--src/declarative/fx/qfxmouseregion_p.h5
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp47
-rw-r--r--src/declarative/fx/qfxpainteditem.h6
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h9
-rw-r--r--src/declarative/fx/qfxpath.cpp1
-rw-r--r--src/declarative/fx/qfxpathview.cpp5
-rw-r--r--src/declarative/fx/qfxpathview.h2
-rw-r--r--src/declarative/fx/qfxpathview_p.h2
-rw-r--r--src/declarative/fx/qfxpixmap.cpp1
-rw-r--r--src/declarative/fx/qfxpixmap.h3
-rw-r--r--src/declarative/fx/qfxrect.cpp356
-rw-r--r--src/declarative/fx/qfxrect.h10
-rw-r--r--src/declarative/fx/qfxrect_p.h10
-rw-r--r--src/declarative/fx/qfxreflectionfilter.cpp352
-rw-r--r--src/declarative/fx/qfxreflectionfilter.h97
-rw-r--r--src/declarative/fx/qfxrepeater.cpp5
-rw-r--r--src/declarative/fx/qfxrepeater.h4
-rw-r--r--src/declarative/fx/qfxscalegrid.h1
-rw-r--r--src/declarative/fx/qfxshadowfilter.cpp214
-rw-r--r--src/declarative/fx/qfxshadowfilter.h87
-rw-r--r--src/declarative/fx/qfxtext.cpp128
-rw-r--r--src/declarative/fx/qfxtext.h7
-rw-r--r--src/declarative/fx/qfxtext_p.h7
-rw-r--r--src/declarative/fx/qfxtextedit.cpp35
-rw-r--r--src/declarative/fx/qfxtextedit.h3
-rw-r--r--src/declarative/fx/qfxtextedit_p.h5
-rw-r--r--src/declarative/fx/qfxtransform.cpp113
-rw-r--r--src/declarative/fx/qfxtransform.h27
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp1
-rw-r--r--src/declarative/fx/qfxwebview.cpp61
-rw-r--r--src/declarative/fx/qfxwebview.h6
-rw-r--r--src/declarative/fx/qfxwidgetcontainer.cpp108
-rw-r--r--src/declarative/opengl/glbasicshaders.cpp707
-rw-r--r--src/declarative/opengl/glbasicshaders.h243
-rw-r--r--src/declarative/opengl/glheaders.h49
-rw-r--r--src/declarative/opengl/glsave.cpp1
-rw-r--r--src/declarative/opengl/gltexture.cpp384
-rw-r--r--src/declarative/opengl/gltexture.h120
-rw-r--r--src/declarative/opengl/opengl.pri20
-rw-r--r--src/declarative/qml/parser/qmljs.g101
-rw-r--r--src/declarative/qml/parser/qmljsgrammar.cpp1857
-rw-r--r--src/declarative/qml/parser/qmljsgrammar_p.h33
-rw-r--r--src/declarative/qml/parser/qmljsparser.cpp1001
-rw-r--r--src/declarative/qml/parser/qmljsparser_p.h41
-rw-r--r--src/declarative/qml/qml.h7
-rw-r--r--src/declarative/qml/qml.pri7
-rw-r--r--src/declarative/qml/qmlbasicscript.cpp79
-rw-r--r--src/declarative/qml/qmlbasicscript_p.h2
-rw-r--r--src/declarative/qml/qmlcompiledcomponent.cpp96
-rw-r--r--src/declarative/qml/qmlcompileddata.cpp205
-rw-r--r--src/declarative/qml/qmlcompiler.cpp1914
-rw-r--r--src/declarative/qml/qmlcompiler_p.h149
-rw-r--r--src/declarative/qml/qmlcomponent.cpp16
-rw-r--r--src/declarative/qml/qmlcomponent.h4
-rw-r--r--src/declarative/qml/qmlcomponent_p.h4
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp10
-rw-r--r--src/declarative/qml/qmlcompositetypemanager_p.h8
-rw-r--r--src/declarative/qml/qmlcontext.cpp66
-rw-r--r--src/declarative/qml/qmlcontext.h5
-rw-r--r--src/declarative/qml/qmlcontext_p.h1
-rw-r--r--src/declarative/qml/qmldeclarativedata_p.h4
-rw-r--r--src/declarative/qml/qmldom.cpp10
-rw-r--r--src/declarative/qml/qmldom.h2
-rw-r--r--src/declarative/qml/qmlengine.cpp382
-rw-r--r--src/declarative/qml/qmlengine.h8
-rw-r--r--src/declarative/qml/qmlengine_p.h3
-rw-r--r--src/declarative/qml/qmlerror.cpp29
-rw-r--r--src/declarative/qml/qmlerror.h2
-rw-r--r--src/declarative/qml/qmlexpression.cpp79
-rw-r--r--src/declarative/qml/qmlexpression_p.h4
-rw-r--r--src/declarative/qml/qmlinstruction.cpp37
-rw-r--r--src/declarative/qml/qmlinstruction_p.h24
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp27
-rw-r--r--src/declarative/qml/qmlmetatype.cpp2
-rw-r--r--src/declarative/qml/qmlparser.cpp51
-rw-r--r--src/declarative/qml/qmlparser_p.h39
-rw-r--r--src/declarative/qml/qmlrewrite.cpp157
-rw-r--r--src/declarative/qml/qmlrewrite_p.h (renamed from src/declarative/qml/qmlcompiledcomponent_p.h)65
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp50
-rw-r--r--src/declarative/qml/qmlvme.cpp107
-rw-r--r--src/declarative/qml/qmlvme_p.h6
-rw-r--r--src/declarative/qml/qmlvmemetaobject.cpp11
-rw-r--r--src/declarative/qml/qmlvmemetaobject_p.h10
-rw-r--r--src/declarative/test/qfxtestengine.cpp463
-rw-r--r--src/declarative/test/qfxtestengine.h85
-rw-r--r--src/declarative/test/qfxtestobjects.cpp354
-rw-r--r--src/declarative/test/qfxtestobjects.h211
-rw-r--r--src/declarative/test/qfxtestview.cpp82
-rw-r--r--src/declarative/test/qfxtestview.h73
-rw-r--r--src/declarative/test/test.pri9
-rw-r--r--src/declarative/util/qfxglobal.h30
-rw-r--r--src/declarative/util/qfxview.cpp113
-rw-r--r--src/declarative/util/qfxview.h9
-rw-r--r--src/declarative/util/qmlpalette.cpp35
-rw-r--r--src/declarative/util/qmlpalette.h34
-rw-r--r--src/declarative/util/qmltransitionmanager.cpp9
158 files changed, 5092 insertions, 16861 deletions
diff --git a/src/declarative/canvas/canvas.pri b/src/declarative/canvas/canvas.pri
deleted file mode 100644
index 9bdd3fa..0000000
--- a/src/declarative/canvas/canvas.pri
+++ /dev/null
@@ -1,19 +0,0 @@
-SOURCES += \
- canvas/qsimplecanvas.cpp \
- canvas/qsimplecanvasitem.cpp \
- canvas/qsimplecanvasfilter.cpp \
- canvas/qsimplecanvasdebugplugin.cpp
-
-HEADERS += \
- canvas/qsimplecanvas.h \
- canvas/qsimplecanvasitem.h \
- canvas/qsimplecanvasfilter.h \
- canvas/qsimplecanvas_p.h \
- canvas/qsimplecanvasitem_p.h \
- canvas/qsimplecanvasfilter_p.h \
- canvas/qsimplecanvasdebugplugin_p.h
-
-contains(QT_CONFIG, opengles2): SOURCES += canvas/qsimplecanvas_opengl.cpp
-else:contains(QT_CONFIG, opengles1): SOURCES += canvas/qsimplecanvas_opengl1.cpp
-else:SOURCES += canvas/qsimplecanvas_software.cpp
-SOURCES += canvas/qsimplecanvas_graphicsview.cpp
diff --git a/src/declarative/canvas/qsimplecanvas.cpp b/src/declarative/canvas/qsimplecanvas.cpp
deleted file mode 100644
index 3e586f7..0000000
--- a/src/declarative/canvas/qsimplecanvas.cpp
+++ /dev/null
@@ -1,1034 +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 "qwidget.h"
-#include "qmutex.h"
-#include "qdebug.h"
-#include "qcoreapplication.h"
-#include "qsimplecanvasitem.h"
-#include "qsimplecanvasitem_p.h"
-#include "qsimplecanvas_p.h"
-#include "qtimer.h"
-#include "qdatetime.h"
-#include "qgraphicssceneevent.h"
-#if defined(QFX_RENDER_OPENGL)
-#include <glheaders.h>
-#endif
-#include "qboxlayout.h"
-#include "qsimplecanvasdebugplugin_p.h"
-#include "qsimplecanvas.h"
-
-
-QT_BEGIN_NAMESPACE
-DEFINE_BOOL_CONFIG_OPTION(fullUpdate, GFX_CANVAS_FULL_UPDATE);
-DEFINE_BOOL_CONFIG_OPTION(continuousUpdate, GFX_CANVAS_CONTINUOUS_UPDATE);
-DEFINE_BOOL_CONFIG_OPTION(useSimpleCanvas, QFX_USE_SIMPLECANVAS);
-
-template<class T, int s = 60>
-class CircularList
-{
-public:
- CircularList()
- : _first(0), _size(0) {}
-
- void append(const T &t)
- {
- int entry = (_first + _size) % s;
- _array[entry] = t;
- if (_size == s)
- _first = (_first + 1) % s;
- else
- _size++;
- }
-
- int size() const
- {
- return _size;
- }
-
- T &operator[](int idx)
- {
- Q_ASSERT(idx < _size);
- int entry = (_first + idx) % s;
- return _array[entry];
- }
-
- void clear()
- {
- _first = 0;
- _size = 0;
- }
-private:
- int _first;
- int _size;
- T _array[s];
-};
-
-
-class QSimpleCanvasRootLayer : public QSimpleCanvasLayer
-{
-public:
- QSimpleCanvasRootLayer(QSimpleCanvas *);
- virtual void addDirty(QSimpleCanvasItem *);
- virtual void remDirty(QSimpleCanvasItem *);
-
-private:
- friend class QSimpleCanvasItem;
- QSimpleCanvas *_canvas;
-};
-
-void QSimpleCanvasRootLayer::addDirty(QSimpleCanvasItem *i)
-{
- _canvas->addDirty(i);
-}
-
-void QSimpleCanvasRootLayer::remDirty(QSimpleCanvasItem *i)
-{
- _canvas->remDirty(i);
-}
-
-void QSimpleCanvasPrivate::clearFocusPanel(QSimpleCanvasItem *panel)
-{
- if (q->activeFocusPanel() == panel) {
- focusPanels.pop();
-
- switchToFocusPanel(q->activeFocusPanel(), panel, Qt::OtherFocusReason);
- panel->activePanelOutEvent();
- } else {
- for (int ii = 0; ii < focusPanels.count(); ++ii)
- if (focusPanels.at(ii) == panel) {
- focusPanels.remove(ii);
- break;
- }
- }
-}
-
-void QSimpleCanvasPrivate::switchToFocusPanel(QSimpleCanvasItem *panel, QSimpleCanvasItem *wasPanel, Qt::FocusReason focusReason)
-{
- if (panel)
- panel->activePanelInEvent();
-
- QSimpleCanvasItem *wasFocusRoot = focusPanelData.value(wasPanel);
- if (wasFocusRoot)
- clearActiveFocusItem(wasFocusRoot, focusReason);
-
- QSimpleCanvasItem *newFocusRoot = focusPanelData.value(panel);
- if (newFocusRoot)
- setFocusItem(newFocusRoot, focusReason);
-}
-
-void QSimpleCanvasPrivate::setActiveFocusPanel(QSimpleCanvasItem *panel, Qt::FocusReason focusReason)
-{
- if (q->activeFocusPanel() == panel)
- return;
-
- if (panel) {
- for (int ii = 0; ii < focusPanels.count(); ++ii)
- if (focusPanels.at(ii) == panel) {
- focusPanels.remove(ii);
- break;
- }
- }
- QSimpleCanvasItem *old = q->activeFocusPanel();
- if (panel)
- focusPanels << panel;
- switchToFocusPanel(panel, old, focusReason);
- if (old)
- old->activePanelOutEvent();
-}
-
-void QSimpleCanvasPrivate::clearActiveFocusItem(QSimpleCanvasItem *item,
- Qt::FocusReason focusReason)
-{
- if (!item || !item->d_func())
- return;
-
- if (!item->d_func()->hasActiveFocus)
- return;
-
- item->d_func()->hasActiveFocus = false;
- if (item->options() & QSimpleCanvasItem::IsFocusRealm) {
- QSimpleCanvasItem *newItem = focusPanelData.value(item);
- if (newItem) {
- clearActiveFocusItem(newItem, focusReason);
- } else {
- focusItem = 0;
- QFocusEvent event(QEvent::FocusOut, focusReason);
- item->focusOutEvent(&event);
- }
- } else {
- focusItem = 0;
- QFocusEvent event(QEvent::FocusOut, focusReason);
- item->focusOutEvent(&event);
- }
-
- if (item->options() & QSimpleCanvasItem::AcceptsInputMethods){
- if (q->testAttribute(Qt::WA_InputMethodEnabled))
- q->setAttribute(Qt::WA_InputMethodEnabled,false);
- }
- item->activeFocusChanged(true);
-}
-
-void QSimpleCanvasPrivate::setActiveFocusItem(QSimpleCanvasItem *item,
- Qt::FocusReason focusReason)
-{
- while(true) {
- item->d_func()->setActiveFocus(true);
- item->activeFocusChanged(true);
- if (item->options() & QSimpleCanvasItem::IsFocusRealm) {
- QSimpleCanvasItem *newItem = focusPanelData.value(item);
- if (newItem)
- item = newItem;
- else
- break;
- } else {
- break;
- }
- }
-
- if (item->options() & QSimpleCanvasItem::AcceptsInputMethods){
- if (!q->testAttribute(Qt::WA_InputMethodEnabled))
- q->setAttribute(Qt::WA_InputMethodEnabled,true);
- }
- focusItem = item;
- QFocusEvent event(QEvent::FocusIn, focusReason);
- focusItem->focusInEvent(&event);
-}
-
-void QSimpleCanvasPrivate::clearFocusItem(QSimpleCanvasItem *item)
-{
- // XXX
-#if 0
- while(item->focusProxy())
- item = item->focusProxy();
-#endif
-
- QSimpleCanvasItem *scope = 0;
- QSimpleCanvasItem *citem = item;
- while(citem && !scope) {
- if (citem->options() & QSimpleCanvasItem::IsFocusPanel)
- scope = citem;
- else if (citem != item && citem->options() & QSimpleCanvasItem::IsFocusRealm)
- scope = citem;
- citem = citem->parent();
- }
- Q_ASSERT(scope); // At the very least we'll find the canvas root
-
- bool isActive = false;
-
- if (scope->options() & QSimpleCanvasItem::IsFocusPanel)
- isActive = (scope == q->activeFocusPanel());
- else if (scope->options() & QSimpleCanvasItem::IsFocusRealm)
- isActive = scope->hasActiveFocus();
-
- if (isActive) clearActiveFocusItem(item, Qt::OtherFocusReason);
- item->d_func()->setFocus(false);
- item->focusChanged(false);
-
- focusPanelData.insert(scope, 0);
-
- if (lastFocusItem == item)
- lastFocusItem = 0;
- if (focusItem == item)
- focusItem = 0;
-
- if (scope->options() & QSimpleCanvasItem::IsFocusRealm && scope->hasActiveFocus()) {
- setActiveFocusItem(scope, Qt::OtherFocusReason);
- } else {
- QSimpleCanvasItem *item = QSimpleCanvasItem::findNextFocus(scope);
- if (item)
- item->setFocus(true);
- }
-}
-
-void QSimpleCanvasPrivate::setFocusItem(QSimpleCanvasItem *item,
- Qt::FocusReason focusReason,
- bool overwrite)
-{
- Q_ASSERT(item);
-
- // XXX
-#if 0
- while(item->focusProxy())
- item = item->focusProxy();
-#endif
-
- if (item == focusItem)
- return;
-
- QSimpleCanvasItem *scope = 0;
- QSimpleCanvasItem *citem = item;
- while(citem && !scope) {
- if (citem->options() & QSimpleCanvasItem::IsFocusPanel)
- scope = citem;
- else if (citem != item && citem->options() & QSimpleCanvasItem::IsFocusRealm)
- scope = citem;
- citem = citem->parent();
- }
- Q_ASSERT(scope); // At the very least we'll find the canvas root
-
- if (!overwrite && focusPanelData.contains(scope)) {
- item->d_func()->setFocus(false);
- item->focusChanged(false);
- return;
- }
-
- QSimpleCanvasItem *oldFocus = focusPanelData.value(scope);
- bool isActive = false;
-
- if (scope->options() & QSimpleCanvasItem::IsFocusPanel)
- isActive = (scope == q->activeFocusPanel());
- else if (scope->options() & QSimpleCanvasItem::IsFocusRealm)
- isActive = scope->hasActiveFocus();
-
- if (oldFocus) {
- if (isActive) clearActiveFocusItem(oldFocus, focusReason);
- oldFocus->d_func()->setFocus(false);
- oldFocus->focusChanged(false);
- }
-
- focusPanelData.insert(scope, item);
-
- if (isActive)
- lastFocusItem = item;
-
- if (item) {
- item->d_func()->setFocus(true);
- item->focusChanged(true);
- if (isActive)
- setActiveFocusItem(item, focusReason);
- }
-}
-
-
-bool QSimpleCanvas::eventFilter(QObject *obj, QEvent *event)
-{
- Q_UNUSED(obj);
- switch (event->type()) {
- case QEvent::GraphicsSceneMouseMove: {
- QGraphicsSceneMouseEvent *me = (QGraphicsSceneMouseEvent*)event;
- if (!me->buttons())
- break;
- }
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease: {
- //same logic as filter() function
- for (int ii = 0; ii < d->mouseFilters.count(); ++ii) {
- if (d->mouseFilters.at(ii)->mouseFilter((QGraphicsSceneMouseEvent*)event))
- return true;
- }
- break;
- }
- default:
- break;
- }
- return false;
-}
-
-void QSimpleCanvasPrivate::installMouseFilter(QSimpleCanvasItem *item)
-{
- mouseFilters << item;
-}
-
-void QSimpleCanvasPrivate::removeMouseFilter(QSimpleCanvasItem *item)
-{
- mouseFilters.removeAll(item);
-}
-
-bool QSimpleCanvasPrivate::filter(QMouseEvent *e)
-{
- if (mouseFilters.isEmpty())
- return false;
-
- QGraphicsSceneMouseEvent *me = mouseEventToSceneMouseEvent(e, e->pos());
- for (int ii = 0; ii < mouseFilters.count(); ++ii) {
- if (mouseFilters.at(ii)->mouseFilter(me)) {
- delete me;
- return true;
- }
- }
- delete me;
- return false;
-}
-
-QGraphicsSceneMouseEvent *QSimpleCanvasPrivate::mouseEventToSceneMouseEvent(QMouseEvent *e, const QPoint &item)
-{
- QEvent::Type t;
- switch(e->type()) {
- default:
- case QEvent::MouseButtonPress:
- t = QEvent::GraphicsSceneMousePress;
- break;
- case QEvent::MouseButtonRelease:
- t = QEvent::GraphicsSceneMouseRelease;
- break;
- case QEvent::MouseMove:
- t = QEvent::GraphicsSceneMouseMove;
- break;
- case QEvent::MouseButtonDblClick:
- t = QGraphicsSceneEvent::GraphicsSceneMouseDoubleClick;
- break;
- }
-
- QGraphicsSceneMouseEvent *me = new QGraphicsSceneMouseEvent(t);
- me->setButton(e->button());
- me->setButtons(e->buttons());
- me->setModifiers(e->modifiers());
- me->setPos(item);
- me->setScreenPos(e->pos());
- me->setScenePos(e->pos());
- return me;
-}
-
-bool QSimpleCanvasPrivate::deliverMousePress(QSimpleCanvasItem *base, QMouseEvent *e, bool seenChildFilter)
-{
- if (base->clipType()) {
- QRectF br = base->boundingRect();
- QPointF pos = base->mapFromScene(e->pos());
- if (!br.contains(pos.toPoint()))
- return false;
- }
-
- const QList<QSimpleCanvasItem *> &children = base->d_func()->children;
-
- if (base->options() & QSimpleCanvasItem::ChildMouseFilter)
- seenChildFilter = true;
-
- for (int ii = children.count() - 1; ii >= 0; --ii) {
- if (children.at(ii)->visible() != 0.)
- if (deliverMousePress(children.at(ii), e, seenChildFilter))
- return true;
- }
-
- if (base->acceptedMouseButtons() & e->button() || base->options() & QSimpleCanvasItem::ChildMouseFilter) {
-
- QRectF br = base->boundingRect();
- QPoint pos = base->mapFromScene(e->pos()).toPoint();
-
- if (br.contains(pos)) {
- QGraphicsSceneMouseEvent *me = mouseEventToSceneMouseEvent(e, pos);
-
- sendMouseEvent(base, me);
- bool isAccepted = me->isAccepted();
- delete me;
- if (isAccepted) {
- lastMouseItem = base;
- return true;
- }
- }
- }
- return false;
-}
-
-// Delivers e to item
-void QSimpleCanvasPrivate::sendMouseEvent(QSimpleCanvasItem *item, QGraphicsSceneMouseEvent *e)
-{
- QSimpleCanvasItem *p = item->parent();
- while(p) {
- if (p->options() & QSimpleCanvasItem::ChildMouseFilter) {
- if (p->mouseFilter(e))
- return;
- }
- p = p->parent();
- }
- switch(e->type()) {
- case QEvent::GraphicsSceneMousePress:
- item->mousePressEvent(e);
- break;
- case QEvent::GraphicsSceneMouseRelease:
- item->mouseReleaseEvent(e);
- break;
- case QEvent::GraphicsSceneMouseMove:
- item->mouseMoveEvent(e);
- break;
- case QEvent::GraphicsSceneMouseDoubleClick:
- item->mouseDoubleClickEvent(e);
- break;
- default:
- break;
- }
-}
-
-
-QSimpleCanvasRootLayer::QSimpleCanvasRootLayer(QSimpleCanvas *c)
-: _canvas(c)
-{
- QSimpleCanvasItem::d_func()->canvas = c;
- setOptions(IsFocusPanel);
- update();
-}
-
-
-struct QSimpleCanvasTiming
-{
- QSimpleCanvasTiming()
- : time(-1), paintTime(-1), timeBetweenFrames(-1) {}
- QSimpleCanvasTiming(const QRegion &_r, int _time, int _paintTime,
- int _timeBetweenFrames)
- : region(_r), time(_time), paintTime(_paintTime),
- timeBetweenFrames(_timeBetweenFrames) {}
- QSimpleCanvasTiming(const QSimpleCanvasTiming &other)
- : region(other.region), time(other.time), paintTime(other.paintTime),
- timeBetweenFrames(other.timeBetweenFrames) {}
- QSimpleCanvasTiming &operator=(const QSimpleCanvasTiming &other) {
- region = other.region; time = other.time; paintTime = other.paintTime;
- timeBetweenFrames = other.timeBetweenFrames; return *this;
- }
- QRegion region;
- int time;
- int paintTime;
- int timeBetweenFrames;
-};
-
-// XXX
-static CircularList<QSimpleCanvasTiming> gfxCanvasTiming;
-
-void QSimpleCanvasGraphicsView::paintEvent(QPaintEvent *pe)
-{
- QRegion r = pe->region();
- int tbf = canvas->frameTimer.restart();
-
- canvas->lrpTimer.start();
- QGraphicsView::paintEvent(pe);
- canvas->lrpTime = canvas->lrpTimer.elapsed();
-
- int frametimer = canvas->frameTimer.elapsed();
- gfxCanvasTiming.append(QSimpleCanvasTiming(r, frametimer, canvas->lrpTime, tbf));
- canvas->lrpTime = 0;
- if (canvas->debugPlugin)
- canvas->debugPlugin->addTiming(canvas->lrpTime, frametimer, tbf);
-}
-
-void QSimpleCanvasGraphicsView::focusInEvent(QFocusEvent *)
-{
-}
-
-/*!
- \internal
- \class QSimpleCanvas
- \brief The QSimpleCanvas class implements the canvas used by Qt Declarative
- */
-
-QSimpleCanvas::QSimpleCanvas(CanvasMode mode, QWidget *parent)
-: QWidget(parent), d(new QSimpleCanvasPrivate(this))
-{
- d->init(mode);
-}
-
-QSimpleCanvas::QSimpleCanvas(QWidget *parent)
-: QWidget(parent), d(new QSimpleCanvasPrivate(this))
-{
- d->init(useSimpleCanvas()?SimpleCanvas:GraphicsView);
-}
-
-void QSimpleCanvasPrivate::init(QSimpleCanvas::CanvasMode mode)
-{
- this->mode = mode;
-
- if (mode == QSimpleCanvas::SimpleCanvas)
- qWarning("QSimpleCanvas: Using simple canvas");
- else
- qWarning("QSimpleCanvas: Using GraphicsView canvas");
-
- if (fullUpdate())
- qWarning("QSimpleCanvas: Full update enabled");
- if (continuousUpdate())
- qWarning("QSimpleCanvas: Continuous update enabled");
-
- if (QmlDebugService::isDebuggingEnabled()) {
- debugPlugin = new QSimpleCanvasDebugPlugin(q);
- new QSimpleCanvasSceneDebugPlugin(q);
- }
-
- root = new QSimpleCanvasRootLayer(q);
- root->setActiveFocusPanel(true);
- q->setFocusPolicy(Qt::StrongFocus);
-
- if (mode == QSimpleCanvas::GraphicsView) {
- view = new QSimpleCanvasGraphicsView(this);
- QHBoxLayout *layout = new QHBoxLayout(q);
- layout->setSpacing(0);
- layout->setContentsMargins(0, 0, 0, 0);
- q->setLayout(layout);
- layout->addWidget(view);
- view->setOptimizationFlags(QGraphicsView::DontSavePainterState);
- view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- view->setFrameStyle(0);
- static_cast<QSimpleCanvasItemPrivate*>(root->d_ptr)->convertToGraphicsItem();
- view->scene()->addItem(static_cast<QSimpleCanvasItemPrivate*>(root->d_ptr)->graphicsItem);
-
- // These seem to give the best performance
- view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- view->scene()->setItemIndexMethod(QGraphicsScene::NoIndex);
- view->viewport()->setFocusPolicy(Qt::NoFocus);
- }
-
-#if defined(QFX_RENDER_OPENGL) && defined(Q_WS_X11)
- QTimer *t = new QTimer(q);
- t->setInterval(200);
- QObject::connect(t, SIGNAL(timeout()), &egl, SLOT(updateGL()));
- t->start();
-#endif
-}
-
-QSimpleCanvas::~QSimpleCanvas()
-{
- delete d->root;
- delete d;
-}
-
-void QSimpleCanvasPrivate::paint(QPainter &p)
-{
-#if defined(QFX_RENDER_QPAINTER)
- if (!isSetup) {
- ++paintVersion;
- root->d_func()->setupPainting(0, q->rect());
- }
-
- lrpTimer.start();
-
- root->d_func()->paint(p);
-
- lrpTime = lrpTimer.elapsed();
-#else
- Q_UNUSED(p);
-#endif
-}
-
-QSimpleCanvas::CanvasMode QSimpleCanvas::canvasMode() const
-{
- return d->mode;
-}
-
-QSimpleCanvasItem *QSimpleCanvas::root()
-{
- return d->root;
-}
-
-void QSimpleCanvas::keyPressEvent(QKeyEvent *event)
-{
- if (d->focusItem)
- d->focusItem->keyPressEvent(event);
- QWidget::keyPressEvent(event);
-}
-
-void QSimpleCanvas::keyReleaseEvent(QKeyEvent *event)
-{
- if (d->focusItem)
- d->focusItem->keyReleaseEvent(event);
- QWidget::keyReleaseEvent(event);
-}
-
-void QSimpleCanvas::inputMethodEvent(QInputMethodEvent *event)
-{
- if (d->focusItem)
- d->focusItem->inputMethodEvent(event);
- else
- QWidget::inputMethodEvent(event);
-}
-
-QVariant QSimpleCanvas::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- if (d->focusItem)
- return d->focusItem->inputMethodQuery(query);
- return QWidget::inputMethodQuery(query);
-}
-
-void QSimpleCanvas::mousePressEvent(QMouseEvent *e)
-{
- if (d->isSimpleCanvas() &&
- (d->filter(e) || d->deliverMousePress(d->root, e))) {
- e->accept();
- } else {
- QWidget::mousePressEvent(e);
- }
-}
-
-void QSimpleCanvas::mouseDoubleClickEvent(QMouseEvent *e)
-{
- if (d->isSimpleCanvas() &&
- (d->filter(e) || d->deliverMousePress(d->root, e))) {
- e->accept();
- } else {
- QWidget::mouseDoubleClickEvent(e);
- }
-}
-
-void QSimpleCanvas::mouseMoveEvent(QMouseEvent *e)
-{
- if (d->isSimpleCanvas() && d->filter(e)) {
- e->accept();
- } else if (d->isSimpleCanvas() && d->lastMouseItem) {
- QPoint p = d->lastMouseItem->mapFromScene(e->pos()).toPoint();
- QGraphicsSceneMouseEvent *me = d->mouseEventToSceneMouseEvent(e, p);
- d->sendMouseEvent(d->lastMouseItem, me);
- e->setAccepted(me->isAccepted());
- delete me;
- } else {
- QWidget::mouseMoveEvent(e);
- }
-}
-
-void QSimpleCanvas::mouseReleaseEvent(QMouseEvent *e)
-{
- if (d->isSimpleCanvas() && d->filter(e)) {
- e->accept();
- } else if (d->isSimpleCanvas() && d->lastMouseItem) {
- QPoint p = d->lastMouseItem->mapFromScene(e->pos()).toPoint();
- QGraphicsSceneMouseEvent *me = d->mouseEventToSceneMouseEvent(e, p);
- d->sendMouseEvent(d->lastMouseItem, me);
- d->lastMouseItem->mouseUngrabEvent();
- e->setAccepted(me->isAccepted());
- delete me;
- d->lastMouseItem = 0;
- } else {
- QWidget::mouseReleaseEvent(e);
- }
-}
-
-void QSimpleCanvas::focusInEvent(QFocusEvent *event)
-{
- // XXX
-#if 0
- if (d->lastFocusItem && event->reason() == Qt::ActiveWindowFocusReason) {
- d->setFocusItem(d->lastFocusItem, event->reason());
- } else {
- QSimpleCanvasItem *panel = activeFocusPanel();
- QSimpleCanvasItem *focusItem = 0;
- if (panel->isFocusable())
- focusItem = panel;
- else
- focusItem = QSimpleCanvasItem::findNextFocus(panel);
-
- if (focusItem)
- d->setFocusItem(focusItem, event->reason());
- else
- QWidget::focusNextPrevChild(true);
- }
-#endif
- QWidget::focusInEvent(event);
-}
-
-void QSimpleCanvas::focusOutEvent(QFocusEvent *event)
-{
- // XXX
-#if 0
- if (event->reason() == Qt::ActiveWindowFocusReason) {
- d->lastFocusItem = activeFocusPanel();
- d->setActiveFocusPanel(0, Qt::ActiveWindowFocusReason);
- }
-#endif
- QWidget::focusOutEvent(event);
-}
-
-bool QSimpleCanvas::focusNextPrevChild(bool)
-{
- // XXX
-#if 0
- if (d->focusItem) {
- QSimpleCanvasItem *item = next ? QSimpleCanvasItem::findNextFocus(d->focusItem) : QSimpleCanvasItem::findPrevFocus(d->focusItem);
- if (item) {
- d->setFocusItem(item,
- next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
- return true;
- }
- }
-
- QSimpleCanvasItem *panel = activeFocusPanel();
- QSimpleCanvasItem *item = 0;
- if (panel->isFocusable())
- item = panel;
- else
- item = next ? QSimpleCanvasItem::findNextFocus(panel) : QSimpleCanvasItem::findPrevFocus(panel);
- if (item && item != d->focusItem) {
- d->setFocusItem(item,
- next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
- return true;
- }
-
- if (d->focusItem)
- d->setActiveFocusPanel(0, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
-
-#endif
- return false;
-}
-
-
-void QSimpleCanvas::showEvent(QShowEvent *e)
-{
-#if defined(QFX_RENDER_OPENGL)
- d->egl.resize(width(), height());
-#endif
- if (d->isGraphicsView())
- d->view->setSceneRect(rect());
-
- QWidget::showEvent(e);
-}
-
-void QSimpleCanvas::resizeEvent(QResizeEvent *e)
-{
-#if defined(QFX_RENDER_OPENGL)
- d->egl.resize(width(), height());
-#endif
- if (d->isGraphicsView())
- d->view->setSceneRect(rect());
- QWidget::resizeEvent(e);
-}
-
-
-void QSimpleCanvas::remDirty(QSimpleCanvasItem *c)
-{
- d->dirtyItems.removeAll(c);
-}
-
-void QSimpleCanvas::queueUpdate()
-{
- if (!d->timer) {
- QCoreApplication::postEvent(this, new QEvent(QEvent::User));
- d->timer = 1;
- }
-}
-
-void QSimpleCanvas::addDirty(QSimpleCanvasItem *c)
-{
- Q_ASSERT(d->isSimpleCanvas());
- queueUpdate();
- d->oldDirty |= c->d_func()->data()->lastPaintRect;
-#if defined(QFX_RENDER_OPENGL)
- // ### Is this parent crawl going to be a problem for scenes with nots
- // of things changing?
- // Check for filters
- QSimpleCanvasItem *fi = c->parent();
- while(fi) {
- if (fi->d_func()->data()->dirty) {
- break;
- } else if (fi->filter()) {
- fi->update();
- break;
- }
- fi = fi->parent();
- }
-#endif
- d->dirtyItems.append(c);
-}
-
-QRect QSimpleCanvasPrivate::dirtyItemClip() const
-{
- QRect rv;
- if (isSimpleCanvas()) {
-#if defined(QFX_RENDER_OPENGL)
- QRectF r;
- for (int ii = 0; ii < dirtyItems.count(); ++ii)
- r |= dirtyItems.at(ii)->d_func()->data()->lastPaintRect;
- rv = egl.map(r);
-#else
- for (int ii = 0; ii < dirtyItems.count(); ++ii)
- rv |= dirtyItems.at(ii)->d_func()->data()->lastPaintRect;
-#endif
- }
- return rv;
-}
-
-QRect QSimpleCanvasPrivate::resetDirty()
-{
- if (isSimpleCanvas()) {
-#if defined(QFX_RENDER_OPENGL)
- QRect r = egl.map(oldDirty) | dirtyItemClip();
-#else
- QRect r = oldDirty | dirtyItemClip();
-#endif
- if (!r.isEmpty())
- r.adjust(-1,-1,2,2); //make sure we get everything (since we rounded from floats to ints)
- for (int ii = 0; ii < dirtyItems.count(); ++ii)
- static_cast<QSimpleCanvasItemPrivate*>(dirtyItems.at(ii)->d_ptr)->data()->dirty = false;
- dirtyItems.clear();
- oldDirty = QRect();
-
- /*if (fullUpdate())
- return QRect();
- else*/
- return r;
- } else {
- return QRect();
- }
-}
-
-QSimpleCanvasItem *QSimpleCanvas::focusItem() const
-{
- return d->focusItem;
-}
-
-QSimpleCanvasItem *QSimpleCanvas::activeFocusPanel() const
-{
- if (d->focusPanels.isEmpty())
- return 0;
- else
- return d->focusPanels.top();
-}
-
-QSimpleCanvasItem *QSimpleCanvas::focusItem(QSimpleCanvasItem *item) const
-{
- while (item && d->focusPanelData.contains(item))
- item = d->focusPanelData.value(item);
- return item;
-}
-
-bool QSimpleCanvas::event(QEvent *e)
-{
- if (e->type() == QEvent::User && d->isSimpleCanvas()) {
- int tbf = d->frameTimer.restart();
- d->timer = 0;
- d->isSetup = true;
-#if defined(QFX_RENDER_OPENGL1)
- unsigned int zero = 0;
- d->root->d_func()->setupPainting(0, rect(), &zero);
-#elif defined(QFX_RENDER_OPENGL2)
- ++d->paintVersion;
- d->opaqueList = 0;
- int z = 0;
- d->root->d_func()->setupPainting(0, z, &d->opaqueList);
-#else
- ++d->paintVersion;
- d->root->d_func()->setupPainting(0, rect());
-#endif
-
- QRect r = d->resetDirty();
-
-#if defined(QFX_RENDER_QPAINTER)
- if (fullUpdate())
- repaint();
- else
- repaint(r);
- emit framePainted();
-#else
-
- QRect nr(r.x(), height() - r.y() - r.height(), r.width(), r.height());
-
- if (r.isEmpty() || fullUpdate())
- d->egl.updateGL();
- else
- d->egl.updateGL(nr);
- emit framePainted();
-#endif
- d->isSetup = false;
-
- int frametimer = d->frameTimer.elapsed();
- gfxCanvasTiming.append(QSimpleCanvasTiming(r, frametimer, d->lrpTime, tbf));
- if (d->debugPlugin)
- d->debugPlugin->addTiming(d->lrpTime, frametimer, tbf);
- d->lrpTime = 0;
- if (continuousUpdate())
- queueUpdate();
-
- return true;
- }
-
- if (e->type() == QEvent::ShortcutOverride) {
- if (QSimpleCanvasItem *focus = focusItem())
- return focus->event(e);
- }
-
- return QWidget::event(e);
-}
-
-void QSimpleCanvas::paintEvent(QPaintEvent *)
-{
-#if defined(QFX_RENDER_QPAINTER)
- if (d->mode == SimpleCanvas) {
- QPainter p(this);
- d->paint(p);
- }
-#endif
-}
-
-void QSimpleCanvas::dumpTiming()
-{
- for (int ii = 0; ii < gfxCanvasTiming.size(); ++ii) {
- const QSimpleCanvasTiming &t = gfxCanvasTiming[ii];
-
- qreal repaintFps = 1000. / qreal(t.time);
- qreal paintFps = 1000. / qreal(t.paintTime);
- qreal tbfFps = 1000. / qreal(t.timeBetweenFrames);
-
- qWarning() << "repaint():" << t.time << "ms," << repaintFps << "fps. paint():" << t.paintTime << "ms," << paintFps << "fps. timeSinceLastFrame:" << t.timeBetweenFrames << "ms," << tbfFps << "fps.";
- qWarning() << t.region;
- }
- gfxCanvasTiming.clear();
-}
-
-void QSimpleCanvas::dumpItems()
-{
- int items = d->root->d_func()->dump(0);
- qWarning() << "Total:" << items;
-}
-
-void QSimpleCanvas::checkState()
-{
- if (d->isSimpleCanvas()) {
- QSimpleCanvasItemPrivate::FocusStateCheckRDatas r;
- if (d->root->d_func()->checkFocusState(0, &r))
- qWarning() << "State OK";
- }
-}
-
-/*!
- Returns canvas as an image. Not a fast operation.
-*/
-QImage QSimpleCanvas::asImage() const
-{
- if (d->isSimpleCanvas()) {
-#if defined(QFX_RENDER_QPAINTER)
- QImage img(width(),height(),QImage::Format_RGB32);
- QPainter p(&img);
- const_cast<QSimpleCanvas*>(this)->d->paint(p);
- return img;
-#elif defined(QFX_RENDER_OPENGL)
- return d->egl.grabFrameBuffer();
-#endif
- } else {
- QImage img(width(),height(),QImage::Format_RGB32);
- QPainter p(&img);
- d->view->render(&p);
- return img;
- }
-}
-QT_END_NAMESPACE
diff --git a/src/declarative/canvas/qsimplecanvas.h b/src/declarative/canvas/qsimplecanvas.h
deleted file mode 100644
index 1cbd3c7..0000000
--- a/src/declarative/canvas/qsimplecanvas.h
+++ /dev/null
@@ -1,173 +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 QSIMPLECANVAS_H
-#define QSIMPLECANVAS_H
-
-#include <QtDeclarative/qfxglobal.h>
-
-#ifdef QFX_RENDER_OPENGL
-#include <QtGui/qmatrix4x4.h>
-#endif
-
-#include <QtGui/QTransform>
-#include <QtGui/QPainter>
-#include <QtCore/QDebug>
-#include <QtGui/QWidget>
-#include <QtGui/QImage>
-#include <QtGui/QKeyEvent>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-namespace QSimpleCanvasConfig
-{
- enum ImageType { Opaque, Translucent };
-
-#ifdef QFX_RENDER_OPENGL
- typedef QMatrix4x4 Matrix;
- typedef QImage Image;
-
- inline Matrix transformToMatrix(const QTransform &)
- {
- return Matrix(); // XXX
- }
- inline QTransform matrixToTransform(const Matrix &)
- {
- return QTransform(); // XXX
- }
- inline bool needConvert(ImageType, const Image &)
- { return false; }
- inline Image convert(ImageType, const Image &i)
- { return i; }
- inline Image create(const QSize &s)
- { return QImage(s, QImage::Format_ARGB32); }
- inline const Image &toImage(const QImage &i)
- { return i; }
-
-#elif defined(QFX_RENDER_QPAINTER)
- typedef QTransform Matrix;
-
- inline Matrix transformToMatrix(const QTransform &t)
- { return t; }
- inline QTransform matrixToTransform(const Matrix &t)
- { return t; }
-#endif
-}
-
-class QSimpleCanvas;
-class QSimpleCanvasLayer;
-
-class QGraphicsSceneMouseEvent;
-class GLBasicShaders;
-class QSimpleCanvasItem;
-class QSimpleCanvasPrivate;
-class Q_DECLARATIVE_EXPORT QSimpleCanvas : public QWidget
-{
-Q_OBJECT
-public:
- typedef QSimpleCanvasConfig::Matrix Matrix;
-
- enum CanvasMode { GraphicsView, SimpleCanvas };
-
- QSimpleCanvas(QWidget *parent = 0);
- QSimpleCanvas(CanvasMode, QWidget *parent = 0);
- virtual ~QSimpleCanvas();
-
- CanvasMode canvasMode() const;
-
- QSimpleCanvasItem *root();
-
- // Debugging
- void dumpTiming();
- void dumpItems();
- void checkState();
-
- QSimpleCanvasItem *focusItem() const;
- QSimpleCanvasItem *focusItem(QSimpleCanvasItem *item) const;
-
- QSimpleCanvasItem *activeFocusPanel() const;
- QImage asImage() const;
-
-Q_SIGNALS:
- void framePainted();
-
-protected:
- virtual bool event(QEvent *);
- virtual void paintEvent(QPaintEvent *);
- virtual void keyPressEvent(QKeyEvent *);
- virtual void keyReleaseEvent(QKeyEvent *);
- virtual void mousePressEvent(QMouseEvent *);
- virtual void mouseDoubleClickEvent(QMouseEvent *);
- virtual void mouseMoveEvent(QMouseEvent *);
- virtual void mouseReleaseEvent(QMouseEvent *);
- virtual void focusInEvent(QFocusEvent *event);
- virtual void focusOutEvent(QFocusEvent *event);
- virtual bool focusNextPrevChild(bool next);
- virtual bool eventFilter(QObject *obj, QEvent *event);
- virtual void inputMethodEvent(QInputMethodEvent *event);
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
-
- virtual void showEvent(QShowEvent *);
- virtual void resizeEvent(QResizeEvent *);
-private:
-
- friend class QSimpleCanvasRootLayer;
- friend class QSimpleCanvasPrivate;
- friend class QSimpleCanvasItem;
- friend class QSimpleCanvasItemPrivate;
- friend class QSimpleCanvasFilter;
- friend class QSimpleGraphicsItem;
-
- void queueUpdate();
- QSimpleCanvasPrivate *d;
- void addDirty(QSimpleCanvasItem *);
- void remDirty(QSimpleCanvasItem *);
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif
diff --git a/src/declarative/canvas/qsimplecanvas_graphicsview.cpp b/src/declarative/canvas/qsimplecanvas_graphicsview.cpp
deleted file mode 100644
index d9ff39b..0000000
--- a/src/declarative/canvas/qsimplecanvas_graphicsview.cpp
+++ /dev/null
@@ -1,219 +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 "qsimplecanvas.h"
-#include "qsimplecanvas_p.h"
-#include "qsimplecanvasitem.h"
-#include "qsimplecanvasitem_p.h"
-#include <QGraphicsItem>
-#include <QGraphicsSceneMouseEvent>
-
-
-QT_BEGIN_NAMESPACE
-static QHash<QGraphicsScene*,QSimpleCanvas*> sceneMap;
-
-QSimpleCanvasGraphicsView::QSimpleCanvasGraphicsView(QSimpleCanvasPrivate *parent)
-: QGraphicsView(parent->q), canvas(parent)
-{
- setScene(&_scene);
- sceneMap[&_scene] = parent->q;
- setFrameShape(QFrame::NoFrame);
- viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
-}
-
-QSimpleCanvasGraphicsView::~QSimpleCanvasGraphicsView()
-{
- sceneMap.remove(&_scene);
-}
-
-void QSimpleCanvasGraphicsView::resizeEvent(QResizeEvent *e)
-{
- _scene.setSceneRect(QRect(QPoint(0, 0), e->size()));
- QGraphicsView::resizeEvent(e);
-}
-
-QSimpleGraphicsItem::QSimpleGraphicsItem(QSimpleCanvasItem *canvasItem)
-: /*scene(0),*/ owner(canvasItem)
-{
- setAcceptedMouseButtons(Qt::NoButton);
-}
-
-QSimpleGraphicsItem::~QSimpleGraphicsItem()
-{
- owner->d_func()->graphicsItem = 0;
-}
-
-void QSimpleGraphicsItem::paint(QPainter *painter,
- const QStyleOptionGraphicsItem *, QWidget *)
-{
- owner->paintContents(*painter);
-}
-
-QRectF QSimpleGraphicsItem::boundingRect() const
-{
- return owner->boundingRect();
-}
-
-void QSimpleGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- QSimpleCanvasItem *p = owner->parent();
- while(p) {
- if (p->options() & QSimpleCanvasItem::ChildMouseFilter) {
- if (p->mouseFilter(event))
- return;
- }
- p = p->parent();
- }
- owner->mousePressEvent(event);
-}
-
-void QSimpleGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- QSimpleCanvasItem *p = owner->parent();
- while(p) {
- if (p->options() & QSimpleCanvasItem::ChildMouseFilter) {
- if (p->mouseFilter(event))
- return;
- }
- p = p->parent();
- }
- owner->mouseReleaseEvent(event);
- ungrabMouse();
-}
-
-void QSimpleGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- QSimpleCanvasItem *p = owner->parent();
- while(p) {
- if (p->options() & QSimpleCanvasItem::ChildMouseFilter) {
- if (p->mouseFilter(event))
- return;
- }
- p = p->parent();
- }
- owner->mouseDoubleClickEvent(event);
-}
-
-void QSimpleGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- QSimpleCanvasItem *p = owner->parent();
- while(p) {
- if (p->options() & QSimpleCanvasItem::ChildMouseFilter) {
- if (p->mouseFilter(event))
- return;
- }
- p = p->parent();
- }
- owner->mouseMoveEvent(event);
-}
-
-bool QSimpleGraphicsItem::sceneEvent(QEvent *event)
-{
- bool rv = QGraphicsItem::sceneEvent(event);
- if (event->type() == QEvent::UngrabMouse)
- owner->mouseUngrabEvent();
- return rv;
-}
-
-QVariant QSimpleGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value)
-{
- if (change == ItemSceneHasChanged) {
- QSimpleCanvasItemPrivate *owner_d = static_cast<QSimpleCanvasItemPrivate*>(owner->d_ptr);
- QSimpleCanvas *oldCanvas = owner_d->canvas;
- owner_d->canvas = sceneMap[scene()];
- if (owner_d->canvas){
- if (owner->hasFocus())
- owner->canvas()->d->setFocusItem(owner, Qt::OtherFocusReason);
- if (owner->options() & QSimpleCanvasItem::IsFocusPanel) {
- if (owner_d->wantsActiveFocusPanelPendingCanvas) {
- owner_d->hasBeenActiveFocusPanel = true;
- owner->canvas()->d->setActiveFocusPanel(owner);
- owner_d->wantsActiveFocusPanelPendingCanvas = false;
- }
- }
- }
- if (owner->options() & QSimpleCanvasItem::MouseFilter)
- owner_d->gvRemoveMouseFilter();
-
- if (oldCanvas != owner_d->canvas)
- owner->canvasChanged();
-
- if (owner->options() & QSimpleCanvasItem::MouseFilter)
- owner_d->gvAddMouseFilter();
- }
-
- return QGraphicsItem::itemChange(change, value);
-}
-
-void QSimpleGraphicsItem::keyPressEvent(QKeyEvent *event)
-{
- owner->keyPressEvent(event);
- QGraphicsItem::keyPressEvent(event);
-}
-
-void QSimpleGraphicsItem::keyReleaseEvent(QKeyEvent *event)
-{
- owner->keyReleaseEvent(event);
- QGraphicsItem::keyReleaseEvent(event);
-}
-
-void QSimpleGraphicsItem::focusInEvent(QFocusEvent *)
-{
- if (!owner->hasFocus())
- owner->setFocus(true);
-}
-
-void QSimpleCanvasItemPrivate::gvRemoveMouseFilter()
-{
- QGraphicsScene *scene = graphicsItem->scene();
- if (!scene) return;
-
- scene->removeEventFilter(q_ptr);
-}
-
-void QSimpleCanvasItemPrivate::gvAddMouseFilter()
-{
- QGraphicsScene *scene = graphicsItem->scene();
- if (!scene) return;
-
- scene->installEventFilter(q_ptr);
-}
-QT_END_NAMESPACE
diff --git a/src/declarative/canvas/qsimplecanvas_opengl.cpp b/src/declarative/canvas/qsimplecanvas_opengl.cpp
deleted file mode 100644
index 7969a2a..0000000
--- a/src/declarative/canvas/qsimplecanvas_opengl.cpp
+++ /dev/null
@@ -1,680 +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 "qsimplecanvas.h"
-#include "qsimplecanvas_p.h"
-#include "qsimplecanvasitem_p.h"
-#include "qsimplecanvasfilter_p.h"
-#include <glsave.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <gltexture.h>
-#include <math.h>
-
-
-QT_BEGIN_NAMESPACE
-void CanvasEGLWidget::paintGL()
-{
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- _canvas->paintGL();
-}
-
-void CanvasEGLWidget::updateGL()
-{
- _clip = QRect();
- QGLWidget::updateGL();
-}
-
-void CanvasEGLWidget::updateGL(const QRect &r)
-{
- if (r.isEmpty())
- return;
-
- _clip = r;
- QGLWidget::updateGL();
-}
-
-void CanvasEGLWidget::resizeGL(int w, int h)
-{
- glViewport(0, 0, w, h);
-}
-
-QRect CanvasEGLWidget::map(const QRectF &f) const
-{
- return invDefaultTransform.mapRect(f).toAlignedRect();
-}
-
-void CanvasEGLWidget::resizeEvent(QResizeEvent *e)
-{
- defaultTransform.setIdentity();
- defaultTransform.flipCoordinates();
- defaultTransform.translate(-1, -1, 0);
- defaultTransform.scale(2. / width(), 2. / height(), 1. / (1024. * 1024.));
- invDefaultTransform = defaultTransform.inverted();
- _canvas->root->d_func()->data()->transformActive = defaultTransform;
- _canvas->root->d_func()->data()->transformValid = true;
-
- QGLWidget::resizeEvent(e);
-}
-
-void CanvasEGLWidget::initializeGL()
-{
- glEnable(GL_BLEND);
- glEnable(GL_STENCIL_TEST);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
- GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- glStencilFunc(GL_EQUAL, 0, 0xFFFFFFFF);
- glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
-}
-
-void QSimpleCanvasPrivate::paintGL()
-{
- lrpTimer.start();
-
- QSimpleCanvasItemPrivate::GLPaintParameters p;
- QSimpleCanvasItem::GLPainter painter;
-
- p.sceneRect = QRect(0, 0, q->width(), q->height());
- p.clipRect = p.sceneRect;
- p.stencilValue = 0;
- p.opacity = 1;
- p.forceParamRefresh = false;
- p.painter = &painter;
- if (!isSetup) {
- opaqueList = 0;
- int z = 0;
- root->d_func()->setupPainting(0, z, &opaqueList);
- }
-
- glEnable(GL_DEPTH_TEST);
-
- glDisable(GL_BLEND);
- painter.blendEnabled = false;
- painter.activeOpacity = 1;
- while (opaqueList) {
- painter.item = opaqueList;
- painter.activeTransform = opaqueList->d_func()->data()->transformActive;
- // ### - I don't think this is right
- painter.sceneClipRect = p.clipRect;
-
- opaqueList->paintGLContents(painter);
- opaqueList = opaqueList->d_func()->nextOpaque;
- }
- glEnable(GL_BLEND);
- painter.blendEnabled = true;
-
- root->d_func()->paint(p);
-
- lrpTime = lrpTimer.elapsed();
-}
-
-QGLFramebufferObject *QSimpleCanvasPrivate::acquire(int w, int h)
-{
- if (w <= 0 || h <= 0)
- return 0;
-
- int size = qMax(w, h);
- for (int ii = 0; ii < frameBuffers.count(); ++ii) {
- if (frameBuffers.at(ii)->width() >= size) {
- QGLFramebufferObject *rv = frameBuffers.at(ii);
- frameBuffers.removeAt(ii);
- return rv;
- }
- }
-
- // Find power of two
- size--;
- size |= size >> 1;
- size |= size >> 2;
- size |= size >> 4;
- size |= size >> 8;
- size |= size >> 16;
- size++;
-
- QGLFramebufferObject *fbo = new QGLFramebufferObject(size, size);
- return fbo;
-}
-
-void QSimpleCanvasPrivate::release(QGLFramebufferObject *buf)
-{
- int size = qMax(buf->width(), buf->height());
- for (int ii = 0; ii < frameBuffers.count(); ++ii) {
- if (frameBuffers.at(ii)->width() >= size) {
- frameBuffers.insert(ii, buf);
- return;
- }
- }
- frameBuffers.append(buf);
-}
-
-GLBasicShaders *QSimpleCanvasItemPrivate::basicShaders() const
-{
- return canvas->d->basicShaders();
-}
-
-QSimpleCanvas::Matrix QSimpleCanvasItemPrivate::localTransform() const
-{
- Q_Q(const QSimpleCanvasItem);
-
- QSimpleCanvas::Matrix trans;
- trans.translate(q->x(), q->y());
- QPointF to = transformOrigin();
- trans.translate(to.x(), to.y());
- trans.scale(q->scale(), q->scale());
- trans.translate(-to.x(), -to.y());
- if (data()->transformUser)
- trans *= *data()->transformUser;
- return trans;
-}
-
-void QSimpleCanvasItemPrivate::simplePaintChild(const GLPaintParameters &params, QSimpleCanvasItem *child)
-{
- Q_Q(QSimpleCanvasItem);
-
- GLPaintParameters childParams = params;
- if (clip)
- ++childParams.stencilValue;
-
- if (child->d_func()->data()->activeOpacity != 0) {
- childParams.boundingRect = child->boundingRect();
-
- if (child->filter() && child->filter()->enabled()) {
- QSimpleCanvasItem::GLPainter &painter = *params.painter;
- painter.item = q;
- painter.activeTransform = child->d_func()->data()->transformActive;
- painter.activeOpacity = child->d_func()->data()->activeOpacity;
- painter.sceneClipRect = params.clipRect;
- child->filter()->d->doFilterGL(painter, childParams);
- } else {
- child->d_func()->paint(childParams);
- }
- }
-}
-
-void QSimpleCanvasItemPrivate::paintChild(const GLPaintParameters &params,
- QSimpleCanvasItem *child)
-{
- if (params.forceParamRefresh) {
- QSimpleCanvas::Matrix t = child->d_func()->data()->transformActive;
- qreal o = child->d_func()->data()->activeOpacity;
- setupChildState(child);
- simplePaintChild(params, child);
- child->d_func()->data()->transformActive = t;
- child->d_func()->data()->transformValid = true;
- child->d_func()->data()->activeOpacity = o;
- } else {
- simplePaintChild(params, child);
- }
-}
-
-void QSimpleCanvasItemPrivate::setupChildState(QSimpleCanvasItem *child)
-{
- QSimpleCanvasItemData *const myData = data();
- QSimpleCanvasItemPrivate *const childPrivate = child->d_func();
- QSimpleCanvasItemData *const childData = childPrivate->data();
-
- childData->activeOpacity = myData->activeOpacity;
- if (childData->visible != 1.)
- childData->activeOpacity *= childData->visible;
-
- if (childData->activeOpacity != 0.) {
- QSimpleCanvas::Matrix &am = childData->transformActive;
- am = myData->transformActive;
-
- // Calculate child's transform
- const qreal x = childData->x;
- const qreal y = childData->y;
- const qreal scale = childPrivate->scale;
- QSimpleCanvasItem::Flip flip = childData->flip;
-
- if (x != 0. || y != 0.)
- am.translate(x, y);
-
- if (scale != 1.) {
- if (childPrivate->origin == QSimpleCanvasItem::TopLeft) {
- am.scale(scale, scale);
- } else {
- QPointF to = childPrivate->transformOrigin();
- am.translate(to.x(), to.y());
- am.scale(scale, scale);
- am.translate(-to.x(), -to.y());
- }
- }
-
- if (childData->transformUser)
- am *= *childData->transformUser;
- if (flip) {
- QRectF br = child->boundingRect();
- am.translate(br.width() / 2., br.height() / 2);
- am.rotate(180, (flip & QSimpleCanvasItem::VerticalFlip)?1:0, (flip & QSimpleCanvasItem::HorizontalFlip)?1:0, 0);
- am.translate(-br.width() / 2., -br.height() / 2);
- }
-
- childData->transformValid = true;
- }
-}
-
-#define QSIMPLECANVAS_DISABLE_TREE_CLIPPING
-QRectF QSimpleCanvasItemPrivate::setupPainting(int version, int &z, QSimpleCanvasItem **opaqueList)
-{
- static QRectF scene(-1., -1., 2., 2.);
- Q_Q(QSimpleCanvasItem);
-
- bool hasContents = options & QSimpleCanvasItem::HasContents;
-
- QSimpleCanvasItemData *myData = data();
-
- QRectF rv;
- if (hasContents) {
- QRectF filteredBoundRect = q->boundingRect();
- if (filter)
- filteredBoundRect = filter->itemBoundingRect(filteredBoundRect);
- const QMatrix4x4 &active = myData->transformActive;
-
- rv = active.mapRect(filteredBoundRect);
- }
-#ifdef QSIMPLECANVAS_DISABLE_TREE_CLIPPING
- myData->doNotPaint = false;
- myData->doNotPaintChildren = false;
-#else
- myData->doNotPaint = !hasContents || !rv.intersects(scene);
- myData->doNotPaintChildren = hasContents && myData->doNotPaint &&
- (clip != QSimpleCanvasItem::NoClip);
-#endif
-
- if (!myData->doNotPaint &&
- (options & QSimpleCanvasItem::IsOpaque) &&
- (myData->activeOpacity == 1.) &&
- (clip == 0)) {
-
- nextOpaque = *opaqueList;
- *opaqueList = q;
- myData->doNotPaint = true;
-
- }
-
- int myZ = z++;
-
- if (myData->doNotPaintChildren) {
- rv = QRectF();
- } else {
- zOrderChildren();
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QSimpleCanvasItem *child = children.at(ii);
- setupChildState(child);
-
- QSimpleCanvasItemData *childData = child->d_func()->data();
- if (childData->activeOpacity != 0)
- rv |= child->d_func()->setupPainting(version, z, opaqueList);
- }
-
-#ifndef QSIMPLECANVAS_DISABLE_TREE_CLIPPING
- myData->doNotPaintChildren |= !rv.intersects(scene);
-#endif
- }
-
- myData->transformActive.translate(0, 0, myZ);
-
- myData->lastPaintRect = rv;
-
- return rv;
-}
-
-
-void QSimpleCanvasItemPrivate::paint(GLPaintParameters &oldParams, QSimpleCanvasFilter::Layer layer)
-{
- if (!layer)
- return;
-
- Q_Q(QSimpleCanvasItem);
-
- bool doNotPaintChildren = data()->doNotPaintChildren;
- if (doNotPaintChildren)
- return;
-
- GLPaintParameters params = oldParams;
-
- qreal width = params.boundingRect.width();
- qreal height = params.boundingRect.height();
-
- GLfloat vertices[] = { 0, height,
- width, height,
- 0, 0,
- width, 0 };
-
- // XXX Handle separate cliping modes
- if (clip) {
- if (params.stencilValue == 255)
- qWarning()
- << "OpenGL: Clip recursion greater than 255 not permitted.";
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
-
- glStencilFunc(GL_EQUAL, params.stencilValue, 0xFFFFFFFF);
- glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
-
- ConstantColorShader *shader = basicShaders()->constantColor();
- params.painter->invalidate();
- shader->enable();
- shader->setTransform(data()->transformActive);
-
- shader->setAttributeArray(ConstantColorShader::Vertices, vertices, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- glStencilFunc(GL_EQUAL, params.stencilValue + 1, 0xFFFFFFFF);
- glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
-
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
-
- // XXX Copied from qsimplecanvas_opengl1 scissor based clipping
- QRectF r = data()->transformActive.mapRect(params.boundingRect);
- r.translate(1, 1);
- float xscale = 0.5 * float(params.sceneRect.width());
- float yscale = 0.5 * float(params.sceneRect.height());
- r.moveTo(r.x() * xscale, r.y() * yscale);
- r.setSize(QSizeF(r.width() * xscale, r.height() * yscale));
- int sr_x = int(::floorf(r.x()));
- int sr_y = int(::floorf(r.y()));
- int sr_width = int(::ceilf(r.right())) - sr_x;
- int sr_height = int(::ceilf(r.bottom())) - sr_y;
- QRect sr(sr_x, sr_y, sr_width, sr_height);
- sr.moveTo(sr.x(), params.sceneRect.height() - sr.y() - sr.height());
- sr &= params.clipRect;
- params.clipRect = sr;
- }
-
- int upto = 0;
- for (upto = 0; upto < children.count(); ++upto) {
- QSimpleCanvasItem *c = children.at(upto);
- if (c->z() < 0) {
- if (layer & QSimpleCanvasFilter::ChildrenUnderItem)
- paintChild(params, c);
- } else {
- break;
- }
- }
-
- bool doNotPaint = data()->doNotPaint;
-
- if (!doNotPaint && layer & QSimpleCanvasFilter::Item) {
- QSimpleCanvasItem::GLPainter &painter = *params.painter;
- painter.item = q;
- painter.activeTransform = data()->transformActive;
- painter.activeOpacity = data()->activeOpacity;
- painter.sceneClipRect = params.clipRect;
-
- q->paintGLContents(painter);
- }
-
- if (layer & QSimpleCanvasFilter::ChildrenAboveItem) {
- for (; upto < children.count(); ++upto) {
- QSimpleCanvasItem *c = children.at(upto);
- paintChild(params, c);
- }
- }
-
- if (clip) {
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
- glStencilFunc(GL_EQUAL, params.stencilValue + 1, 0xFFFFFFFF);
- glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
-
- params.painter->invalidate();
- ConstantColorShader *shader = basicShaders()->constantColor();
- shader->enable();
- shader->setTransform(data()->transformActive);
-
- shader->setAttributeArray(ConstantColorShader::Vertices, vertices, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- glStencilFunc(GL_EQUAL, params.stencilValue, 0xFFFFFFFF);
- glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- }
-}
-
-enum ShaderType { ST_None, ST_SingleTexture, ST_SingleTextureOpacity, ST_Color };
-
-QSimpleCanvasItem::GLPainter::GLPainter()
-: item(0), activeOpacity(1), blendEnabled(true), flags(0)
-{
-}
-
-QSimpleCanvasItem::GLPainter::GLPainter(QSimpleCanvasItem *i)
-: item(i), activeOpacity(1), blendEnabled(true), flags(0)
-{
-}
-
-QGLShaderProgram *QSimpleCanvasItem::GLPainter::useTextureShader()
-{
- if (activeOpacity == 1.) {
- SingleTextureShader *shader = item->basicShaders()->singleTexture();
- if (flags != ST_SingleTexture) {
- shader->enable();
- flags = ST_SingleTexture;
- }
-
- shader->setTransform(activeTransform);
- return shader;
- } else {
- SingleTextureOpacityShader *shader = item->basicShaders()->singleTextureOpacity();
-
- if (flags != ST_SingleTextureOpacity) {
- shader->enable();
- flags = ST_SingleTextureOpacity;
- }
-
- shader->setTransform(activeTransform);
- shader->setOpacity(activeOpacity);
- return shader;
- }
-}
-
-void QSimpleCanvasItem::GLPainter::invalidate()
-{
- flags = ST_None;
-}
-
-QGLShaderProgram *QSimpleCanvasItem::GLPainter::useColorShader(const QColor &color)
-{
- QColor c = color;
-
- ConstantColorShader *shader = item->basicShaders()->constantColor();
-
- if (flags != ST_Color) {
- shader->enable();
- flags = ST_Color;
- }
-
- if (activeOpacity != 1.)
- c.setAlpha(int(c.alpha() * activeOpacity));
-
- shader->setColor(c);
- shader->setTransform(activeTransform);
-
- return shader;
-}
-
-void QSimpleCanvasItem::GLPainter::drawPixmap(const QPointF &point,
- const GLTexture &texture)
-{
- drawPixmap(QRectF(point, QSizeF(texture.width(), texture.height())), texture);
-}
-
-void QSimpleCanvasItem::GLPainter::drawPixmap(const QRectF &rect,
- const GLTexture &img)
-{
- QGLShaderProgram *shader = useTextureShader();
-
- GLfloat vertices[8];
- GLfloat texVertices[8];
-
- float widthV = img.width();
- float heightV = img.height();
-
- vertices[0] = rect.x(); vertices[1] = rect.y()+heightV;
- vertices[2] = rect.x()+widthV; vertices[3] = rect.y()+heightV;
- vertices[4] = rect.x(); vertices[5] = rect.y();
- vertices[6] = rect.x()+widthV; vertices[7] = rect.y();
-
- texVertices[0] = 0; texVertices[1] = 0;
- texVertices[2] = 1; texVertices[3] = 0;
- texVertices[4] = 0; texVertices[5] = 1;
- texVertices[6] = 1; texVertices[7] = 1;
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, img.texture());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-}
-
-void QSimpleCanvasItem::GLPainter::fillRect(const QRectF &rect,
- const QColor &color)
-{
- if (color.alpha() == 0xFF)
- glDisable(GL_BLEND);
-
- QGLShaderProgram *shader = useColorShader(color);
- float x = rect.x();
- float y = rect.y();
- float width = rect.width();
- float height = rect.height();
-
- GLfloat vertices[] = { x, height,
- width, height,
- x, y,
-
- width, height,
- x, y,
- width, y };
-
- shader->setAttributeArray(ConstantColorShader::Vertices, vertices, 2);
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- if (color.alpha() == 0xFF)
- glEnable(GL_BLEND);
-}
-
-void QSimpleCanvasItem::CachedTexture::addRef()
-{
- ++r;
-}
-
-void QSimpleCanvasItem::CachedTexture::release()
-{
- Q_ASSERT(r > 0);
- --r;
-
- if (r == 0) {
- if (!s.isEmpty())
- d->cachedTextures.remove(s);
- delete this;
- }
-}
-
-int QSimpleCanvasItem::CachedTexture::pixmapWidth() const
-{
- return w;
-}
-
-int QSimpleCanvasItem::CachedTexture::pixmapHeight() const
-{
- return h;
-}
-
-QSimpleCanvasItem::CachedTexture::CachedTexture()
-: r(0), w(0), h(0)
-{
-}
-
-QSimpleCanvasItem::CachedTexture *
-QSimpleCanvasItem::cachedTexture(const QString &key)
-{
- Q_D(QSimpleCanvasItem);
- if (!d->canvas || key.isEmpty())
- return 0;
-
- QSimpleCanvasPrivate *canvas = d->canvas->d;
- QHash<QString, QSimpleCanvasItem::CachedTexture *>::ConstIterator iter =
- canvas->cachedTextures.find(key);
- if (iter != canvas->cachedTextures.end()) {
- (*iter)->addRef();
- return (*iter);
- } else {
- return 0;
- }
-}
-
-QSimpleCanvasItem::CachedTexture *
-QSimpleCanvasItem::cachedTexture(const QString &key, const QPixmap &pix)
-{
- Q_D(QSimpleCanvasItem);
- if (!d->canvas)
- return 0;
-
- QSimpleCanvasPrivate *canvas = d->canvas->d;
- QHash<QString, QSimpleCanvasItem::CachedTexture *>::ConstIterator iter =
- canvas->cachedTextures.end();
- if (!key.isEmpty())
- iter = canvas->cachedTextures.find(key);
-
- if (iter != canvas->cachedTextures.end()) {
- (*iter)->addRef();
- return (*iter);
- } else {
- CachedTexture *rv = new CachedTexture;
- rv->s = key;
- rv->d = canvas;
- rv->w = pix.width();
- rv->h = pix.height();
- rv->setImage(pix.toImage(), GLTexture::PowerOfTwo);
- rv->setHorizontalWrap(GLTexture::Repeat);
- rv->setVerticalWrap(GLTexture::Repeat);
- rv->addRef();
- if (!key.isEmpty())
- canvas->cachedTextures.insert(key, rv);
- return rv;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/canvas/qsimplecanvas_opengl1.cpp b/src/declarative/canvas/qsimplecanvas_opengl1.cpp
deleted file mode 100644
index 6e50ef8..0000000
--- a/src/declarative/canvas/qsimplecanvas_opengl1.cpp
+++ /dev/null
@@ -1,401 +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 "qsimplecanvas.h"
-#include "qsimplecanvas_p.h"
-#include "qsimplecanvasitem_p.h"
-#include "qsimplecanvasfilter_p.h"
-#include <gltexture.h>
-#include <glsave.h>
-#include <math.h>
-
-
-QT_BEGIN_NAMESPACE
-void CanvasEGLWidget::updateGL()
-{
- _clip = QRect();
- QGLWidget::updateGL();
-}
-
-void CanvasEGLWidget::updateGL(const QRect &r)
-{
- if (r.isEmpty())
- return;
-
- _clip = r;
- QGLWidget::updateGL();
-}
-
-void CanvasEGLWidget::paintGL()
-{
- if (!_clip.isEmpty()) {
- glEnable(GL_SCISSOR_TEST);
- glScissor(_clip.x(), _clip.y(), _clip.width(), _clip.height());
- } else {
- glDisable(GL_SCISSOR_TEST);
- }
-
- glDepthMask(GL_TRUE);
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glDepthMask(GL_FALSE);
-
- _canvas->paintGL();
-}
-
-QRect CanvasEGLWidget::map(const QRectF &f)
-{
- return invDefaultTransform.mapRect(f).toAlignedRect();
-}
-
-void CanvasEGLWidget::resizeGL(int w, int h)
-{
- glViewport(0, 0, w, h);
-}
-
-void CanvasEGLWidget::resizeEvent(QResizeEvent *e)
-{
- defaultTransform.identity();
- defaultTransform.flipCoordinates();
- defaultTransform.translate(-1, -1, 0);
- defaultTransform.scale(2. / width(), 2. / height(), -2. / 65536.);
- invDefaultTransform = defaultTransform.inverted();
- _canvas->root->d_func()->transformActive = defaultTransform;
- QGLWidget::resizeEvent(e);
-}
-
-void CanvasEGLWidget::initializeGL()
-{
- glEnable(GL_BLEND);
- glEnable(GL_DEPTH_TEST);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDepthFunc(GL_GREATER);
-#ifdef QT_OPENGL_ES
- glClearDepthf(0);
-#else
- glClearDepth(0);
-#endif
-}
-
-void QSimpleCanvasPrivate::paintGL()
-{
- lrpTimer.start();
-
- QSimpleCanvasItemPrivate::GLPaintParameters p;
- p.sceneRect = QRect(0, 0, q->width(), q->height());
- p.clipRect = p.sceneRect;
- p.opacity = 1;
- p.forceParamRefresh = false;
- if (!isSetup) {
- unsigned int zero = 0;
- root->d_func()->setupPainting(0, QRect(), &zero);
- }
- root->d_func()->paint(p);
-
- lrpTime = lrpTimer.elapsed();
-}
-
-QSimpleCanvas::Matrix QSimpleCanvasItemPrivate::localTransform() const
-{
- Q_Q(const QSimpleCanvasItem);
-
- QSimpleCanvas::Matrix trans;
- trans.translate(q->x(), q->y());
- QPointF to = transformOrigin();
- trans.translate(to.x(), to.y());
- trans.scale(q->scale().value(), q->scale().value());
- trans.translate(-to.x(), -to.y());
- trans *= transformUser;
- return trans;
-}
-
-void QSimpleCanvasItemPrivate::simplePaintChild(const GLPaintParameters &params, QSimpleCanvasItem *child)
-{
- GLPaintParameters childParams = params;
-
- if (child->d_func()->activeOpacity != 0) {
- childParams.boundingRect = child->boundingRect();
- child->d_func()->paint(childParams);
- }
-}
-
-void QSimpleCanvasItemPrivate::paintChild(const GLPaintParameters &params,
- QSimpleCanvasItem *child)
-{
- if (params.forceParamRefresh) {
- QSimpleCanvas::Matrix t = child->d_func()->transformActive;
- qreal o = child->d_func()->activeOpacity;
- setupChildState(child);
- simplePaintChild(params, child);
- child->d_func()->transformActive = t;
- child->d_func()->activeOpacity = o;
- } else {
- simplePaintChild(params, child);
- }
-}
-
-
-void QSimpleCanvasItemPrivate::setupChildState(QSimpleCanvasItem *child)
-{
- qreal visible = child->visible().value();
- child->d_func()->activeOpacity = activeOpacity;
- if (visible != 1)
- child->d_func()->activeOpacity *= visible;
-
- if (child->d_func()->activeOpacity != 0) {
- // Calculate child's transform
- qreal x = child->x();
- qreal y = child->y();
- qreal scale = child->scale().value();
- QSimpleCanvasItem::Flip flip = child->flip();
-
- QSimpleCanvas::Matrix &am = child->d_func()->transformActive;
- am = transformActive;
- if (x != 0 || y != 0)
- am.translate(x, y);
- if (scale != 1) {
- QPointF to = child->d_func()->transformOrigin();
- if (to.x() != 0. || to.y() != 0.)
- am.translate(to.x(), to.y());
- am.scale(scale, scale);
- if (to.x() != 0. || to.y() != 0.)
- am.translate(-to.x(), -to.y());
- }
- if (child->d_func()->transformUserSet)
- am *= child->d_func()->transformUser;
- if (flip) {
- QRectF br = child->boundingRect();
- am.translate(br.width() / 2., br.height() / 2);
- am.rotate(180, (flip & QSimpleCanvasItem::VerticalFlip)?1:0, (flip & QSimpleCanvasItem::HorizontalFlip)?1:0, 0);
- am.translate(-br.width() / 2., -br.height() / 2);
- }
- }
-}
-
-QRectF QSimpleCanvasItemPrivate::setupPainting(int version, const QRect &bounding, unsigned int *zero)
-{
- Q_Q(QSimpleCanvasItem);
-
- QRectF rv = transformActive.mapRect(q->boundingRect());
-
- unsigned int oldZero = *zero;
-
- for (int ii = 0; ii < children.count(); ++ii) {
- QSimpleCanvasItem *child = children.at(ii);
- setupChildState(child);
-
- if (child->d_func()->activeOpacity != 0)
- rv |= child->d_func()->setupPainting(version, bounding, zero);
- }
-
- if (clip || oldZero != *zero)
- (*zero)++;
- transformActive.translate(0, 0, *zero);
-
- lastPaintRect = rv;
- return rv;
-}
-
-void QSimpleCanvasItemPrivate::paintNoClip(GLPaintParameters &params, QSimpleCanvasFilter::Layer layer)
-{
- Q_Q(QSimpleCanvasItem);
-
- zOrderChildren();
-
- int upto = 0;
- for (upto = 0; upto < children.count(); ++upto) {
- QSimpleCanvasItem *c = children.at(upto);
- if (c->zValue().value() < 0) {
- if (layer & QSimpleCanvasFilter::ChildrenUnderItem)
- paintChild(params, c);
- } else {
- break;
- }
- }
-
- if (layer & QSimpleCanvasFilter::Item &&
- q->options() & QSimpleCanvasItem::HasContents) {
- QSimpleCanvasItem::GLPainter painter(q);
- painter.activeTransform = transformActive;
- painter.activeOpacity = activeOpacity;
- painter.sceneClipRect = params.clipRect;
-
- q->paintGLContents(painter);
- }
-
- if (layer & QSimpleCanvasFilter::ChildrenAboveItem) {
- for (; upto < children.count(); ++upto) {
- QSimpleCanvasItem *c = children.at(upto);
- paintChild(params, c);
- }
- }
-}
-
-void QSimpleCanvasItemPrivate::paint(GLPaintParameters &params, QSimpleCanvasFilter::Layer layer)
-{
- if (!layer)
- return;
-
- // XXX Handle separate cliping modes
- if (clip) {
-
- GLSaveScissor ss;
- qreal width = params.boundingRect.width();
- qreal height = params.boundingRect.height();
- float margin = width + height;
-
- GLfloat clipvertices[] =
- {
- -margin, -margin,
- margin, -margin,
- margin, 0,
-
- -margin, -margin,
- -margin, 0,
- margin, 0,
-
- -margin, 0,
- -margin, margin,
- 0, 0,
-
- 0, 0,
- 0, margin,
- -margin, margin,
-
- 0, height,
- 0, margin,
- margin, margin,
-
- margin, margin,
- 0, height,
- margin, height,
-
- width, 0,
- margin, 0,
- margin, height,
-
- margin, height,
- width, height,
- width, 0
- };
-
- QRectF r = transformActive.mapRect(params.boundingRect);
- r.translate(1, 1);
- float xscale = 0.5 * float(params.sceneRect.width());
- float yscale = 0.5 * float(params.sceneRect.height());
- r.moveTo(r.x() * xscale, r.y() * yscale);
- r.setSize(QSizeF(r.width() * xscale, r.height() * yscale));
-
- glEnable(GL_SCISSOR_TEST);
- int sr_x = ::floorf(r.x());
- int sr_y = ::floorf(r.y());
- int sr_width = ::ceilf(r.right()) - sr_x;
- int sr_height = ::ceilf(r.bottom()) - sr_y;
-
- QRect sr(sr_x, sr_y, sr_width, sr_height);
- if (ss.wasEnabled())
- sr &= ss.rect();
-
- glScissor(sr.x(), sr.y(), sr.width(), sr.height());
-
- {
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(transformActive.data());
- glDepthMask(GL_TRUE);
- glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(2, GL_FLOAT, 0, clipvertices);
- glDrawArrays(GL_TRIANGLES, 0, 24);
- glDisableClientState(GL_VERTEX_ARRAY);
- glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glDepthMask(GL_FALSE);
- }
-
- GLPaintParameters newParams = params;
- newParams.clipRect = sr;
- newParams.clipRect.moveTo(sr.x(), params.sceneRect.height() - sr.y() - sr.height());
- paintNoClip(newParams, layer);
- } else {
- paintNoClip(params, layer);
- }
-}
-
-QGLShaderProgram *QSimpleCanvasItem::GLPainter::useTextureShader()
-{
- qFatal("Cannot call QSimpleCanvasItem::GLPainter::useTextureShader() when using OpenGL ES 1.1");
- return 0;
-}
-
-QGLShaderProgram *QSimpleCanvasItem::GLPainter::useColorShader(const QColor &color)
-{
- Q_UNUSED(color);
- qFatal("Cannot call QSimpleCanvasItem::GLPainter::useColorShader() when using OpenGL ES 1.1");
- return 0;
-}
-
-GLBasicShaders *QSimpleCanvasItemPrivate::basicShaders() const
-{
- qFatal("Cannot call QSimpleCanvasItem::basicShaders() when using OpenGL ES 1.1");
- return 0;
-}
-
-QGLFramebufferObject *QSimpleCanvasPrivate::acquire(int, int)
-{
- return 0;
-}
-
-void QSimpleCanvasPrivate::release(QGLFramebufferObject *)
-{
-}
-
-void QSimpleCanvasItem::GLPainter::drawPixmap(const QPointF &point,
- const GLTexture &texture)
-{
- drawPixmap(QRectF(point, QSizeF(texture.width(), texture.height())), texture);
-}
-
-void QSimpleCanvasItem::GLPainter::drawPixmap(const QRectF &rect,
- const GLTexture &img)
-{
- qFatal("Cannot call QSimpleCanvasItem::GLPainter::drawPixmap() when using OpenGL ES 1.1");
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/canvas/qsimplecanvas_p.h b/src/declarative/canvas/qsimplecanvas_p.h
deleted file mode 100644
index c2b5130..0000000
--- a/src/declarative/canvas/qsimplecanvas_p.h
+++ /dev/null
@@ -1,207 +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 QSIMPLECANVAS_P_H
-#define QSIMPLECANVAS_P_H
-
-#include "qsimplecanvas.h"
-#include "qsimplecanvasitem.h"
-#include <qstack.h>
-#include <qdatetime.h>
-
-#if defined(QFX_RENDER_OPENGL)
-
-#if defined(QFX_RENDER_OPENGL2)
-#include "glbasicshaders.h"
-#endif
-
-#include <QGLWidget>
-QT_BEGIN_NAMESPACE
-
-class CanvasEGLWidget : public QGLWidget
-{
-public:
- CanvasEGLWidget(QSimpleCanvas *parent, QSimpleCanvasPrivate *canvas)
- :
- QGLWidget(parent),
- _canvas(canvas)
- {
- }
-
- virtual void paintGL();
- virtual void resizeGL(int,int);
- virtual void resizeEvent(QResizeEvent *e);
- virtual void initializeGL();
-
- void updateGL();
- void updateGL(const QRect &);
-
- QRect map(const QRectF &) const;
-private:
- QRect _clip;
- QSimpleCanvasPrivate *_canvas;
- QSimpleCanvas::Matrix defaultTransform;
- QSimpleCanvas::Matrix invDefaultTransform;
-};
-QT_END_NAMESPACE
-#endif
-
-#include <QGraphicsView>
-#include <QGraphicsScene>
-
-QT_BEGIN_NAMESPACE
-
-struct QSimpleCanvasGraphicsView : public QGraphicsView
-{
-public:
- QSimpleCanvasGraphicsView(QSimpleCanvasPrivate *parent);
- ~QSimpleCanvasGraphicsView();
-
-protected:
- virtual void paintEvent(QPaintEvent *);
- virtual void focusInEvent(QFocusEvent *);
- virtual void resizeEvent(QResizeEvent *);
-
-private:
- QSimpleCanvasPrivate *canvas;
- QGraphicsScene _scene;
-};
-
-class QGLFramebufferObject;
-class QSimpleCanvasDebugPlugin;
-class QSimpleCanvasPrivate
-{
-public:
- QSimpleCanvasPrivate(QSimpleCanvas *canvas)
- : q(canvas), timer(0), root(0), lrpTime(0), debugPlugin(0), focusItem(0),
- lastFocusItem(0), lastMouseItem(0),
- isSetup(false), view(0)
-#if defined(QFX_RENDER_OPENGL)
- ,egl(q, this), basicShadersInstance(0)
-#endif
- , paintVersion(1)
- {
- }
-
- QSimpleCanvas *q;
- QSimpleCanvas::CanvasMode mode;
- bool isSimpleCanvas() const { return mode == QSimpleCanvas::SimpleCanvas; }
- bool isGraphicsView() const { return mode == QSimpleCanvas::GraphicsView; }
-
-#if defined(QFX_RENDER_OPENGL)
- QRectF oldDirty;
-#else
- QRect oldDirty;
-#endif
- QRect resetDirty();
- void paint(QPainter &p);
-
- QSimpleCanvasItem *opaqueList;
-
- int timer;
-
- QSimpleCanvasLayer *root;
- QList<QSimpleCanvasItem *> dirtyItems;
- int lrpTime;
-
- QTime frameTimer;
- QTime lrpTimer;
-
- QSimpleCanvasDebugPlugin *debugPlugin;
-
- QStack<QSimpleCanvasItem *> focusPanels;
- QHash<QSimpleCanvasItem *, QSimpleCanvasItem *> focusPanelData;
- QSimpleCanvasItem *focusItem;
- QSimpleCanvasItem *lastFocusItem;
-
- QRect dirtyItemClip() const;
- void clearFocusPanel(QSimpleCanvasItem *);
- void setActiveFocusPanel(QSimpleCanvasItem *, Qt::FocusReason focusReason = Qt::OtherFocusReason);
- void switchToFocusPanel(QSimpleCanvasItem *, QSimpleCanvasItem *, Qt::FocusReason focusReason);
-
- void setFocusItem(QSimpleCanvasItem *item, Qt::FocusReason focusReason,
- bool overwrite = true);
- void clearFocusItem(QSimpleCanvasItem *item);
-
- void clearActiveFocusItem(QSimpleCanvasItem *, Qt::FocusReason focusReason);
- void setActiveFocusItem(QSimpleCanvasItem *, Qt::FocusReason focusReason);
- void installMouseFilter(QSimpleCanvasItem *);
- void removeMouseFilter(QSimpleCanvasItem *);
- QList<QSimpleCanvasItem *> mouseFilters;
- bool filter(QMouseEvent *e);
- bool deliverMousePress(QSimpleCanvasItem *, QMouseEvent *, bool = false);
- QGraphicsSceneMouseEvent *mouseEventToSceneMouseEvent(QMouseEvent *, const QPoint &);
- QSimpleCanvasItem *lastMouseItem;
- void sendMouseEvent(QSimpleCanvasItem *, QGraphicsSceneMouseEvent *);
-
- bool isSetup;
-
- void init(QSimpleCanvas::CanvasMode mode);
-
- QSimpleCanvasGraphicsView *view;
-
-#if defined(QFX_RENDER_OPENGL)
- CanvasEGLWidget egl;
- GLBasicShaders *basicShaders() const
- {
-#if defined(QFX_RENDER_OPENGL2)
- if (!basicShadersInstance)
- basicShadersInstance = new GLBasicShaders;
- return basicShadersInstance;
-#else
- return 0;
-#endif
- }
- mutable GLBasicShaders *basicShadersInstance;
-
- QHash<QString, QSimpleCanvasItem::CachedTexture *> cachedTextures;
-
- QList<QGLFramebufferObject *> frameBuffers;
- QGLFramebufferObject *acquire(int, int);
- void release(QGLFramebufferObject *);
- void paintGL();
-#endif
- int paintVersion;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/declarative/canvas/qsimplecanvas_software.cpp b/src/declarative/canvas/qsimplecanvas_software.cpp
deleted file mode 100644
index dd5e201..0000000
--- a/src/declarative/canvas/qsimplecanvas_software.cpp
+++ /dev/null
@@ -1,232 +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 "qsimplecanvas.h"
-#include "qsimplecanvasitem_p.h"
-#include "qsimplecanvas_p.h"
-
-
-QT_BEGIN_NAMESPACE
-QRect QSimpleCanvasItemPrivate::setupPainting(int version, const QRect &bounding)
-{
- Q_Q(QSimpleCanvasItem);
-
- bool hasContents = options & QSimpleCanvasItem::HasContents;
-
- QRect rv;
-
- if (hasContents || q->clip()) {
- QRectF boundingRectActive = q->boundingRect();
- rv = data()->transformActive.mapRect(boundingRectActive).toAlignedRect() & bounding;
- }
-
- data()->doNotPaint = rv.isEmpty();
- data()->doNotPaintChildren = data()->doNotPaint && q->clip();
- QRect myBounding = bounding;
- if (q->clip())
- myBounding &= rv;
-
- if (!data()->doNotPaintChildren) {
- for (int ii = 0; ii < children.count(); ++ii) {
- QSimpleCanvasItem *child = children.at(ii);
-
- int childVersion = version;
- if (!child->d_func()->data()->transformValid)
- childVersion = canvas->d->paintVersion;
-
- bool recalcNeeded =
- (childVersion > child->d_func()->data()->transformVersion);
-
- if (recalcNeeded) {
- qreal visible = child->visible();
- child->d_func()->data()->activeOpacity = data()->activeOpacity;
- if (visible != 1)
- child->d_func()->data()->activeOpacity *= visible;
- }
-
- if (child->d_func()->data()->activeOpacity != 0) {
- if (recalcNeeded) {
- // Calculate child's transform
- qreal x = child->x();
- qreal y = child->y();
- qreal scale = child->scale();
- QSimpleCanvasItem::Flip flip = child->flip();
-
- QSimpleCanvas::Matrix &am =
- child->d_func()->data()->transformActive;
- am = data()->transformActive;
- if (x != 0 || y != 0)
- am.translate(x, y);
- if (scale != 1) {
- QPointF to = child->d_func()->transformOrigin();
- if (to.x() != 0. || to.y() != 0.)
- am.translate(to.x(), to.y());
- am.scale(scale, scale);
- if (to.x() != 0. || to.y() != 0.)
- am.translate(-to.x(), -to.y());
- }
-
- if (child->d_func()->data()->transformUser)
- am = *child->d_func()->data()->transformUser * am;
-
- if (flip) {
- QRectF br = child->boundingRect();
- am.translate(br.width() / 2., br.height() / 2);
- am.scale((flip & QSimpleCanvasItem::HorizontalFlip)?-1:1,
- (flip & QSimpleCanvasItem::VerticalFlip)?-1:1);
- am.translate(-br.width() / 2., -br.height() / 2);
- }
- child->d_func()->data()->transformValid = true;
- child->d_func()->data()->transformVersion = childVersion;
- }
- rv |= child->d_func()->setupPainting(child->d_func()->data()->transformVersion, myBounding);
- }
- }
- }
-
- data()->lastPaintRect = rv;
- if (!data()->doNotPaintChildren) {
- if (!bounding.intersects(rv)) {
- data()->doNotPaintChildren = true;
- data()->doNotPaint = true;
- }
- }
-
- return rv;
-}
-
-void QSimpleCanvasItemPrivate::paint(QPainter &p)
-{
- Q_Q(QSimpleCanvasItem);
-
- QRect oldUcr;
- if (clip) {
-
- p.save();
- QRectF boundingRectActive = q->boundingRect();
-
- QRect cr;
- switch(clip) {
- case QSimpleCanvasItem::ClipToHeight:
- {
- qWarning("QSimpleCanvasItem: ClipToHeight not implemented");
- QRect r = p.clipRegion().boundingRect();
- cr = QRect(r.x(), 0, r.width(),
- boundingRectActive.height());
- }
- break;
- case QSimpleCanvasItem::ClipToWidth:
- {
- qWarning("QSimpleCanvasItem: ClipToWidth not implemented");
- QRect r = p.clipRegion().boundingRect();
- cr = QRect(0, r.y(), boundingRectActive.width(),
- r.height());
- }
- break;
- case QSimpleCanvasItem::ClipToRect:
- cr = boundingRectActive.toAlignedRect();
- break;
- default:
- break;
- }
-
- p.setWorldTransform(data()->transformActive);
- if (p.clipRegion().isEmpty()) {
- p.setClipRect(cr);
- } else {
- p.setClipRect(cr, Qt::IntersectClip);
- }
-
- if (p.clipRegion().isEmpty()) {
- p.restore();
- return;
- }
- }
-
- zOrderChildren();
-
- int upto = 0;
- if (!data()->doNotPaintChildren) {
- for (upto = 0; upto < children.count(); ++upto) {
- QSimpleCanvasItem *c = children.at(upto);
- if (c->z() < 0) {
- paintChild(p, c);
- } else {
- break;
- }
- }
- }
-
- if (!data()->doNotPaint) {
- p.setWorldTransform(data()->transformActive);
- q->paintContents(p);
- }
-
- if (!data()->doNotPaintChildren) {
- for (; upto < children.count(); ++upto) {
- QSimpleCanvasItem *c = children.at(upto);
- paintChild(p, c);
- }
- }
-
- if (clip)
- p.restore();
-
- if (debuggerStatus && debuggerStatus->selected) {
- p.setWorldTransform(data()->transformActive);
- p.fillRect(q->boundingRect(), QColor(255, 0, 0, 80));
- }
-}
-
-void QSimpleCanvasItemPrivate::paintChild(QPainter &p, QSimpleCanvasItem *c)
-{
- if (c->d_func()->data()->activeOpacity != 0) {
-
- qreal op = p.opacity();
- p.setOpacity(c->d_func()->data()->activeOpacity);
-
- c->d_func()->paint(p);
-
- p.setOpacity(op);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/canvas/qsimplecanvasdebugplugin.cpp b/src/declarative/canvas/qsimplecanvasdebugplugin.cpp
deleted file mode 100644
index ffb3517..0000000
--- a/src/declarative/canvas/qsimplecanvasdebugplugin.cpp
+++ /dev/null
@@ -1,155 +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 "qsimplecanvasdebugplugin_p.h"
-#include "qdebug.h"
-#include <QtCore/qabstractanimation.h>
-#include <qsimplecanvas.h>
-#include <qsimplecanvasitem.h>
-
-QT_BEGIN_NAMESPACE
-
-class FrameBreakAnimation : public QAbstractAnimation
-{
-public:
- FrameBreakAnimation(QSimpleCanvasDebugPlugin *s)
- : QAbstractAnimation(s), server(s)
- {
- start();
- }
-
- virtual int duration() const { return -1; }
- virtual void updateCurrentTime(int msecs) {
- Q_UNUSED(msecs);
- server->frameBreak();
- }
-
-private:
- QSimpleCanvasDebugPlugin *server;
-};
-
-QSimpleCanvasDebugPlugin::QSimpleCanvasDebugPlugin(QObject *parent)
-: QmlDebugService(QLatin1String("CanvasFrameRate"), parent), _breaks(0)
-{
- _time.start();
- new FrameBreakAnimation(this);
-}
-
-void QSimpleCanvasDebugPlugin::addTiming(quint32 paint,
- quint32 repaint,
- quint32 timeBetweenFrames)
-{
- if (!isEnabled())
- return;
-
- bool isFrameBreak = _breaks > 1;
- _breaks = 0;
- int e = _time.elapsed();
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- ds << (int)paint << (int)repaint << (int)timeBetweenFrames << (int)e
- << (bool)isFrameBreak;
- sendMessage(data);
-}
-
-void QSimpleCanvasDebugPlugin::frameBreak()
-{
- _breaks++;
-}
-
-QSimpleCanvasSceneDebugPlugin::QSimpleCanvasSceneDebugPlugin(QSimpleCanvas *parent)
-: QmlDebugService(QLatin1String("CanvasScene"), parent), m_canvas(parent)
-{
-}
-
-void QSimpleCanvasSceneDebugPlugin::messageReceived(const QByteArray &)
-{
- refresh();
-}
-
-void QSimpleCanvasSceneDebugPlugin::refresh()
-{
- QByteArray data;
- QDataStream ds(&data, QIODevice::WriteOnly);
- const QList<QSimpleCanvasItem *> &children = m_canvas->root()->children();
- ds << children.count();
- for (int ii = 0; ii < children.count(); ++ii)
- refresh(ds, children.at(ii));
-
- sendMessage(data);
-}
-
-void QSimpleCanvasSceneDebugPlugin::refresh(QDataStream &ds,
- QSimpleCanvasItem *item)
-{
- ds << QmlDebugService::objectToString(item) << item->x() << item->y()
- << item->z() << item->width() << item->height()
- << (int)item->transformOrigin() << item->scale() << (int)item->flip()
-#ifdef QFX_RENDER_OPENGL
- << item->transform().toTransform()
-#elif defined(QFX_RENDER_QPAINTER)
- << item->transform()
-#endif
- << item->hasActiveFocus() << (int)item->options();
-
- QPixmap pix;
-
- if(item->options() & QSimpleCanvasItem::HasContents &&
- item->width() > 0 && item->height() > 0) {
-
- pix = QPixmap(item->width(), item->height());
- pix.fill(QColor(0,0,0,0));
- QPainter p(&pix);
- item->paintContents(p);
-
- }
-
- ds << pix;
-
- const QList<QSimpleCanvasItem *> &children = item->children();
- ds << children.count();
-
- for(int ii = 0; ii < children.count(); ++ii)
- refresh(ds, children.at(ii));
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/declarative/canvas/qsimplecanvasdebugplugin_p.h b/src/declarative/canvas/qsimplecanvasdebugplugin_p.h
deleted file mode 100644
index 4c6af2c..0000000
--- a/src/declarative/canvas/qsimplecanvasdebugplugin_p.h
+++ /dev/null
@@ -1,85 +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 QSIMPLECANVASDEBUGPLUGIN_P_H
-#define QSIMPLECANVASDEBUGPLUGIN_P_H
-
-#include "qobject.h"
-#include "qtcpserver.h"
-#include "qtcpsocket.h"
-#include "qdatetime.h"
-#include <QtDeclarative/qmldebugservice.h>
-
-QT_BEGIN_NAMESPACE
-class QSimpleCanvasDebugPlugin : public QmlDebugService
-{
-public:
- QSimpleCanvasDebugPlugin(QObject *parent = 0);
-
- void addTiming(quint32, quint32, quint32);
-
-private:
- friend class FrameBreakAnimation;
- void frameBreak();
- int _breaks;
- QTime _time;
-};
-
-class QSimpleCanvas;
-class QSimpleCanvasItem;
-class QSimpleCanvasSceneDebugPlugin : public QmlDebugService
-{
-public:
- QSimpleCanvasSceneDebugPlugin(QSimpleCanvas *parent = 0);
-
- virtual void messageReceived(const QByteArray &);
-
-private:
- void refresh();
- void refresh(QDataStream &, QSimpleCanvasItem *);
- QSimpleCanvas *m_canvas;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QSIMPLECANVASDEBUGPLUGIN_P_H
-
diff --git a/src/declarative/canvas/qsimplecanvasfilter.cpp b/src/declarative/canvas/qsimplecanvasfilter.cpp
deleted file mode 100644
index 5bc6b35..0000000
--- a/src/declarative/canvas/qsimplecanvasfilter.cpp
+++ /dev/null
@@ -1,323 +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 "qsimplecanvasfilter.h"
-#include "qsimplecanvasfilter_p.h"
-#include "qsimplecanvasitem_p.h"
-#include "qsimplecanvas.h"
-#include "qsimplecanvas_p.h"
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glsave.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass Filter
- \brief A Filter is a graphical filter that can be applied to items.
-*/
-
-QSimpleCanvasFilter::QSimpleCanvasFilter(QObject *parent)
-: QObject(parent), d(new QSimpleCanvasFilterPrivate(this))
-{
-}
-
-QSimpleCanvasFilter::~QSimpleCanvasFilter()
-{
- if (d->item) d->item->setFilter(0);
- delete d; d = 0;
-}
-
-bool QSimpleCanvasFilter::enabled() const
-{
- return d->enabled;
-}
-
-/*!
- \qmlproperty bool Filter::enabled
- \brief Controls whether the filter is applied.
-*/
-
-void QSimpleCanvasFilter::setEnabled(bool e)
-{
- if (e == d->enabled)
- return;
- d->enabled = e;
- emit enabledChanged();
- update();
-}
-
-QGLFramebufferObject *QSimpleCanvasFilter::renderToFBO(float scale, const QRectF &src, const QPoint &offset, Layer)
-{
- // XXX - respect src
-#if defined(QFX_RENDER_OPENGL2)
- Q_UNUSED(src);
- Q_UNUSED(offset);
-
- QSimpleCanvasItem *item = d->item;
- QRect br = item->itemBoundingRect();
- if (br.isEmpty())
- return 0;
- QGLFramebufferObject *fbo =
- item->canvas()->d->acquire(int(br.width() * scale), int(br.height() * scale));
-
- GLSaveViewport sv; GLSaveScissor ss;
- qreal oldOpacity = item->d_func()->data()->activeOpacity;
- item->d_func()->data()->activeOpacity = 1;
-
- fbo->bind();
-
- glClearColor(0,0,0,0);
- glEnable(GL_SCISSOR_TEST);
- glScissor(0, 0, int(br.width() * scale), int(br.height() * scale));
- glClear(GL_COLOR_BUFFER_BIT);
- glViewport(0, 0, int(br.width() * scale), int(br.height() * scale));
-
- QMatrix4x4 mat;
- mat.flipCoordinates();
- mat.translate(-1, -1, 0);
- mat.scale(2. / (br.width()), 2. / (br.height()), 1. / (1024. * 1024.));
-
- renderToScreen(mat);
-
- fbo->release();
-
- item->d_func()->data()->activeOpacity = oldOpacity;
- return fbo;
-#else
- Q_UNUSED(src);
- Q_UNUSED(offset);
- Q_UNUSED(scale);
- return 0;
-#endif
-}
-
-QGLFramebufferObject *QSimpleCanvasFilter::renderToFBO(const QRectF &src, const QPoint &offset, Layer)
-{
- // XXX - respect src
-#if defined(QFX_RENDER_OPENGL2)
- Q_UNUSED(src);
- Q_UNUSED(offset);
-
- QSimpleCanvasItem *item = d->item;
- QRect br = item->itemBoundingRect();
- if (br.isEmpty())
- return 0;
- QGLFramebufferObject *fbo =
- item->canvas()->d->acquire(br.width(), br.height());
-
- GLSaveViewport sv; GLSaveScissor ss;
- qreal oldOpacity = item->d_func()->data()->activeOpacity;
- item->d_func()->data()->activeOpacity = 1;
-
- fbo->bind();
-
- glClearColor(0,0,0,0);
- glEnable(GL_SCISSOR_TEST);
- glScissor(0, 0, br.width(), br.height());
- glClear(GL_COLOR_BUFFER_BIT);
- glViewport(0, 0, br.width(), br.height());
-
- QMatrix4x4 mat;
- mat.flipCoordinates();
- mat.translate(-1, -1, 0);
- mat.scale(2. / br.width(), 2. / br.height(), 1. / (1024. * 1024.));
-
- renderToScreen(mat);
-
- fbo->release();
-
- item->d_func()->data()->activeOpacity = oldOpacity;
- return fbo;
-#else
- Q_UNUSED(src);
- Q_UNUSED(offset);
- return 0;
-#endif
-}
-
-QGLFramebufferObject *QSimpleCanvasFilter::acquireFBO(const QSize &s)
-{
-#if defined(QFX_RENDER_OPENGL2)
- QSize size;
- QSimpleCanvasItem *item = d->item;
- if (size.isNull()) {
- QRect br = item->itemBoundingRect();
- size = br.size();
- } else {
- size = s;
- }
-
- QGLFramebufferObject *fbo =
- item->canvas()->d->acquire(s.width(), s.height());
-
- return fbo;
-#else
- Q_UNUSED(s);
- return 0;
-#endif
-}
-
-void QSimpleCanvasFilter::releaseFBO(QGLFramebufferObject *fbo)
-{
-#if defined(QFX_RENDER_OPENGL2)
- d->item->d_func()->canvas->d->release(fbo);
-#else
- Q_UNUSED(fbo);
-#endif
-}
-
-void QSimpleCanvasFilter::renderToScreen(const QRectF &src, Layer layer)
-{
- // XXX - respect src
-#if defined(QFX_RENDER_OPENGL2)
- Q_UNUSED(src);
- Q_UNUSED(layer);
- d->item->d_func()->paint(d->params, layer);
-#else
- Q_UNUSED(src);
- Q_UNUSED(layer);
-#endif
-}
-
-void QSimpleCanvasFilter::renderToScreen(const QSimpleCanvas::Matrix &trans, const QRectF &src, Layer layer)
-{
- // XXX - respect src
-#if defined(QFX_RENDER_OPENGL2)
- Q_UNUSED(src);
- QSimpleCanvas::Matrix old = d->item->d_func()->data()->transformActive;
- d->item->d_func()->data()->transformActive = trans;
- QSimpleCanvasItemPrivate::GLPaintParameters params = d->params;
- params.forceParamRefresh = true;
- d->item->d_func()->paint(params, layer);
- d->item->d_func()->data()->transformActive = old;
-#else
- Q_UNUSED(trans);
- Q_UNUSED(src);
- Q_UNUSED(layer);
-#endif
-}
-
-QSimpleCanvasItem *QSimpleCanvasFilter::item() const
-{
- return d->item;
-}
-
-void QSimpleCanvasFilter::setItem(QSimpleCanvasItem *i)
-{
- if (d->item == i)
- return;
- if (d->item) {
- d->item->setFilter(0);
- d->item = 0;
- }
-
- if (i->filter() != this) {
- i->setFilter(this);
- } else {
- d->item = i;
- }
-}
-
-#if defined(QFX_RENDER_OPENGL2)
-void QSimpleCanvasFilterPrivate::doFilterGL(QSimpleCanvasItem::GLPainter &p, const QSimpleCanvasItemPrivate::GLPaintParameters &prms)
-{
- params = prms;
- q->filterGL(p);
-}
-#endif
-
-QRectF QSimpleCanvasFilter::itemBoundingRect(const QRectF &r) const
-{
- return r;
-}
-
-void QSimpleCanvasFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
- Q_UNUSED(p);
-}
-
-void QSimpleCanvasFilter::filter(QPainter &)
-{
-}
-
-void QSimpleCanvasFilter::update()
-{
- if (d->item)
- d->item->update();
-}
-
-#if defined(QFX_RENDER_OPENGL2)
-bool QSimpleCanvasFilterPrivate::isSimpleItem(QSimpleCanvasItem *item, QSimpleCanvasItem **out, QSimpleCanvas::Matrix *mout)
-{
- if (item->options() & QSimpleCanvasItem::SimpleItem && !item->hasChildren()) {
- *out = item;
- return true;
- } else if (!(item->options() & QSimpleCanvasItem::HasContents) &&
- item->children().count() == 1) {
- QSimpleCanvasItem *child = item->children().first();
- if (child->filter() && child->filter()->enabled())
- return false;
- bool rv = isSimpleItem(child, out, mout);
- if (rv)
- *mout *= child->d_func()->localTransform();
- return rv;
- } else {
- return false;
- }
-}
-#endif
-
-bool QSimpleCanvasFilter::isSimpleItem(QSimpleCanvasItem **out, QSimpleCanvas::Matrix *mout)
-{
-#if defined(QFX_RENDER_OPENGL2)
- return d->isSimpleItem(item(), out, mout);
-#else
- Q_UNUSED(out);
- Q_UNUSED(mout);
-#endif
-
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/canvas/qsimplecanvasfilter.h b/src/declarative/canvas/qsimplecanvasfilter.h
deleted file mode 100644
index 14bb765..0000000
--- a/src/declarative/canvas/qsimplecanvasfilter.h
+++ /dev/null
@@ -1,113 +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 QSIMPLECANVASFILTER_H
-#define QSIMPLECANVASFILTER_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qfxglobal.h>
-#include <QtDeclarative/qsimplecanvasitem.h>
-#include <QtDeclarative/qsimplecanvas.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QSimpleCanvasFilterPrivate;
-class QRectF;
-class QPoint;
-class QGLFramebufferObject;
-class GLShaderProgram;
-class Q_DECLARATIVE_EXPORT QSimpleCanvasFilter : public QObject
-{
-Q_OBJECT
-public:
- QSimpleCanvasFilter(QObject *parent);
- virtual ~QSimpleCanvasFilter();
-
- enum Layer { ChildrenUnderItem = 0x01,
- Item = 0x02,
- ChildrenAboveItem = 0x04,
- All = 0x07 };
-
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- bool enabled() const;
- void setEnabled(bool);
-
- QSimpleCanvasItem *item() const;
- void setItem(QSimpleCanvasItem *);
-Q_SIGNALS:
- void enabledChanged();
-
-protected:
-
- virtual QRectF itemBoundingRect(const QRectF &) const;
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
- virtual void filter(QPainter &p);
-
- QGLFramebufferObject *renderToFBO(const QRectF &src = QRect(), const QPoint &offset = QPoint(), Layer = All);
- QGLFramebufferObject *renderToFBO(float scale, const QRectF &src = QRect(), const QPoint &offset = QPoint(), Layer = All);
- QGLFramebufferObject *acquireFBO(const QSize & = QSize());
- void releaseFBO(QGLFramebufferObject *);
-
- void renderToScreen(const QRectF &src = QRect(), Layer = All);
- void renderToScreen(const QSimpleCanvas::Matrix &trans, const QRectF &src = QRect(), Layer = All);
-
- void update();
-
- bool isSimpleItem(QSimpleCanvasItem **, QSimpleCanvas::Matrix *);
-
-private:
- friend class QSimpleCanvasFilterPrivate;
- friend class QSimpleCanvasItemPrivate;
- friend class QSimpleCanvasItem;
-
- QSimpleCanvasFilterPrivate *d;
-};
-
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif
diff --git a/src/declarative/canvas/qsimplecanvasfilter_p.h b/src/declarative/canvas/qsimplecanvasfilter_p.h
deleted file mode 100644
index 1c72993..0000000
--- a/src/declarative/canvas/qsimplecanvasfilter_p.h
+++ /dev/null
@@ -1,70 +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 QSIMPLECANVASFILTER_P_H
-#define QSIMPLECANVASFILTER_P_H
-
-#include "qsimplecanvasitem.h"
-#include "qsimplecanvasitem_p.h"
-
-
-QT_BEGIN_NAMESPACE
-class QSimpleCanvasFilterPrivate
-{
-public:
- QSimpleCanvasFilterPrivate(QSimpleCanvasFilter *_q)
- : q(_q), item(0), enabled(true) {}
-
- QSimpleCanvasFilter *q;
-
- QSimpleCanvasItem *item;
- bool enabled;
-#if defined(QFX_RENDER_OPENGL)
- QSimpleCanvasItemPrivate::GLPaintParameters params;
-
- void doFilterGL(QSimpleCanvasItem::GLPainter &, const QSimpleCanvasItemPrivate::GLPaintParameters &);
-
- bool isSimpleItem(QSimpleCanvasItem *item, QSimpleCanvasItem **out, QSimpleCanvas::Matrix *mout);
-#endif
-};
-
-QT_END_NAMESPACE
-#endif
diff --git a/src/declarative/canvas/qsimplecanvasitem.cpp b/src/declarative/canvas/qsimplecanvasitem.cpp
deleted file mode 100644
index 0ceb7b7..0000000
--- a/src/declarative/canvas/qsimplecanvasitem.cpp
+++ /dev/null
@@ -1,1885 +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 "qsimplecanvasitem.h"
-#include "qsimplecanvas.h"
-#include "qsimplecanvasitem_p.h"
-#include "qsimplecanvas_p.h"
-#include <qfxitem.h>
-#include <QGraphicsSceneEvent>
-
-
-QT_BEGIN_NAMESPACE
-QSimpleCanvasItemData::QSimpleCanvasItemData()
-: buttons(Qt::NoButton), flip(QSimpleCanvasItem::NoFlip),
- dirty(false), transformValid(true), doNotPaint(false),
- doNotPaintChildren(false), x(0), y(0), z(0),
- visible(1), transformUser(0), transformVersion(0), activeOpacity(1)
-{
-}
-
-QSimpleCanvasItemData::~QSimpleCanvasItemData()
-{
- if (transformUser)
- delete transformUser;
-}
-
-/*!
- \internal
- \class QSimpleCanvasItem
- \brief The QSimpleCanvasItem class is the base class of canvas items.
- */
-QSimpleCanvasLayer::QSimpleCanvasLayer()
-{
-}
-
-QSimpleCanvasLayer::QSimpleCanvasLayer(QSimpleCanvasItem *parent)
-: QSimpleCanvasItem(parent)
-{
-}
-
-void QSimpleCanvasLayer::addChild(QSimpleCanvasItem *c)
-{
- QSimpleCanvasItem::addChild(c);
-}
-
-void QSimpleCanvasLayer::addDirty(QSimpleCanvasItem *)
-{
-}
-
-void QSimpleCanvasLayer::remDirty(QSimpleCanvasItem *)
-{
-}
-
-QSimpleCanvasLayer *QSimpleCanvasLayer::layer()
-{
- return this;
-}
-
-QSimpleCanvasItem::Options QSimpleCanvasItem::options() const
-{
- Q_D(const QSimpleCanvasItem);
- return (QSimpleCanvasItem::Options)d->options;
-}
-
-bool QSimpleCanvasItem::mouseFilter(QGraphicsSceneMouseEvent *)
-{
- return false;
-}
-
-void QSimpleCanvasItem::mousePressEvent(QGraphicsSceneMouseEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::mouseUngrabEvent()
-{
-}
-
-void QSimpleCanvasItem::keyPressEvent(QKeyEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::keyReleaseEvent(QKeyEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::focusOutEvent(QFocusEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::focusInEvent(QFocusEvent *e)
-{
- e->ignore();
-}
-
-void QSimpleCanvasItem::activePanelInEvent()
-{
-}
-
-void QSimpleCanvasItem::activePanelOutEvent()
-{
-}
-
-void QSimpleCanvasItem::inputMethodEvent(QInputMethodEvent *e)
-{
- e->ignore();
-}
-
-QVariant QSimpleCanvasItem::inputMethodQuery(Qt::InputMethodQuery) const
-{
- return QVariant();
-}
-
-void QSimpleCanvasItem::childrenChanged()
-{
-}
-
-void QSimpleCanvasItem::setPaintMargin(qreal margin)
-{
- Q_D(QSimpleCanvasItem);
- if (margin < d->paintmargin)
- update(); // schedule repaint of old boundingRect
- d->paintmargin = margin;
-}
-
-QRectF QSimpleCanvasItem::boundingRect() const
-{
- Q_D(const QSimpleCanvasItem);
- return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2);
-}
-
-void QSimpleCanvasItem::paintContents(QPainter &)
-{
-}
-
-void QSimpleCanvasItem::paintGLContents(GLPainter &)
-{
-}
-
-uint QSimpleCanvasItem::glSimpleItemData(float *vertices, float *texVertices,
- GLTexture **texture, uint count)
-{
- Q_UNUSED(vertices);
- Q_UNUSED(texVertices);
- Q_UNUSED(texture);
- Q_UNUSED(count);
- return 0;
-}
-
-void QSimpleCanvasItem::canvasChanged()
-{
-}
-
-void QSimpleCanvasItem::focusChanged(bool)
-{
-}
-
-void QSimpleCanvasItem::activeFocusChanged(bool)
-{
-}
-
-void QSimpleCanvasItem::parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *)
-{
-}
-
-GLBasicShaders *QSimpleCanvasItem::basicShaders() const
-{
-#if defined(QFX_RENDER_OPENGL2)
- return canvas()->d->basicShaders();
-#else
- return 0;
-#endif
-}
-
-/*!
- Returns the item's (0, 0) point relative to its parent.
- */
-QPointF QSimpleCanvasItem::pos() const
-{
- return QPointF(x(),y());
-}
-
-/*!
- Returns the item's (0, 0) point mapped to scene coordinates.
- */
-QPointF QSimpleCanvasItem::scenePos() const
-{
- return mapToScene(QPointF(0, 0));
-}
-
-/*!
- \enum QSimpleCanvasItem::TransformOrigin
-
- Controls the point about which simple transforms like scale apply.
-
- \value TopLeft The top-left corner of the item.
- \value TopCenter The center point of the top of the item.
- \value TopRight The top-right corner of the item.
- \value MiddleLeft The left most point of the vertical middle.
- \value Center The center of the item.
- \value MiddleRight The right most point of the vertical middle.
- \value BottomLeft The bottom-left corner of the item.
- \value BottomCenter The center point of the bottom of the item.
- \value BottomRight The bottom-right corner of the item.
-*/
-
-/*!
- Returns the current transform origin.
-*/
-QSimpleCanvasItem::TransformOrigin QSimpleCanvasItem::transformOrigin() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->origin;
-}
-
-/*!
- Set the transform \a origin.
-*/
-void QSimpleCanvasItem::setTransformOrigin(TransformOrigin origin)
-{
- Q_D(QSimpleCanvasItem);
- if (origin != d->origin) {
- d->origin = origin;
- update();
- }
-}
-
-QPointF QSimpleCanvasItem::transformOriginPoint() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->transformOrigin();
-}
-
-/*!
- Returns the canvas the item is on, or 0 if the item is not on a canvas.
- */
-QSimpleCanvas *QSimpleCanvasItem::canvas() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->canvas;
-}
-
-/*!
- Returns the parent if the item, or 0 if the item has no parent.
- */
-QSimpleCanvasItem *QSimpleCanvasItem::parent() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->parent;
-}
-
-void QSimpleCanvasItemPrivate::zOrderChildren()
-{
- if (!needsZOrder || children.count() <= 1)
- return;
-
- needsZOrder = false;
- // This is a bubble sort for a reason - it is the fastest sort for a mostly
- // ordered list. We only expect z ordering to change infrequently.
- bool swap = true;
- int c = 0;
- while(swap) {
- ++c;
- swap = false;
- QSimpleCanvasItem *item = children.first();
- qreal z = item->z();
- for (int ii = 1; ii < children.count(); ++ii) {
- QSimpleCanvasItem *i2 = children.at(ii);
- qreal z2 = i2->z();
- if (z2 < z) {
- swap = true;
- children[ii] = item;
- children[ii - 1] = i2;
- } else {
- item = i2;
- z = z2;
- }
- }
- }
-}
-
-void QSimpleCanvasItemPrivate::canvasChanged(QSimpleCanvas *newCanvas, QSimpleCanvas *oldCanvas)
-{
- Q_Q(QSimpleCanvasItem);
- canvas = newCanvas;
- if (options & QSimpleCanvasItem::MouseFilter) {
- if (oldCanvas) oldCanvas->d->removeMouseFilter(q);
- if (newCanvas) newCanvas->d->installMouseFilter(q);
- }
- if (newCanvas) {
- if (!oldCanvas && hasFocus)
- newCanvas->d->setFocusItem(q, Qt::OtherFocusReason, false);
- if (wantsActiveFocusPanelPendingCanvas) {
- hasBeenActiveFocusPanel = true;
- newCanvas->d->setActiveFocusPanel(q);
- wantsActiveFocusPanelPendingCanvas = false;
- }
- }
-
- for (int ii = 0; ii < children.count(); ++ii)
- children.at(ii)->d_func()->canvasChanged(newCanvas, oldCanvas);
- q->canvasChanged();
-}
-
-void QSimpleCanvasItem::setFocus(bool focus)
-{
- Q_D(QSimpleCanvasItem);
- if (d->hasFocus == focus)
- return;
- QSimpleCanvas *c = canvas();
-
- if (c) {
- if (focus)
- c->d->setFocusItem(this, Qt::OtherFocusReason);
- else
- c->d->clearFocusItem(this);
- } else {
- d->setFocus(focus);
- focusChanged(d->hasFocus);
- }
-}
-
-qreal QSimpleCanvasItem::x() const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem)
- return d->graphicsItem->x();
- else if (d->data_ptr)
- return d->data()->x;
- else
- return 0;
-}
-
-qreal QSimpleCanvasItem::y() const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem)
- return d->graphicsItem->y();
- else if (d->data_ptr)
- return d->data()->y;
- else
- return 0;
-}
-
-qreal QSimpleCanvasItem::z() const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem)
- return d->graphicsItem->zValue();
- else if (d->data_ptr)
- return d->data()->z;
- else
- return 0;
-}
-
-void QSimpleCanvasItem::setX(qreal x)
-{
- Q_D(QSimpleCanvasItem);
- if (x == this->x())
- return;
-
- qreal oldX = this->x();
-
- if (d->graphicsItem) {
- d->graphicsItem->setPos(x, y());
- } else {
- d->data()->x = x;
- update();
- }
-
- geometryChanged(QRectF(this->x(), y(), width(), height()),
- QRectF(oldX, y(), width(), height()));
-}
-
-void QSimpleCanvasItem::setY(qreal y)
-{
- Q_D(QSimpleCanvasItem);
- if (y == this->y())
- return;
-
- qreal oldY = this->y();
-
- if (d->graphicsItem) {
- d->graphicsItem->setPos(x(), y);
- } else {
- d->data()->y = y;
- update();
- }
-
- geometryChanged(QRectF(x(), this->y(), width(), height()),
- QRectF(x(), oldY, width(), height()));
-}
-
-void QSimpleCanvasItem::setZ(qreal z)
-{
- Q_D(QSimpleCanvasItem);
- if (z == this->z())
- return;
-
- if (d->graphicsItem) {
-
- if (z < 0)
- d->graphicsItem->setFlag(QGraphicsItem::ItemStacksBehindParent,
- true);
- else
- d->graphicsItem->setFlag(QGraphicsItem::ItemStacksBehindParent,
- false);
-
- d->graphicsItem->setZValue(z);
-
- } else {
- if (d->data()->z == z)
- return;
-
- d->data()->z = z;
- if (parent())
- static_cast<QSimpleCanvasItemPrivate*>(parent()->d_ptr)->needsZOrder = true;
- update();
- }
-}
-
-qreal QSimpleCanvasItem::width() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->width;
-}
-
-void QSimpleCanvasItem::setWidth(qreal w)
-{
- Q_D(QSimpleCanvasItem);
- d->widthValid = true;
- if (d->width == w)
- return;
-
- qreal oldWidth = d->width;
-
- d->width = w;
- update();
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), oldWidth, height()));
-}
-
-void QSimpleCanvasItem::setImplicitWidth(qreal w)
-{
- Q_D(QSimpleCanvasItem);
- if (d->width == w || widthValid())
- return;
-
- qreal oldWidth = d->width;
-
- d->width = w;
- update();
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), oldWidth, height()));
-}
-
-bool QSimpleCanvasItem::widthValid() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->widthValid;
-}
-
-qreal QSimpleCanvasItem::height() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->height;
-}
-
-void QSimpleCanvasItem::setHeight(qreal h)
-{
- Q_D(QSimpleCanvasItem);
- d->heightValid = true;
- if (d->height == h)
- return;
-
- qreal oldHeight = d->height;
-
- d->height = h;
- update();
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), width(), oldHeight));
-}
-
-void QSimpleCanvasItem::setImplicitHeight(qreal h)
-{
- Q_D(QSimpleCanvasItem);
- if (d->height == h || heightValid())
- return;
-
- qreal oldHeight = d->height;
-
- d->height = h;
- update();
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(x(), y(), width(), oldHeight));
-}
-
-bool QSimpleCanvasItem::heightValid() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->heightValid;
-}
-
-void QSimpleCanvasItem::setPos(const QPointF &point)
-{
- Q_D(QSimpleCanvasItem);
- qreal oldX = x();
- qreal oldY = y();
-
- if (d->graphicsItem) {
- d->graphicsItem->setPos(point);
- } else {
- d->data()->x = point.x();
- d->data()->y = point.y();
- update();
- }
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(oldX, oldY, width(), height()));
-}
-
-qreal QSimpleCanvasItem::scale() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->scale;
-}
-
-void QSimpleCanvasItem::setScale(qreal s)
-{
- Q_D(QSimpleCanvasItem);
- d->scale = s;
- if (d->graphicsItem) {
- QTransform t;
- QPointF to = transformOriginPoint();
- if (to.x() != 0. || to.y() != 0.)
- t.translate(to.x(), to.y());
- t.scale(s, s);
- if (to.x() != 0. || to.y() != 0.)
- t.translate(-to.x(), -to.y());
- d->graphicsItem->setTransform(t * d->graphicsItem->transform);
- } else {
- update();
- }
-}
-
-bool QSimpleCanvasItem::isVisible() const
-{
- if (visible() <= 0)
- return false;
- else if (!parent())
- return true;
- else
- return parent()->isVisible();
-}
-
-qreal QSimpleCanvasItem::visible() const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem)
- return d->graphicsItem->opacity();
- else if (d->data_ptr)
- return d->data()->visible;
- else
- return 1;
-}
-
-void QSimpleCanvasItem::setVisible(qreal v)
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem) {
- d->graphicsItem->setOpacity(v);
- } else {
- if (v == visible())
- return;
- if (v == 0)
- update();
-
- d->data()->visible = v;
-
- if (v != 0)
- update();
- }
-}
-
-void QSimpleCanvasItem::addChild(QSimpleCanvasItem *c)
-{
- Q_D(QSimpleCanvasItem);
- d->children.append(c);
- if (!d->graphicsItem)
- d->needsZOrder = true;
- childrenChanged();
-}
-
-void QSimpleCanvasItem::remChild(QSimpleCanvasItem *c)
-{
- Q_D(QSimpleCanvasItem);
- d->children.removeAll(c);
- childrenChanged();
-}
-
-QSimpleCanvasFilter *QSimpleCanvasItem::filter() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->filter;
-}
-
-/*!
-QSimpleCanvasItem takes ownership of filter.
-*/
-void QSimpleCanvasItem::setFilter(QSimpleCanvasFilter *f)
-{
- Q_D(QSimpleCanvasItem);
- if (!d || f == d->filter)
- return;
-
- d->filter = f;
- if (d->filter)
- d->filter->setItem(this);
- update();
-}
-
-const QList<QSimpleCanvasItem *> &QSimpleCanvasItem::children() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->children;
-}
-
-bool QSimpleCanvasItem::hasChildren() const
-{
- Q_D(const QSimpleCanvasItem);
- return !d->children.isEmpty();
-}
-
-QSimpleCanvasLayer *QSimpleCanvasItem::layer()
-{
- if (parent())
- return parent()->layer();
- else
- return 0;
-}
-
-void QSimpleCanvasItem::update()
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem) {
- d->graphicsItem->update();
- } else {
- if (!parent())
- return;
-
- if (d->data()->dirty || 0. == d->data()->visible) return;
-
- QSimpleCanvasLayer *l = layer();
- if (l == this && parent())
- l = parent()->layer();
- if (l) {
- l->addDirty(this);
- d->data()->dirty = true;
- d->data()->transformValid = false;
- }
- }
-}
-
-bool QSimpleCanvasItem::clip() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->clip;
-}
-
-void QSimpleCanvasItem::setClip(bool c)
-{
- Q_D(const QSimpleCanvasItem);
- if (bool(d->clip) == c)
- return;
-
- if (c)
- setClipType(ClipToRect);
- else
- setClipType(NoClip);
-
- update();
-}
-
-QSimpleCanvasItem::ClipType QSimpleCanvasItem::clipType() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->clip;
-}
-
-void QSimpleCanvasItem::setClipType(ClipType c)
-{
- Q_D(QSimpleCanvasItem);
- d->clip = c;
- if (d->graphicsItem)
- d->graphicsItem->setFlag(QGraphicsItem::ItemClipsChildrenToShape, bool(c));
- else
- update();
-}
-
-Qt::MouseButtons QSimpleCanvasItem::acceptedMouseButtons() const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem)
- return d->graphicsItem->acceptedMouseButtons();
- else if (d->data_ptr)
- return (Qt::MouseButtons)d->data()->buttons;
- else
- return Qt::NoButton;
-}
-
-void QSimpleCanvasItem::setAcceptedMouseButtons(Qt::MouseButtons buttons)
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem)
- d->graphicsItem->setAcceptedMouseButtons(buttons);
- else
- d->data()->buttons = buttons;
-}
-
-
-QRect QSimpleCanvasItem::itemBoundingRect()
-{
- return boundingRect().toAlignedRect();
-}
-
-QPointF QSimpleCanvasItemPrivate::adjustFrom(const QPointF &p) const
-{
-#if defined(QFX_RENDER_OPENGL)
- if (!canvas)
- return p;
-
- QPointF rv(-1. + 2. * p.x() / qreal(canvas->width()),
- 1 - 2. * p.y() / qreal(canvas->height()));
-
- return rv;
-#else
- return p;
-#endif
-}
-
-QRectF QSimpleCanvasItemPrivate::adjustFrom(const QRectF &r) const
-{
-#if defined(QFX_RENDER_OPENGL)
- if (!canvas)
- return r;
-
- qreal width = r.width() * 2. / qreal(canvas->width());
- qreal height = r.height() * 2. / qreal(canvas->height());
- qreal x = -1. + 2. * r.x() / qreal(canvas->width());
- qreal y = 1. - 2. * r.y() / qreal(canvas->height()) - height;
-
- return QRectF(x, y, width, height);
-#else
- return r;
-#endif
-}
-
-QPointF QSimpleCanvasItemPrivate::adjustTo(const QPointF &p) const
-{
-#if defined(QFX_RENDER_OPENGL)
- if (!canvas)
- return p;
-
- QPointF rv(0.5 * (p.x() + 1.) * qreal(canvas->width()),
- 0.5 * (1. - p.y()) * qreal(canvas->height()));
-
- return rv;
-#else
- return p;
-#endif
-}
-
-QRectF QSimpleCanvasItemPrivate::adjustTo(const QRectF &r) const
-{
-#if defined(QFX_RENDER_OPENGL)
- if (!canvas)
- return r;
-
- qreal width = 0.5 * r.width() * qreal(canvas->width());
- qreal height = 0.5 * r.height() * qreal(canvas->height());
- qreal x = 0.5 * (r.x() + 1.) * qreal(canvas->width());
- qreal y = 0.5 * (1. - r.y()) * qreal(canvas->height()) - height;
-
- return QRectF(x, y, width, height);
-#else
- return r;
-#endif
-}
-
-QPointF QSimpleCanvasItem::mapFromScene(const QPointF &p) const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem) {
- return d->graphicsItem->mapFromScene(p);
- } else {
- QPointF mp = d->adjustFrom(p);
- d->freshenTransforms();
-#if defined(QFX_RENDER_OPENGL)
- // m20X + m21Y + m22Z + m23 = 1
- // Z = (1 - m23 - m20X - m21Y) / m22
-
- QMatrix4x4 inv = d->data()->transformActive.inverted();
- qreal z_s = (1 - inv(2,3) - inv(2,0) * mp.x() - inv(2, 1) * mp.y()) / inv(2, 2);
-
- QVector3D vec(mp.x(), mp.y(), z_s);
- QVector3D r = inv.map(vec);
-
- return r.toPointF();
-#else
- return d->data()->transformActive.inverted().map(mp);
-#endif
- }
-}
-
-QRectF QSimpleCanvasItem::mapFromScene(const QRectF &r) const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem) {
- return d->graphicsItem->mapFromScene(r).boundingRect();
- } else {
- QRectF mr = d->adjustFrom(r);
- d->freshenTransforms();
-#if defined(QFX_RENDER_OPENGL)
- // m20X + m21Y + m22Z + m23 = 1
- // Z = (1 - m23 - m20X - m21Y) / m22
-
- QMatrix4x4 inv = d->data()->transformActive.inverted();
- qreal tl_z_s = (1 - inv(2,3) - inv(2,0) * mr.topLeft().x() - inv(2, 1) * mr.topLeft().y()) / inv(2, 2);
- qreal tr_z_s = (1 - inv(2,3) - inv(2,0) * mr.topRight().x() - inv(2, 1) * mr.topRight().y()) / inv(2, 2);
- qreal bl_z_s = (1 - inv(2,3) - inv(2,0) * mr.bottomLeft().x() - inv(2, 1) * mr.bottomLeft().y()) / inv(2, 2);
- qreal br_z_s = (1 - inv(2,3) - inv(2,0) * mr.bottomRight().x() - inv(2, 1) * mr.bottomRight().y()) / inv(2, 2);
-
- QVector3D tl(mr.topLeft().x(), mr.topLeft().y(), tl_z_s);
- QVector3D tr(mr.topRight().x(), mr.topRight().y(), tr_z_s);
- QVector3D bl(mr.bottomLeft().x(), mr.bottomLeft().y(), bl_z_s);
- QVector3D br(mr.bottomRight().x(), mr.bottomRight().y(), br_z_s);
-
- tl = inv.map(tl); tr = inv.map(tr); bl = inv.map(bl); br = inv.map(br);
-
- qreal xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));
- qreal xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));
- qreal ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));
- qreal ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));
-
- return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
-#else
- return d->data()->transformActive.inverted().mapRect(mr);
-#endif
- }
-}
-
-QPointF QSimpleCanvasItem::mapToScene(const QPointF &p) const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem) {
- return d->graphicsItem->mapToScene(p);
- } else {
- d->freshenTransforms();
- QPointF rp = d->data()->transformActive.map(p);
- return d->adjustTo(rp);
- }
-}
-
-QRectF QSimpleCanvasItem::mapToScene(const QRectF &r) const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem) {
- return d->graphicsItem->mapToScene(r).boundingRect();
- } else {
- d->freshenTransforms();
- QRectF rr = d->data()->transformActive.mapRect(r);
- return d->adjustTo(rr);
- }
-}
-
-void QSimpleCanvasItemPrivate::freshenTransforms() const
-{
- if (freshenNeeded())
- doFreshenTransforms();
-}
-
-bool QSimpleCanvasItemPrivate::freshenNeeded() const
-{
-#if 0
- return parent &&
- (data()->transformVersion == -1 ||
- data()->parentTransformVersion == -1 ||
- parent->d_func()->data()->transformVersion != data()->parentTransformVersion);
-#else
- const QSimpleCanvasItemPrivate *me = this;
- while(me) {
- if (me->data_ptr && !me->data_ptr->transformValid)
- return true;
- if (me->parent)
- me = me->parent->d_func();
- else
- me = 0;
- }
- return false;
-#endif
-}
-
-void QSimpleCanvasItemPrivate::doFreshenTransforms() const
-{
- Q_Q(const QSimpleCanvasItem);
- if (parent)
- parent->d_func()->doFreshenTransforms();
-
- if (freshenNeeded()) {
- if (parent)
- data()->transformActive = parent->d_func()->data()->transformActive;
- else
- data()->transformActive = QSimpleCanvas::Matrix();
- data()->transformActive.translate(q->x(), q->y());
- if (scale != 1.) {
- QPointF to = transformOrigin();
- if (to.x() != 0. || to.y() != 0.)
- data()->transformActive.translate(to.x(), to.y());
- data()->transformActive.scale(scale, scale);
- if (to.x() != 0. || to.y() != 0.)
- data()->transformActive.translate(-to.x(), -to.y());
- }
-
- Q_Q(const QSimpleCanvasItem);
-#if defined(QFX_RENDER_OPENGL)
- if (q->d_func()->data()->transformUser)
- data()->transformActive *= *q->d_func()->data()->transformUser;
-#endif
-
- if (data()->flip) {
- QRectF br = q->boundingRect();
- data()->transformActive.translate(br.width() / 2., br.height() / 2);
-#if defined(QFX_RENDER_OPENGL)
- data()->transformActive.rotate(180, (data()->flip & QSimpleCanvasItem::VerticalFlip)?1:0, (data()->flip & QSimpleCanvasItem::HorizontalFlip)?1:0, 0);
-#else
- data()->transformActive.scale((data()->flip & QSimpleCanvasItem::HorizontalFlip)?-1:1,
- (data()->flip & QSimpleCanvasItem::VerticalFlip)?-1:1);
-#endif
- data()->transformActive.translate(-br.width() / 2., -br.height() / 2);
- }
- }
-}
-
-QSimpleCanvas::Matrix QSimpleCanvasItem::transform() const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem)
- return QSimpleCanvasConfig::transformToMatrix(d->graphicsItem->transform);
- else if (d->data()->transformUser)
- return *d->data()->transformUser;
- else
- return QSimpleCanvas::Matrix();
-}
-
-void QSimpleCanvasItem::setTransform(const QSimpleCanvas::Matrix &m)
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem) {
- d->graphicsItem->transform = QSimpleCanvasConfig::matrixToTransform(m);
- QTransform t;
- if (d->scale != 1) {
- QPointF to = transformOriginPoint();
- if (to.x() != 0. || to.y() != 0.)
- t.translate(to.x(), to.y());
- t.scale(d->scale, d->scale);
- if (to.x() != 0. || to.y() != 0.)
- t.translate(-to.x(), -to.y());
- }
- d->graphicsItem->setTransform(t * d->graphicsItem->transform);
- } else {
- if (!d->data()->transformUser)
- d->data()->transformUser = new QSimpleCanvas::Matrix;
- *d->data()->transformUser = m;
- update();
- }
-}
-
-QSimpleCanvasItem *QSimpleCanvasItem::mouseGrabberItem() const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem) {
- QGraphicsScene *s = d->graphicsItem->scene();
- if (s) {
- QGraphicsItem *item = s->mouseGrabberItem();
- QSimpleGraphicsItem *dgi = static_cast<QSimpleGraphicsItem *>(item);
- return dgi?static_cast<QSimpleCanvasItem*>(dgi->owner):0;
- }
- } else {
- QSimpleCanvas *c = canvas();
- if (c)
- return c->d->lastMouseItem;
- }
- return 0;
-}
-
-void QSimpleCanvasItem::ungrabMouse()
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem) {
- d->graphicsItem->ungrabMouse();
- } else {
- QSimpleCanvas *c = canvas();
- if (c && c->d->lastMouseItem == this) {
- c->d->lastMouseItem->mouseUngrabEvent();
- c->d->lastMouseItem = 0;
- }
- }
-}
-
-void QSimpleCanvasItem::grabMouse()
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem) {
- d->graphicsItem->grabMouse();
- } else {
- QSimpleCanvas *c = canvas();
- if (c) {
- if (c->d->lastMouseItem != this) {
- if (c->d->lastMouseItem)
- c->d->lastMouseItem->mouseUngrabEvent();
- c->d->lastMouseItem = this;
- }
- }
- }
-}
-
-bool QSimpleCanvasItem::isFocusable() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->focusable;
-}
-
-void QSimpleCanvasItem::setFocusable(bool f)
-{
- Q_D(QSimpleCanvasItem);
- d->focusable = f;
-}
-
-bool QSimpleCanvasItem::hasFocus() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->hasFocus;
-}
-
-void QSimpleCanvasItemPrivate::setFocus(bool f)
-{
- hasFocus = f;
-}
-
-void QSimpleCanvasItemPrivate::setActiveFocus(bool f)
-{
- hasActiveFocus = f;
-
- if (graphicsItem) {
- if (f) {
- if (!(graphicsItem->flags() & QGraphicsItem::ItemIsFocusable))
- graphicsItem->setFlag(QGraphicsItem::ItemIsFocusable);
- graphicsItem->setFocus();
- } else {
- graphicsItem->clearFocus();
- if ((graphicsItem->flags() & QGraphicsItem::ItemIsFocusable) && !focusable)
- graphicsItem->setFlag(QGraphicsItem::ItemIsFocusable, false);
- }
-
- }
-}
-
-QSimpleCanvasItem::Flip QSimpleCanvasItem::flip() const
-{
- Q_D(const QSimpleCanvasItem);
- if (d->graphicsItem)
- return NoFlip;
- else if (d->data_ptr)
- return d->data()->flip;
- else
- return NoFlip;
-}
-
-void QSimpleCanvasItem::setFlip(Flip f)
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem)
- return;
-
- if (d->data()->flip == f)
- return;
-
- d->data()->flip = f;
- update();
-}
-
-/*!
- Places the item under \a item in the parent item's stack.
-
- The item itself and \a item must be siblings, or this method has no effect.
-
- \sa stackOver(), stackAt()
- */
-void QSimpleCanvasItem::stackUnder(QSimpleCanvasItem *item)
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem)
- return; // XXX
-
- QSimpleCanvasItem *p = parent();
- if (!p || !item || item == this) return;
-
- QSimpleCanvasItemPrivate *parent_d_ptr = static_cast<QSimpleCanvasItemPrivate*>(p->d_ptr);
- int idx = parent_d_ptr->children.indexOf(item);
- if (idx == -1) return;
-
- parent_d_ptr->children.removeAll(this);
- idx = parent_d_ptr->children.indexOf(item);
- parent_d_ptr->children.insert(idx + 1, this);
- parent_d_ptr->needsZOrder = true;
-
- p->childrenChanged();
-}
-
-/*!
- Places the item over \a item in the parent item's stack.
-
- The item itself and \a item must be siblings, or this method has no effect.
-
- \sa stackUnder(), stackAt()
- */
-void QSimpleCanvasItem::stackOver(QSimpleCanvasItem *item)
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem)
- return; // XXX
-
- QSimpleCanvasItem *p = parent();
- if (!p || !item || item == this) return;
-
- QSimpleCanvasItemPrivate *parent_d_ptr = static_cast<QSimpleCanvasItemPrivate*>(p->d_ptr);
- int idx = parent_d_ptr->children.indexOf(item);
- if (idx == -1) return;
-
- parent_d_ptr->children.removeAll(this);
- idx = parent_d_ptr->children.indexOf(item);
- parent_d_ptr->children.insert(idx, this);
- parent_d_ptr->needsZOrder = true;
-
- p->childrenChanged();
-}
-
-/*!
- Places the item at position \a index in the parent item's stack.
-
- If index is zero or less, the item is placed at the beginning of the
- stack. If the index is greater than the number of items in the stack, the
- item is placed at the end.
-
- \sa stackOver(), stackUnder()
- */
-void QSimpleCanvasItem::stackAt(int index)
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem)
- return; // XXX
-
- QSimpleCanvasItem *p = parent();
- if (!p) return;
-
- QSimpleCanvasItemPrivate *parent_d_ptr = static_cast<QSimpleCanvasItemPrivate*>(p->d_ptr);
- parent_d_ptr->children.removeAll(this);
-
- if (index < 0) index = 0;
- if (index > parent_d_ptr->children.size()) index = parent_d_ptr->children.size();
-
- parent_d_ptr->children.insert(index, this);
- parent_d_ptr->needsZOrder = true;
- p->childrenChanged();
-}
-
-/*!
- Returns the current stacking index for the child \a item.
-
- If \a item is not a child, -1 is returned.
-
- \sa stackAt()
- */
-int QSimpleCanvasItem::indexForChild(QSimpleCanvasItem *item)
-{
- Q_D(QSimpleCanvasItem);
- return d->children.indexOf(item);
-}
-
-bool QSimpleCanvasItem::eventFilter(QObject *o, QEvent *e)
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem) {
- switch(e->type()) {
- case QEvent::GraphicsSceneMouseDoubleClick:
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- if (mouseFilter(static_cast<QGraphicsSceneMouseEvent *>(e)))
- return true;
- break;
- default:
- break;
- }
- }
-
- return QObject::eventFilter(o, e);
-}
-
-void QSimpleCanvasItem::setOptions(Options options, bool set)
-{
- Q_D(QSimpleCanvasItem);
- Options old = (Options)d->options;
-
- if (options & IsFocusPanel) {
- if (!set) {
- qWarning("QSimpleCanvasItem::setOptions: Cannot unset IsFocusPanel");
- return;
- } else if (hasChildren()) {
- qWarning("QSimpleCanvasItem::setOptions: Cannot set IsFocusPanel once item has children");
- return;
- }
- }
-
- if (options & IsFocusRealm) {
- if (!set) {
- qWarning("QSimpleCanvasItem::setOptions: Cannot unset IsFocusRealm");
- return;
- }
- }
-
- if (set)
- d->options |= options;
- else
- d->options &= ~options;
-
- if ((d->options & IsFocusPanel) && (d->options & IsFocusRealm)) {
- qWarning("QSimpleCanvasItem::setOptions: Cannot set both IsFocusPanel and IsFocusRealm. IsFocusRealm will be unset.");
- d->options &= ~IsFocusRealm;
- }
-
- if (d->graphicsItem)
- d->graphicsItem->setFlag(QGraphicsItem::ItemHasNoContents, !(d->options & HasContents));
-
- if ((old & MouseFilter) != (d->options & MouseFilter)) {
- if (d->graphicsItem) {
- if (d->options & MouseFilter)
- d->gvAddMouseFilter();
- else
- d->gvRemoveMouseFilter();
-
- } else {
- QSimpleCanvas *c = canvas();
- if (c) {
- if (d->options & MouseFilter)
- c->d->installMouseFilter(this);
- else
- c->d->removeMouseFilter(this);
- }
- }
- }
-}
-
-QSimpleCanvasItem::QSimpleCanvasItem(QSimpleCanvasItemPrivate &dd, QSimpleCanvasItem *parent)
-: QObject(dd, parent)
-{
-}
-
-QSimpleCanvasItem::QSimpleCanvasItem(QSimpleCanvasItem *p)
-: QObject(*(new QSimpleCanvasItemPrivate), p)
-{
-}
-
-QSimpleCanvasItem::~QSimpleCanvasItem()
-{
- Q_D(QSimpleCanvasItem);
- if (d->graphicsItem) {
- if ((d->options & (IsFocusPanel|IsFocusRealm)) && d->canvas)
- d->canvas->d->focusPanelData.remove(this);
- if (d->hasFocus && d->canvas) {
- QSimpleCanvasItem *prnt = parent();
- while (prnt && !(prnt->options() & (IsFocusPanel|IsFocusRealm)))
- prnt = prnt->parent();
- if (prnt && d->canvas->d->focusPanelData.value(prnt) == this)
- d->canvas->d->focusPanelData.remove(prnt);
- }
- if (d->filter)
- delete d->filter;
-
- qDeleteAll(children());
- if (parent())
- parent()->remChild(this);
- delete d->graphicsItem;
- } else {
- update();
- setOptions(MouseFilter, false);
-
- if (d->canvas){
- if (d->canvas->focusItem() == this)
- d->canvas->d->focusItem = 0;
- if (d->canvas->d->lastFocusItem == this)
- d->canvas->d->lastFocusItem = 0;
- if (d->hasBeenActiveFocusPanel)
- d->canvas->d->clearFocusPanel(this);
- if (d->hasFocus)
- d->canvas->d->clearFocusItem(this);
- }
-
- while(!d->children.isEmpty()) {
- QSimpleCanvasItem *child = d->children.takeFirst();
- delete child;
- }
-
- delete d->filter;
-
- if (parent() && d->data_ptr && d->data()->dirty) {
- QSimpleCanvasLayer *l = parent()->layer();
- if (l) {
- l->remDirty(this);
- }
- }
- if (d->parent)
- d->parent->remChild(this);
-
-
- if (d->data_ptr)
- delete d->data_ptr;
- }
-}
-
-QSimpleCanvasItem::operator QGraphicsItem *()
-{
- Q_D(QSimpleCanvasItem);
- if (!d->graphicsItem) {
- if (parent()) {
- qWarning("QSimpleCanvasItem: Only the root item can be converted into a QGraphicsItem");
- return 0;
- }
- d->convertToGraphicsItem();
- }
- return d->graphicsItem;
-}
-
-QSimpleCanvasItem::operator QmlDebuggerStatus *()
-{
- Q_D(QSimpleCanvasItem);
- if(!d->debuggerStatus)
- d->debuggerStatus = new QSimpleCanvasItemDebuggerStatus(this);
- return d->debuggerStatus;
-}
-
-QPointF QSimpleCanvasItemPrivate::transformOrigin() const
-{
- Q_Q(const QSimpleCanvasItem);
-
- QRectF br = q->boundingRect();
-
- switch(origin) {
- default:
- case QSimpleCanvasItem::TopLeft:
- return QPointF(0, 0);
- case QSimpleCanvasItem::TopCenter:
- return QPointF(br.width() / 2., 0);
- case QSimpleCanvasItem::TopRight:
- return QPointF(br.width(), 0);
- case QSimpleCanvasItem::MiddleLeft:
- return QPointF(0, br.height() / 2.);
- case QSimpleCanvasItem::Center:
- return QPointF(br.width() / 2., br.height() / 2.);
- case QSimpleCanvasItem::MiddleRight:
- return QPointF(br.width(), br.height() / 2.);
- case QSimpleCanvasItem::BottomLeft:
- return QPointF(0, br.height());
- case QSimpleCanvasItem::BottomCenter:
- return QPointF(br.width() / 2., br.height());
- case QSimpleCanvasItem::BottomRight:
- return QPointF(br.width(), br.height());
- }
-}
-
-void QSimpleCanvasItemPrivate::setParentInternal(QSimpleCanvasItem *p)
-{
- Q_Q(QSimpleCanvasItem);
- QSimpleCanvasItem *oldParent = parent;
- if (graphicsItem) {
- if (oldParent)
- oldParent->remChild(q);
-
- parent = p;
- graphicsItem->setParentItem(p->d_func()->graphicsItem);
-
- if (parent)
- p->addChild(q);
-
- } else {
- bool canvasChange = false;
- if (p)
- canvasChange = (p->d_func()->canvas != canvas);
- QSimpleCanvas *old = canvas;
-
- QSimpleCanvasLayer *o = q->layer();
- if (q->parent()) {
- q->update();
- q->parent()->remChild(q);
- }
- parent = p;
- QSimpleCanvasLayer *n = 0;
- if (q->parent()) {
- q->parent()->addChild(q);
- n = q->layer();
- }
-
- if (o != n) {
- data()->dirty = false;
- data()->transformValid = false;
- if (o) o->remDirty(q);
- if (n) n->addDirty(q);
- }
-
- if (canvasChange)
- canvasChanged(p->d_func()->canvas, old);
-
- q->update();
- }
-}
-
-void QSimpleCanvasItemPrivate::convertToGraphicsItem(QGraphicsItem *parent)
-{
- Q_Q(QSimpleCanvasItem);
- Q_ASSERT(!graphicsItem);
- graphicsItem = new QSimpleGraphicsItem(q);
- graphicsItem->setFlag(QGraphicsItem::ItemHasNoContents, !(q->options() & QSimpleCanvasItem::HasContents));
- if (parent)
- graphicsItem->setParentItem(parent);
-
- QSimpleCanvasItemData *old = data_ptr;
- data_ptr = 0;
-
- if (old) {
- q->QSimpleCanvasItem::setX(old->x);
- q->QSimpleCanvasItem::setY(old->y);
- q->QSimpleCanvasItem::setZ(old->z);
- q->QSimpleCanvasItem::setVisible(old->visible);
- if (old->transformUser)
- q->QSimpleCanvasItem::setTransform(*old->transformUser);
- q->QSimpleCanvasItem::setFlip(old->flip);
- q->QSimpleCanvasItem::setAcceptedMouseButtons((Qt::MouseButtons)old->buttons);
- delete old;
- }
-
- if (scale != 1) {
- qreal s = scale;
- scale = 1;
- q->QSimpleCanvasItem::setScale(s);
- }
-
- q->setClipType(clip);
-
- for (int ii = 0; ii < children.count(); ++ii)
- static_cast<QSimpleCanvasItemPrivate*>(children.at(ii)->d_ptr)->convertToGraphicsItem(graphicsItem);
-}
-
-/*!
- \fn void QSimpleCanvasItem::setParent(QSimpleCanvasItem *parent)
-
- Sets the parent of the item to \a parent.
- */
-void QSimpleCanvasItem::setParent(QSimpleCanvasItem *p)
-{
- Q_D(QSimpleCanvasItem);
- if (p == parent() || !p) return;
-
- QObject::setParent(p);
-
- if (d->graphicsItem && !static_cast<QSimpleCanvasItemPrivate*>(p->d_ptr)->graphicsItem)
- qWarning("QSimpleCanvasItem: Cannot reparent a QGraphicsView item to a QSimpleCanvas item");
-
- if (static_cast<QSimpleCanvasItemPrivate*>(p->d_ptr)->graphicsItem && !d->graphicsItem) {
- d->setParentInternal(0);
- d->convertToGraphicsItem();
- }
-
- QSimpleCanvasItem *oldParent = d->parent;
- d->setParentInternal(p);
- parentChanged(p, oldParent);
-}
-
-int QSimpleCanvasItemPrivate::dump(int indent)
-{
- Q_Q(QSimpleCanvasItem);
- QByteArray ba(indent * 2, ' ');
-
- QByteArray state;
- if (options & QSimpleCanvasItem::MouseFilter)
- state.append("i");
- else
- state.append("-");
- if (options & QSimpleCanvasItem::HoverEvents)
- state.append("h");
- else
- state.append("-");
- if (options & QSimpleCanvasItem::MouseEvents)
- state.append("m");
- else
- state.append("-");
- if (options & QSimpleCanvasItem::HasContents)
- state.append("c");
- else
- state.append("-");
- if (options & QSimpleCanvasItem::SimpleItem)
- state.append("s");
- else
- state.append("-");
- if (options & QSimpleCanvasItem::IsFocusPanel) {
- if (q->activeFocusPanel())
- state.append("P");
- else
- state.append("p");
- } else {
- state.append("-");
- }
- if (options & QSimpleCanvasItem::IsFocusRealm)
- state.append("r");
- else
- state.append("-");
- if (q->hasFocus()) {
- if (q->hasActiveFocus())
- state.append("F");
- else
- state.append("f");
- } else {
- if (q->hasActiveFocus())
- state.append("X");
- else
- state.append("-");
- }
-
- QByteArray name;
- QFxItem *i = qobject_cast<QFxItem *>(q);
- if (i)
- name = i->id().toLatin1();
- qWarning().nospace() << ba.constData() << state.constData() << " " << children.count() << " " << q << " " << name.constData();
-
- int rv = 0;
-
- for (int ii = 0; ii < children.count(); ++ii)
- rv += children.at(ii)->d_func()->dump(indent + 1);
-
- return rv + 1;
-}
-
-bool QSimpleCanvasItemPrivate::checkFocusState(FocusStateCheckDatas d,
- FocusStateCheckRDatas *r)
-{
- Q_Q(QSimpleCanvasItem);
-
- bool rv = true;
- bool isRealm = (options & QSimpleCanvasItem::IsFocusPanel ||
- options & QSimpleCanvasItem::IsFocusRealm);
-
- if (options & QSimpleCanvasItem::IsFocusPanel) {
-
- if (q->activeFocusPanel()) {
- if (d & InActivePanel) {
- qWarning() << "State ERROR: Nested active focus panels";
- rv = false;
- }
-
- d |= InActivePanel;
- } else {
- d &= ~InActivePanel;
- }
-
- }
-
- if (q->hasActiveFocus()) {
- if (!(d & InActivePanel)) {
- qWarning() << "State ERROR: Active focus in non-active panel";
- rv = false;
- }
-
- if (d & InRealm && !(d & InActiveFocusedRealm)) {
- qWarning() << "State ERROR: Active focus in non-active-focused realm";
- rv = false;
- }
-
- if (!q->hasFocus()) {
- qWarning() << "State ERROR: Active focus on element that does not have focus";
- rv = false;
- }
-
- if (*r & SeenActiveFocus) {
- qWarning() << "State ERROR: Two active focused elements in same realm";
- rv = false;
- }
-
- *r |= SeenActiveFocus;
- }
-
- if (q->hasFocus()) {
- if (*r & SeenFocus) {
- qWarning() << "State ERROR: Two focused elements in same realm";
- rv = false;
- }
-
- *r |= SeenFocus;
- }
-
- if (options & QSimpleCanvasItem::IsFocusRealm) {
- d |= InRealm;
-
- if (q->hasActiveFocus())
- d |= InActiveFocusedRealm;
- else
- d &= ~InActiveFocusedRealm;
- }
-
- FocusStateCheckRDatas newR = NoCheckRData;
- if (isRealm)
- r = &newR;
-
- for (int ii = 0; ii < children.count(); ++ii)
- rv &= children.at(ii)->d_func()->checkFocusState(d, r);
-
- return rv;
-}
-
-bool QSimpleCanvasItem::activeFocusPanel() const
-{
- QSimpleCanvas *c = canvas();
- if (!c) {
- Q_D(const QSimpleCanvasItem);
- return d->wantsActiveFocusPanelPendingCanvas;
- } else {
- return c->activeFocusPanel() == this;
- }
-}
-
-void QSimpleCanvasItem::setActiveFocusPanel(bool b)
-{
- if (!(options() & IsFocusPanel)) {
- qWarning("QSimpleCanvasItem::setActiveFocusPanel: Item is not a focus panel");
- return;
- }
-
- QSimpleCanvas *c = canvas();
- Q_D(QSimpleCanvasItem);
- if (c) {
- if (b) {
- d->hasBeenActiveFocusPanel = true;
- c->d->setActiveFocusPanel(this);
- } else if (d->hasBeenActiveFocusPanel) {
- d->hasBeenActiveFocusPanel = false;
- c->d->clearFocusPanel(this);
- }
- } else {
- d->wantsActiveFocusPanelPendingCanvas = b;
- }
-}
-
-bool QSimpleCanvasItem::hasActiveFocus() const
-{
- Q_D(const QSimpleCanvasItem);
- return d->hasActiveFocus;
-}
-
-QSimpleCanvasItem *QSimpleCanvasItem::findFirstFocusChild() const
-{
- Q_D(const QSimpleCanvasItem);
-
- const QList<QSimpleCanvasItem *> &children = d->children;
-
- for (int i = 0; i < children.count(); ++i) {
- QSimpleCanvasItem *child = children.at(i);
- if (child->options() & IsFocusPanel)
- continue;
-
- if (child->isFocusable())
- return child;
-
- QSimpleCanvasItem *testFocus = child->findFirstFocusChild();
- if (testFocus)
- return testFocus;
- }
-
- return 0;
-}
-
-QSimpleCanvasItem *QSimpleCanvasItem::findLastFocusChild() const
-{
- Q_D(const QSimpleCanvasItem);
-
- const QList<QSimpleCanvasItem *> &children = d->children;
-
- for (int i = children.count()-1; i >= 0; --i) {
- QSimpleCanvasItem *child = children.at(i);
- if (child->options() & IsFocusPanel)
- continue;
-
- if (child->isFocusable())
- return child;
- QSimpleCanvasItem *testFocus = child->findLastFocusChild();
- if (testFocus)
- return testFocus;
- }
-
- return 0;
-}
-
-QSimpleCanvasItem *QSimpleCanvasItem::findPrevFocus(QSimpleCanvasItem *item)
-{
- QSimpleCanvasItem *focusChild = item->findLastFocusChild();
- if (focusChild)
- return focusChild;
-
- if (item->options() & IsFocusPanel) {
- if (item->isFocusable())
- return item;
- else
- return 0;
- }
-
- QSimpleCanvasItem *parent = item->parent();
- while (parent) {
- const QList<QSimpleCanvasItem *> &children = parent->d_func()->children;
-
- int idx = children.indexOf(item);
- QSimpleCanvasItem *testFocus = 0;
- if (idx > 0) {
- while (--idx >= 0) {
- testFocus = children.at(idx);
- if (testFocus->options() & IsFocusPanel)
- continue;
- if (testFocus->isFocusable())
- return testFocus;
- testFocus = testFocus->findLastFocusChild();
- if (testFocus)
- return testFocus;
- }
- }
- if (parent->options() & IsFocusPanel) {
- if (parent->isFocusable())
- return parent;
- else
- return 0;
- }
- item = parent;
- parent = parent->parent();
- }
-
- return 0;
-}
-
-QSimpleCanvasItem *QSimpleCanvasItem::findNextFocus(QSimpleCanvasItem *item)
-{
- QSimpleCanvasItem *focusChild = item->findFirstFocusChild();
- if (focusChild)
- return focusChild;
-
- if (item->options() & IsFocusPanel) {
- if (item->isFocusable())
- return item;
- else
- return 0;
- }
-
- QSimpleCanvasItem *parent = item->parent();
- while (parent) {
- const QList<QSimpleCanvasItem *> &children = parent->d_func()->children;
-
- int idx = children.indexOf(item);
- QSimpleCanvasItem *testFocus = 0;
- if (idx >= 0) {
- while (++idx < children.count()) {
- testFocus = children.at(idx);
- if (testFocus->options() & IsFocusPanel)
- continue;
- if (testFocus->isFocusable())
- return testFocus;
- testFocus = testFocus->findFirstFocusChild();
- if (testFocus)
- return testFocus;
- }
- }
- if (parent->options() & IsFocusPanel) {
- if (parent->isFocusable())
- return parent;
- else
- return 0;
- }
- item = parent;
- parent = parent->parent();
- }
-
- return 0;
-}
-
-QPixmap QSimpleCanvasItem::string(const QString &str, const QColor &c, const QFont &f)
-{
- QFontMetrics fm(f);
- QSize size(fm.width(str), fm.height()*(str.count(QLatin1Char('\n'))+1)); //fm.boundingRect(str).size();
- QPixmap img(size);
- img.fill(Qt::transparent);
- QPainter p(&img);
- p.setPen(c);
- p.setFont(f);
- p.drawText(img.rect(), Qt::AlignVCenter, str);
- return img;
-}
-
-void QSimpleCanvasItem::geometryChanged(const QRectF &, const QRectF &)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/canvas/qsimplecanvasitem.h b/src/declarative/canvas/qsimplecanvasitem.h
deleted file mode 100644
index 6452aa4..0000000
--- a/src/declarative/canvas/qsimplecanvasitem.h
+++ /dev/null
@@ -1,335 +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 QSIMPLECANVASITEM_H
-#define QSIMPLECANVASITEM_H
-
-#include <QtDeclarative/qfxglobal.h>
-#include <QtDeclarative/qmldebuggerstatus.h>
-#include <QtDeclarative/qsimplecanvas.h>
-#if defined(QFX_RENDER_OPENGL)
-#include <QtDeclarative/gltexture.h>
-#endif
-#include <QtCore/qobject.h>
-#include <QtGui/qgraphicsitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QPainter;
-class QRect;
-class QSimpleCanvas;
-class QMouseEvent;
-class QKeyEvent;
-class QSimpleCanvasItemPrivate;
-class QSimpleCanvasLayer;
-class QPointF;
-class QRectF;
-class QGraphicsSceneHoverEvent;
-class QSimpleCanvasFilter;
-class GLTexture;
-class QGLShaderProgram;
-
-class Q_DECLARATIVE_EXPORT QSimpleCanvasItem : public QObject
-{
- Q_OBJECT
- Q_CAST_INTERFACES(QGraphicsItem)
- Q_CAST_INTERFACES(QmlDebuggerStatus)
- Q_DECLARE_PRIVATE(QSimpleCanvasItem)
- Q_ENUMS(TransformOrigin)
- Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin)
-
-public:
- enum ClipType { NoClip = 0x00,
- ClipToHeight = 0x01,
- ClipToWidth = 0x02,
- ClipToRect = 0x03 };
- enum Option { NoOption = 0x00000000,
- MouseFilter = 0x00000001,
- ChildMouseFilter = 0x00000002,
- HoverEvents = 0x00000004,
- MouseEvents = 0x00000008,
- HasContents = 0x00000010,
- SimpleItem = 0x00000020,
- IsFocusPanel = 0x00000040,
- IsFocusRealm = 0x00000080,
- AcceptsInputMethods = 0x00000100,
- IsOpaque = 0x00000200 };
- Q_DECLARE_FLAGS(Options, Option)
-
- QSimpleCanvasItem(QSimpleCanvasItem *parent=0);
- virtual ~QSimpleCanvasItem();
- operator QGraphicsItem *();
- operator QmlDebuggerStatus *();
-
- bool clip() const;
- void setClip(bool);
- ClipType clipType() const;
- void setClipType(ClipType);
-
- Options options() const;
- void setOptions(Options, bool set = true);
-
- Qt::MouseButtons acceptedMouseButtons() const;
- void setAcceptedMouseButtons(Qt::MouseButtons buttons);
-
- qreal x() const;
- qreal y() const;
- qreal z() const;
- QPointF pos() const;
- void setX(qreal);
- void setY(qreal);
- virtual void setZ(qreal);
- void setPos(const QPointF &);
-
- qreal width() const;
- void setWidth(qreal);
- void setImplicitWidth(qreal);
- bool widthValid() const;
- qreal height() const;
- void setHeight(qreal);
- void setImplicitHeight(qreal);
- bool heightValid() const;
-
- QPointF scenePos() const;
-
- enum TransformOrigin {
- TopLeft, TopCenter, TopRight,
- MiddleLeft, Center, MiddleRight,
- BottomLeft, BottomCenter, BottomRight
- };
- TransformOrigin transformOrigin() const;
- void setTransformOrigin(TransformOrigin);
- QPointF transformOriginPoint() const;
-
-
- qreal scale() const;
- virtual void setScale(qreal);
-
- enum Flip { NoFlip = 0,
- VerticalFlip = 0x01,
- HorizontalFlip = 0x02,
- VerticalAndHorizontalFlip = 0x03 };
- Flip flip() const;
- void setFlip(Flip);
-
- qreal visible() const;
- virtual void setVisible(qreal);
- bool isVisible() const;
-
- QSimpleCanvas *canvas() const;
-
- QSimpleCanvasItem *parent() const;
- void setParent(QSimpleCanvasItem *);
- void stackUnder(QSimpleCanvasItem *);
- void stackOver(QSimpleCanvasItem *);
- void stackAt(int idx);
- int indexForChild(QSimpleCanvasItem *);
-
- QRect itemBoundingRect();
-
- class GLPainter
- {
- public:
- GLPainter();
- GLPainter(QSimpleCanvasItem *i);
- QSimpleCanvasItem *item;
- QSimpleCanvas::Matrix activeTransform;
- qreal activeOpacity;
- QRect sceneClipRect;
-
- QGLShaderProgram *useTextureShader();
- QGLShaderProgram *useColorShader(const QColor &);
- void drawPixmap(const QPointF &, const GLTexture &);
- void drawPixmap(const QRectF &, const GLTexture &);
- void fillRect(const QRectF &, const QColor &);
-
- void invalidate();
-
- bool blendEnabled;
-
- private:
- int flags;
- GLPainter(const GLPainter &);
- GLPainter &operator=(const GLPainter &);
- };
-
-
- void setPaintMargin(qreal margin);
- QRectF boundingRect() const;
- virtual void paintContents(QPainter &);
- virtual void paintGLContents(GLPainter &);
- virtual uint glSimpleItemData(float *vertices, float *texVertices,
- GLTexture **texture, uint count);
-
- void update();
-
- virtual QSimpleCanvasLayer *layer();
-
- bool hasChildren() const;
- const QList<QSimpleCanvasItem *> &children() const;
-
- QPointF mapFromScene(const QPointF &) const;
- QRectF mapFromScene(const QRectF &) const;
- QPointF mapToScene(const QPointF &) const;
- QRectF mapToScene(const QRectF &) const;
-
- QSimpleCanvas::Matrix transform() const;
- void setTransform(const QSimpleCanvas::Matrix &);
-
- QSimpleCanvasFilter *filter() const;
- void setFilter(QSimpleCanvasFilter *);
-
- QSimpleCanvasItem *mouseGrabberItem() const;
- void ungrabMouse();
- void grabMouse();
-
- virtual bool isFocusable() const;
- void setFocusable(bool);
- virtual bool hasFocus() const;
- void setFocus(bool);
- bool activeFocusPanel() const;
- void setActiveFocusPanel(bool);
-
- bool hasActiveFocus() const;
-
- QSimpleCanvasItem *findFirstFocusChild() const;
- QSimpleCanvasItem *findLastFocusChild() const;
- static QSimpleCanvasItem *findPrevFocus(QSimpleCanvasItem *item);
- static QSimpleCanvasItem *findNextFocus(QSimpleCanvasItem *item);
-
- GLBasicShaders *basicShaders() const;
-
-#if defined(QFX_RENDER_OPENGL)
- class CachedTexture : public GLTexture
- {
- public:
- void addRef();
- void release();
-
- int pixmapWidth() const;
- int pixmapHeight() const;
-
- private:
- CachedTexture();
- friend class QSimpleCanvasItem;
- QSimpleCanvasPrivate *d;
- QString s;
- int r, w, h;
- };
-
- CachedTexture *cachedTexture(const QString &);
- CachedTexture *cachedTexture(const QString &, const QPixmap &);
-#endif
-
- static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont());
-
-protected:
- virtual void geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry);
- virtual void addChild(QSimpleCanvasItem *);
- virtual void remChild(QSimpleCanvasItem *);
- virtual void canvasChanged();
- virtual void childrenChanged();
- virtual void parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *);
- virtual void focusChanged(bool);
- virtual void activeFocusChanged(bool);
- virtual bool eventFilter(QObject *, QEvent *);
-
-public:
- // Events
- virtual bool mouseFilter(QGraphicsSceneMouseEvent *);
- virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
- virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
- virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
- virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseUngrabEvent();
- virtual void keyPressEvent(QKeyEvent *event);
- virtual void keyReleaseEvent(QKeyEvent *event);
- virtual void focusOutEvent(QFocusEvent *e);
- virtual void focusInEvent(QFocusEvent *e);
- virtual void activePanelInEvent();
- virtual void activePanelOutEvent();
- virtual void inputMethodEvent(QInputMethodEvent* event);
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
-
-private:
- friend class QSimpleCanvas;
- friend class QSimpleCanvasPrivate;
- friend class QSimpleCanvasRootLayer;
- friend class QSimpleCanvasItem::GLPainter;
- friend class QSimpleCanvasFilter;
- friend class QGraphicsQSimpleCanvasItem;
- friend class QSimpleGraphicsItem;
- friend class CanvasEGLWidget;
- friend class QSimpleCanvasFilterPrivate;
-
-public:
- QSimpleCanvasItem(QSimpleCanvasItemPrivate &dd, QSimpleCanvasItem *parent);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QSimpleCanvasItem::Options)
-
-class QSimpleCanvasLayer : public QSimpleCanvasItem
-{
-public:
- QSimpleCanvasLayer(QSimpleCanvasItem *parent);
-
- virtual void addChild(QSimpleCanvasItem *);
- virtual void addDirty(QSimpleCanvasItem *);
- virtual void remDirty(QSimpleCanvasItem *);
- virtual QSimpleCanvasLayer *layer();
-
-private:
- friend class QSimpleCanvas;
- friend class QSimpleCanvasRootLayer;
- QSimpleCanvasLayer();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSIMPLECANVASITEM_H
diff --git a/src/declarative/canvas/qsimplecanvasitem_p.h b/src/declarative/canvas/qsimplecanvasitem_p.h
deleted file mode 100644
index 7a8f40a..0000000
--- a/src/declarative/canvas/qsimplecanvasitem_p.h
+++ /dev/null
@@ -1,270 +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 QSIMPLECANVASITEM_P_H
-#define QSIMPLECANVASITEM_P_H
-
-#include "private/qobject_p.h"
-#include "qsimplecanvas.h"
-#include "qsimplecanvasitem.h"
-#include "qsimplecanvasfilter.h"
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glbasicshaders.h>
-#endif
-
-#include "qgraphicsitem.h"
-
-QT_BEGIN_NAMESPACE
-
-class QSimpleGraphicsItem : public QGraphicsItem
-{
-public:
- QSimpleGraphicsItem(QSimpleCanvasItem *);
- virtual ~QSimpleGraphicsItem();
-
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
- virtual QRectF boundingRect() const;
-
- QTransform transform;
-protected:
- virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- virtual bool sceneEvent(QEvent *);
- virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
- virtual void keyPressEvent(QKeyEvent *event);
- virtual void keyReleaseEvent(QKeyEvent *event);
- virtual void focusInEvent(QFocusEvent *event);
-
-private:
- friend class QSimpleCanvasItem;
- QSimpleCanvasItem *owner;
-};
-
-class QSimpleCanvasItemData
-{
-public:
- QSimpleCanvasItemData();
- ~QSimpleCanvasItemData();
-
- // 5 bits is all that's needed to store Qt::MouseButtons
- int buttons:5;
- QSimpleCanvasItem::Flip flip:2;
- bool dirty:1;
- bool transformValid:1;
- bool doNotPaint:1;
- bool doNotPaintChildren:1;
-
- qreal x;
- qreal y;
- qreal z;
- float visible;
-
- QSimpleCanvas::Matrix *transformUser;
- QSimpleCanvas::Matrix transformActive;
- int transformVersion;
-
- float activeOpacity;
-
-#if defined(QFX_RENDER_OPENGL)
- QRectF lastPaintRect;
-#else
- QRect lastPaintRect;
-#endif
-};
-
-class QSimpleCanvasItemDebuggerStatus : public QmlDebuggerStatus
-{
-public:
- QSimpleCanvasItemDebuggerStatus(QSimpleCanvasItem *i)
- : item(i), selected(false) {}
-
- virtual void setSelectedState(bool state)
- {
- selected = state;
- item->update();
- }
-
- QSimpleCanvasItem *item;
- bool selected;
-};
-
-class QSimpleCanvasFilter;
-class QGraphicsQSimpleCanvasItem;
-class QSimpleCanvasItemPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QSimpleCanvasItem)
-public:
- QSimpleCanvasItemPrivate()
- : parent(0), canvas(0), debuggerStatus(0), filter(0),
- clip(QSimpleCanvasItem::NoClip),
- origin(QSimpleCanvasItem::TopLeft), options(QSimpleCanvasItem::NoOption),
- focusable(false), wantsActiveFocusPanelPendingCanvas(false),
- hasBeenActiveFocusPanel(false),
- hasFocus(false), hasActiveFocus(false), needsZOrder(false),
- widthValid(false), heightValid(false), width(0), height(0), paintmargin(0), scale(1),
- graphicsItem(0), data_ptr(0)
- {
- }
-
- virtual ~QSimpleCanvasItemPrivate()
- {
- if(debuggerStatus) delete debuggerStatus;
- }
-
- QSimpleCanvasItem *parent;
- QSimpleCanvas *canvas;
- QList<QSimpleCanvasItem *> children;
-
- QSimpleCanvasItemDebuggerStatus *debuggerStatus;
- QSimpleCanvasFilter *filter;
-
- QSimpleCanvasItem::ClipType clip:3;
- QSimpleCanvasItem::TransformOrigin origin:4;
- int options:10;
- bool focusable:1;
- bool wantsActiveFocusPanelPendingCanvas:1;
- bool hasBeenActiveFocusPanel:1;
- bool hasFocus:1;
- bool hasActiveFocus:1;
- bool needsZOrder:1;
- bool widthValid:1;
- bool heightValid:1;
-
- void setFocus(bool f);
- void setActiveFocus(bool f);
-
- qreal width;
- qreal height;
- qreal paintmargin;
- qreal scale;
-
- QSimpleGraphicsItem *graphicsItem;
- inline QSimpleCanvasItemData *data() const {
- if (!data_ptr) data_ptr = new QSimpleCanvasItemData;
- return data_ptr;
- }
- mutable QSimpleCanvasItemData *data_ptr;
-
- void gvRemoveMouseFilter();
- void gvAddMouseFilter();
-
- void canvasChanged(QSimpleCanvas *newCanvas, QSimpleCanvas *oldCanvas);
-
- void freshenTransforms() const;
-
- QPointF adjustFrom(const QPointF &) const;
- QRectF adjustFrom(const QRectF &) const;
- QPointF adjustTo(const QPointF &) const;
- QRectF adjustTo(const QRectF &) const;
-
- QPointF transformOrigin() const;
-
- void setParentInternal(QSimpleCanvasItem *);
- void convertToGraphicsItem(QGraphicsItem * = 0);
-
-#if defined(QFX_RENDER_QPAINTER)
- void paint(QPainter &);
- void paintChild(QPainter &, QSimpleCanvasItem *);
- QRect setupPainting(int version, const QRect &bounding);
-#else
- struct GLPaintParameters
- {
- QRect sceneRect;
- QRectF boundingRect;
- QRect clipRect;
-#if defined(QFX_RENDER_OPENGL2)
- uchar stencilValue;
-#endif
- float opacity;
- bool forceParamRefresh;
-
- QSimpleCanvasItem::GLPainter *painter;
- };
-#if defined(QFX_RENDER_OPENGL2)
- QRectF setupPainting(int version, int &z, QSimpleCanvasItem **);
-#elif defined(QFX_RENDER_OPENGL1)
- QRectF setupPainting(int version, const QRect &bounding, unsigned int *zero);
-#endif
- void setupChildState(QSimpleCanvasItem *);
-
- void paint(GLPaintParameters &, QSimpleCanvasFilter::Layer = QSimpleCanvasFilter::All);
-#if defined(QFX_RENDER_OPENGL1)
- void paintNoClip(GLPaintParameters &, QSimpleCanvasFilter::Layer = QSimpleCanvasFilter::All);
-#endif
- void paintChild(const GLPaintParameters &, QSimpleCanvasItem *);
- void simplePaintChild(const GLPaintParameters &, QSimpleCanvasItem *);
-
- inline GLBasicShaders *basicShaders() const;
-
- QSimpleCanvas::Matrix localTransform() const;
-
-#endif
-
- QSimpleCanvasItem *nextOpaque;
-
- void zOrderChildren();
- bool freshenNeeded() const;
- void doFreshenTransforms() const;
-
- // Debugging
- int dump(int);
- enum FocusStateCheckData { NoCheckData = 0x00,
- InActivePanel = 0x01,
- InRealm = 0x02,
- InActiveFocusedRealm = 0x04
- };
- Q_DECLARE_FLAGS(FocusStateCheckDatas, FocusStateCheckData)
- enum FocusStateCheckRData { NoCheckRData = 0x00,
- SeenFocus = 0x01,
- SeenActiveFocus = 0x02 };
- Q_DECLARE_FLAGS(FocusStateCheckRDatas, FocusStateCheckRData)
- bool checkFocusState(FocusStateCheckDatas, FocusStateCheckRDatas *);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QSimpleCanvasItemPrivate::FocusStateCheckDatas)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QSimpleCanvasItemPrivate::FocusStateCheckRDatas)
-
-QT_END_NAMESPACE
-
-#endif // QSIMPLECANVASITEM_P_H
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro
index 4bf267c..942b74e 100644
--- a/src/declarative/declarative.pro
+++ b/src/declarative/declarative.pro
@@ -2,6 +2,7 @@ TARGET = QtDeclarative
QPRO_PWD = $$PWD
QT = core gui xml script network
contains(QT_CONFIG, svg): QT += svg
+contains(QT_CONFIG, opengl): QT += opengl
DEFINES += QT_BUILD_DECLARATIVE_LIB
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
@@ -17,13 +18,9 @@ include(../qbase.pri)
include(3rdparty/3rdparty.pri)
include(util/util.pri)
include(fx/fx.pri)
-include(canvas/canvas.pri)
include(qml/qml.pri)
include(extra/extra.pri)
include(widgets/widgets.pri)
-include(test/test.pri)
include(debugger/debugger.pri)
-contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1):include(opengl/opengl.pri)
-
symbian:TARGET.UID3=0x2001E623
diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri
index 4179817..d3ce7eb 100644
--- a/src/declarative/extra/extra.pri
+++ b/src/declarative/extra/extra.pri
@@ -5,7 +5,6 @@ SOURCES += \
extra/qfxintegermodel.cpp \
extra/qmlfolderlistmodel.cpp \
extra/qfxanimatedimageitem.cpp \
- extra/qfxblendedimage.cpp \
extra/qfxflowview.cpp \
extra/qfxparticles.cpp \
extra/qmlbehaviour.cpp \
@@ -19,7 +18,6 @@ HEADERS += \
extra/qmlfolderlistmodel.h \
extra/qfxanimatedimageitem.h \
extra/qfxanimatedimageitem_p.h \
- extra/qfxblendedimage.h \
extra/qfxflowview.h \
extra/qfxparticles.h \
extra/qmlbehaviour.h \
diff --git a/src/declarative/extra/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h
index 86ded86..720d187 100644
--- a/src/declarative/extra/qfxanimatedimageitem.h
+++ b/src/declarative/extra/qfxanimatedimageitem.h
@@ -88,7 +88,7 @@ protected:
private:
Q_DISABLE_COPY(QFxAnimatedImageItem)
- Q_DECLARE_PRIVATE(QFxAnimatedImageItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxAnimatedImageItem)
};
QT_END_NAMESPACE
diff --git a/src/declarative/extra/qfxblendedimage.cpp b/src/declarative/extra/qfxblendedimage.cpp
deleted file mode 100644
index 0c93fef..0000000
--- a/src/declarative/extra/qfxblendedimage.cpp
+++ /dev/null
@@ -1,308 +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 "qfxblendedimage.h"
-#include <QtDeclarative/qmlcontext.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glbasicshaders.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass BlendedImage
- \brief The BlendedImage elements blends two different images depending on a blend ratio.
-
- This element can be used to simulate blur on slow devices by setting secondaryUrl with
- a pre-rendered blurred version of primaryUrl.
-
- Note that this class will only work under OpenGL. On the software canvas it will display
- only the primary image unless the blend is > 0.75, in which case it will display only the
- secondary image.
-*/
-
-/*!
- \internal
- \class QFxBlendedImage
- \brief The QFxBlendedImage blends two different images depending on a blend ratio.
-
- This class can be used to simulate blur on slow devices by setting secondaryUrl with
- a pre-rendered blurred version of primaryUrl.
-
- Note that this class will only work under OpenGL. On the software canvas it will display
- only the primary image unless the blend is > 0.75, in which case it will display only the
- secondary image.
-*/
-QFxBlendedImage::QFxBlendedImage(QFxItem *parent)
-: QFxItem(parent), _blend(0), _smooth(false), dirty(false)
-{
-#if defined(QFX_RENDER_OPENGL2)
- setOptions(HasContents);
-#endif
-}
-
-/*!
- Cancels any pending image loads and destroys the image.
-*/
-QFxBlendedImage::~QFxBlendedImage()
-{
- if (!primUrl.isEmpty())
- QFxPixmap::cancelGet(primUrl,this);
- if (!secUrl.isEmpty())
- QFxPixmap::cancelGet(secUrl,this);
-}
-
-/*!
- \qmlproperty string BlendedImage::primaryUrl
- The URL of the first image to be displayed in this item.
-*/
-QUrl QFxBlendedImage::primaryUrl() const
-{
- return primUrl;
-}
-
-void QFxBlendedImage::primaryLoaded()
-{
- primPix = QFxPixmap(primUrl);
- dirty = true;
- update();
-}
-
-void QFxBlendedImage::setPrimaryUrl(const QUrl &url)
-{
- if (primUrl == url)
- return;
- if (!primUrl.isEmpty())
- QFxPixmap::cancelGet(primUrl,this);
- Q_ASSERT(!url.isRelative());
- primUrl = url;
- if (!primUrl.isEmpty())
- QFxPixmap::get(qmlEngine(this), primUrl,this,SLOT(primaryLoaded()));
-}
-
-/*!
- \qmlproperty string BlendedImage::secondaryUrl
- The URL of the second image to be displayed in this item.
-*/
-QUrl QFxBlendedImage::secondaryUrl() const
-{
- return secUrl;
-}
-
-void QFxBlendedImage::secondaryLoaded()
-{
- secPix = QFxPixmap(secUrl);
- dirty = true;
- update();
-}
-
-void QFxBlendedImage::setSecondaryUrl(const QUrl &url)
-{
- if (secUrl == url)
- return;
- if (!secUrl.isEmpty())
- QFxPixmap::cancelGet(secUrl,this);
- Q_ASSERT(!url.isRelative());
- secUrl = url;
- if (!secUrl.isEmpty())
- QFxPixmap::get(qmlEngine(this), secUrl,this,SLOT(secondaryLoaded()));
-}
-
-/*!
- \qmlproperty real BlendedImage::blend
- The ratio used to blend the two images.
-
- If blend has a value of 0, only the first image will be displayed.
- If blend has a value of 1, only the second image will be displayed.
-*/
-qreal QFxBlendedImage::blend() const
-{
- return _blend;
-}
-
-void QFxBlendedImage::setBlend(qreal b)
-{
- _blend = b;
- update();
-}
-
-/*!
- \qmlproperty bool BlendedImage::smooth
-
- Set this property if you want the image to be smoothly filtered when scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the BlendedImage is displayed at its natural size, this property has no visual or
- performance effect.
-
- \note Generally scaling artifacts are only visible if the image is stationary on
- the screen. A common pattern when animating an image is to disable smooth
- filtering at the beginning of the animation and reenable it at the conclusion.
- */
-bool QFxBlendedImage::smoothTransform() const
-{
- return _smooth;
-}
-
-void QFxBlendedImage::setSmoothTransform(bool s)
-{
- if (_smooth == s)
- return;
- _smooth = s;
- update();
-}
-
-#if defined(QFX_RENDER_QPAINTER)
-
-void QFxBlendedImage::paintContents(QPainter &p)
-{
- if (primUrl.isEmpty() && secUrl.isEmpty())
- return;
-
- if (_smooth) {
- p.save();
- p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth);
- }
-
- if (_blend < 0.75)
- p.drawPixmap(0, 0, primPix);
- else
- p.drawPixmap(0, 0, secPix);
-
- if (_smooth) {
- p.restore();
- }
-}
-
-#elif defined(QFX_RENDER_OPENGL2)
-
-void QFxBlendedImage::paintGLContents(GLPainter &p)
-{
- static DualTextureBlendShader *shader = 0;
- if (!shader)
- shader = new DualTextureBlendShader();
-
- if (dirty) {
- prim.clear();
- sec.clear();
- prim.setImage(primPix.toImage());
- sec.setImage(secPix.toImage());
-
- dirty = false;
- }
-
- if (prim.isNull() || sec.isNull()) {
-
- return;
- }
-
- GLfloat vertices[8];
- GLfloat texVertices[8];
-
- float widthV = width();
- float heightV = height();
- if (!widthV)
- widthV = qMax(primPix.width(), secPix.width());
- if (!heightV)
- heightV = qMax(primPix.height(), secPix.height());
-
- vertices[0] = 0; vertices[1] = heightV;
- vertices[2] = widthV; vertices[3] = heightV;
- vertices[4] = 0; vertices[5] = 0;
- vertices[6] = widthV; vertices[7] = 0;
-
- texVertices[0] = 0; texVertices[1] = 0;
- texVertices[2] = 1; texVertices[3] = 0;
- texVertices[4] = 0; texVertices[5] = 1;
- texVertices[6] = 1; texVertices[7] = 1;
-
- if (_blend == 0 || _blend == 1) {
- QGLShaderProgram *tshader = p.useTextureShader();
-
- GLTexture *tex = 0;
-
- if (_blend == 0)
- tex = &prim;
- else
- tex = &sec;
-
- tshader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- tshader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, tex->texture());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- tshader->disableAttributeArray(SingleTextureShader::Vertices);
- tshader->disableAttributeArray(SingleTextureShader::TextureCoords);
- } else {
-
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, prim.texture());
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, sec.texture());
-
- shader->enable();
- shader->setOpacity(1);
- qreal b = _blend;
- if (b > 1) b = 1;
- else if (b < 0) b = 0;
- shader->setBlend(b);
- shader->setTransform(p.activeTransform);
-
- shader->setAttributeArray(DualTextureBlendShader::Vertices, vertices, 2);
- shader->setAttributeArray(DualTextureBlendShader::TextureCoords, texVertices, 2);
- shader->setAttributeArray(DualTextureBlendShader::BlendTextureCoords, texVertices, 2);
-
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- shader->disableAttributeArray(DualTextureBlendShader::Vertices);
- shader->disableAttributeArray(DualTextureBlendShader::TextureCoords);
- shader->disableAttributeArray(DualTextureBlendShader::BlendTextureCoords);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- glActiveTexture(GL_TEXTURE0);
- }
-}
-#endif
-
-QML_DEFINE_TYPE(QFxBlendedImage,BlendedImage)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/extra/qfxblendedimage.h b/src/declarative/extra/qfxblendedimage.h
deleted file mode 100644
index 44de94c..0000000
--- a/src/declarative/extra/qfxblendedimage.h
+++ /dev/null
@@ -1,111 +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 QFXBLENDEDIMAGE_H
-#define QFXBLENDEDIMAGE_H
-
-#include <QtDeclarative/qfxitem.h>
-#if defined(QFX_RENDER_OPENGL2)
-#include <gltexture.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QFxBlendedImage : public QFxItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QUrl primaryUrl READ primaryUrl WRITE setPrimaryUrl)
- Q_PROPERTY(QUrl secondaryUrl READ secondaryUrl WRITE setSecondaryUrl)
- Q_PROPERTY(qreal blend READ blend WRITE setBlend)
- Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
-public:
- QFxBlendedImage(QFxItem *parent=0);
- ~QFxBlendedImage();
-
- QUrl primaryUrl() const;
- void setPrimaryUrl(const QUrl &);
-
- QUrl secondaryUrl() const;
- void setSecondaryUrl(const QUrl &);
-
- qreal blend() const;
- void setBlend(qreal);
-
- bool smoothTransform() const;
- void setSmoothTransform(bool);
-
-#if defined(QFX_RENDER_QPAINTER)
- void paintContents(QPainter &painter);
-#elif defined(QFX_RENDER_OPENGL2)
- void paintGLContents(GLPainter &);
-#endif
-
-private Q_SLOTS:
- void primaryLoaded();
- void secondaryLoaded();
-
-private:
- QUrl primUrl;
- QUrl secUrl;
-
- qreal _blend;
- bool _smooth;
- bool dirty;
-#if defined(QFX_RENDER_OPENGL2)
- GLTexture prim;
- GLTexture sec;
-#endif
- QPixmap primPix;
- QPixmap secPix;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxBlendedImage)
-
-QT_END_HEADER
-
-#endif // QFXBLENDEDIMAGE_H
diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp
index 3130f06..08d38ba 100644
--- a/src/declarative/extra/qfxparticles.cpp
+++ b/src/declarative/extra/qfxparticles.cpp
@@ -40,9 +40,6 @@
****************************************************************************/
#include "private/qfxitem_p.h"
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
#include <stdlib.h>
#include <math.h>
@@ -58,7 +55,7 @@
#include <private/qmlanimation_p.h>
#include "qfxparticles.h"
-
+#include <QPainter>
QT_BEGIN_NAMESPACE
#define PI_SQR 9.8696044
@@ -350,11 +347,7 @@ public:
maxX = minX = maxY = minY = 0;
}
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &p);
-#elif defined(QFX_RENDER_OPENGL2)
- void paintGLContents(GLPainter &);
-#endif
void updateSize();
@@ -375,9 +368,6 @@ public:
, angle(0), angleDev(0), velocity(0), velocityDev(0)
, addParticleTime(0), addParticleCount(0), lastAdvTime(0), stream(false), streamDelay(0)
, emitting(true), motion(0), clock(this)
-#if defined(QFX_RENDER_OPENGL)
- , texDirty(true)
-#endif
{
}
@@ -418,13 +408,8 @@ public:
QList<QFxParticle> particles;
QTickAnimationProxy<QFxParticlesPrivate, &QFxParticlesPrivate::tick> clock;
-#if defined(QFX_RENDER_OPENGL)
- bool texDirty;
- GLTexture tex;
-#endif
};
-//TODO: Stop the clock if no visible particles and not emitting (restart on emittingChanged)
void QFxParticlesPrivate::tick(int time)
{
Q_Q(QFxParticles);
@@ -473,17 +458,15 @@ void QFxParticlesPrivate::tick(int time)
}
}
}
- while(particles.count() < count && particles.count() < percCount && streamWidth--)
- createParticle(time);
+ while(particles.count() < count &&
+ (!stream || (particles.count() < percCount && streamWidth--)))
+ createParticle(time);
}
lastAdvTime = time;
- if (oldCount || particles.count()) {
- if (q->itemParent())
- q->itemParent()->update();
- else
- q->update();
- } else if (!count) {
+ paintItem->updateSize();
+ paintItem->update();
+ if (!(oldCount || particles.count()) && (!count || !emitting)) {
lastAdvTime = 0;
clock.stop();
}
@@ -654,11 +637,8 @@ void QFxParticles::imageLoaded()
{
Q_D(QFxParticles);
d->image = QFxPixmap(d->url);
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- d->tex.clear();
-#endif
- update();
+ d->paintItem->updateSize();
+ d->paintItem->update();
}
void QFxParticles::setSource(const QUrl &name)
@@ -673,11 +653,8 @@ void QFxParticles::setSource(const QUrl &name)
if (name.isEmpty()) {
d->url = name;
d->image = QPixmap();
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- d->tex.clear();
-#endif
- update();
+ d->paintItem->updateSize();
+ d->paintItem->update();
} else {
d->url = name;
Q_ASSERT(!name.isRelative());
@@ -704,12 +681,15 @@ void QFxParticles::setCount(int cnt)
{
Q_D(QFxParticles);
if (cnt != d->count) {
- if (!d->count && d->clock.state() != QAbstractAnimation::Running)
- d->clock.start(); // infinity??
+ int oldCount = d->count;
d->count = cnt;
d->addParticleTime = 0;
d->addParticleCount = d->particles.count();
- update();
+ if (!oldCount && d->clock.state() != QAbstractAnimation::Running) {
+ d->clock.start();
+ }
+ d->paintItem->updateSize();
+ d->paintItem->update();
}
}
@@ -1025,6 +1005,8 @@ void QFxParticles::setEmitting(bool r)
{
Q_D(QFxParticles);
d->emitting = r;
+ if (d->count && r)
+ d->clock.start();
}
/*!
\qmlproperty ParticleMotion Particles::motion
@@ -1059,31 +1041,16 @@ void QFxParticles::setMotion(QFxParticleMotion *motion)
d->motion = motion;
}
-void QFxParticles::dump(int depth)
-{
- Q_D(QFxParticles);
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << "URL:" << d->url << "Count:" << d->count;
- QFxItem::dump(depth);
-}
-
QString QFxParticles::propertyInfo() const
{
Q_D(const QFxParticles);
return d->url.toString();
}
-void QFxParticlesPainter::updateSize(){
- setX(-500);
- setY(-500);
- setWidth(1000);
- setHeight(1000);
- return ;
- const int parentX = parent()->x();
- const int parentY = parent()->y();
- //Have to use statistical approach to needed size as arbitrary particle
- //motions make it impossible to calculate.
- //max/min vars stored to give a never shrinking rect
+void QFxParticlesPainter::updateSize()
+{
+ const int parentX = parentItem()->x();
+ const int parentY = parentItem()->y();
for (int i = 0; i < d->particles.count(); ++i) {
const QFxParticle &particle = d->particles.at(i);
if(particle.x > maxX)
@@ -1106,7 +1073,6 @@ void QFxParticlesPainter::updateSize(){
setY(myY);
}
-#if defined(QFX_RENDER_QPAINTER)
void QFxParticles::paintContents(QPainter &p)
{
Q_UNUSED(p);
@@ -1118,82 +1084,24 @@ void QFxParticlesPainter::paintContents(QPainter &p)
if (d->image.isNull())
return;
- updateSize();
- const int myX = x() + parent()->x();
- const int myY = y() + parent()->y();
+ const int myX = x() + parentItem()->x();
+ const int myY = y() + parentItem()->y();
for (int i = 0; i < d->particles.count(); ++i) {
const QFxParticle &particle = d->particles.at(i);
p.setOpacity(particle.opacity);
p.drawPixmap(particle.x - myX, particle.y - myY, d->image);
}
- update();//Should I need this? (GV does)
-}
-#elif defined(QFX_RENDER_OPENGL2)
-void QFxParticles::paintGLContents(GLPainter &)
-{
- //painting is done by the ParticlesPainter, so it can have the right size
-}
-
-void QFxParticlesPainter::paintGLContents(GLPainter &p)
-{
-
- if (d->image.isNull())
- return;
-
- updateSize();
-
- if (d->texDirty && !d->image.isNull()) {
- d->tex.setImage(d->image.toImage());
- d->tex.setHorizontalWrap(GLTexture::Repeat);
- d->tex.setVerticalWrap(GLTexture::Repeat);
- }
- d->texDirty = false;
-
- SingleTextureOpacityShader *shader = basicShaders()->singleTextureOpacity();
- shader->enable();
- shader->setTransform(p.activeTransform);
-
- glBindTexture(GL_TEXTURE_2D, d->tex.texture());
-
- const int myX = (int)(x() + parent()->x());
- const int myY = (int)(y() + parent()->y());
- float widthV = d->image.width();
- float heightV = d->image.height();
- for (int i = 0; i < d->particles.count(); ++i) {
- const QFxParticle &particle = d->particles.at(i);
- float left = particle.x - myX;
- float right = particle.x - myX + widthV;
- float top = particle.y - myY;
- float bottom = particle.y - myY + heightV;
-
- GLfloat vertices[] = { left, bottom,
- right, bottom,
- left, top,
- right, top };
-
- GLfloat texVertices[] = { 0, 0,
- 1, 0,
- 0, 1,
- 1, 1 };
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
- shader->setOpacity(particle.opacity * p.activeOpacity);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- }
-
- shader->disableAttributeArray(SingleTextureShader::Vertices);
- shader->disableAttributeArray(SingleTextureShader::TextureCoords);
}
-#endif
void QFxParticles::componentComplete()
{
Q_D(QFxParticles);
QFxItem::componentComplete();
- if (d->count)
- d->clock.start(); // infinity??
+ if (d->count) {
+ d->paintItem->updateSize();
+ d->clock.start();
+ }
if (d->lifeSpanDev > d->lifeSpan)
d->lifeSpanDev = d->lifeSpan;
}
diff --git a/src/declarative/extra/qfxparticles.h b/src/declarative/extra/qfxparticles.h
index cfaffa7..9f085cd 100644
--- a/src/declarative/extra/qfxparticles.h
+++ b/src/declarative/extra/qfxparticles.h
@@ -44,10 +44,6 @@
#include <QtDeclarative/qfxitem.h>
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -207,14 +203,9 @@ public:
QFxParticleMotion *motion() const;
void setMotion(QFxParticleMotion *);
- virtual void dump(int depth);
virtual QString propertyInfo() const;
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &p);
-#elif defined(QFX_RENDER_OPENGL2)
- void paintGLContents(GLPainter &);
-#endif
protected:
virtual void componentComplete();
@@ -225,7 +216,7 @@ private Q_SLOTS:
private:
Q_DISABLE_COPY(QFxParticles)
- Q_DECLARE_PRIVATE(QFxParticles)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxParticles)
};
QT_END_NAMESPACE
diff --git a/src/declarative/extra/qmlbehaviour.cpp b/src/declarative/extra/qmlbehaviour.cpp
index f2d5e9a..92a85b0 100644
--- a/src/declarative/extra/qmlbehaviour.cpp
+++ b/src/declarative/extra/qmlbehaviour.cpp
@@ -75,15 +75,12 @@ private:
class QmlBehaviourPrivate : public QObjectPrivate
{
public:
- QmlBehaviourPrivate()
- : context(0), valueData(0), operations(this) {}
+ QmlBehaviourPrivate() : operations(this) {}
QmlMetaProperty property;
QVariant currentValue;
QVariant fromValue;
QVariant toValue;
- QmlContext *context;
- QmlBehaviourData *valueData;
class AnimationList : public QmlConcreteList<QmlAbstractAnimation *>
{
public:
@@ -128,7 +125,6 @@ QmlBehaviour::QmlBehaviour(QObject *parent)
: QmlPropertyValueSource(*(new QmlBehaviourPrivate), parent)
{
Q_D(QmlBehaviour);
- d->valueData = new QmlBehaviourData(this);
d->group = new QParallelAnimationGroup(this);
}
@@ -200,10 +196,6 @@ void QmlBehaviour::propertyValueChanged()
//### does this clean up everything needed?
d->group->stop();
- d->valueData->e = newValue;
- d->valueData->s = d->currentValue;
- emit d->valueData->valuesChanged();
-
QmlStateOperation::ActionList actions;
Action action;
action.property = d->property;
@@ -238,22 +230,6 @@ void QmlBehaviour::setTarget(const QmlMetaProperty &property)
}
}
-void QmlBehaviour::classBegin()
-{
- Q_D(QmlBehaviour);
- if (!d->context) {
- d->context = new QmlContext(qmlContext(this), this);
- d->context->addDefaultObject(d->valueData);
- }
- d->context->activate();
-}
-
-void QmlBehaviour::classComplete()
-{
- Q_D(QmlBehaviour);
- d->context->deactivate();
-}
-
QT_END_NAMESPACE
#include "qmlbehaviour.moc"
diff --git a/src/declarative/extra/qmlbehaviour.h b/src/declarative/extra/qmlbehaviour.h
index 1b5f524..99fc779 100644
--- a/src/declarative/extra/qmlbehaviour.h
+++ b/src/declarative/extra/qmlbehaviour.h
@@ -54,12 +54,10 @@ QT_MODULE(Declarative)
class QmlAbstractAnimation;
class QmlBehaviourPrivate;
-class Q_DECLARATIVE_EXPORT QmlBehaviour : public QmlPropertyValueSource,
- public QmlParserStatus
+class Q_DECLARATIVE_EXPORT QmlBehaviour : public QmlPropertyValueSource
{
Q_OBJECT
Q_DECLARE_PRIVATE(QmlBehaviour)
- Q_INTERFACES(QmlParserStatus)
Q_PROPERTY(QVariant from READ fromValue WRITE setFromValue)
Q_PROPERTY(QVariant to READ toValue WRITE setToValue)
@@ -80,10 +78,6 @@ public:
static bool _ignore;
-protected:
- virtual void classBegin();
- virtual void classComplete();
-
private Q_SLOTS:
void propertyValueChanged();
};
diff --git a/src/declarative/extra/qmlfolderlistmodel.cpp b/src/declarative/extra/qmlfolderlistmodel.cpp
index acee5e1..4a71109 100644
--- a/src/declarative/extra/qmlfolderlistmodel.cpp
+++ b/src/declarative/extra/qmlfolderlistmodel.cpp
@@ -161,7 +161,9 @@ void QmlFolderListModel::classComplete()
bool QmlFolderListModel::isFolder(int index) const
{
Q_D(const QmlFolderListModel);
- return d->model.isDir(d->model.index(index, 0, d->folderIndex));
+ if (index != -1)
+ return d->model.isDir(d->model.index(index, 0, d->folderIndex));
+ return false;
}
void QmlFolderListModel::refresh()
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index 95c3de6..7f0029d 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -410,7 +410,7 @@ QmlXmlListModel::~QmlXmlListModel()
}
/*!
- \qmlproperty list<XmlRole> QmlListModel::roles
+ \qmlproperty list<XmlRole> XmlListModel::roles
The roles to make available for this model.
*/
@@ -645,6 +645,7 @@ void QmlXmlListModel::queryCompleted(int id, int size)
if (size > 0) {
d->data = d->qmlXmlQuery.modelData();
emit itemsInserted(0, d->size);
+ emit countChanged();
}
}
diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h
index d9871ab..3b6ffb4 100644
--- a/src/declarative/extra/qmlxmllistmodel.h
+++ b/src/declarative/extra/qmlxmllistmodel.h
@@ -98,6 +98,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public
Q_PROPERTY(QString query READ query WRITE setQuery)
Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
Q_PROPERTY(QmlList<XmlListModelRole *> *roles READ roleObjects)
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "roles")
public:
@@ -130,6 +131,7 @@ public:
signals:
void statusChanged(Status);
void progressChanged(qreal progress);
+ void countChanged();
public Q_SLOTS:
void reload();
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 0c26356..24c5536 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -1,23 +1,20 @@
HEADERS += \
fx/qfxanchors.h \
fx/qfxanchors_p.h \
- fx/qfxblurfilter.h \
fx/qfxcomponentinstance.h \
fx/qfxcomponentinstance_p.h \
fx/qfxevents_p.h \
fx/qfxflickable.h \
fx/qfxflickable_p.h \
fx/qfxflipable.h \
- fx/qfxfocuspanel.h \
- fx/qfxfocusrealm.h \
fx/qfxgridview.h \
- fx/qfxhighlightfilter.h \
fx/qfximage.h \
fx/qfxpainteditem.h \
fx/qfxpainteditem_p.h \
fx/qfximage_p.h \
fx/qfxitem.h \
fx/qfxitem_p.h \
+ fx/qfxfocusrealm.h \
fx/qfxkeyactions.h \
fx/qfxkeyproxy.h \
fx/qfxlayouts.h \
@@ -30,11 +27,11 @@ HEADERS += \
fx/qfxpathview_p.h \
fx/qfxrect.h \
fx/qfxrect_p.h \
- fx/qfxreflectionfilter.h \
fx/qfxrepeater.h \
fx/qfxrepeater_p.h \
fx/qfxscalegrid.h \
- fx/qfxshadowfilter.h \
+ fx/qfxlineedit.h \
+ fx/qfxlineedit_p.h \
fx/qfxtextedit.h \
fx/qfxtextedit_p.h \
fx/qfxtext.h \
@@ -43,22 +40,19 @@ HEADERS += \
fx/qfxpixmap.cpp \
fx/qfxvisualitemmodel.h \
fx/qfxlistview.h \
- fx/qfxwidgetcontainer.h \
+ fx/qfxgraphicsobjectcontainer.h \
SOURCES += \
fx/qfxanchors.cpp \
- fx/qfxblurfilter.cpp \
fx/qfxcomponentinstance.cpp \
fx/qfxevents.cpp \
fx/qfxflickable.cpp \
fx/qfxflipable.cpp \
- fx/qfxfocuspanel.cpp \
- fx/qfxfocusrealm.cpp \
fx/qfxgridview.cpp \
- fx/qfxhighlightfilter.cpp \
fx/qfximage.cpp \
fx/qfxpainteditem.cpp \
fx/qfxitem.cpp \
+ fx/qfxfocusrealm.cpp \
fx/qfxkeyactions.cpp \
fx/qfxkeyproxy.cpp \
fx/qfxlayouts.cpp \
@@ -66,17 +60,16 @@ SOURCES += \
fx/qfxpath.cpp \
fx/qfxpathview.cpp \
fx/qfxrect.cpp \
- fx/qfxreflectionfilter.cpp \
fx/qfxrepeater.cpp \
fx/qfxscalegrid.cpp \
- fx/qfxshadowfilter.cpp \
+ fx/qfxlineedit.cpp \
fx/qfxtext.cpp \
fx/qfxtextedit.cpp \
fx/qfxtransform.cpp \
fx/qfxpixmap.cpp \
fx/qfxvisualitemmodel.cpp \
fx/qfxlistview.cpp \
- fx/qfxwidgetcontainer.cpp \
+ fx/qfxgraphicsobjectcontainer.cpp \
contains(QT_CONFIG, webkit) {
QT+=webkit
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp
index 9a5c516..e1b450d 100644
--- a/src/declarative/fx/qfxanchors.cpp
+++ b/src/declarative/fx/qfxanchors.cpp
@@ -222,7 +222,7 @@ void QFxAnchorsPrivate::addDepend(QFxItem *item)
if (!item)
return;
QFxItemPrivate *p =
- static_cast<QFxItemPrivate *>(QObjectPrivate::get(item));
+ static_cast<QFxItemPrivate *>(QGraphicsItemPrivate::get(item));
p->dependantAnchors.append(q);
}
@@ -232,7 +232,7 @@ void QFxAnchorsPrivate::remDepend(QFxItem *item)
if (!item)
return;
QFxItemPrivate *p =
- static_cast<QFxItemPrivate *>(QObjectPrivate::get(item));
+ static_cast<QFxItemPrivate *>(QGraphicsItemPrivate::get(item));
p->dependantAnchors.removeAll(q);
}
@@ -324,6 +324,11 @@ QFxItem *QFxAnchors::fill() const
void QFxAnchors::setFill(QFxItem *f)
{
Q_D(QFxAnchors);
+ if (!f) {
+ d->remDepend(d->fill);
+ d->fill = f;
+ return;
+ }
if (f != d->item->itemParent() && f->itemParent() != d->item->itemParent()){
qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling.";
return;
@@ -351,8 +356,9 @@ QFxItem *QFxAnchors::centeredIn() const
void QFxAnchors::setCenteredIn(QFxItem* c)
{
Q_D(QFxAnchors);
- if (!c){
- qmlInfo(d->item) << "Cannot center in null item.";
+ if (!c) {
+ d->remDepend(d->centeredIn);
+ d->centeredIn = c;
return;
}
if (c != d->item->itemParent() && c->itemParent() != d->item->itemParent()){
diff --git a/src/declarative/fx/qfxblurfilter.cpp b/src/declarative/fx/qfxblurfilter.cpp
deleted file mode 100644
index 84799ec..0000000
--- a/src/declarative/fx/qfxblurfilter.cpp
+++ /dev/null
@@ -1,467 +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 "qfxblurfilter.h"
-#include <private/qsimplecanvasitem_p.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glsave.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glbasicshaders.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-class QFxBlurFilterPrivate
-{
-public:
- QFxBlurFilterPrivate()
- : radius(0)
- {
- }
- qreal radius;
-};
-
-/*!
- \qmlclass Blur
- \brief The Blur filter blurs an item and its contents.
- \inherits Filter
-
- Blurring reduces the clarity of a visual item. The following example
- shows an icon at a blur radius of 0, 5 and 10.
-
- \table
- \row
- \o
- \qml
-HorizontalLayout {
- Image {
- source: "icon.png"
- filter: Blur { radius: 0 }
- }
- Image {
- source: "icon.png"
- filter: Blur { radius: 5 }
- }
- Image {
- source: "icon.png"
- filter: Blur { radius: 10 }
- }
-}
- \endqml
- \row
- \o \image blur_example.png
- \endtable
-
- Bluring is only supported when Qt Declarative is compiled for OpenGL ES 2.0.
- Otherwise the Blur filter has no effect.
- */
-/*!
- \internal
- \class QFxBlurFilter
- \ingroup group_effects
- \brief The QFxBlurFilter class allows you to blur an item.
-*/
-
-QFxBlurFilter::QFxBlurFilter(QObject *parent)
-: QSimpleCanvasFilter(parent), d(new QFxBlurFilterPrivate)
-{
-}
-
-QFxBlurFilter::~QFxBlurFilter()
-{
- delete d; d = 0;
-}
-
-/*!
- \qmlproperty real Blur::radius
-
- Sets the blur kernel radius.
- The larger the radius the more blurry the item will appear.
- A radius of 0 (or less) is equivalent to no blur.
- */
-
-/*!
- \property QFxBlurFilter::radius
- \brief the radius of the blur.
-*/
-qreal QFxBlurFilter::radius() const
-{
- return d->radius;
-}
-
-void QFxBlurFilter::setRadius(qreal radius)
-{
- if (d->radius == radius) return;
- d->radius = radius;
- emit radiusChanged(radius);
- update();
-}
-
-QRectF QFxBlurFilter::itemBoundingRect(const QRectF &r) const
-{
- QRectF rv = r;
- if (d->radius > 0)
- rv.adjust(-d->radius, -d->radius, d->radius, d->radius);
- return rv;
-}
-
-#include <math.h>
-void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
-#if defined(QFX_RENDER_OPENGL2)
-#if 1
- if (d->radius <= 0) {
- renderToScreen();
- return;
- }
- float radius = d->radius;
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
- float blurScale = 1.0;
- QRect tr = QRect(QPoint(0, 0), r.size() * blurScale);
- radius *= blurScale;
-
- QGLFramebufferObject *fbo = renderToFBO(blurScale);
- if (!fbo)
- return;
-
- float height = r.height();
- float width = r.width();
-
- float texWidth = float(tr.width()) / float(fbo->width());
- float texHeight = float(tr.height()) / float(fbo->height());
-
- int steps = int(::ceil(radius));
- int dispSteps = int(::ceil(d->radius));
- float xstep = texWidth * radius / float(steps * fbo->width());
- float xinc = steps / float(fbo->width());
-
- glDisable(GL_BLEND);
-
- // Render x pass
- QSize xSize(tr.width() + 2 * steps, tr.height());
- QGLFramebufferObject *xBlur = acquireFBO(xSize);
- float xWidth = float(xSize.width()) / float(xBlur->width());
- float xHeight = float(xSize.height()) / float(xBlur->height());
- {
- xBlur->bind();
-
- GLSaveViewport sv; GLSaveScissor ss;
- glClearColor(0,0,0,0);
- glDisable(GL_SCISSOR_TEST);
- glViewport(0, 0, xBlur->width(), xBlur->height());
- glClear(GL_COLOR_BUFFER_BIT);
-
- float vert[] = { 0, xHeight,
- xWidth, xHeight,
- 0, 0,
- xWidth, 0 };
- float texVert[] = { -xinc, 0,
- texWidth + xinc, 0,
- -xinc, texHeight,
- texWidth + xinc, texHeight };
-
- QMatrix4x4 trans;
- trans.translate(-1, -1);
- trans.scale(2, 2);
- BlurTextureShader *shader = item->basicShaders()->blurTexture();
- shader->enable();
- shader->setTransform(trans);
- if (steps > 1) {
- shader->setStep(xstep * 2);
- shader->setSteps(steps / 2);
- } else {
- shader->setStep(xstep);
- shader->setSteps(steps);
- }
- shader->setMode(BlurTextureShader::Horizontal);
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
-
- shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(BlurTextureShader::Vertices);
- shader->disableAttributeArray(BlurTextureShader::TextureCoords);
- xBlur->release();
- }
-
- // Render y pass
- QSize ySize(xSize.width(), tr.height() + 2 * steps);
- QGLFramebufferObject *yBlur = acquireFBO(ySize);
-
- float yWidth = float(ySize.width()) / float(yBlur->width());
- float yHeight = float(ySize.height()) / float(yBlur->height());
- float ystep = radius / float(steps * xBlur->height());
- float yinc = steps / float(xBlur->height());
- {
- yBlur->bind();
-
- GLSaveViewport sv; GLSaveScissor ss;
- glClearColor(0,0,0,0);
- glDisable(GL_SCISSOR_TEST);
- glViewport(0, 0, yBlur->width(), yBlur->height());
- glClear(GL_COLOR_BUFFER_BIT);
-
- float vert[] = { 0, yHeight,
- yWidth, yHeight,
- 0, 0,
- yWidth, 0 };
- float texVert[] = { 0, -yinc,
- xWidth, -yinc,
- 0, xHeight + yinc,
- xWidth, xHeight + yinc };
-
- QMatrix4x4 trans;
- trans.translate(-1, -1);
- trans.scale(2, 2);
- BlurTextureShader *shader = item->basicShaders()->blurTexture();
- shader->enable();
- shader->setTransform(trans);
- if (steps > 1) {
- shader->setStep(ystep * 2);
- shader->setSteps(steps / 2);
- } else {
- shader->setStep(ystep);
- shader->setSteps(steps);
- }
- shader->setMode(BlurTextureShader::Vertical);
-
- glBindTexture(GL_TEXTURE_2D, xBlur->texture());
-
- shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(BlurTextureShader::Vertices);
- shader->disableAttributeArray(BlurTextureShader::TextureCoords);
- yBlur->release();
- }
-
- glEnable(GL_BLEND);
-
- // Render display pass
- {
- glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- float vert[] = { -dispSteps, height + dispSteps,
- width + dispSteps, height + dispSteps,
- -dispSteps, -dispSteps,
- width + dispSteps, -dispSteps };
- float texVert[] = { 0, 0,
- yWidth, 0,
- 0, yHeight,
- yWidth, yHeight };
- SingleTextureShader *shader = item->basicShaders()->singleTexture();
- shader->enable();
- shader->setTransform(p.activeTransform);
-
- glBindTexture(GL_TEXTURE_2D, yBlur->texture());
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVert, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(SingleTextureShader::Vertices);
- shader->disableAttributeArray(SingleTextureShader::TextureCoords);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- releaseFBO(yBlur);
- releaseFBO(xBlur);
- releaseFBO(fbo);
-#else
-#if 0
- if (d->radius <= 0) {
- renderToScreen();
- return;
- }
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
-
- float scale = 0.5;
- float scalePercent = scale / d->radius;
- QGLFramebufferObject *fbo = renderToFBO(scalePercent);
- if (!fbo)
- return;
-
- QGLFramebufferObject *xfbo = acquireFBO(QSize(scale * r.width(), fbo->height()));
- QGLFramebufferObject *yfbo = acquireFBO(QSize(scale * r.width(), scale * r.height()));
-
-
- BlurTextureShader *shader = item->basicShaders()->blurTexture();
- shader->enable();
- shader->setTransform(QMatrix4x4());
-
- // Render up - x
- {
- shader->setMode(BlurTextureShader::Horizontal);
- shader->setStep(1. / float(xfbo->width()));
-
- GLSaveViewport vp;
- xfbo->bind();
- glClearColor(0,0,0,0);
- glViewport(0, 0, xfbo->width(), xfbo->height());
- glClear(GL_COLOR_BUFFER_BIT);
-
- float oWidth = -1. + 2. * float(r.width()) * scale / float(xfbo->width());
- float oHeight = -1. + 2. * float(r.height()) * scalePercent / float(xfbo->height());
- float vert[] = {
- -1, -1,
- oWidth, -1,
- -1, oHeight,
-
- -1, oHeight,
- oWidth, oHeight,
- oWidth, -1
- };
-
- float tWidth = r.width() * scalePercent / fbo->width();
- float tHeight = r.height() * scalePercent / fbo->height();
- float texVert[] = {
- 0, 0,
- tWidth, 0,
- 0, tHeight,
-
- 0, tHeight,
- tWidth, tHeight,
- tWidth, 0
- };
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
- shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2);
-
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- xfbo->release();
- }
-
- // Render up - y
- {
- shader->setMode(BlurTextureShader::Vertical);
- shader->setStep(1. / float(yfbo->height()));
-
- GLSaveViewport vp;
- yfbo->bind();
- glClearColor(0,0,0,0);
- glViewport(0, 0, yfbo->width(), yfbo->height());
- glClear(GL_COLOR_BUFFER_BIT);
-
- float oWidth = -1. + 2. * r.width() * scale / yfbo->width();
- float oHeight = -1. + 2. * r.height() * scale / yfbo->height();
- float vert[] = {
- -1, -1,
- oWidth, -1,
- -1, oHeight,
-
- -1, oHeight,
- oWidth, oHeight,
- oWidth, -1
- };
-
- float tWidth = r.width() * scale / xfbo->width();
- float tHeight = r.height() * scalePercent / xfbo->height();
- float texVert[] = {
- 0, 0,
- tWidth, 0,
- 0, tHeight,
-
- 0, tHeight,
- tWidth, tHeight,
- tWidth, 0
- };
-
- glBindTexture(GL_TEXTURE_2D, xfbo->texture());
- shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2);
-
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- yfbo->release();
- }
-
- shader->disableAttributeArray(BlurTextureShader::Vertices);
- shader->disableAttributeArray(BlurTextureShader::TextureCoords);
-
- float width = r.width();
- float height = r.height();
- //paint to screen
- {
- float texWidth = r.width() * scale / float(yfbo->width());
- float texHeight = r.height() * scale / float(yfbo->height());
-
- GLfloat vertices[] = { 0, height,
- width, height,
- 0, 0,
- width, 0 };
- GLfloat texVertices[] = { 0, 0,
- texWidth, 0,
- 0, texHeight,
- texWidth, texHeight };
-
- glBindTexture(GL_TEXTURE_2D, yfbo->texture());
-
- SingleTextureOpacityShader *shader =
- item->basicShaders()->singleTextureOpacity();
- shader->enable();
- shader->setTransform(p.activeTransform);
- shader->setOpacity(p.activeOpacity);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, texVertices, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords);
- }
-
-
- releaseFBO(fbo);
- releaseFBO(xfbo);
- releaseFBO(yfbo);
-#endif
-#endif
-#else
- Q_UNUSED(p);
-#endif
-
-}
-
-QML_DEFINE_TYPE(QFxBlurFilter,Blur)
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxblurfilter.h b/src/declarative/fx/qfxblurfilter.h
deleted file mode 100644
index 830663f..0000000
--- a/src/declarative/fx/qfxblurfilter.h
+++ /dev/null
@@ -1,83 +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 QFXBLURFILTER_H
-#define QFXBLURFILTER_H
-
-#include <QtDeclarative/qsimplecanvasfilter.h>
-#include <QtDeclarative/qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QFxBlurFilterPrivate;
-class Q_DECLARATIVE_EXPORT QFxBlurFilter : public QSimpleCanvasFilter
-{
- Q_OBJECT
- Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
-public:
- QFxBlurFilter(QObject *parent=0);
- virtual ~QFxBlurFilter();
-
- qreal radius() const;
- void setRadius(qreal);
-
-Q_SIGNALS:
- void radiusChanged(qreal);
-
-protected:
- virtual QRectF itemBoundingRect(const QRectF &) const;
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
-
-private:
- QFxBlurFilterPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxBlurFilter)
-
-QT_END_HEADER
-
-#endif // QFXBLURFILTER_H
diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h
index f3bf6b3..940fb6d 100644
--- a/src/declarative/fx/qfxcomponentinstance.h
+++ b/src/declarative/fx/qfxcomponentinstance.h
@@ -78,7 +78,7 @@ protected:
QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent);
private:
- Q_DECLARE_PRIVATE(QFxComponentInstance)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxComponentInstance)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index a82385a..24f6d72 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -111,7 +111,7 @@ void QFxFlickablePrivate::init()
QObject::connect(&_tl, SIGNAL(updated()), q, SLOT(ticked()));
QObject::connect(&_tl, SIGNAL(completed()), q, SLOT(movementEnding()));
q->setAcceptedMouseButtons(Qt::LeftButton);
- q->setOptions(QSimpleCanvasItem::ChildMouseFilter | QSimpleCanvasItem::MouseEvents);
+ q->setOptions(QFxItem::ChildMouseFilter | QFxItem::MouseEvents);
QObject::connect(_flick, SIGNAL(xChanged()), q, SIGNAL(positionChanged()));
QObject::connect(_flick, SIGNAL(yChanged()), q, SIGNAL(positionChanged()));
QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked()));
@@ -740,6 +740,7 @@ void QFxFlickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Q_D(QFxFlickable);
d->handleMouseReleaseEvent(event);
event->accept();
+ ungrabMouse();
}
qreal QFxFlickable::minYExtent() const
@@ -1047,7 +1048,7 @@ bool QFxFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
break;
}
grabber = static_cast<QFxItem*>(mouseGrabberItem());
- if (grabber && d->stealMouse && !grabber->keepMouseGrab())
+ if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this)
grabMouse();
return d->stealMouse;
diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h
index da38df8..a6c2a6c 100644
--- a/src/declarative/fx/qfxflickable.h
+++ b/src/declarative/fx/qfxflickable.h
@@ -184,7 +184,7 @@ protected:
private:
Q_DISABLE_COPY(QFxFlickable)
- Q_DECLARE_PRIVATE(QFxFlickable)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlickable)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index 7672858..6089d0a 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -221,22 +221,13 @@ void QFxFlipablePrivate::setBackTransform()
p3 = axisRotation.transform().map(p3);
axisRotation.setAngle(rotation);
- QSimpleCanvas::Matrix mat;
-#ifdef QFX_RENDER_OPENGL
- mat.translate(back->width()/2,back->height()/2, 0);
- if (back->width() && p1.x() >= p2.x())
- mat.rotate(180, 0, 1, 0);
- if (back->height() && p2.y() >= p3.y())
- mat.rotate(180, 1, 0, 0);
- mat.translate(-back->width()/2,-back->height()/2, 0);
-#else
+ QTransform mat;
mat.translate(back->width()/2,back->height()/2);
if (back->width() && p1.x() >= p2.x())
mat.rotate(180, Qt::YAxis);
if (back->height() && p2.y() >= p3.y())
mat.rotate(180, Qt::XAxis);
mat.translate(-back->width()/2,-back->height()/2);
-#endif
back->setTransform(mat);
}
@@ -295,7 +286,7 @@ QFxFlipable::Side QFxFlipable::side() const
//in some cases the user may want to specify a more complex transformation.
//in that case, we still allow the generic use of transform.
//(the logic here should be kept in sync with setBackTransform and setRotation)
-void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans)
+void QFxFlipable::transformChanged(const QTransform &trans)
{
Q_D(QFxFlipable);
QPointF p1(0, 0);
@@ -319,22 +310,13 @@ void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans)
if (newSide != d->current) {
d->current = newSide;
if (d->current==Back) {
- QSimpleCanvas::Matrix mat;
-#ifdef QFX_RENDER_OPENGL
- mat.translate(d->back->width()/2,d->back->height()/2, 0);
- if (d->back->width() && p1.x() >= p2.x())
- mat.rotate(180, 0, 1, 0);
- if (d->back->height() && p2.y() >= p3.y())
- mat.rotate(180, 1, 0, 0);
- mat.translate(-d->back->width()/2,-d->back->height()/2, 0);
-#else
+ QTransform mat;
mat.translate(d->back->width()/2,d->back->height()/2);
if (d->back->width() && p1.x() >= p2.x())
mat.rotate(180, Qt::YAxis);
if (d->back->height() && p2.y() >= p3.y())
mat.rotate(180, Qt::XAxis);
mat.translate(-d->back->width()/2,-d->back->height()/2);
-#endif
d->back->setTransform(mat);
}
if (d->front)
diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h
index 06f8b93..5aa038d 100644
--- a/src/declarative/fx/qfxflipable.h
+++ b/src/declarative/fx/qfxflipable.h
@@ -44,9 +44,6 @@
#include <QtCore/QObject>
#include <QtGui/QTransform>
-#if defined(QFX_RENDER_OPENGL)
-#include <QtGui/qmatrix4x4.h>
-#endif
#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
@@ -87,7 +84,7 @@ public:
Side side() const;
protected:
- virtual void transformChanged(const QSimpleCanvas::Matrix &);
+ virtual void transformChanged(const QTransform &);
Q_SIGNALS:
void sideChanged();
@@ -95,7 +92,7 @@ Q_SIGNALS:
private:
Q_PRIVATE_SLOT(d_func(), void _q_updateAxis())
Q_DISABLE_COPY(QFxFlipable)
- Q_DECLARE_PRIVATE(QFxFlipable)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlipable)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxfocuspanel.h b/src/declarative/fx/qfxfocuspanel.h
deleted file mode 100644
index 623c9fb..0000000
--- a/src/declarative/fx/qfxfocuspanel.h
+++ /dev/null
@@ -1,81 +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 QFXFOCUSPANEL_H
-#define QFXFOCUSPANEL_H
-
-#include <QtDeclarative/qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QFxFocusPanel : public QFxItem
-{
- Q_OBJECT
- Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
-public:
- QFxFocusPanel(QFxItem *parent=0);
- virtual ~QFxFocusPanel();
-
- bool isActive() const;
- void setActive(bool);
-
-Q_SIGNALS:
- void activeChanged();
-
-protected:
- virtual void activePanelInEvent();
- virtual void activePanelOutEvent();
-
-private:
- Q_DISABLE_COPY(QFxFocusPanel)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxFocusPanel)
-
-QT_END_HEADER
-
-#endif // QFXFOCUSPANEL_H
diff --git a/src/declarative/fx/qfxfocuspanel.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
index 6da8564..479a21d 100644
--- a/src/declarative/fx/qfxfocuspanel.cpp
+++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
@@ -39,66 +39,60 @@
**
****************************************************************************/
-#include "qfxfocuspanel.h"
-
+#include "qfxgraphicsobjectcontainer.h"
+#include <QGraphicsObject>
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(QFxFocusPanel,FocusPanel)
/*!
- \qmlclass FocusPanel
- \brief The FocusPanel object explicitly creates a focus panel.
- \inherits Item
-
- Focus panels assist in keyboard focus handling when building QML
- applications. All the details are covered in the
- \l {qmlfocus}{keyboard focus documentation}.
+ \qmlclass GraphicsObjectContainer QFxGraphicsObjectContainer
+ \brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements.
*/
/*!
\internal
- \class QFxFocusPanel
+ \class QFxGraphicsObjectContainer
+ \brief The QFxGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications.
*/
-QFxFocusPanel::QFxFocusPanel(QFxItem *parent) :
- QFxItem(parent)
-{
- setOptions(IsFocusPanel);
-}
+QML_DEFINE_TYPE(QFxGraphicsObjectContainer, GraphicsObjectContainer)
-QFxFocusPanel::~QFxFocusPanel()
+QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent)
+: QFxItem(parent), _graphicsObject(0)
{
}
-/*!
- \qmlproperty bool FocusPanel::active
-
- Sets whether the object is the active focus panel.
-*/
-
-bool QFxFocusPanel::isActive() const
+QFxGraphicsObjectContainer::~QFxGraphicsObjectContainer()
{
- QSimpleCanvas *canvas = QSimpleCanvasItem::canvas();
- if (canvas)
- return canvas->activeFocusPanel() == this;
- else
- return false;
}
-void QFxFocusPanel::setActive(bool a)
+QGraphicsObject *QFxGraphicsObjectContainer::graphicsObject() const
{
- setActiveFocusPanel(a);
+ return _graphicsObject;
}
-void QFxFocusPanel::activePanelInEvent()
+/*!
+ \qmlproperty QGraphicsObject GraphicsObjectContainer::graphicsObject
+ The QGraphicsObject associated with this element.
+*/
+void QFxGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object)
{
- QFxItem::activePanelInEvent();
- emit activeChanged();
+ if (object == _graphicsObject)
+ return;
+
+ _graphicsObject = object;
+
+ _graphicsObject->setParentItem(this);
}
-void QFxFocusPanel::activePanelOutEvent()
+QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value)
{
- QFxItem::activePanelOutEvent();
- emit activeChanged();
+ if (change == ItemSceneHasChanged) {
+ QGraphicsObject *o = _graphicsObject;
+ _graphicsObject = 0;
+ setGraphicsObject(o);
+ }
+ return QFxItem::itemChange(change, value);
}
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h
index 862a280..e118555 100644
--- a/src/declarative/fx/qfxwidgetcontainer.h
+++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QFXWIDGETCONTAINER_H
-#define QFXWIDGETCONTAINER_H
+#ifndef QFXGRAPHICSOBJECTCONTAINER_H
+#define QFXGRAPHICSOBJECTCONTAINER_H
#include <QtDeclarative/qfxitem.h>
@@ -50,33 +50,33 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QGraphicsWidget;
+class QGraphicsObject;
-class Q_DECLARATIVE_EXPORT QFxWidgetContainer : public QFxItem
+class Q_DECLARATIVE_EXPORT QFxGraphicsObjectContainer : public QFxItem
{
Q_OBJECT
- Q_CLASSINFO("DefaultProperty", "graphicsWidget")
- Q_PROPERTY(QGraphicsWidget *graphicsWidget READ graphicsWidget WRITE setGraphicsWidget)
+ Q_CLASSINFO("DefaultProperty", "graphicsObject")
+ Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject)
public:
- QFxWidgetContainer(QFxItem *parent = 0);
- ~QFxWidgetContainer();
+ QFxGraphicsObjectContainer(QFxItem *parent = 0);
+ ~QFxGraphicsObjectContainer();
- QGraphicsWidget *graphicsWidget() const;
- void setGraphicsWidget(QGraphicsWidget *);
+ QGraphicsObject *graphicsObject() const;
+ void setGraphicsObject(QGraphicsObject *);
protected:
- virtual void canvasChanged();
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
- QGraphicsWidget *_graphicsWidget;
+ QGraphicsObject *_graphicsObject;
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QFxWidgetContainer)
+QML_DECLARE_TYPE(QFxGraphicsObjectContainer)
QT_END_HEADER
-#endif // QFXGRAPHICSWIDGET_H
+#endif // QFXGRAPHICSOBJECTCONTAINER_H
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index a43e84c..3c80e98 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -45,6 +45,8 @@
#include "private/qfxflickable_p.h"
#include "qfxgridview.h"
+#include <QKeyEvent>
+
QT_BEGIN_NAMESPACE
class QFxGridViewAttached : public QObject
@@ -811,7 +813,7 @@ QFxItem *QFxGridView::currentItem()
Q_D(QFxGridView);
if (!d->currentItem) {
// Always return something valid
- if (!d->tmpCurrent)
+ if (!d->tmpCurrent)
d->tmpCurrent = new QFxItem(viewport());
return d->tmpCurrent;
}
diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h
index b6d585e..8f443e1 100644
--- a/src/declarative/fx/qfxgridview.h
+++ b/src/declarative/fx/qfxgridview.h
@@ -54,7 +54,7 @@ class QFxGridViewPrivate;
class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QFxGridView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxGridView)
Q_PROPERTY(QVariant model READ model WRITE setModel)
Q_CLASSINFO("DefaultProperty", "delegate")
diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp
deleted file mode 100644
index 78a91af..0000000
--- a/src/declarative/fx/qfxhighlightfilter.cpp
+++ /dev/null
@@ -1,320 +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 "qfxhighlightfilter.h"
-#include <qfxpixmap.h>
-#include <qmlcontext.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <gltexture.h>
-#include <glbasicshaders.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glsave.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QFxHighlightFilterPrivate
-{
-public:
- QFxHighlightFilterPrivate()
- : xOffset(0), yOffset(0), tiled(false) {}
-
- QUrl url;
- int xOffset;
- int yOffset;
- bool tiled;
-#if defined(QFX_RENDER_OPENGL2)
- GLTexture tex;
-#endif
-};
-
-/*!
- \qmlclass Highlight
- \brief The Highlight filter adds a highlight to an item.
- \inherits Filter
-
- \qml
-Text {
- id: highlighttext
- color: "red"
- font.size: 32
- text: "Highlight"
- filter: Highlight {
- source: "pics/highlight.png"
- xOffset: NumberAnimation {
- running: true
- repeat: true
- from: 320
- to: -320
- duration: 2000
- }
- }
-}
- \endqml
- \image highlight.gif
-
- Highlighting is only supported when Qt Declarative is compiled for OpenGL ES 2.0.
- Otherwise the Highlight filter has no effect.
-*/
-
-/*!
- \internal
- \class QFxHighlightFilter
- \ingroup group_effects
- \brief The QFxHightlightFilter class allows you to add a highlight to an item.
-*/
-
-QFxHighlightFilter::QFxHighlightFilter(QObject *parent)
-: QSimpleCanvasFilter(parent), d(new QFxHighlightFilterPrivate)
-{
-#if defined(QFX_RENDER_OPENGL2)
- d->tex.setHorizontalWrap(GLTexture::ClampToEdge);
- d->tex.setVerticalWrap(GLTexture::ClampToEdge);
-#endif
-}
-
-QFxHighlightFilter::~QFxHighlightFilter()
-{
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
- delete d;
- d = 0;
-}
-
-/*!
- \qmlproperty string Highlight::source
- This property holds the URL of the image to be used as the highlight.
-*/
-
-/*!
- \property QFxHighlightFilter::source
- \brief the URL of the image to be used as the highlight.
-*/
-QUrl QFxHighlightFilter::source() const
-{
- return d->url;
-}
-
-void QFxHighlightFilter::imageLoaded()
-{
- QPixmap img = QFxPixmap(d->url);
-#if defined(QFX_RENDER_OPENGL2)
- if (!img.isNull())
- d->tex.setImage(img.toImage());
-#endif
- emit sourceChanged(d->url);
- update();
-}
-
-void QFxHighlightFilter::setSource(const QUrl &f)
-{
- if (d->url == f)
- return;
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
- Q_ASSERT(!f.isRelative());
- d->url = f;
-#if defined(QFX_RENDER_OPENGL2)
- d->tex.clear();
-#endif
- if (!f.isEmpty())
- QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
- else
- emit sourceChanged(d->url);
-}
-
-/*!
- \qmlproperty bool Highlight::tiled
- This property holds whether or not the highlight should be tiled.
-*/
-
-/*!
- \property QFxHighlightFilter::tiled
- \brief whether or not the highlight should be tiled.
-*/
-bool QFxHighlightFilter::tiled() const
-{
- return d->tiled;
-}
-
-void QFxHighlightFilter::setTiled(bool t)
-{
- if (t == d->tiled)
- return;
-
- d->tiled = t;
-
-#if defined(QFX_RENDER_OPENGL2)
- if (d->tiled) {
- d->tex.setHorizontalWrap(GLTexture::ClampToEdge);
- d->tex.setVerticalWrap(GLTexture::ClampToEdge);
- } else {
- d->tex.setHorizontalWrap(GLTexture::Repeat);
- d->tex.setVerticalWrap(GLTexture::Repeat);
- }
-#endif
-
- emit tiledChanged(d->tiled);
-}
-
-/*!
- \qmlproperty int Highlight::xOffset
- \qmlproperty int Highlight::yOffset
- These properties hold the position of the highlight, relative to the item.
-*/
-
-/*!
- \property QFxHighlightFilter::xOffset
- \brief the x position of the highlight, relative to the item.
-*/
-int QFxHighlightFilter::xOffset() const
-{
- return d->xOffset;
-}
-
-void QFxHighlightFilter::setXOffset(int x)
-{
- if (x == d->xOffset)
- return;
-
- d->xOffset = x;
- emit offsetChanged(d->xOffset, d->yOffset);
-#if defined(QFX_RENDER_OPENGL2)
- update();
-#endif
-}
-
-/*!
- \property QFxHighlightFilter::yOffset
- \brief the y position of the highlight, relative to the item.
-*/
-int QFxHighlightFilter::yOffset() const
-{
- return d->yOffset;
-}
-
-void QFxHighlightFilter::setYOffset(int y)
-{
- if (y == d->yOffset)
- return;
-
- d->yOffset = y;
- emit offsetChanged(d->xOffset, d->yOffset);
-#if defined(QFX_RENDER_OPENGL2)
- update();
-#endif
-}
-
-void QFxHighlightFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
-#if defined(QFX_RENDER_OPENGL2)
- if (d->tex.isNull()) {
- renderToScreen();
- } else {
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
-
- QGLFramebufferObject *fbo = renderToFBO();
-
- float width = r.width();
- float height = r.height();
-
- float texWidth = width / float(fbo->width());
- float texHeight = height / float(fbo->height());
-
- GLfloat vert[] = { 0, height,
- width, height,
- 0, 0,
- width, 0 };
- GLfloat texVert[] = { 0, 0,
- texWidth, 0,
- 0, texHeight,
- texWidth, texHeight };
- float texXOffset = 0;
- float texYOffset = 0;
-
- if (xOffset())
- texXOffset = float(xOffset()) / float(d->tex.width());
- if (yOffset())
- texYOffset = float(yOffset()) / float(d->tex.height());
-
- GLfloat addTexVert[] = { texXOffset, texYOffset,
- 1 + texXOffset, texYOffset,
- texXOffset, 1 + texYOffset,
- 1 + texXOffset, 1 + texYOffset };
-
- glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, d->tex.texture());
-
- DualTextureAddShader *shader = item->basicShaders()->dualTextureAdd();
- shader->enable();
- shader->setTransform(p.activeTransform);
- shader->setOpacity(p.activeOpacity);
-
- shader->setAttributeArray(DualTextureAddShader::Vertices, vert, 2);
- shader->setAttributeArray(DualTextureAddShader::TextureCoords, texVert, 2);
- shader->setAttributeArray(DualTextureAddShader::AddTextureCoords, addTexVert, 2);
-
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- shader->disableAttributeArray(DualTextureAddShader::Vertices);
- shader->disableAttributeArray(DualTextureAddShader::TextureCoords);
- shader->disableAttributeArray(DualTextureAddShader::AddTextureCoords);
-
- glActiveTexture(GL_TEXTURE0);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- releaseFBO(fbo);
- }
-#else
- Q_UNUSED(p);
-#endif
-}
-
-QML_DEFINE_TYPE(QFxHighlightFilter,Highlight)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxhighlightfilter.h b/src/declarative/fx/qfxhighlightfilter.h
deleted file mode 100644
index 56509a3..0000000
--- a/src/declarative/fx/qfxhighlightfilter.h
+++ /dev/null
@@ -1,99 +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 QFXHIGHLIGHTFILTER_H
-#define QFXHIGHLIGHTFILTER_H
-
-#include <QtDeclarative/qsimplecanvasfilter.h>
-#include <QtDeclarative/qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QFxHighlightFilterPrivate;
-class Q_DECLARATIVE_EXPORT QFxHighlightFilter : public QSimpleCanvasFilter
-{
- Q_OBJECT
-
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(bool tiled READ tiled WRITE setTiled NOTIFY tiledChanged)
- Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
- Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
-public:
- QFxHighlightFilter(QObject *parent=0);
- virtual ~QFxHighlightFilter();
-
- QUrl source() const;
- void setSource(const QUrl &);
-
- bool tiled() const;
- void setTiled(bool);
-
- int xOffset() const;
- void setXOffset(int);
- int yOffset() const;
- void setYOffset(int);
-
-Q_SIGNALS:
- void sourceChanged(const QUrl &);
- void offsetChanged(int x, int y);
- void tiledChanged(bool);
-
-private Q_SLOTS:
- void imageLoaded();
-
-protected:
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
-
-private:
- QFxHighlightFilterPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxHighlightFilter)
-
-QT_END_HEADER
-
-#endif // QFXHIGHLIGHTFILTER_H
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 539ad02..027b22a 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -42,14 +42,14 @@
#include "qfximage.h"
#include "qfximage_p.h"
#include <private/qfxperf_p.h>
-#if defined(QFX_RENDER_OPENGL)
-#include <glsave.h>
-#endif
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QFile>
#include <QtDeclarative/qmlengine.h>
+#include <QKeyEvent>
+#include <QPainter>
+
QT_BEGIN_NAMESPACE
@@ -131,12 +131,6 @@ QFxImage::~QFxImage()
QFxPixmap::cancelGet(d->url, this);
if (!d->sciurl.isEmpty())
QFxPixmap::cancelGet(d->sciurl, this);
-#if defined(QFX_RENDER_OPENGL)
- if (d->tex) {
- d->tex->release();
- d->tex = 0;
- }
-#endif
}
/*!
@@ -164,13 +158,6 @@ void QFxImage::setPixmap(const QPixmap &pix)
setImplicitWidth(d->pix.width());
setImplicitHeight(d->pix.height());
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- if (d->tex) {
- d->tex->release();
- d->tex = 0;
- }
-#endif
update();
}
@@ -235,44 +222,6 @@ void QFxImage::setTiled(bool tile)
d->tiled = tile;
}
-/*!
- \qmlproperty bool Image::opaque
-
- Set this property if you know that the image is opaque to give your
- application a significant performance boost.
-
- \note
- This is a performance hint to Qt Declarative. Unfortunately whether or not an image
- is opaque is not automatically detected. Setting this property to true when
- the image is not opaque will lead to drawing artifacts. However, leaving it as
- false will always work correctly - although possibly not at maximum performance.
- */
-
-/*!
- \property QFxImage::opaque
- \brief whether the image is opaque (non-transparent).
-
- This property is provided purely for the purpose of optimization. An opaque
- image can be optimized more than a non-opaque one.
-*/
-bool QFxImage::isOpaque() const
-{
- Q_D(const QFxImage);
- return d->opaque;
-}
-
-void QFxImage::setOpaque(bool o)
-{
- Q_D(QFxImage);
- if (o == d->opaque)
- return;
- d->opaque = o;
-
- setOptions(IsOpaque, o);
-
- update();
-}
-
void QFxImage::componentComplete()
{
QFxItem::componentComplete();
@@ -287,12 +236,12 @@ void QFxImage::componentComplete()
\qmlproperty bool Image::smooth
Set this property if you want the image to be smoothly filtered when scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the Image is displayed at its natural size, this property has no visual or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the Image is displayed at its natural size, this property has no visual or
performance effect.
- \note Generally scaling artifacts are only visible if the image is stationary on
- the screen. A common pattern when animating an image is to disable smooth
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
filtering at the beginning of the animation and reenable it at the conclusion.
*/
@@ -301,7 +250,7 @@ void QFxImage::componentComplete()
\brief whether the image is smoothly transformed.
This property is provided purely for the purpose of optimization. Turning
- smooth transforms off is faster, but looks worse; turning smooth
+ smooth transforms off is faster, but looks worse; turning smooth
transformations on is slower, but looks better.
By default smooth transformations are off.
@@ -321,15 +270,6 @@ void QFxImage::setSmoothTransform(bool s)
update();
}
-void QFxImage::dump(int depth)
-{
- Q_D(QFxImage);
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << "URL:" << d->url;
- QFxItem::dump(depth);
-}
-
-#if defined(QFX_RENDER_QPAINTER)
void QFxImage::paintContents(QPainter &p)
{
Q_D(QFxImage);
@@ -364,9 +304,22 @@ void QFxImage::paintContents(QPainter &p)
p.restore();
} else if (!d->scaleGrid || d->scaleGrid->isNull()) {
if (width() != pix.width() || height() != pix.height()) {
+ qreal widthScale = width() / qreal(pix.width());
+ qreal heightScale = height() / qreal(pix.height());
+
QTransform scale;
- scale.scale(width() / qreal(pix.width()),
- height() / qreal(pix.height()));
+
+ if (d->preserveAspect) {
+ if (widthScale < heightScale) {
+ heightScale = widthScale;
+ scale.translate(0, (height() - heightScale * pix.height()) / 2);
+ } else if(heightScale < widthScale) {
+ widthScale = heightScale;
+ scale.translate((width() - widthScale * pix.width()) / 2, 0);
+ }
+ }
+
+ scale.scale(widthScale, heightScale);
QTransform old = p.transform();
p.setWorldTransform(scale * old);
p.drawPixmap(0, 0, pix);
@@ -398,7 +351,7 @@ void QFxImage::paintContents(QPainter &p)
p.drawPixmap(QRect(sgl, 0, w - xSide, sgt), pix,
QRect(sgl, 0, pix.width() - xSide, sgt));
// Upper right
- if (sgt && pix.width() - sgr)
+ if (sgt && pix.width() - sgr)
p.drawPixmap(QPoint(w-sgr, 0), pix,
QRect(pix.width()-sgr, 0, sgr, sgt));
// Middle left
@@ -409,13 +362,13 @@ void QFxImage::paintContents(QPainter &p)
// Middle
if (pix.width() - xSide && pix.height() - ySide)
p.drawPixmap(QRect(sgl, sgt, w - xSide, h - ySide),
- pix,
+ pix,
QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide));
// Middle right
if (sgr && pix.height() - ySide)
p.drawPixmap(QRect(w-sgr, sgt, sgr, h - ySide), pix,
QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide));
- // Lower left
+ // Lower left
if (sgl && sgr)
p.drawPixmap(QPoint(0, h - sgb), pix,
QRect(0, pix.height() - sgb, sgl, sgb));
@@ -434,333 +387,6 @@ void QFxImage::paintContents(QPainter &p)
p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
}
-#elif defined(QFX_RENDER_OPENGL)
-uint QFxImage::glSimpleItemData(float *vertices, float *texVertices,
- GLTexture **texture, uint count)
-{
- Q_D(QFxImage);
-
- if (d->pix.isNull() || (d->scaleGrid && !d->scaleGrid->isNull()))
- return 0;
-
- if (count < 8)
- return 8;
-
- d->checkDirty();
-
- float widthV = width();
- float heightV = height();
-
- vertices[0] = 0; vertices[1] = heightV;
- vertices[2] = widthV; vertices[3] = heightV;
- vertices[4] = 0; vertices[5] = 0;
- vertices[6] = widthV; vertices[7] = 0;
-
- *texture = d->tex;
-
- if (d->tiled) {
- float tileWidth = widthV / d->pix.width();
- float tileHeight = heightV / d->pix.height();
- texVertices[0] = 0; texVertices[1] = 0;
- texVertices[2] = tileWidth; texVertices[3] = 0;
- texVertices[4] = 0; texVertices[5] = tileHeight;
- texVertices[6] = tileWidth; texVertices[7] = tileHeight;
- } else {
- texVertices[0] = 0; texVertices[1] = 0;
- texVertices[2] = d->tex->glWidth(); texVertices[3] = 0;
- texVertices[4] = 0; texVertices[5] = d->tex->glHeight();
- texVertices[6] = d->tex->glWidth(); texVertices[7] = d->tex->glHeight();
- }
-
- return 8;
-}
-
-void QFxImagePrivate::checkDirty()
-{
- Q_Q(QFxImage);
- if (texDirty && !pix.isNull())
- tex = q->cachedTexture(url.toString(), pix);
- texDirty = false;
-}
-
-#if defined(QFX_RENDER_OPENGL2)
-void QFxImage::paintGLContents(GLPainter &p)
-{
- Q_D(QFxImage);
- if (d->pix.isNull())
- return;
-
- QGLShaderProgram *shader = p.useTextureShader();
-
- bool restoreBlend = false;
- if (p.blendEnabled && isOpaque() && p.activeOpacity == 1) {
- glDisable(GL_BLEND);
- restoreBlend = true;
- }
-
- d->checkDirty();
-
- if (d->tiled || (!d->scaleGrid || d->scaleGrid->isNull())) {
-
- if (!d->tiled) {
-
- float widthV = width();
- float heightV = height();
- float glWidth = d->tex->glWidth();
- float glHeight = d->tex->glHeight();
-
- float deltaX = 0.5 / qreal(d->tex->glSize().width());
- float deltaY = 0.5 / qreal(d->tex->glSize().height());
- glWidth -= deltaX;
- glHeight -= deltaY;
-
-
- float vert[] = {
- 0, heightV,
- widthV, heightV,
- 0, 0,
-
- widthV, heightV,
- 0, 0,
- widthV, 0 };
-
- float tex[] = {
- deltaX, deltaY,
- glWidth, deltaY,
- deltaX, glHeight,
-
- glWidth, deltaY,
- deltaX, glHeight,
- glWidth, glHeight
- };
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, tex, 2);
- glBindTexture(GL_TEXTURE_2D, d->tex->texture());
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- } else {
-
- GLfloat vertices[8];
- GLfloat texVertices[8];
- GLTexture *tex = 0;
-
- QFxImage::glSimpleItemData(vertices, texVertices, &tex, 8);
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, tex->texture());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- }
-
- } else {
-
- float imgWidth = d->pix.width();
- float imgHeight = d->pix.height();
- if (!imgWidth || !imgHeight) {
- if (restoreBlend)
- glEnable(GL_BLEND);
- return;
- }
-
- float widthV = width();
- float heightV = height();
- float glWidth = d->tex->glWidth();
- float glHeight = d->tex->glHeight();
- float deltaX = 0.5 / qreal(d->tex->glSize().width());
- float deltaY = 0.5 / qreal(d->tex->glSize().height());
- glHeight -= deltaY;
- glWidth -= deltaX;
-
- float texleft = deltaX;
- float texright = glWidth;
- float textop = glHeight;
- float texbottom = deltaY;
- float imgleft = 0;
- float imgright = widthV;
- float imgtop = 0;
- float imgbottom = heightV;
-
- const int sgl = d->scaleGrid->left();
- const int sgr = d->scaleGrid->right();
- const int sgt = d->scaleGrid->top();
- const int sgb = d->scaleGrid->bottom();
-
- if (sgl) {
- texleft = deltaX + d->tex->glWidth() * float(sgl) / imgWidth;
- imgleft = sgl;
- }
- if (sgr) {
- texright = d->tex->glWidth() - float(sgr) / imgWidth - deltaX;
- imgright = widthV - sgr;
- }
- if (sgt) {
- textop = d->tex->glHeight() - float(sgb) / imgHeight - deltaY;
- imgtop = sgt;
- }
- if (sgb) {
- texbottom = deltaY + d->tex->glHeight() * float(sgt) / imgHeight;
- imgbottom = heightV - sgb;
- }
-
- float vert1[] = { 0, 0,
- 0, imgtop,
- imgleft, 0,
-
- 0, imgtop,
- imgleft, 0,
- imgleft, imgtop,
-
- imgleft, 0,
- imgleft, imgtop,
- imgright, 0,
-
- imgleft, imgtop,
- imgright, 0,
- imgright, imgtop,
-
- imgright, 0,
- imgright, imgtop,
- widthV, 0,
-
- imgright, imgtop,
- widthV, 0,
- widthV, imgtop,
-
- 0, imgtop,
- 0, imgbottom,
- imgleft, imgtop,
-
- 0, imgbottom,
- imgleft, imgtop,
- imgleft, imgbottom,
-
- imgleft, imgtop,
- imgleft, imgbottom,
- imgright, imgtop,
-
- imgleft, imgbottom,
- imgright, imgtop,
- imgright, imgbottom,
-
- imgright, imgtop,
- imgright, imgbottom,
- widthV, imgtop,
-
- imgright, imgbottom,
- widthV, imgtop,
- widthV, imgbottom,
-
- 0, imgbottom,
- 0, heightV,
- imgleft, imgbottom,
-
- 0, heightV,
- imgleft, imgbottom,
- imgleft, heightV,
-
- imgleft, imgbottom,
- imgleft, heightV,
- imgright, imgbottom,
-
- imgleft, heightV,
- imgright, imgbottom,
- imgright, heightV,
-
- imgright, imgbottom,
- imgright, heightV,
- widthV, imgbottom,
-
- imgright, heightV,
- widthV, imgbottom,
- widthV, heightV };
-
- float tex1[] = { deltaX, glHeight,
- deltaX, textop,
- texleft, glHeight,
-
- deltaX, textop,
- texleft, glHeight,
- texleft, textop,
-
- texleft, glHeight,
- texleft, textop,
- texright, glHeight,
-
- texleft, textop,
- texright, glHeight,
- texright, textop,
-
- texright, glHeight,
- texright, textop,
- glWidth, glHeight,
-
- texright, textop,
- glWidth, glHeight,
- glWidth, textop,
-
- deltaX, textop,
- deltaX, texbottom,
- texleft, textop,
-
- deltaX, texbottom,
- texleft, textop,
- texleft, texbottom,
-
- texleft, textop,
- texleft, texbottom,
- texright, textop,
-
- texleft, texbottom,
- texright, textop,
- texright, texbottom,
-
- texright, textop,
- texright, texbottom,
- glWidth, textop,
-
- texright, texbottom,
- glWidth, textop,
- glWidth, texbottom,
-
- deltaX, texbottom,
- deltaX, deltaY,
- texleft, texbottom,
-
- deltaX, deltaY,
- texleft, texbottom,
- texleft, deltaY,
-
- texleft, texbottom,
- texleft, deltaY,
- texright, texbottom,
-
- texleft, deltaY,
- texright, texbottom,
- texright, deltaY,
-
- texright, texbottom,
- texright, deltaY,
- glWidth, texbottom,
-
- texright, deltaY,
- glWidth, texbottom,
- glWidth, deltaY };
-
- glBindTexture(GL_TEXTURE_2D, d->tex->texture());
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vert1, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, tex1, 2);
- glDrawArrays(GL_TRIANGLES, 0, 54);
- }
-
- if (restoreBlend)
- glEnable(GL_BLEND);
-}
-#endif
-
-#endif
QString QFxImage::propertyInfo() const
{
@@ -838,6 +464,22 @@ QUrl QFxImage::source() const
return d->url;
}
+bool QFxImage::preserveAspect() const
+{
+ Q_D(const QFxImage);
+ return d->preserveAspect;
+}
+
+void QFxImage::setPreserveAspect(bool p)
+{
+ Q_D(QFxImage);
+
+ if (p == d->preserveAspect)
+ return;
+ d->preserveAspect = p;
+ update();
+}
+
void QFxImage::setSource(const QUrl &url)
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
@@ -870,13 +512,6 @@ void QFxImage::setSource(const QUrl &url)
d->progress = 1.0;
setImplicitWidth(0);
setImplicitHeight(0);
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- if (d->tex) {
- d->tex->release();
- d->tex = 0;
- }
-#endif
emit statusChanged(d->status);
emit sourceChanged(d->url);
emit progressChanged(1.0);
@@ -934,13 +569,6 @@ void QFxImage::requestFinished()
if (d->status == Loading)
d->status = Idle;
d->progress = 1.0;
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- if (d->tex) {
- d->tex->release();
- d->tex = 0;
- }
-#endif
emit statusChanged(d->status);
emit sourceChanged(d->url);
emit progressChanged(1.0);
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 3071a9e..7b3445c 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -64,8 +64,8 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem
Q_PROPERTY(QFxScaleGrid *scaleGrid READ scaleGrid)
Q_PROPERTY(bool tile READ isTiled WRITE setTiled)
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false)
- Q_PROPERTY(bool opaque READ isOpaque WRITE setOpaque)
Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
+ Q_PROPERTY(bool preserveAspect READ preserveAspect WRITE setPreserveAspect);
public:
QFxImage(QFxItem *parent=0);
~QFxImage();
@@ -78,9 +78,6 @@ public:
QPixmap pixmap() const;
void setPixmap(const QPixmap &);
- bool isOpaque() const;
- void setOpaque(bool);
-
bool smoothTransform() const;
void setSmoothTransform(bool);
@@ -88,18 +85,14 @@ public:
Status status() const;
qreal progress() const;
+ bool preserveAspect() const;
+ void setPreserveAspect(bool);
+
QUrl source() const;
virtual void setSource(const QUrl &url);
- virtual void dump(int depth);
virtual QString propertyInfo() const;
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
-#elif defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
- uint glSimpleItemData(float *vertices, float *texVertices,
- GLTexture **texture, uint count);
-#endif
Q_SIGNALS:
void sourceChanged(const QUrl &);
@@ -117,7 +110,7 @@ private Q_SLOTS:
private:
Q_DISABLE_COPY(QFxImage)
- Q_DECLARE_PRIVATE(QFxImage)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxImage)
void setGridScaledImage(const QFxGridScaledImage& sci);
};
diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h
index 1785abb..7792dbf 100644
--- a/src/declarative/fx/qfximage_p.h
+++ b/src/declarative/fx/qfximage_p.h
@@ -55,9 +55,7 @@
#include "qfxitem_p.h"
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
+#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
@@ -73,14 +71,12 @@ class QFxImagePrivate : public QFxItemPrivate
public:
QFxImagePrivate()
: scaleGrid(0), tiled(false), smooth(false), opaque(false),
-#if defined(QFX_RENDER_OPENGL)
- texDirty(true), tex(0),
-#endif
- status(QFxImage::Idle), sciReply(0), progress(0.0)
+ preserveAspect(false), status(QFxImage::Idle), sciReply(0),
+ progress(0.0)
{
}
- ~QFxImagePrivate()
+ ~QFxImagePrivate()
{
delete scaleGrid;
}
@@ -89,21 +85,17 @@ public:
QFxScaleGrid *getScaleGrid()
{
- if (!scaleGrid)
+ if (!scaleGrid)
scaleGrid = new QFxScaleGrid;
return scaleGrid;
}
-
+
QFxScaleGrid *scaleGrid;
QPixmap pix;
bool tiled : 1;
bool smooth : 1;
bool opaque : 1;
-#if defined(QFX_RENDER_OPENGL)
- bool texDirty : 1;
- void checkDirty();
- QSimpleCanvasItem::CachedTexture *tex;
-#endif
+ bool preserveAspect : 1;
QFxImage::Status status;
QUrl url;
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index bd4def4..481733b 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -62,7 +62,6 @@
#include "qfxitem_p.h"
#include "qfxitem.h"
#include "qfxevents_p.h"
-#include <qsimplecanvasfilter.h>
#include <qmlcomponent.h>
QT_BEGIN_NAMESPACE
@@ -73,7 +72,6 @@ QT_BEGIN_NAMESPACE
QML_DEFINE_NOCREATE_TYPE(QFxContents)
QML_DEFINE_TYPE(QFxItem,Item)
-QML_DEFINE_NOCREATE_TYPE(QSimpleCanvasFilter)
/*!
\group group_animation
@@ -162,9 +160,9 @@ void QFxContents::calcHeight()
qreal top = FLT_MAX;
qreal bottom = 0;
- const QList<QSimpleCanvasItem *> &children = m_item->QSimpleCanvasItem::children();
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
- const QSimpleCanvasItem *child = children.at(i);
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
qreal y = child->y();
if (y + child->height() > bottom)
bottom = y + child->height();
@@ -185,10 +183,10 @@ void QFxContents::calcWidth()
qreal left = FLT_MAX;
qreal right = 0;
- const QList<QSimpleCanvasItem *> &children = m_item->QSimpleCanvasItem::children();
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
- const QSimpleCanvasItem *child = children.at(i);
- qreal x = int(child->x());
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
+ qreal x = child->x();
if (x + child->width() > right)
right = x + child->width();
if (x < left)
@@ -204,9 +202,9 @@ void QFxContents::setItem(QFxItem *item)
{
m_item = item;
- const QList<QSimpleCanvasItem *> &children = m_item->QSimpleCanvasItem::children();
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
- const QSimpleCanvasItem *child = children.at(i);
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight()));
connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight()));
connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth()));
@@ -260,11 +258,6 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
- \property QFxItem::activeFocus
- This property indicates whether the item has the active focus.
- */
-
-/*!
\fn void QFxItem::activeFocusChanged()
This signal is emitted when this item gains active focus.
@@ -384,7 +377,7 @@ void QFxContents::setItem(QFxItem *item)
This signal is emitted when the item's focus state changes.
- \sa QSimpleCanvasItem::setFocus()
+ \sa QFxItem::setFocus()
*/
/*!
@@ -393,7 +386,7 @@ void QFxContents::setItem(QFxItem *item)
Constructs a QFxItem with the given \a parent.
*/
QFxItem::QFxItem(QFxItem* parent)
- : QSimpleCanvasItem(*(new QFxItemPrivate), parent)
+ : QGraphicsObject(*(new QFxItemPrivate), parent, 0)
{
Q_D(QFxItem);
d->init(parent);
@@ -402,7 +395,7 @@ QFxItem::QFxItem(QFxItem* parent)
/*! \internal
*/
QFxItem::QFxItem(QFxItemPrivate &dd, QFxItem *parent)
- : QSimpleCanvasItem(dd, parent)
+ : QGraphicsObject(dd, parent, 0)
{
Q_D(QFxItem);
d->init(parent);
@@ -535,7 +528,12 @@ void QFxItem::moveToParent(QFxItem *parent)
*/
QFxItem *QFxItem::itemParent() const
{
- return qobject_cast<QFxItem *>(QObject::parent());
+ return qobject_cast<QFxItem *>(QGraphicsItem::parentItem());
+}
+
+QFxItem *QFxItem::parentItem() const
+{
+ return itemParent();
}
/*!
@@ -699,7 +697,7 @@ int QFxItemPrivate::children_count() const
void QFxItemPrivate::children_append(QFxItem *i)
{
Q_Q(QFxItem);
- i->setParent(q);
+ i->setParentItem(q);
}
void QFxItemPrivate::children_insert(int, QFxItem *)
@@ -787,6 +785,16 @@ QFxContents *QFxItem::contents()
return d->_contents;
}
+bool QFxItem::clip() const
+{
+ return flags() & ItemClipsChildrenToShape;
+}
+
+void QFxItem::setClip(bool c)
+{
+ setFlag(ItemClipsChildrenToShape, c);
+}
+
/*!
\internal
\property QFxItem::qmlItem
@@ -1091,52 +1099,6 @@ void QFxItem::geometryChanged(const QRectF &newGeometry,
}
}
-/*!
- \qmlproperty bool Item::flipVertically
- \qmlproperty bool Item::flipHorizontally
-
- When set, the item will be displayed flipped horizontally or vertically
- about its center.
- */
-
-/*!
- \property QFxItem::flipVertically
-
- When set, the item will be displayed flipped horizontally or vertically
- about its center.
- */
-bool QFxItem::flipVertically() const
-{
- return flip() & VerticalFlip;
-}
-
-void QFxItem::setFlipVertically(bool v)
-{
- if (v)
- setFlip((QSimpleCanvasItem::Flip)(flip() | VerticalFlip));
- else
- setFlip((QSimpleCanvasItem::Flip)(flip() & ~VerticalFlip));
-}
-
-/*!
- \property QFxItem::flipHorizontally
-
- When set, the item will be displayed flipped horizontally or vertically
- about its center.
- */
-bool QFxItem::flipHorizontally() const
-{
- return flip() & HorizontalFlip;
-}
-
-void QFxItem::setFlipHorizontally(bool v)
-{
- if (v)
- setFlip((QSimpleCanvasItem::Flip)(flip() | HorizontalFlip));
- else
- setFlip((QSimpleCanvasItem::Flip)(flip() & ~HorizontalFlip));
-}
-
/*! \fn void QFxItem::keyPress(QFxKeyEvent *event)
This signal is emitted by keyPressEvent() for the \a event.
*/
@@ -1503,19 +1465,7 @@ void QFxItem::setRotation(qreal rotation)
if (d->_rotation == rotation)
return;
d->_rotation = rotation;
-#if defined(QFX_RENDER_OPENGL)
- QMatrix4x4 trans;
- QPointF to = transformOriginPoint();
- trans.translate(to.x(), to.y());
- trans.rotate(d->_rotation, 0, 0, 1);
- trans.translate(-to.x(), -to.y());
-#else
- QPointF to = d->transformOrigin();
- QTransform trans = QTransform::fromTranslate(to.x(), to.y());
- trans.rotate(d->_rotation);
- trans.translate(-to.x(), -to.y());
-#endif
- setTransform(trans);
+ setTransform(d->transform);
emit rotationChanged();
}
@@ -1569,18 +1519,6 @@ void QFxItem::setRotation(qreal rotation)
Scaling is from the item's transformOrigin.
*/
-qreal QFxItem::scale() const
-{
- return QSimpleCanvasItem::scale();
-}
-
-void QFxItem::setScale(qreal s)
-{
- if (QSimpleCanvasItem::scale() == s) return;
- QSimpleCanvasItem::setScale(s);
- emit scaleChanged();
- update();
-}
/*!
\qmlproperty real Item::opacity
@@ -1638,19 +1576,12 @@ void QFxItem::setScale(qreal s)
also applied individually to child items.
*/
-qreal QFxItem::opacity() const
-{
- return QSimpleCanvasItem::visible();
-}
-
void QFxItem::setOpacity(qreal v)
{
- if (v == QSimpleCanvasItem::visible())
+ if (v == opacity())
return;
- if (v < 0) v = 0;
- else if (v > 1) v = 1;
- QSimpleCanvasItem::setVisible(v);
+ QGraphicsItem::setOpacity(v);
emit opacityChanged();
}
@@ -1909,16 +1840,6 @@ QList<QFxTransform *> *QFxItem::transform()
}
/*!
- \property QFxItem::focus
- This property holds the item's focus state.
-*/
-
-/*!
- \property QFxItem::focusable
- This property holds whether the item has focus state.
-*/
-
-/*!
Returns true if the item is visible; otherwise returns false.
An item is considered visible if its opacity is not 0.
@@ -1958,14 +1879,6 @@ void QFxItem::setVisible(bool visible)
/*! \internal
*/
-void QFxItem::dump(int depth)
-{
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << metaObject()->className() << "(" << (void *)static_cast<QFxItem*>(this) << ", " << (void *)static_cast<QSimpleCanvasItem*>(this) << "):" << x() << y() << width() << height() << (void *) itemParent();
-}
-
-/*! \internal
-*/
QString QFxItem::propertyInfo() const
{
return QString();
@@ -2045,27 +1958,13 @@ void QFxItem::componentComplete()
updateTransform();
}
-/*! \internal
-*/
-void QFxItem::parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *)
-{
- emit parentChanged();
-}
-
-/*! \internal
-*/
-void QFxItem::reparentItems()
-{
- qFatal("EEK");
-}
-
/*!
\internal
*/
void QFxItem::updateTransform()
{
Q_D(QFxItem);
- QSimpleCanvas::Matrix trans;
+ QTransform trans;
for (int ii = d->_transform.count() - 1; ii >= 0; --ii) {
QFxTransform *a = d->_transform.at(ii);
if (!a->isIdentity())
@@ -2079,7 +1978,7 @@ void QFxItem::updateTransform()
/*!
\internal
*/
-void QFxItem::transformChanged(const QSimpleCanvas::Matrix &)
+void QFxItem::transformChanged(const QTransform &)
{
}
@@ -2115,4 +2014,551 @@ QFxItemPrivate::AnchorLines::AnchorLines(QFxItem *q)
baseline.anchorLine = QFxAnchorLine::Baseline;
}
+QPointF QFxItemPrivate::transformOrigin() const
+{
+ Q_Q(const QFxItem);
+
+ QRectF br = q->boundingRect();
+
+ switch(origin) {
+ default:
+ case QFxItem::TopLeft:
+ return QPointF(0, 0);
+ case QFxItem::TopCenter:
+ return QPointF(br.width() / 2., 0);
+ case QFxItem::TopRight:
+ return QPointF(br.width(), 0);
+ case QFxItem::MiddleLeft:
+ return QPointF(0, br.height() / 2.);
+ case QFxItem::Center:
+ return QPointF(br.width() / 2., br.height() / 2.);
+ case QFxItem::MiddleRight:
+ return QPointF(br.width(), br.height() / 2.);
+ case QFxItem::BottomLeft:
+ return QPointF(0, br.height());
+ case QFxItem::BottomCenter:
+ return QPointF(br.width() / 2., br.height());
+ case QFxItem::BottomRight:
+ return QPointF(br.width(), br.height());
+ }
+}
+
+QFxItem::Options QFxItem::options() const
+{
+ Q_D(const QFxItem);
+ return (QFxItem::Options)d->options;
+}
+
+bool QFxItem::mouseFilter(QGraphicsSceneMouseEvent *)
+{
+ return false;
+}
+
+bool QFxItem::sceneEvent(QEvent *event)
+{
+ bool rv = QGraphicsItem::sceneEvent(event);
+ if (event->type() == QEvent::UngrabMouse)
+ mouseUngrabEvent();
+ return rv;
+}
+
+QVariant QFxItem::itemChange(GraphicsItemChange change,
+ const QVariant &value)
+{
+ Q_D(QFxItem);
+ if (change == ItemSceneHasChanged) {
+ if (options() & QFxItem::MouseFilter)
+ d->gvRemoveMouseFilter();
+
+ d->canvas = qvariant_cast<QGraphicsScene *>(value);
+
+ if (options() & QFxItem::MouseFilter)
+ d->gvAddMouseFilter();
+
+ if (d->canvas && d->isFocusItemForArea)
+ d->canvas->setFocusItem(this);
+ } else if (change == ItemChildAddedChange ||
+ change == ItemChildRemovedChange) {
+ childrenChanged();
+ }
+
+ return QGraphicsItem::itemChange(change, value);
+}
+
+
+void QFxItem::mouseUngrabEvent()
+{
+}
+
+void QFxItem::childrenChanged()
+{
+}
+
+void QFxItem::setPaintMargin(qreal margin)
+{
+ Q_D(QFxItem);
+ if (margin < d->paintmargin)
+ update(); // schedule repaint of old boundingRect
+ d->paintmargin = margin;
+}
+
+QRectF QFxItem::boundingRect() const
+{
+ Q_D(const QFxItem);
+ return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2);
+}
+
+void QFxItem::paintContents(QPainter &)
+{
+}
+
+void QFxItem::parentChanged(QFxItem *, QFxItem *)
+{
+ emit parentChanged();
+}
+
+/*!
+ Returns the item's (0, 0) point relative to its parent.
+ */
+QPointF QFxItem::pos() const
+{
+ return QPointF(x(),y());
+}
+
+/*!
+ Returns the item's (0, 0) point mapped to scene coordinates.
+ */
+QPointF QFxItem::scenePos() const
+{
+ return mapToScene(QPointF(0, 0));
+}
+
+/*!
+ \enum QFxItem::TransformOrigin
+
+ Controls the point about which simple transforms like scale apply.
+
+ \value TopLeft The top-left corner of the item.
+ \value TopCenter The center point of the top of the item.
+ \value TopRight The top-right corner of the item.
+ \value MiddleLeft The left most point of the vertical middle.
+ \value Center The center of the item.
+ \value MiddleRight The right most point of the vertical middle.
+ \value BottomLeft The bottom-left corner of the item.
+ \value BottomCenter The center point of the bottom of the item.
+ \value BottomRight The bottom-right corner of the item.
+*/
+
+/*!
+ Returns the current transform origin.
+*/
+QFxItem::TransformOrigin QFxItem::transformOrigin() const
+{
+ Q_D(const QFxItem);
+ return d->origin;
+}
+
+/*!
+ Set the transform \a origin.
+*/
+void QFxItem::setTransformOrigin(TransformOrigin origin)
+{
+ Q_D(QFxItem);
+ if (origin != d->origin) {
+ d->origin = origin;
+ update();
+ }
+}
+
+QPointF QFxItem::transformOriginPoint() const
+{
+ Q_D(const QFxItem);
+ return d->transformOrigin();
+}
+
+qreal QFxItem::z() const
+{
+ return zValue();
+}
+
+void QFxItem::setX(qreal x)
+{
+ if (x == this->x())
+ return;
+
+ qreal oldX = this->x();
+
+ QGraphicsItem::setPos(x, y());
+
+ geometryChanged(QRectF(this->x(), y(), width(), height()),
+ QRectF(oldX, y(), width(), height()));
+}
+
+void QFxItem::setY(qreal y)
+{
+ if (y == this->y())
+ return;
+
+ qreal oldY = this->y();
+
+ QGraphicsItem::setPos(x(), y);
+
+ geometryChanged(QRectF(x(), this->y(), width(), height()),
+ QRectF(x(), oldY, width(), height()));
+}
+
+void QFxItem::setZ(qreal z)
+{
+ if (z == this->z())
+ return;
+
+ if (z < 0)
+ setFlag(QGraphicsItem::ItemStacksBehindParent, true);
+ else
+ setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+
+ setZValue(z);
+}
+
+qreal QFxItem::width() const
+{
+ Q_D(const QFxItem);
+ return d->width;
+}
+
+void QFxItem::setWidth(qreal w)
+{
+ Q_D(QFxItem);
+ d->widthValid = true;
+ if (d->width == w)
+ return;
+
+ qreal oldWidth = d->width;
+
+ d->width = w;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, height()));
+}
+
+void QFxItem::setImplicitWidth(qreal w)
+{
+ Q_D(QFxItem);
+ if (d->width == w || widthValid())
+ return;
+
+ qreal oldWidth = d->width;
+
+ d->width = w;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, height()));
+}
+
+bool QFxItem::widthValid() const
+{
+ Q_D(const QFxItem);
+ return d->widthValid;
+}
+
+qreal QFxItem::height() const
+{
+ Q_D(const QFxItem);
+ return d->height;
+}
+
+void QFxItem::setHeight(qreal h)
+{
+ Q_D(QFxItem);
+ d->heightValid = true;
+ if (d->height == h)
+ return;
+
+ qreal oldHeight = d->height;
+
+ d->height = h;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), width(), oldHeight));
+}
+
+void QFxItem::setImplicitHeight(qreal h)
+{
+ Q_D(QFxItem);
+ if (d->height == h || heightValid())
+ return;
+
+ qreal oldHeight = d->height;
+
+ d->height = h;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), width(), oldHeight));
+}
+
+bool QFxItem::heightValid() const
+{
+ Q_D(const QFxItem);
+ return d->heightValid;
+}
+
+void QFxItem::setPos(const QPointF &point)
+{
+ qreal oldX = x();
+ qreal oldY = y();
+
+ QGraphicsItem::setPos(point);
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(oldX, oldY, width(), height()));
+}
+
+qreal QFxItem::scale() const
+{
+ Q_D(const QFxItem);
+ return d->scale;
+}
+
+void QFxItem::setScale(qreal s)
+{
+ Q_D(QFxItem);
+ if (d->scale == s)
+ return;
+
+ d->scale = s;
+ setTransform(d->transform);
+
+ emit scaleChanged();
+}
+
+QRect QFxItem::itemBoundingRect()
+{
+ return boundingRect().toAlignedRect();
+}
+
+QPointF QFxItem::mapFromScene(const QPointF &p) const
+{
+ return QGraphicsItem::mapFromScene(p);
+}
+
+QRectF QFxItem::mapFromScene(const QRectF &r) const
+{
+ return QGraphicsItem::mapFromScene(r).boundingRect();
+}
+
+QPointF QFxItem::mapToScene(const QPointF &p) const
+{
+ return QGraphicsItem::mapToScene(p);
+}
+
+QRectF QFxItem::mapToScene(const QRectF &r) const
+{
+ return QGraphicsItem::mapToScene(r).boundingRect();
+}
+
+QTransform QFxItem::transform() const
+{
+ Q_D(const QFxItem);
+ return d->transform;
+}
+
+//### optimize (perhaps cache scale and rot transforms, and have dirty flags)
+//### we rely on there not being an "if (d->transform == m) return;" check
+void QFxItem::setTransform(const QTransform &m)
+{
+ Q_D(QFxItem);
+ d->transform = m;
+ QTransform scaleTransform, rotTransform;
+ if (d->scale != 1) {
+ QPointF to = transformOriginPoint();
+ if (to.x() != 0. || to.y() != 0.)
+ scaleTransform.translate(to.x(), to.y());
+ scaleTransform.scale(d->scale, d->scale);
+ if (to.x() != 0. || to.y() != 0.)
+ scaleTransform.translate(-to.x(), -to.y());
+ }
+ if (d->_rotation != 0) {
+ QPointF to = d->transformOrigin();
+ if (to.x() != 0. || to.y() != 0.)
+ rotTransform.translate(to.x(), to.y());
+ rotTransform.rotate(d->_rotation);
+ if (to.x() != 0. || to.y() != 0.)
+ rotTransform.translate(-to.x(), -to.y());
+ }
+ QGraphicsItem::setTransform(scaleTransform * rotTransform * d->transform);
+}
+
+QFxItem *QFxItem::mouseGrabberItem() const
+{
+ QGraphicsScene *s = scene();
+ if (s) {
+ QGraphicsItem *item = s->mouseGrabberItem();
+ return static_cast<QFxItem*>(item); // ###
+ }
+ return 0;
+}
+
+/*!
+ \qmlproperty bool Item::focus
+ This property indicates whether the item has has an active focus request. Set this
+ property to true to request active focus.
+*/
+
+bool QFxItem::hasFocus() const
+{
+ Q_D(const QFxItem);
+ return d->isFocusItemForArea;
+}
+
+void QFxItem::setFocus(bool focus)
+{
+ Q_D(QFxItem);
+ QGraphicsScene *s = scene();
+ if (s) {
+ if (d->hasActiveFocus)
+ s->setFocusItem(focus ? this : 0);
+ else if (focus)
+ s->setFocusItem(this);
+ else {
+ d->isFocusItemForArea = false;
+ focusChanged(false);
+ }
+
+ } else {
+ d->isFocusItemForArea = focus;
+ focusChanged(focus);
+ }
+}
+
+/*!
+ \qmlproperty bool Item::activeFocus
+ This property indicates whether the item has the active focus.
+*/
+
+bool QFxItem::hasActiveFocus() const
+{
+ Q_D(const QFxItem);
+ return d->hasActiveFocus;
+}
+
+bool QFxItem::activeFocusPanel() const
+{
+ return false;
+}
+
+void QFxItem::setActiveFocusPanel(bool b)
+{
+ Q_UNUSED(b)
+}
+
+bool QFxItem::sceneEventFilter(QGraphicsItem *w, QEvent *e)
+{
+ switch(e->type()) {
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ if (mouseFilter(static_cast<QGraphicsSceneMouseEvent *>(e)))
+ return true;
+ break;
+ default:
+ break;
+ }
+
+ return QGraphicsItem::sceneEventFilter(w, e);
+}
+
+void QFxItem::setOptions(Options options, bool set)
+{
+ Q_D(QFxItem);
+ Options old = (Options)d->options;
+
+ if (options & IsFocusRealm) {
+ if (!set) {
+ qWarning("QFxItem::setOptions: Cannot unset IsFocusRealm");
+ return;
+ }
+ }
+
+ if (set)
+ d->options |= options;
+ else
+ d->options &= ~options;
+
+ if ((d->options & IsFocusPanel) && (d->options & IsFocusRealm)) {
+ qWarning("QFxItem::setOptions: Cannot set both IsFocusPanel and IsFocusRealm. IsFocusRealm will be unset.");
+ d->options &= ~IsFocusRealm;
+ }
+
+ setFlag(QGraphicsItem::ItemHasNoContents, !(d->options & HasContents));
+ setFiltersChildEvents(d->options & ChildMouseFilter);
+ setFlag(QGraphicsItem::ItemAcceptsInputMethod, (d->options & AcceptsInputMethods));
+ setAcceptHoverEvents(d->options & HoverEvents);
+ d->isFocusRealm = static_cast<bool>(d->options & IsFocusRealm);
+
+ if ((old & MouseFilter) != (d->options & MouseFilter)) {
+ if (d->options & MouseFilter)
+ d->gvAddMouseFilter();
+ else
+ d->gvRemoveMouseFilter();
+ }
+}
+
+/*!
+ \fn void QFxItem::setParent(QFxItem *parent)
+
+ Sets the parent of the item to \a parent.
+ */
+void QFxItem::setParent(QFxItem *p)
+{
+ if (p == parent() || !p) return;
+
+ QObject::setParent(p);
+
+ QFxItem *oldParent = itemParent();
+ setParentItem(p);
+ parentChanged(p, oldParent);
+}
+
+void QFxItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ paintContents(*p);
+}
+
+void QFxItemPrivate::gvRemoveMouseFilter()
+{
+ Q_Q(QFxItem);
+ if (q->scene())
+ q->removeSceneEventFilter(q);
+}
+
+void QFxItemPrivate::gvAddMouseFilter()
+{
+ Q_Q(QFxItem);
+ if (q->scene())
+ q->installSceneEventFilter(q);
+}
+
+QPixmap QFxItem::string(const QString &str, const QColor &c, const QFont &f)
+{
+ QFontMetrics fm(f);
+ QSize size(fm.width(str), fm.height()*(str.count(QLatin1Char('\n'))+1)); //fm.boundingRect(str).size();
+ QPixmap img(size);
+ img.fill(Qt::transparent);
+ QPainter p(&img);
+ p.setPen(c);
+ p.setFont(f);
+ p.drawText(img.rect(), Qt::AlignVCenter, str);
+ return img;
+}
+
+QVariant QFxItem::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ return QGraphicsItem::inputMethodQuery(query);
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 5fb4eff..67b60c1 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -49,9 +49,10 @@
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qfxscalegrid.h>
-#include <QtDeclarative/qsimplecanvasitem.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlstate.h>
+#include <QtGui/qgraphicsitem.h>
+#include <QtGui/qfont.h>
QT_BEGIN_HEADER
@@ -93,58 +94,75 @@ class QmlTransition;
class QFxTransform;
class QFxKeyEvent;
class QFxItemPrivate;
-class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserStatus
+class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QmlParserStatus)
- Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false)
+ Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false FINAL)
Q_PROPERTY(QFxItem * moveToParent READ itemParent WRITE moveToParent NOTIFY parentChanged DESIGNABLE false)
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 CONSTANT)
+ Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
Q_PROPERTY(QmlList<QObject *> *data READ data DESIGNABLE false)
- Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT)
+ Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT FINAL)
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 xChanged)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
- Q_PROPERTY(qreal z READ z WRITE setZ)
- 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 x READ x WRITE setX NOTIFY xChanged FINAL)
+ Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL)
+ Q_PROPERTY(qreal z READ z WRITE setZ FINAL)
+ Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL)
+ Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL)
+ Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine right READ right CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine top READ top CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine bottom READ bottom CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine baseline READ baseline CONSTANT FINAL)
Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
- Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically)
- Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally)
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)
- Q_PROPERTY(QSimpleCanvasFilter *filter READ filter WRITE setFilter)
Q_PROPERTY(bool clip READ clip WRITE setClip)
- Q_PROPERTY(bool focusable READ isFocusable WRITE setFocusable)
- Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged)
- Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged)
+ Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
+ Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL)
Q_PROPERTY(QList<QFxTransform *>* transform READ transform)
- Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
+ Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin)
+ Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
typedef QHash<QString, QFxItem *> QmlChildren;
public:
+ enum Option { NoOption = 0x00000000,
+ MouseFilter = 0x00000001,
+ ChildMouseFilter = 0x00000002,
+ HoverEvents = 0x00000004,
+ MouseEvents = 0x00000008,
+ HasContents = 0x00000010,
+ SimpleItem = 0x00000020,
+ IsFocusPanel = 0x00000040,
+ IsFocusRealm = 0x00000080,
+ AcceptsInputMethods = 0x00000100 };
+ Q_DECLARE_FLAGS(Options, Option)
+
+ enum TransformOrigin {
+ TopLeft, TopCenter, TopRight,
+ MiddleLeft, Center, MiddleRight,
+ BottomLeft, BottomCenter, BottomRight
+ };
+
QFxItem(QFxItem *parent = 0);
virtual ~QFxItem();
QFxItem *itemParent() const;
+ QFxItem *parentItem() const;
void setItemParent(QFxItem *parent);
void moveToParent(QFxItem *parent);
@@ -160,6 +178,9 @@ public:
QFxContents *contents();
+ bool clip() const;
+ void setClip(bool);
+
QmlList<QmlState *>* states();
QmlState *findState(const QString &name) const;
@@ -172,11 +193,6 @@ public:
QUrl qml() const;
void setQml(const QUrl &);
- bool flipVertically() const;
- void setFlipVertically(bool);
- bool flipHorizontally() const;
- void setFlipHorizontally(bool);
-
qreal baselineOffset() const;
void setBaselineOffset(qreal);
@@ -186,15 +202,13 @@ public:
qreal scale() const;
void setScale(qreal);
- qreal opacity() const;
- virtual void setOpacity(qreal);
+ void setOpacity(qreal);
QList<QFxTransform *> *transform();
bool isVisible() const;
void setVisible(bool);
- virtual void dump(int depth = 0);
virtual QString propertyInfo() const;
bool isClassComplete() const;
@@ -207,6 +221,60 @@ public:
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
+ Options options() const;
+ void setOptions(Options, bool set = true);
+
+ qreal z() const;
+ QPointF pos() const;
+ void setX(qreal);
+ void setY(qreal);
+ virtual void setZ(qreal);
+ void setPos(const QPointF &);
+
+ qreal width() const;
+ void setWidth(qreal);
+ void setImplicitWidth(qreal);
+ bool widthValid() const;
+ qreal height() const;
+ void setHeight(qreal);
+ void setImplicitHeight(qreal);
+ bool heightValid() const;
+
+ QPointF scenePos() const;
+
+ TransformOrigin transformOrigin() const;
+ void setTransformOrigin(TransformOrigin);
+ QPointF transformOriginPoint() const;
+
+ void setParent(QFxItem *);
+
+ QRect itemBoundingRect();
+
+ void setPaintMargin(qreal margin);
+ QRectF boundingRect() const;
+ virtual void paintContents(QPainter &);
+
+ QPointF mapFromScene(const QPointF &) const;
+ QRectF mapFromScene(const QRectF &) const;
+ QPointF mapToScene(const QPointF &) const;
+ QRectF mapToScene(const QRectF &) const;
+
+ QTransform transform() const;
+ void setTransform(const QTransform &);
+
+ QFxItem *mouseGrabberItem() const;
+
+ virtual bool hasFocus() const;
+ void setFocus(bool);
+ bool activeFocusPanel() const;
+ void setActiveFocusPanel(bool);
+
+ bool hasActiveFocus() const;
+
+ static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont());
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy
+
public Q_SLOTS:
void newChild(const QString &url);
@@ -230,16 +298,23 @@ Q_SIGNALS:
void newChildCreated(const QString &url, QScriptValue);
protected:
- virtual void transformChanged(const QSimpleCanvas::Matrix &);
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ virtual void childrenChanged();
+ virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
+ virtual bool sceneEvent(QEvent *);
+ virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
+ virtual bool mouseFilter(QGraphicsSceneMouseEvent *);
+ virtual void mouseUngrabEvent();
+
+ virtual void transformChanged(const QTransform &);
virtual void classBegin();
virtual void classComplete();
virtual void componentComplete();
- virtual void parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *);
- virtual void reparentItems();
+ virtual void parentChanged(QFxItem *, QFxItem *);
virtual void focusChanged(bool);
virtual void activeFocusChanged(bool);
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *event);
+ virtual void keyPressEvent(QKeyEvent *event);
+ virtual void keyReleaseEvent(QKeyEvent *event);
virtual void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
@@ -263,14 +338,23 @@ private:
friend class QmlStatePrivate;
friend class QFxAnchors;
Q_DISABLE_COPY(QFxItem)
- Q_DECLARE_PRIVATE(QFxItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxItem)
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFxItem::Options)
+
+template<typename T>
+T qobject_cast(QGraphicsItem *item)
+{
+ if (!item) return 0;
+ QObject *o = item->toGraphicsObject();
+ return qobject_cast<T>(o);
+}
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QFxContents)
QML_DECLARE_TYPE(QFxItem)
-QML_DECLARE_TYPE(QSimpleCanvasFilter)
QT_END_HEADER
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index 32e8aef..eddeb9b 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -54,17 +54,18 @@
//
#include <QtDeclarative/qfxitem.h>
-#include <private/qsimplecanvasitem_p.h>
#include <private/qmlnullablevalue_p.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlcontext.h>
#include <QtCore/qlist.h>
+#include <private/qgraphicsitem_p.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
class QNetworkReply;
-class QFxItemPrivate : public QSimpleCanvasItemPrivate
+class QFxItemPrivate : public QGraphicsItemPrivate
{
Q_DECLARE_PUBLIC(QFxItem)
@@ -75,8 +76,11 @@ public:
: _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0),
_baselineOffset(0), _rotation(0.),
_classComplete(true), _componentComplete(true), _keepMouse(false),
- visible(true), _anchorLines(0), visibleOp(1), reparentedChildren(0),
- _stateGroup(0)
+ visible(true), _anchorLines(0), visibleOp(1),
+ _stateGroup(0), canvas(0), origin(QFxItem::TopLeft),
+ options(QFxItem::NoOption),
+ widthValid(false), heightValid(false), width(0), height(0),
+ paintmargin(0), scale(1)
{}
~QFxItemPrivate()
{ delete _anchors; }
@@ -89,6 +93,9 @@ public:
q->setItemParent(parent);
_baselineOffset.invalidate();
q->setAcceptedMouseButtons(Qt::NoButton);
+ q->setFlag(QGraphicsItem::ItemHasNoContents, true);
+ q->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ mouseSetsFocus = false;
}
QString _id;
@@ -168,10 +175,39 @@ public:
float visibleOp;
- int reparentedChildren;
-
QmlStateGroup *states();
QmlStateGroup *_stateGroup;
+
+
+ QGraphicsScene *canvas;
+
+ QFxItem::TransformOrigin origin:4;
+ int options:10;
+ bool widthValid:1;
+ bool heightValid:1;
+
+ qreal width;
+ qreal height;
+ qreal paintmargin;
+ qreal scale;
+
+ QPointF transformOrigin() const;
+ QTransform transform;
+
+ void gvRemoveMouseFilter();
+ void gvAddMouseFilter();
+
+ virtual void setActiveFocus(bool b) {
+ Q_Q(QFxItem);
+ QGraphicsItemPrivate::setActiveFocus(b);
+ q->activeFocusChanged(b);
+ }
+
+ virtual void setFocusItemForArea(bool b) {
+ Q_Q(QFxItem);
+ QGraphicsItemPrivate::setFocusItemForArea(b);
+ q->focusChanged(b);
+ }
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp
index 4aae74f..2c662a6 100644
--- a/src/declarative/fx/qfxkeyactions.cpp
+++ b/src/declarative/fx/qfxkeyactions.cpp
@@ -41,7 +41,7 @@
#include "qfxkeyactions.h"
#include <qmlexpression.h>
-
+#include <QKeyEvent>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxKeyActions,KeyActions)
diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp
index e80f2c7..e4b4269 100644
--- a/src/declarative/fx/qfxkeyproxy.cpp
+++ b/src/declarative/fx/qfxkeyproxy.cpp
@@ -40,34 +40,63 @@
****************************************************************************/
#include "qfxkeyproxy.h"
-
+#include <QGraphicsScene>
+#include <QKeyEvent>
QT_BEGIN_NAMESPACE
+
QML_DEFINE_TYPE(QFxKeyProxy,KeyProxy)
/*!
\qmlclass KeyProxy
- \brief The KeyProxy item proxies key presses to a number of other items.
+ \brief The KeyProxy item proxies key events to a number of other items.
\inherits Item
+ KeyProxy provides a way to forward key presses, key releases, and keyboard input
+ coming from input methods to other items. This can be useful when you want
+ one item to handle some keys (e.g. the up and down arrow keys), and another item to
+ handle other keys (e.g. the left and right arrow keys).
+
+ To receive key events, the KeyProxy item must be in the current focus chain,
+ just like any other item.
+
+ KeyProxy is an invisible item: it is never painted.
+
+ A simple KeyProxy that forward key events to two lists:
+ \qml
+ ListView { id: List1 ... }
+ ListView { id: List2 ... }
+ KeyProxy {
+ focus: true
+ targets: [List1, List2]
+ }
+ \endqml
*/
/*!
\internal
\class QFxKeyProxy
- \brief The QFxKeyProxy class proxies key presses to a number of other items.
- \ingroup group_utility
+ \brief The QFxKeyProxy class proxies key events to a number of other items.
*/
class QFxKeyProxyPrivate
{
public:
+ QFxKeyProxyPrivate() : inPress(false), inRelease(false), inIM(false), imeItem(0) {}
QList<QFxItem *> targets;
+
+ //loop detection
+ bool inPress:1;
+ bool inRelease:1;
+ bool inIM:1;
+
+ QFxItem *imeItem;
};
QFxKeyProxy::QFxKeyProxy(QFxItem *parent)
: QFxItem(parent), d(new QFxKeyProxyPrivate)
{
+ setOptions(AcceptsInputMethods);
}
QFxKeyProxy::~QFxKeyProxy()
@@ -78,12 +107,10 @@ QFxKeyProxy::~QFxKeyProxy()
/*!
\qmlproperty list<Item> KeyProxy::targets
- The proxy targets.
-*/
+ An ordered list of the items that will be forwarded key events.
-/*!
- \property QFxKeyProxy::targets
- \brief the proxy targets.
+ The events will be forwarded to the targets in turn until one of them
+ accepts the event.
*/
QList<QFxItem *> *QFxKeyProxy::targets() const
@@ -93,24 +120,77 @@ QList<QFxItem *> *QFxKeyProxy::targets() const
void QFxKeyProxy::keyPressEvent(QKeyEvent *e)
{
- for (int ii = 0; ii < d->targets.count(); ++ii) {
- QSimpleCanvasItem *i = canvas()->focusItem(d->targets.at(ii));
- if (i)
- i->keyPressEvent(e);
- if (e->isAccepted())
- return;
+ if (!scene())
+ return;
+ if (!d->inPress) {
+ d->inPress = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii)));
+ if (i) {
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->inPress = false;
+ return;
+ }
+ }
+ }
+ d->inPress = false;
}
}
void QFxKeyProxy::keyReleaseEvent(QKeyEvent *e)
{
+ if (!scene())
+ return;
+ if (!d->inRelease) {
+ d->inRelease = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii)));
+ if (i) {
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->inRelease = false;
+ return;
+ }
+ }
+ }
+ d->inRelease = false;
+ }
+}
+
+void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e)
+{
+ if (!scene())
+ return;
+ if (!d->inIM) {
+ d->inIM = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii)));
+ if (i && (i->options() & AcceptsInputMethods)) {
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->imeItem = i;
+ d->inIM = false;
+ return;
+ }
+ }
+ }
+ d->inIM = false;
+ }
+}
+
+QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const
+{
for (int ii = 0; ii < d->targets.count(); ++ii) {
- QSimpleCanvasItem *i = canvas()->focusItem(d->targets.at(ii));
- if (i)
- i->keyReleaseEvent(e);
- if (e->isAccepted())
- return;
+ QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii)));
+ if (i && (i->options() & AcceptsInputMethods) && i == d->imeItem) { //### how robust is i == d->imeItem check?
+ QVariant v = i->inputMethodQuery(query);
+ if (v.type() == QVariant::RectF)
+ v = mapRectFromItem(i, v.toRectF()); //### cost?
+ return v;
+ }
}
+ return QFxItem::inputMethodQuery(query);
}
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h
index d075295..e77ffac 100644
--- a/src/declarative/fx/qfxkeyproxy.h
+++ b/src/declarative/fx/qfxkeyproxy.h
@@ -64,6 +64,8 @@ public:
protected:
virtual void keyPressEvent(QKeyEvent *);
virtual void keyReleaseEvent(QKeyEvent *);
+ virtual void inputMethodEvent(QInputMethodEvent *);
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
private:
Q_DISABLE_COPY(QFxKeyProxy)
diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp
index 20e7c7c..f71b35a 100644
--- a/src/declarative/fx/qfxlayouts.cpp
+++ b/src/declarative/fx/qfxlayouts.cpp
@@ -311,8 +311,9 @@ void QFxBaseLayout::preLayout()
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
QSet<QFxItem *> allItems;
- for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
- QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
+ QList<QGraphicsItem *> children = childItems();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(ii));
if (!child)
continue;
if (!d->_items.contains(child)){
@@ -618,8 +619,10 @@ void QFxVerticalLayout::doLayout()
applyRemove(changes, item);
}
}
- for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
- QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
+
+ QList<QGraphicsItem *> children = childItems();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(ii));
if (!child || !child->isVisible())
continue;
@@ -784,8 +787,9 @@ void QFxHorizontalLayout::doLayout()
applyRemove(changes, item);
}
}
- for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
- QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
+ QList<QGraphicsItem *> children = childItems();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(ii));
if (!child || !child->isVisible())
continue;
@@ -1013,15 +1017,17 @@ void QFxGridLayout::doLayout()
QList<int> maxColWidth;
QList<int> maxRowHeight;
int childIndex =0;
+ QList<QGraphicsItem *> children = childItems();
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
if (j==0)
maxRowHeight << 0;
if (i==0)
maxColWidth << 0;
- if (childIndex == this->QSimpleCanvasItem::children().count())
+
+ if (childIndex == children.count())
continue;
- QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(childIndex++));
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(childIndex++));
if (!child || !child->isVisible())
continue;
if (child->width() > maxColWidth[j])
@@ -1041,7 +1047,7 @@ void QFxGridLayout::doLayout()
applyRemove(changes, item);
}
}
- foreach(QSimpleCanvasItem* schild, this->QSimpleCanvasItem::children()){
+ foreach(QGraphicsItem* schild, children){
QFxItem *child = qobject_cast<QFxItem *>(schild);
if (!child || !child->isVisible())
continue;
diff --git a/src/declarative/fx/qfxlayouts.h b/src/declarative/fx/qfxlayouts.h
index 112fe85..5767bc5 100644
--- a/src/declarative/fx/qfxlayouts.h
+++ b/src/declarative/fx/qfxlayouts.h
@@ -115,7 +115,7 @@ private:
void applyTransition(const QList<QPair<QString, QVariant> >& changes, QFxItem* target,
QmlTransition* transition);
Q_DISABLE_COPY(QFxBaseLayout)
- Q_DECLARE_PRIVATE(QFxBaseLayout)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxBaseLayout)
};
class Q_DECLARATIVE_EXPORT QFxVerticalLayout : public QFxBaseLayout
diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp
new file mode 100644
index 0000000..da79979
--- /dev/null
+++ b/src/declarative/fx/qfxlineedit.cpp
@@ -0,0 +1,518 @@
+/****************************************************************************
+**
+** 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 "qfxlineedit.h"
+#include "qfxlineedit_p.h"
+#include <QValidator>
+#include <QApplication>
+#include <QFontMetrics>
+#include <QPainter>
+
+QT_BEGIN_NAMESPACE
+QML_DEFINE_TYPE(QFxLineEdit,LineEdit);
+QML_DEFINE_TYPE(QIntValidator,QIntValidator);
+
+QFxLineEdit::QFxLineEdit(QFxItem* parent)
+ : QFxPaintedItem(*(new QFxLineEditPrivate), parent)
+{
+ Q_D(QFxLineEdit);
+ d->init();
+}
+
+/*
+ \internal
+*/
+QFxLineEdit::QFxLineEdit(QFxLineEditPrivate &dd, QFxItem* parent)
+ : QFxPaintedItem(dd, parent)
+{
+ Q_D(QFxLineEdit);
+ d->init();
+}
+
+QFxLineEdit::~QFxLineEdit()
+{
+}
+
+QString QFxLineEdit::text() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->text();
+}
+
+void QFxLineEdit::setText(const QString &s)
+{
+ Q_D(QFxLineEdit);
+ if(s == text())
+ return;
+ d->control->setText(s);
+ //emit textChanged();
+}
+
+QmlFont *QFxLineEdit::font()
+{
+ Q_D(QFxLineEdit);
+ return d->font;
+}
+
+QColor QFxLineEdit::color() const
+{
+ Q_D(const QFxLineEdit);
+ return d->color;
+}
+
+void QFxLineEdit::setColor(const QColor &c)
+{
+ Q_D(QFxLineEdit);
+ d->color = c;
+}
+
+/*
+QFxText::TextStyle QFxLineEdit::style() const
+{
+ Q_D(const QFxLineEdit);
+ return d->style;
+}
+
+void QFxLineEdit::setStyle(QFxText::TextStyle style)
+{
+ Q_D(QFxLineEdit);
+ d->style = style;
+}
+
+QColor QFxLineEdit::styleColor() const
+{
+ Q_D(const QFxLineEdit);
+ return d->styleColor;
+}
+
+void QFxLineEdit::setStyleColor(const QColor &c)
+{
+ Q_D(QFxLineEdit);
+ d->styleColor = c;
+}
+*/
+
+QFxText::HAlignment QFxLineEdit::hAlign() const
+{
+ Q_D(const QFxLineEdit);
+ return d->hAlign;
+}
+
+void QFxLineEdit::setHAlign(QFxText::HAlignment align)
+{
+ Q_D(QFxLineEdit);
+ d->hAlign = align;
+}
+
+QFxText::VAlignment QFxLineEdit::vAlign() const
+{
+ Q_D(const QFxLineEdit);
+ return d->vAlign;
+}
+
+void QFxLineEdit::setVAlign(QFxText::VAlignment align)
+{
+ Q_D(QFxLineEdit);
+ d->vAlign = align;
+}
+
+//### Should this also toggle cursor visibility?
+bool QFxLineEdit::isReadOnly() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->isReadOnly();
+}
+
+void QFxLineEdit::setReadOnly(bool ro)
+{
+ Q_D(QFxLineEdit);
+ d->control->setReadOnly(ro);
+}
+
+int QFxLineEdit::maxLength() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->maxLength();
+}
+
+void QFxLineEdit::setMaxLength(int ml)
+{
+ Q_D(QFxLineEdit);
+ d->control->setMaxLength(ml);
+}
+
+int QFxLineEdit::cursorPosition() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->cursor();
+}
+void QFxLineEdit::setCursorPosition(int cp)
+{
+ Q_D(QFxLineEdit);
+ d->control->moveCursor(cp);
+}
+
+int QFxLineEdit::selectionLength() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->selectionEnd() - d->control->selectionStart();
+}
+
+void QFxLineEdit::setSelectionLength(int len)
+{
+ Q_D(QFxLineEdit);
+ d->control->setSelection(d->control->cursor(), len);
+}
+
+QString QFxLineEdit::selectedText() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->selectedText();
+}
+
+QObject* QFxLineEdit::validator() const
+{
+ Q_D(const QFxLineEdit);
+ //###const cast isn't good, but needed for property system?
+ //###same should be said about using QObject* as the property type
+ return const_cast<QValidator*>(d->control->validator());
+}
+
+void QFxLineEdit::setValidator(QObject* v)
+{
+ Q_D(QFxLineEdit);
+ QValidator* valid = qobject_cast<QValidator*>(v);
+ if(!valid)
+ return;
+ d->control->setValidator(valid);
+ if(!d->control->hasAcceptableInput()){
+ d->oldValidity = false;
+ emit acceptableInputChanged();
+ }
+}
+
+QString QFxLineEdit::inputMask() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->inputMask();
+}
+
+void QFxLineEdit::setInputMask(const QString &im)
+{
+ Q_D(QFxLineEdit);
+ d->control->setInputMask(im);
+}
+
+bool QFxLineEdit::hasAcceptableInput() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->hasAcceptableInput();
+}
+
+uint QFxLineEdit::echoMode() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->echoMode();
+}
+
+void QFxLineEdit::setEchoMode(uint echo)
+{
+ Q_D(QFxLineEdit);
+ d->control->setEchoMode(echo);
+}
+
+QmlComponent* QFxLineEdit::cursorDelegate() const
+{
+ Q_D(const QFxLineEdit);
+ return d->cursorComponent;
+}
+
+void QFxLineEdit::setCursorDelegate(QmlComponent* c)
+{
+ Q_D(QFxLineEdit);
+ if(d->cursorComponent)
+ delete d->cursorComponent;
+ d->cursorComponent = c;
+ d->startCreatingCursor();
+}
+
+void QFxLineEditPrivate::startCreatingCursor()
+{
+ Q_Q(QFxLineEdit);
+ if(!cursorComponent){
+ q->disconnect(control, SIGNAL(cursorPositionChanged(int, int)),
+ q, SLOT(moveCursor()));
+ return;
+ }
+ q->connect(control, SIGNAL(cursorPositionChanged(int, int)),
+ q, SLOT(moveCursor()));
+ if(cursorComponent->isReady()){
+ q->createCursor();
+ }else if(cursorComponent->isLoading()){
+ q->connect(cursorComponent, SIGNAL(statusChanged(int)),
+ q, SLOT(createCursor()));
+ }else{//isError
+ qWarning() << "You could really use the error checking for QFxLineEdit. We'll implement it soon.";
+ }
+}
+
+void QFxLineEdit::createCursor()
+{
+ Q_D(QFxLineEdit);
+ //Handle isError too
+ if(!d->cursorComponent->isReady())
+ return;
+
+ if(d->cursorItem)
+ delete d->cursorItem;
+ d->cursorItem = qobject_cast<QFxItem*>(d->cursorComponent->create());
+ if(!d->cursorItem){
+ qWarning() << "You could really use the error reporting for QFxLineEdit. We'll implement it soon.";
+ return;
+ }
+
+ d->cursorItem->setItemParent(this);
+ d->cursorItem->setX(d->control->cursorToX());
+ d->cursorItem->setHeight(d->control->height());
+}
+
+void QFxLineEdit::moveCursor()
+{
+ Q_D(QFxLineEdit);
+ if(!d->cursorItem)
+ return;
+ d->cursorItem->setX(d->control->cursorToX() - d->hscroll);
+}
+
+/*
+int QFxLineEdit::scrollDuration() const
+{
+ Q_D(const QFxLineEdit);
+ return d->scrollDur;
+}
+
+void QFxLineEdit::setScrollDuration(int s)
+{
+ Q_D(QFxLineEdit);
+ d->scrollDur = s;
+ //Need to update cur anims as well
+}
+*/
+int QFxLineEdit::xToPos(int x)
+{
+ Q_D(const QFxLineEdit);
+ return d->control->xToPos(x - d->hscroll);
+}
+
+void QFxLineEdit::focusChanged(bool hasFocus)
+{
+ Q_D(QFxLineEdit);
+ if(d->focused && !hasFocus){
+ d->focused = false;
+ d->control->setCursorBlinkPeriod(0);
+ updateAll();//Only need the cursor rect
+ }else{
+ d->focused = hasFocus;
+ updateAll();//Only need the cursor rect
+ }
+}
+
+void QFxLineEdit::keyPressEvent(QKeyEvent* ev)
+{
+ Q_D(QFxLineEdit);
+ d->control->processKeyEvent(ev);
+}
+
+void QFxLineEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QFxLineEdit);
+ setFocus(true);
+ d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
+ d->focused = true;
+ d->control->processEvent(event);
+ //event->accept();
+}
+
+bool QFxLineEdit::event(QEvent* ev)
+{
+ Q_D(QFxLineEdit);
+ //Anything we don't deal with ourselves, pass to the control
+ switch(ev->type()){
+ case QEvent::GraphicsSceneMousePress:
+ break;
+ default:
+ return d->control->processEvent(ev);
+ }
+ return false;
+}
+
+void QFxLineEdit::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ if (newGeometry.width() != oldGeometry.width())
+ updateSize();
+ QFxPaintedItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+void QFxLineEdit::drawContents(QPainter *p, const QRect &r)
+{
+ Q_D(QFxLineEdit);
+ p->setRenderHint(QPainter::TextAntialiasing, true);
+ p->save();
+ p->setPen(QPen(d->color));
+ int flags = QLineControl::DrawText;
+ if(!isReadOnly() && d->focused && !d->cursorItem)
+ flags |= QLineControl::DrawCursor;
+ if (d->control->hasSelectedText())
+ flags |= QLineControl::DrawSelections;
+
+ //TODO: Clean up this cut'n'pasted section from QLineEdit
+ QRect lineRect(r);
+
+ int cix = qRound(d->control->cursorToX());
+
+ // horizontal scrolling. d->hscroll is the left indent from the beginning
+ // of the text line to the left edge of lineRect. we update this value
+ // depending on the delta from the last paint event; in effect this means
+ // the below code handles all scrolling based on the textline (widthUsed,
+ // minLB, minRB), the line edit rect (lineRect) and the cursor position
+ // (cix).
+ QFontMetrics fm = QApplication::fontMetrics();
+ int minLB = qMax(0, -fm.minLeftBearing());
+ int minRB = qMax(0, -fm.minRightBearing());
+ int widthUsed = d->control->width() + minRB;
+ if ((minLB + widthUsed) <= lineRect.width()) {
+ // text fits in lineRect; use hscroll for alignment
+ d->hscroll = 0;
+ d->hscroll -= minLB;
+ } else if (cix - d->hscroll >= lineRect.width()) {
+ // text doesn't fit, cursor is to the right of lineRect (scroll right)
+ d->hscroll = cix - lineRect.width() + 1;
+ } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) {
+ // text doesn't fit, cursor is to the left of lineRect (scroll left)
+ d->hscroll = cix;
+ }
+ // the y offset is there to keep the baseline constant in case we have script changes in the text.
+ QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
+
+ if(d->hscroll != d->oldScroll)
+ moveCursor();
+
+ d->control->draw(p, topLeft, r, flags);
+
+ d->oldScroll = d->hscroll;
+ p->restore();
+}
+
+void QFxLineEditPrivate::init()
+{
+ Q_Q(QFxLineEdit);
+ control->setCursorWidth(1);
+ control->setPasswordCharacter(QLatin1Char('*'));
+ control->setLayoutDirection(Qt::LeftToRight);
+ control->setSelection(0,0);
+ q->setSmooth(true);
+ q->setAcceptedMouseButtons(Qt::LeftButton);
+ q->setOptions(QFxLineEdit::AcceptsInputMethods | QFxLineEdit::SimpleItem
+ | QFxLineEdit::HasContents | QFxLineEdit::MouseEvents);
+ q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
+ q, SIGNAL(cursorPositionChanged()));
+ q->connect(control, SIGNAL(selectionChanged()),
+ q, SLOT(selectionChanged()));
+ q->connect(control, SIGNAL(textChanged(const QString &)),
+ q, SLOT(q_textChanged()));
+ q->connect(control, SIGNAL(accepted()),
+ q, SIGNAL(accepted()));
+ q->connect(control, SIGNAL(updateNeeded(const QRect &)),
+ // q, SLOT(dirtyCache(const QRect &)));
+ q, SLOT(updateAll()));
+ q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
+ q, SLOT(updateAll()));
+ q->connect(control, SIGNAL(selectionChanged()),
+ q, SLOT(updateAll()));
+ if(!font)
+ font = new QmlFont();
+ q->updateSize();
+ oldValidity = control->hasAcceptableInput();
+ oldSelectLength = q->selectionLength();
+}
+
+void QFxLineEdit::selectionChanged()
+{
+ Q_D(QFxLineEdit);
+ emit selectedTextChanged();
+ if(selectionLength() != d->oldSelectLength){
+ d->oldSelectLength = selectionLength();
+ emit selectionLengthChanged();
+ }
+}
+
+void QFxLineEdit::q_textChanged()
+{
+ Q_D(QFxLineEdit);
+ updateAll();
+ emit textChanged();
+ if(hasAcceptableInput() != d->oldValidity){
+ d->oldValidity = hasAcceptableInput();
+ emit acceptableInputChanged();
+ }
+}
+
+//### Please replace this function with proper updating
+void QFxLineEdit::updateAll()
+{
+ clearCache();
+ updateSize();
+ update();
+}
+
+void QFxLineEdit::updateSize()
+{
+ Q_D(QFxLineEdit);
+ setImplicitHeight(d->control->height());
+ //d->control->width() is max width, not current width
+ QFontMetrics fm = QFontMetrics(d->font->font());
+ setImplicitWidth(fm.boundingRect(d->control->text()).width()+1);
+ setContentsSize(QSize(width(), height()));
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h
new file mode 100644
index 0000000..e053c54
--- /dev/null
+++ b/src/declarative/fx/qfxlineedit.h
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** 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 QFXLINEEDIT_H
+#define QFXLINEEDIT_H
+
+#include "qfxtext.h"
+#include "qfxpainteditem.h"
+#include <QGraphicsSceneMouseEvent>
+#include <QIntValidator>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QFxLineEditPrivate;
+class QValidator;
+class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QmlFont *font READ font)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ /*
+ Q_PROPERTY(QFxText::TextStyle style READ style WRITE setStyle)
+ Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor)
+ Q_PROPERTY(QFxText::HAlignment hAlign READ hAlign WRITE setHAlign)
+ Q_PROPERTY(QFxText::VAlignment vAlign READ vAlign WRITE setVAlign)
+ */
+
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly);
+ Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength);
+ Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged);
+ Q_PROPERTY(int selectionLength READ selectionLength WRITE setSelectionLength NOTIFY selectionLengthChanged);
+ Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged);
+
+ Q_PROPERTY(QObject* validator READ validator WRITE setValidator);
+ Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask);
+ Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged);
+ Q_PROPERTY(uint echoMode READ echoMode WRITE setEchoMode);
+
+ Q_PROPERTY(QmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate);
+ /*
+ Q_PROPERTY(int scrollDuration READ scrollDuration SET setScrollDuration NOTIFY scrollDurationChanged);
+ */
+
+public:
+ QFxLineEdit(QFxItem* parent=0);
+ ~QFxLineEdit();
+
+ QString text() const;
+ void setText(const QString &);
+
+ QmlFont *font();
+
+ QColor color() const;
+ void setColor(const QColor &c);
+
+ //### Should we have this function or x variants of properties?
+ Q_INVOKABLE int xToPos(int x);
+
+ /*
+ QFxText::TextStyle style() const;
+ void setStyle(QFxText::TextStyle style);
+
+ QColor styleColor() const;
+ void setStyleColor(const QColor &c);
+ */
+
+ QFxText::HAlignment hAlign() const;
+ void setHAlign(QFxText::HAlignment align);
+
+ QFxText::VAlignment vAlign() const;
+ void setVAlign(QFxText::VAlignment align);
+
+ bool isReadOnly() const;
+ void setReadOnly(bool);
+
+ int maxLength() const;
+ void setMaxLength(int ml);
+
+ int cursorPosition() const;
+ void setCursorPosition(int cp);
+
+ int selectionLength() const;
+ void setSelectionLength(int len);
+
+ QString selectedText() const;
+
+ QObject * validator() const;
+ void setValidator(QObject* v);
+
+ QString inputMask() const;
+ void setInputMask(const QString &im);
+
+ uint echoMode() const;
+ void setEchoMode(uint echo);
+
+ QmlComponent* cursorDelegate() const;
+ void setCursorDelegate(QmlComponent*);
+
+ /*
+ int scrollDuration() const;
+ void setScrollDuration(int);
+ */
+
+ bool hasAcceptableInput() const;
+
+ void drawContents(QPainter *p,const QRect &r);
+Q_SIGNALS:
+ void textChanged();
+ void cursorPositionChanged();
+ void selectionLengthChanged();
+ void selectedTextChanged();
+ void accepted();
+ void acceptableInputChanged();
+
+protected:
+ QFxLineEdit(QFxLineEditPrivate &dd, QFxItem *parent);
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void keyPressEvent(QKeyEvent* ev);
+ bool event(QEvent *e);
+
+ void focusChanged(bool hasFocus);
+
+private slots:
+ void updateSize();
+ void q_textChanged();
+ void selectionChanged();
+ void updateAll();
+ void createCursor();
+ void moveCursor();
+
+private:
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxLineEdit);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QFxLineEdit)
+QML_DECLARE_TYPE(QIntValidator)
+
+QT_END_HEADER
+#endif // QFXLINEEDIT_H
diff --git a/src/declarative/opengl/glsave.h b/src/declarative/fx/qfxlineedit_p.h
index ad6c0ec..a0ab19c 100644
--- a/src/declarative/opengl/glsave.h
+++ b/src/declarative/fx/qfxlineedit_p.h
@@ -39,73 +39,66 @@
**
****************************************************************************/
-#ifndef _GLSAVE_H_
-#define _GLSAVE_H_
+#ifndef QFXLINEEDIT_P_H
+#define QFXLINEEDIT_P_H
-#include <QtCore/qglobal.h>
-#include <QtDeclarative/qfxglobal.h>
-#include <QtCore/QRect>
-#include "glheaders.h"
-
-
-QT_BEGIN_HEADER
+#include "qfxlineedit.h"
+#include "qml.h"
+#include "qfxpainteditem_p.h"
+#include "private/qlinecontrol_p.h"
+#include <QPointer>
+//
+// 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
-QT_MODULE(Declarative)
-class GLSaveViewport
+class QFxLineEditPrivate : public QFxPaintedItemPrivate
{
+ Q_DECLARE_PUBLIC(QFxLineEdit);
public:
- GLSaveViewport()
+ QFxLineEditPrivate() : control(new QLineControl(QString())),
+ font(0), color((QRgb)0), style(QFxText::Normal),
+ styleColor((QRgb)0),
+ hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop),
+ hscroll(0), oldScroll(0), focused(false)
{
- glGetIntegerv(GL_VIEWPORT, viewport);
}
- ~GLSaveViewport()
+ ~QFxLineEditPrivate()
{
- glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
}
-private:
- Q_DISABLE_COPY(GLSaveViewport)
- GLint viewport[4];
-};
+ void init();
+ void startCreatingCursor();
-class GLSaveScissor
-{
-public:
- GLSaveScissor()
- {
- enabled = glIsEnabled(GL_SCISSOR_TEST);
- glGetIntegerv(GL_SCISSOR_BOX, box);
- }
+ QLineControl* control;
- ~GLSaveScissor()
- {
- if (enabled)
- glEnable(GL_SCISSOR_TEST);
- else
- glDisable(GL_SCISSOR_TEST);
- glScissor(box[0], box[1], box[2], box[3]);
- }
-
- bool wasEnabled() const
- {
- return enabled == GL_TRUE;
- }
+ QmlFont *font;
+ QColor color;
+ QFxText::TextStyle style;
+ QColor styleColor;
+ QFxText::HAlignment hAlign;
+ QFxText::VAlignment vAlign;
+ QPointer<QmlComponent> cursorComponent;
+ QPointer<QFxItem> cursorItem;
- QRect rect() const
- {
- return QRect(box[0], box[1], box[2], box[3]);
- }
-
-private:
- Q_DISABLE_COPY(GLSaveScissor)
- GLint box[4];
- GLboolean enabled;
+ int oldSelectLength;
+ int oldHeight;
+ int oldWidth;
+ bool oldValidity;
+ int hscroll;
+ int oldScroll;
+ bool focused;
};
QT_END_NAMESPACE
-QT_END_HEADER
-#endif // _GLSAVE_H_
+#endif
+
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 8b39773..50564fb 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -46,6 +46,7 @@
#include "qfxlistview.h"
#include <qmlexpression.h>
+#include <QKeyEvent>
QT_BEGIN_NAMESPACE
class QFxListViewAttached : public QObject
@@ -292,7 +293,7 @@ public:
}
return -1; // Not in visibleList
}
-
+
bool mapRangeFromModel(int &index, int &count) const {
if (index + count < visibleIndex)
return false;
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 6e9451e..2a70af0 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -55,7 +55,7 @@ class QFxListViewPrivate;
class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QFxListView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxListView)
Q_ENUMS(CurrentItemPositioning)
Q_PROPERTY(QVariant model READ model WRITE setModel)
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index 6eb358b..af16d4d 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -173,28 +173,12 @@ void QFxDrag::setYmax(int m)
\qmlsignal MouseRegion::onEntered
This handler is called when the mouse enters the mouse region.
-
- \warning This handler is not yet implemented.
*/
/*!
\qmlsignal MouseRegion::onExited
This handler is called when the mouse exists the mouse region.
-
- \warning This handler is not yet implemented.
-*/
-
-/*!
- \qmlsignal MouseRegion::onReenteredWhilePressed
-
- This handler is called when the mouse reenters the mouse region while pressed.
-*/
-
-/*!
- \qmlsignal MouseRegion::onExitedWhilePressed
-
- This handler is called when the mouse exists the mouse region while pressed.
*/
/*!
@@ -322,10 +306,6 @@ void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!d->absorb)
QFxItem::mousePressEvent(event);
else {
- if (!d->inside) {
- d->inside = true;
- emit hoveredChanged();
- }
d->longPress = false;
d->saveEvent(event);
d->dragX = drag()->axis().contains(QLatin1String("x"));
@@ -352,17 +332,13 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
d->saveEvent(event);
// ### we should skip this if these signals aren't used
+ // ### can GV handle this for us?
const QRect &bounds = itemBoundingRect();
bool contains = bounds.contains(d->lastPos.toPoint());
- if (d->inside && !contains) {
- d->inside = false;
- emit hoveredChanged();
- emit exitedWhilePressed();
- } else if (!d->inside && contains) {
- d->inside = true;
- emit hoveredChanged();
- emit reenteredWhilePressed();
- }
+ if (d->hovered && !contains)
+ setHovered(false);
+ else if (!d->hovered && contains)
+ setHovered(true);
if (drag()->target()) {
if (!d->moved) {
@@ -373,8 +349,8 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QPointF startLocalPos;
QPointF curLocalPos;
if (drag()->target()->parent()) {
- startLocalPos = drag()->target()->parent()->mapFromScene(d->startScene);
- curLocalPos = drag()->target()->parent()->mapFromScene(event->scenePos());
+ startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
+ curLocalPos = drag()->target()->parentItem()->mapFromScene(event->scenePos());
} else {
startLocalPos = d->startScene;
curLocalPos = event->scenePos();
@@ -424,8 +400,6 @@ void QFxMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
else {
d->saveEvent(event);
setPressed(false);
- //d->inside = false;
- //emit hoveredChanged();
event->accept();
}
}
@@ -436,8 +410,6 @@ void QFxMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
if (!d->absorb)
QFxItem::mouseDoubleClickEvent(event);
else {
- //d->inside = true;
- //emit hoveredChanged();
d->saveEvent(event);
setPressed(true);
QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
@@ -453,7 +425,6 @@ void QFxMouseRegion::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
QFxItem::hoverEnterEvent(event);
else {
setHovered(true);
- emit entered();
}
}
@@ -464,7 +435,6 @@ void QFxMouseRegion::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QFxItem::hoverLeaveEvent(event);
else {
setHovered(false);
- emit exited();
}
}
@@ -475,7 +445,6 @@ void QFxMouseRegion::mouseUngrabEvent()
// if our mouse grab has been removed (probably by Flickable), fix our
// state
d->pressed = false;
- //d->inside = false;
setKeepMouseGrab(false);
emit pressedChanged();
//emit hoveredChanged();
@@ -487,7 +456,7 @@ void QFxMouseRegion::timerEvent(QTimerEvent *event)
Q_D(QFxMouseRegion);
if (event->timerId() == d->pressAndHoldTimer.timerId()) {
d->pressAndHoldTimer.stop();
- if (d->pressed && d->dragged == false && d->inside == true) {
+ if (d->pressed && d->dragged == false && d->hovered == true) {
d->longPress = true;
QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
emit pressAndHold(&me);
@@ -504,7 +473,7 @@ void QFxMouseRegion::timerEvent(QTimerEvent *event)
bool QFxMouseRegion::hovered()
{
Q_D(QFxMouseRegion);
- return d->hovered || d->inside;
+ return d->hovered;
}
/*!
@@ -523,13 +492,14 @@ void QFxMouseRegion::setHovered(bool h)
if (d->hovered != h) {
d->hovered = h;
emit hoveredChanged();
+ d->hovered ? emit entered() : emit exited();
}
}
void QFxMouseRegion::setPressed(bool p)
{
Q_D(QFxMouseRegion);
- bool isclick = d->pressed == true && p == false && d->dragged == false && d->inside == true;
+ bool isclick = d->pressed == true && p == false && d->dragged == false && d->hovered == true;
if (d->pressed != p) {
d->pressed = p;
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index 429ad00..47929be 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -129,8 +129,6 @@ Q_SIGNALS:
void doubleClicked(QFxMouseEvent *mouse);
void entered();
void exited();
- void exitedWhilePressed();
- void reenteredWhilePressed();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
@@ -151,7 +149,7 @@ protected:
private:
Q_DISABLE_COPY(QFxMouseRegion)
- Q_DECLARE_PRIVATE(QFxMouseRegion)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxMouseRegion)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxmouseregion_p.h b/src/declarative/fx/qfxmouseregion_p.h
index e444bf2..a41f32a 100644
--- a/src/declarative/fx/qfxmouseregion_p.h
+++ b/src/declarative/fx/qfxmouseregion_p.h
@@ -66,7 +66,7 @@ class QFxMouseRegionPrivate : public QFxItemPrivate
public:
QFxMouseRegionPrivate()
- : absorb(true), hovered(false), inside(true), pressed(false), longPress(false), drag(0)
+ : absorb(true), hovered(false), pressed(false), longPress(false), drag(0)
{
}
@@ -74,7 +74,7 @@ public:
{
Q_Q(QFxMouseRegion);
q->setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
- q->setOptions(QSimpleCanvasItem::HoverEvents | QSimpleCanvasItem::MouseEvents);
+ q->setOptions(QFxItem::HoverEvents | QFxItem::MouseEvents);
}
void saveEvent(QGraphicsSceneMouseEvent *event) {
@@ -86,7 +86,6 @@ public:
bool absorb : 1;
bool hovered : 1;
- bool inside : 1;
bool pressed : 1;
bool longPress : 1;
bool moved : 1;
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index 0a13dc4..7ff3361 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -48,11 +48,7 @@
#include <QEvent>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glsave.h>
-#endif
+#include <QPainter>
QT_BEGIN_NAMESPACE
@@ -210,26 +206,16 @@ void QFxPaintedItem::init()
connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache()));
}
-#if defined(QFX_RENDER_QPAINTER)
/*!
\reimp
*/
void QFxPaintedItem::paintContents(QPainter &p)
-#elif defined(QFX_RENDER_OPENGL)
-/*!
- \reimp
-*/
-void QFxPaintedItem::paintGLContents(GLPainter &p)
-#else
-#error "What render?"
-#endif
{
Q_D(QFxPaintedItem);
const QRect content(QPoint(0,0),d->contentsSize);
if (content.width() <= 0 || content.height() <= 0)
return;
-#if defined(QFX_RENDER_QPAINTER)
bool oldAntiAliasing = p.testRenderHint(QPainter::Antialiasing);
bool oldSmoothPixmap = p.testRenderHint(QPainter::SmoothPixmapTransform);
if (oldAntiAliasing)
@@ -242,29 +228,12 @@ void QFxPaintedItem::paintGLContents(GLPainter &p)
else
clipf = mapToScene(clipf);
-#elif defined(QFX_RENDER_OPENGL2)
- p.useTextureShader();
- const QRectF clipf = p.sceneClipRect;
-
-#elif defined(QFX_RENDER_OPENGL1)
- p.useTextureShader();
- const QRectF clipf = p.sceneClipRect;
-#endif
-
const QRect clip = mapFromScene(clipf).toRect();
QRegion topaint(clip);
topaint &= content;
QRegion uncached(content);
-#if defined(QFX_RENDER_OPENGL2)
- glEnableVertexAttribArray(SingleTextureShader::Vertices);
- glEnableVertexAttribArray(SingleTextureShader::TextureCoords);
-#elif defined(QFX_RENDER_OPENGL1)
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-#endif
-
int cachesize=0;
for (int i=0; i<d->imagecache.count(); ++i) {
QRect area = d->imagecache[i]->area;
@@ -312,29 +281,17 @@ void QFxPaintedItem::paintGLContents(GLPainter &p)
}
QFxPaintedItemPrivate::ImageCacheItem *newitem = new QFxPaintedItemPrivate::ImageCacheItem;
newitem->area = r;
-#if defined(QFX_RENDER_QPAINTER)
newitem->image = img;
-#else
- newitem->image.setImage(img.toImage());
-#endif
d->imagecache.append(newitem);
QRectF target(r.x(), r.y(), r.width(), r.height());
p.drawPixmap(target.toRect(), newitem->image);
}
}
-#if defined(QFX_RENDER_OPENGL2)
- glDisableVertexAttribArray(SingleTextureShader::Vertices);
- glDisableVertexAttribArray(SingleTextureShader::TextureCoords);
-#elif defined(QFX_RENDER_OPENGL1)
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-#endif
-#if defined(QFX_RENDER_QPAINTER)
+
if (oldAntiAliasing)
p.setRenderHints(QPainter::Antialiasing, oldAntiAliasing);
if (d->smooth)
p.setRenderHints(QPainter::SmoothPixmapTransform, oldSmoothPixmap);
-#endif
}
/*!
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index 7a0a9a9..e74ead0 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -66,11 +66,7 @@ public:
QFxPaintedItem(QFxItem *parent=0);
~QFxPaintedItem();
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
-#elif defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
-#endif
bool isSmooth() const;
QSize contentsSize() const;
@@ -99,7 +95,7 @@ protected Q_SLOTS:
private:
void init();
Q_DISABLE_COPY(QFxPaintedItem)
- Q_DECLARE_PRIVATE(QFxPaintedItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxPaintedItem)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index 4e953a0..06e80ff 100644
--- a/src/declarative/fx/qfxpainteditem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -54,11 +54,6 @@
//
#include <private/qfxitem_p.h>
-#include <QtDeclarative/qsimplecanvas.h>
-
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
QT_BEGIN_NAMESPACE
@@ -77,11 +72,7 @@ public:
~ImageCacheItem() { }
int age;
QRect area;
-#if defined(QFX_RENDER_QPAINTER)
QPixmap image;
-#else
- GLTexture image;
-#endif
};
QList<ImageCacheItem*> imagecache;
diff --git a/src/declarative/fx/qfxpath.cpp b/src/declarative/fx/qfxpath.cpp
index 4c241d3..a1b6032 100644
--- a/src/declarative/fx/qfxpath.cpp
+++ b/src/declarative/fx/qfxpath.cpp
@@ -43,6 +43,7 @@
#include "qfxpath_p.h"
#include <private/qfxperf_p.h>
#include <private/qbezier_p.h>
+#include <QSet>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 625d778..f940f68 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -489,6 +489,7 @@ void QFxPathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
d->lastPosTime = QTime();
d->stealMouse = false;
+ ungrabMouse();
}
bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
@@ -524,8 +525,8 @@ bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
break;
}
grabber = static_cast<QFxItem*>(mouseGrabberItem());
- if (grabber && d->stealMouse && !grabber->keepMouseGrab())
- mouseGrabberItem()->ungrabMouse();
+ if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this)
+ grabMouse();
return d->stealMouse;
} else if (!d->lastPosTime.isNull()) {
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index 159c865..9d91006 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -125,7 +125,7 @@ private:
friend class QFxPathViewAttached;
static QHash<QObject*, QObject*> attachedProperties;
Q_DISABLE_COPY(QFxPathView)
- Q_DECLARE_PRIVATE(QFxPathView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxPathView)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h
index b77c2a0..63c8224 100644
--- a/src/declarative/fx/qfxpathview_p.h
+++ b/src/declarative/fx/qfxpathview_p.h
@@ -87,7 +87,7 @@ public:
Q_Q(QFxPathView);
_offset = 0;
q->setAcceptedMouseButtons(Qt::NoButton);
- q->setOptions(QSimpleCanvasItem::MouseFilter | QSimpleCanvasItem::MouseEvents | QSimpleCanvasItem::IsFocusRealm);
+ q->setOptions(QFxItem::ChildMouseFilter | QFxItem::MouseEvents | QFxItem::IsFocusRealm);
q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
}
diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp
index 5ee6528..ac8a701 100644
--- a/src/declarative/fx/qfxpixmap.cpp
+++ b/src/declarative/fx/qfxpixmap.cpp
@@ -46,6 +46,7 @@
#include <private/qfxperf_p.h>
#include <QtDeclarative/qmlengine.h>
#include <QFile>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
class QSharedNetworkReply;
diff --git a/src/declarative/fx/qfxpixmap.h b/src/declarative/fx/qfxpixmap.h
index ae693c1..f63299b 100644
--- a/src/declarative/fx/qfxpixmap.h
+++ b/src/declarative/fx/qfxpixmap.h
@@ -44,9 +44,8 @@
#include <QtCore/QString>
#include <QtGui/QPixmap>
-#include <QtDeclarative/qsimplecanvas.h>
#include <QtDeclarative/qfxglobal.h>
-
+#include <QtCore/qurl.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index b521d00..32d3eb4 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -42,6 +42,7 @@
#include "qfxrect.h"
#include "qfxrect_p.h"
+#include <QPainter>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxPen,Pen)
@@ -251,17 +252,8 @@ QFxRect::QFxRect(QFxRectPrivate &dd, QFxItem *parent)
void QFxRect::doUpdate()
{
-#if defined(QFX_RENDER_QPAINTER)
Q_D(QFxRect);
d->rectImage = QPixmap();
-#endif
-#if defined(QFX_RENDER_OPENGL)
- Q_D(QFxRect);
- if (d->rectTexture) {
- d->rectTexture->release();
- d->rectTexture = 0;
- }
-#endif
const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
setPaintMargin((pw+1)/2);
update();
@@ -340,7 +332,7 @@ void QFxRect::setGradient(QFxGradient *gradient)
This property holds the corner radius used to draw a rounded rect.
If radius is non-zero, the rect will be painted as a rounded rectangle, otherwise it will be
- painted as a normal rectangle. The same radius is used by all 4 corners; there is currently
+ painted as a normal rectangle. The same radius is used by all 4 corners; there is currently
no way to specify different radii for different corners.
*/
@@ -361,25 +353,10 @@ void QFxRect::setRadius(qreal radius)
return;
d->radius = radius;
-#if defined(QFX_RENDER_QPAINTER)
d->rectImage = QPixmap();
-#elif defined(QFX_RENDER_OPENGL)
- if (d->rectTexture) {
- d->rectTexture->release();
- d->rectTexture = 0;
- }
-#endif
update();
}
-void QFxRect::dump(int depth)
-{
- Q_D(QFxRect);
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << "QFxRect:" << d->color;
- QFxItem::dump(depth);
-}
-
/*!
\qmlproperty color Rect::color
This property holds the color used to fill the rect.
@@ -412,15 +389,7 @@ void QFxRect::setColor(const QColor &c)
return;
d->color = c;
-#if defined(QFX_RENDER_QPAINTER)
d->rectImage = QPixmap();
-#endif
-#if defined(QFX_RENDER_OPENGL)
- if (d->rectTexture) {
- d->rectTexture->release();
- d->rectTexture = 0;
- }
-#endif
update();
}
@@ -488,7 +457,6 @@ QColor QFxRectPrivate::getColor()
}
-#if defined(QFX_RENDER_QPAINTER)
void QFxRect::generateRoundedRect()
{
Q_D(QFxRect);
@@ -535,72 +503,7 @@ void QFxRect::generateBorderedRect()
p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw));
}
}
-#elif defined(QFX_RENDER_OPENGL)
-void QFxRect::generateRoundedRect()
-{
- Q_D(QFxRect);
- if (!d->rectTexture) {
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- QString key = QString("QFxRect://r_%1_%2_%3_%4").arg(pw).arg(d->radius).arg((d->pen && d->pen->isValid())?d->pen->color().name():QString()).arg(d->color.name());
-
- d->rectTexture = cachedTexture(key);
-
- if (!d->rectTexture) {
- QPixmap roundRect(d->radius*2 + 4 + pw*2, d->radius*2 + 4 + pw*2);
- roundRect.fill(Qt::transparent);
- QPainter p(&roundRect);
- p.setRenderHint(QPainter::Antialiasing);
- if (d->pen && d->pen->isValid()) {
- QPen pn(QColor(pen()->color()), pen()->width());
- p.setPen(pn);
- } else {
- p.setPen(Qt::NoPen);
- }
- p.setBrush(d->color);
- if (pw%2)
- p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, roundRect.width()-(pw+1), roundRect.height()-(pw+1)), d->radius, d->radius);
- else
- p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, roundRect.width()-pw, roundRect.height()-pw), d->radius, d->radius);
-
- d->rectTexture = cachedTexture(key, roundRect);
- }
- }
-}
-
-void QFxRect::generateBorderedRect()
-{
- Q_D(QFxRect);
- if (!d->rectTexture) {
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- QString key = QString("QFxRect://b_%1_%2_%3_%4").arg(pw).arg(d->radius).arg((d->pen && d->pen->isValid())?d->pen->color().name():QString()).arg(d->color.name());
-
- d->rectTexture = cachedTexture(key);
-
- if (!d->rectTexture) {
- QPixmap borderedRect(pw*2 + 4, pw*2 + 4);
- borderedRect.fill(Qt::transparent);
- QPainter p(&(borderedRect));
- p.setRenderHint(QPainter::Antialiasing);
- if (d->pen && d->pen->isValid()) {
- QPen pn(QColor(pen()->color()), pen()->width());
- pn.setJoinStyle(Qt::MiterJoin);
- p.setPen(pn);
- } else {
- p.setPen(Qt::NoPen);
- }
- p.setBrush(d->color);
- if (pw%2)
- p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, borderedRect.width()-(pw+1), borderedRect.height()-(pw+1)));
- else
- p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, borderedRect.width()-pw, borderedRect.height()-pw));
- d->rectTexture = cachedTexture(key, borderedRect);
- }
- }
-}
-#endif
-
-#if defined(QFX_RENDER_QPAINTER)
void QFxRect::paintContents(QPainter &p)
{
Q_D(QFxRect);
@@ -689,7 +592,7 @@ void QFxRect::drawRect(QPainter &p)
if (yMiddles)
p.drawPixmap(QRect(width()-xOffset+pw/2, yOffset-pw/2, xOffset, height() - ySide + pw), d->rectImage,
QRect(d->rectImage.width()-xOffset, d->rectImage.height()/2, xOffset, 1));
- // Lower left
+ // Lower left
p.drawPixmap(QPoint(-pw/2, height() - yOffset + pw/2), d->rectImage, QRect(0, d->rectImage.height() - yOffset, xOffset, yOffset));
// Lower Middle
@@ -701,258 +604,5 @@ void QFxRect::drawRect(QPainter &p)
QRect(d->rectImage.width()-xOffset, d->rectImage.height() - yOffset, xOffset, yOffset));
}
}
-#endif
-
-#if defined(QFX_RENDER_OPENGL2)
-#include "glbasicshaders.h"
-
-void QFxRect::paintGLContents(GLPainter &p)
-{
- Q_D(QFxRect);
- if (d->radius == 0 && (!d->pen || !d->pen->isValid())) {
- if (d->gradient) {
- float widthV = width();
- float heightV = height();
-
- GLfloat vertices[] = { 0, heightV,
- widthV, heightV,
- 0, 0,
- widthV, 0 };
-
- int count = d->gradient->stops()->size();
- GLfloat colors[count*8];
- for (int i = 0; i < count; i += 8) {
- QFxGradientStop *g = d->gradient->stops()->at(i);
- QColor c = g->color();
- colors[i] = c.redF(); colors[i+4] = colors[i];
- colors[i+1] = c.greenF(); colors[i+5] = colors[i+1];
- colors[i+2] = c.blueF(); colors[i+6] = colors[i+2];
- colors[i+3] = c.alphaF() * p.activeOpacity; colors[i+7] = colors[i+3];
- }
-
- p.invalidate();
- ColorShader *shader = basicShaders()->color();
- shader->enable();
- shader->setTransform(p.activeTransform);
-
- shader->setAttributeArray(ColorShader::Vertices, vertices, 2);
- shader->setAttributeArray(ColorShader::Colors, colors, 4);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, count*2);
- shader->disableAttributeArray(ColorShader::Vertices);
- shader->disableAttributeArray(ColorShader::Colors);
- } else {
-
- p.fillRect(QRectF(0, 0, width(), height()), d->getColor());
-
- }
- } else {
- qreal offset = 0;
- qreal pw = d->pen && d->pen->isValid() ? d->pen->width() : 0.0;
-
- if (d->radius > 0) {
- generateRoundedRect();
- offset = d->radius + pw+1.5;
- } else {
- generateBorderedRect();
- offset = pw+1.5;
- }
-
- QGLShaderProgram *shader = p.useTextureShader();
-
- float texWidth = d->rectTexture->width();
- float texHeight = d->rectTexture->height();
- if (!texWidth || !texHeight)
- return;
-
- float widthV = qreal(width())+pw/2;
- float heightV = qreal(height())+pw/2;
-
- float xOffset = offset;
- bool xMiddles = true;
- if (xOffset*2 > width()+pw) {
- xMiddles = false;
- xOffset = (width()+pw)/2;
- }
- float yOffset = offset;
- bool yMiddles = true;
- if (yOffset*2 > height()+pw) {
- yMiddles = false;
- yOffset = (height()+pw)/2;
- }
-
- float texleft = xOffset / texWidth;
- float imgleft = xOffset-pw/2;
- float texright = (texWidth-xOffset) / texWidth;
- float imgright = widthV - xOffset;
-
- float textop = yOffset / texHeight;
- float imgtop = yOffset-pw/2;
- float texbottom = (texHeight-yOffset) / texHeight;
- float imgbottom = heightV - yOffset;
-
- //Bug 231768: Inappropriate interpolation was occuring on 3x3 textures
- if (offset==1)
- texleft=texright=textop=texbottom=0.5;
-
- texleft *= d->rectTexture->glWidth();
- texright *= d->rectTexture->glWidth();
- textop *= d->rectTexture->glHeight();
- texbottom *= d->rectTexture->glHeight();
-
- float vert1[] = { -pw/2, -pw/2,
- -pw/2, imgtop,
- imgleft, -pw/2,
-
- -pw/2, imgtop,
- imgleft, -pw/2,
- imgleft, imgtop,
-
- imgleft, -pw/2,
- imgleft, imgtop,
- imgright, -pw/2,
-
- imgleft, imgtop,
- imgright, -pw/2,
- imgright, imgtop,
-
- imgright, -pw/2,
- imgright, imgtop,
- widthV, -pw/2,
-
- imgright, imgtop,
- widthV, -pw/2,
- widthV, imgtop,
-
- -pw/2, heightV,
- -pw/2, imgbottom,
- imgleft, heightV,
-
- -pw/2, imgbottom,
- imgleft, heightV,
- imgleft, imgbottom,
-
- imgleft, heightV,
- imgleft, imgbottom,
- imgright, heightV,
-
- imgleft, imgbottom,
- imgright, heightV,
- imgright, imgbottom,
-
- imgright, heightV,
- imgright, imgbottom,
- widthV, heightV,
-
- imgright, imgbottom,
- widthV, heightV,
- widthV, imgbottom,
-
- -pw/2, imgtop,
- -pw/2, imgbottom,
- imgleft, imgtop,
-
- -pw/2, imgbottom,
- imgleft, imgtop,
- imgleft, imgbottom,
-
- imgleft, imgtop,
- imgleft, imgbottom,
- imgright, imgtop,
-
- imgleft, imgbottom,
- imgright, imgtop,
- imgright, imgbottom,
-
- imgright, imgtop,
- imgright, imgbottom,
- widthV, imgtop,
-
- imgright, imgbottom,
- widthV, imgtop,
- widthV, imgbottom };
-
-
- float tex1[] = { 0, 0,
- 0, textop,
- texleft, 0,
-
- 0, textop,
- texleft, 0,
- texleft, textop,
-
- texleft, 0,
- texleft, textop,
- texright, 0,
-
- texleft, textop,
- texright, 0,
- texright, textop,
-
- texright, 0,
- texright, textop,
- d->rectTexture->glWidth(), 0,
-
- texright, textop,
- d->rectTexture->glWidth(), 0,
- d->rectTexture->glWidth(), textop,
-
- 0, d->rectTexture->glHeight(),
- 0, texbottom,
- texleft, d->rectTexture->glHeight(),
-
- 0, texbottom,
- texleft, d->rectTexture->glHeight(),
- texleft, texbottom,
-
- texleft, d->rectTexture->glHeight(),
- texleft, texbottom,
- texright, d->rectTexture->glHeight(),
-
- texleft, texbottom,
- texright, d->rectTexture->glHeight(),
- texright, texbottom,
-
- texright, d->rectTexture->glHeight(),
- texright, texbottom,
- d->rectTexture->glWidth(), d->rectTexture->glHeight(),
-
- texright, texbottom,
- d->rectTexture->glWidth(), d->rectTexture->glHeight(),
- d->rectTexture->glWidth(), texbottom,
-
- 0, textop,
- 0, texbottom,
- texleft, textop,
-
- 0, texbottom,
- texleft, textop,
- texleft, texbottom,
-
- texleft, textop,
- texleft, texbottom,
- texright, textop,
-
- texleft, texbottom,
- texright, textop,
- texright, texbottom,
-
- texright, textop,
- texright, texbottom,
- d->rectTexture->glWidth(), textop,
-
- texright, texbottom,
- d->rectTexture->glWidth(), textop,
- d->rectTexture->glWidth(), texbottom };
-
-
-
- glBindTexture(GL_TEXTURE_2D, d->rectTexture->texture());
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vert1, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, tex1, 2);
- glDrawArrays(GL_TRIANGLES, 0, 36 + (yMiddles?18:0));
- }
-}
-#endif
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h
index 2b35d8d..7790af1 100644
--- a/src/declarative/fx/qfxrect.h
+++ b/src/declarative/fx/qfxrect.h
@@ -43,6 +43,7 @@
#define QFXRECT_H
#include <QtDeclarative/qfxitem.h>
+#include <QtGui/qbrush.h>
QT_BEGIN_HEADER
@@ -156,14 +157,7 @@ public:
qreal radius() const;
void setRadius(qreal radius);
- virtual void dump(int depth);
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
-#endif
-
-#if defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
-#endif
private Q_SLOTS:
void doUpdate();
@@ -179,7 +173,7 @@ protected:
private:
Q_DISABLE_COPY(QFxRect)
- Q_DECLARE_PRIVATE(QFxRect)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxRect)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h
index 23bb944..3544d36 100644
--- a/src/declarative/fx/qfxrect_p.h
+++ b/src/declarative/fx/qfxrect_p.h
@@ -55,10 +55,6 @@
#include "qfxitem_p.h"
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
QT_BEGIN_NAMESPACE
class QFxGradient;
@@ -69,9 +65,6 @@ class QFxRectPrivate : public QFxItemPrivate
public:
QFxRectPrivate() :
-#if defined(QFX_RENDER_OPENGL)
- rectTexture(0),
-#endif //QFX_RENDER_OPENGL
color(Qt::white), gradient(0), pen(0), radius(0)
{
}
@@ -85,9 +78,6 @@ public:
{
}
-#if defined(QFX_RENDER_OPENGL)
- QSimpleCanvasItem::CachedTexture *rectTexture;
-#endif
QColor getColor();
QColor color;
QFxGradient *gradient;
diff --git a/src/declarative/fx/qfxreflectionfilter.cpp b/src/declarative/fx/qfxreflectionfilter.cpp
deleted file mode 100644
index c66deb7..0000000
--- a/src/declarative/fx/qfxreflectionfilter.cpp
+++ /dev/null
@@ -1,352 +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 "qfxreflectionfilter.h"
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glsave.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glbasicshaders.h>
-#include <gltexture.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-class QFxReflectionFilterPrivate
-{
-public:
- QFxReflectionFilterPrivate()
- : alpha(1), height(-1), offset(0), scale(1)
- {
- }
- qreal alpha;
- int height;
- int offset;
- qreal scale;
-};
-
-/*!
- \qmlclass Reflection
- \inherits Filter
- \brief The Reflection filter reflects an item and its contents.
-
- Here is an example of various Reflections applied to an image.
-
- \qml
-HorizontalLayout {
- Image {
- source: "icon.png"
- filter: Reflection { }
- }
- Image {
- source: "icon.png"
- filter: Reflection { offset: 1 }
- }
- Image {
- source: "icon.png"
- filter: Reflection { offset: 1; alpha: 0.5 }
- }
- Image {
- source: "icon.png"
- filter: Reflection { offset: 1; alpha: 0.5; height: 50 }
- }
- Image {
- source: "icon.png"
- filter: Reflection { offset: 1; alpha: 0.5; height: 50; scale: 0.5 }
- }
-}
- \endqml
-
- \image reflection_example.png
-
- Reflection is only supported when Qt Declarative is compiled for OpenGL ES 2.0.
- Otherwise the Reflection filter has no effect.
-*/
-
-/*!
- \internal
- \class QFxReflectionFilter
- \ingroup group_effects
- \brief The QFxReflectionFilter class allows you to add a reflection to an item.
-*/
-QFxReflectionFilter::QFxReflectionFilter(QObject *parent)
-: QSimpleCanvasFilter(parent), d(new QFxReflectionFilterPrivate)
-{
-}
-
-QFxReflectionFilter::~QFxReflectionFilter()
-{
- delete d; d = 0;
-}
-
-/*!
- \property QFxReflectionFilter::alpha
- \brief the starting opacity of the reflection.
-
- The starting opacity is the opacity closest to the item. The opacity will fade
- from this value to zero over the height of the reflection.
-*/
-qreal QFxReflectionFilter::alpha() const
-{
- return d->alpha;
-}
-
-void QFxReflectionFilter::setAlpha(qreal a)
-{
- if (d->alpha == a) return;
- d->alpha = a;
- emit alphaChanged(a);
- update();
-}
-
-/*!
- \qmlproperty int Reflection::height
-
- The height property controls how much of the item, in pixels, to reflect.
- If it is set to the default value of -1, the whole item is reflected. If
- it is set to 50, the bottom 50 pixels of the item are reflected. Data
- binding could be used to reflect a percentage of the item.
-
- \qml
-Image {
- id: myImage
- source: "album.png"
- filter: Reflection {
- height: myImage.height * 0.5
- }
-}
- \endqml
- */
-/*!
- \qmlproperty int Reflection::offset
-
- The offset controls how far from the base of the item, in pixels, the
- start of the reflection is placed. This can be used to create a nice
- sliver of space between the item and its reflection or for more advanced
- effects.
-
- The default offset is 0 pixels.
-*/
-
-/*!
- \qmlproperty real Reflection::alpha
-
- The alpha value controls the starting opacity of the reflected item. If
- set to the default value of 1, the reflected item starts completely opaque
- and gradually fades to completely transparent. If set to less than one, the
- reflection starts out partially transparent as though the item was sitting
- on a visually less reflective surface.
-
- Valid values are from 0 (which would be silly, but is allowed) to 1.
-*/
-/*!
- \qmlproperty real Reflection::scale
-
- When set to the default value of 1, the reflection is a 1:1 reflection of
- the item. That is, each horizontal pixel in the item corresponds to one
- horizontal pixel in the reflection.
-
- When set a value other than 1, the reflection is scaled acordingly - less
- than 1 scales it down and greater than 1 scales it up. The scale is applied
- after the height parameter and does not effect the reflection offset.
-*/
-
-/*!
- \property QFxReflectionFilter::height
- \brief the height of the reflection, in pixels.
-*/
-int QFxReflectionFilter::height() const
-{
- return d->height;
-}
-
-void QFxReflectionFilter::setHeight(int h)
-{
- if (d->height == h) return;
- d->height = h;
- emit heightChanged(h);
- update();
-}
-
-/*!
- \property QFxReflectionFilter::offset
- \brief the distance of the reflection from the item, in pixels.
-*/
-int QFxReflectionFilter::offset()
-{
- return d->offset;
-}
-
-void QFxReflectionFilter::setOffset(int o)
-{
- if (d->offset == o) return;
- d->offset = o;
- emit offsetChanged(o);
- update();
-}
-
-/*!
- \property QFxReflectionFilter::scale
- \brief the scale of the reflection relative to the item.
-*/
-qreal QFxReflectionFilter::scale() const
-{
- return d->scale;
-}
-
-void QFxReflectionFilter::setScale(qreal s)
-{
- if (d->scale == s) return;
- d->scale = s;
- emit scaleChanged(s);
- update();
-}
-
-static inline float floatmin(float a, float b)
-{
- return (a < b)?a:b;
-}
-
-void QFxReflectionFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
-#if defined(QFX_RENDER_OPENGL2)
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
- if (r.isEmpty())
- return;
- float width = r.width();
- float height = r.height();
-
- float refHeight = height;
- if (d->height > 0)
- refHeight = floatmin(height, d->height);
-
- QSimpleCanvas::Matrix simpMat;
- QSimpleCanvasItem *simpItem = 0;
- if (isSimpleItem(&simpItem, &simpMat) &&
- simpItem->glSimpleItemData(0, 0, 0, 0)) {
-
- GLfloat vertices[8];
- GLfloat texVertices[8];
- GLTexture *texture = 0;
-
- simpItem->glSimpleItemData(vertices, texVertices, &texture, 8);
-
- GLfloat opacity[4];
-
- float invRefHeight = 1. / refHeight;
- for (int ii = 0; ii < 4; ++ii) {
- float vertex = vertices[ii * 2 + 1];
- float o = (1. - (height - vertex) * invRefHeight);
- opacity[ii] = o * d->alpha * p.activeOpacity;
- }
-
- QSimpleCanvas::Matrix trans = p.activeTransform;
- trans.rotate(180, 1, 0, 0);
- trans.translate(0, -r.height() - d->offset);
- if (d->scale != 1)
- trans.scale(1, d->scale, 1);
- trans.translate(0, -r.height());
- trans *= simpMat;
-
- glBindTexture(GL_TEXTURE_2D, texture->texture());
-
- SingleTextureVertexOpacityShader *shader =
- item->basicShaders()->singleTextureVertexOpacity();
- shader->enable();
- shader->setTransform(trans);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, texVertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords, opacity, 1);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords);
-
- } else {
- QGLFramebufferObject *fbo = renderToFBO();
-
- float texWidth = width / float(fbo->width());
- float texHeight = refHeight / float(fbo->height());
-
- GLfloat invVertices[] = { width, height + d->scale * refHeight + d->offset,
- 0, height + d->scale * refHeight + d->offset,
- width, height + d->offset,
- 0, height + d->offset };
- GLfloat invTexVertices[] = { texWidth, texHeight,
- 0, texHeight,
- texWidth, 0,
- 0, 0 };
- GLfloat invOpacity[] = { 0, 0, d->alpha * p.activeOpacity, d->alpha * p.activeOpacity};
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
-
- SingleTextureVertexOpacityShader *shader =
- item->basicShaders()->singleTextureVertexOpacity();
- shader->enable();
- shader->setTransform(p.activeTransform);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, invVertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, invTexVertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords, invOpacity, 1);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords);
-
- releaseFBO(fbo);
- }
-
- renderToScreen();
-
-#else
- Q_UNUSED(p);
-#endif
-}
-
-QRectF QFxReflectionFilter::itemBoundingRect(const QRectF &r) const
-{
- QRectF rv = r;
- rv |= r.translated(0, r.height() + d->offset);
- return rv;
-}
-
-QML_DEFINE_TYPE(QFxReflectionFilter,Reflection)
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxreflectionfilter.h b/src/declarative/fx/qfxreflectionfilter.h
deleted file mode 100644
index d862040..0000000
--- a/src/declarative/fx/qfxreflectionfilter.h
+++ /dev/null
@@ -1,97 +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 QFXREFLECTIONFILTER_H
-#define QFXREFLECTIONFILTER_H
-
-#include <QtDeclarative/qsimplecanvasfilter.h>
-#include <QtDeclarative/qml.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QFxReflectionFilterPrivate;
-class Q_DECLARATIVE_EXPORT QFxReflectionFilter : public QSimpleCanvasFilter
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal alpha READ alpha WRITE setAlpha NOTIFY alphaChanged)
- Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
- Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
- Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
-public:
- QFxReflectionFilter(QObject *parent=0);
- virtual ~QFxReflectionFilter();
-
- qreal alpha() const;
- void setAlpha(qreal);
- int height() const;
- void setHeight(int);
- int offset();
- void setOffset(int);
- qreal scale() const;
- void setScale(qreal);
-
-Q_SIGNALS:
- void alphaChanged(qreal);
- void heightChanged(int);
- void offsetChanged(int);
- void scaleChanged(qreal);
-
-protected:
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
- virtual QRectF itemBoundingRect(const QRectF &r) const;
-
-private:
- Q_DISABLE_COPY(QFxReflectionFilter)
- QFxReflectionFilterPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxReflectionFilter)
-
-QT_END_HEADER
-
-#endif // QFXREFLECTIONFILTER_H
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index 0211ebb..a4dc809 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -57,12 +57,13 @@ QFxRepeaterPrivate::~QFxRepeaterPrivate()
QFxItem *QFxRepeaterPrivate::addItem(QmlContext *ctxt, QFxItem *lastItem)
{
+ Q_UNUSED(lastItem)
Q_Q(QFxRepeater);
QObject *nobj = component->create(ctxt);
QFxItem *item = qobject_cast<QFxItem *>(nobj);
if (item) {
item->setParent(q->itemParent());
- item->stackUnder(lastItem);
+// item->stackUnder(lastItem);
deletables << nobj;
} else {
delete nobj;
@@ -243,7 +244,7 @@ void QFxRepeater::componentComplete()
/*!
\internal
*/
-void QFxRepeater::parentChanged(QSimpleCanvasItem *o, QSimpleCanvasItem *n)
+void QFxRepeater::parentChanged(QFxItem *o, QFxItem *n)
{
QFxItem::parentChanged(o, n);
regenerate();
diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h
index b82b9b0..6f950d3 100644
--- a/src/declarative/fx/qfxrepeater.h
+++ b/src/declarative/fx/qfxrepeater.h
@@ -73,12 +73,12 @@ private:
protected:
virtual void componentComplete();
- virtual void parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *);
+ virtual void parentChanged(QFxItem *, QFxItem *);
QFxRepeater(QFxRepeaterPrivate &dd, QFxItem *parent);
private:
Q_DISABLE_COPY(QFxRepeater)
- Q_DECLARE_PRIVATE(QFxRepeater)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxRepeater)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxscalegrid.h b/src/declarative/fx/qfxscalegrid.h
index 03b2dd3..986bcda 100644
--- a/src/declarative/fx/qfxscalegrid.h
+++ b/src/declarative/fx/qfxscalegrid.h
@@ -45,7 +45,6 @@
#include <QtCore/QString>
#include <QtCore/QObject>
#include <QtDeclarative/qfxglobal.h>
-#include <QtDeclarative/qsimplecanvas.h>
#include <QtDeclarative/qfxpixmap.h>
#include <QtDeclarative/qml.h>
diff --git a/src/declarative/fx/qfxshadowfilter.cpp b/src/declarative/fx/qfxshadowfilter.cpp
deleted file mode 100644
index d37d565..0000000
--- a/src/declarative/fx/qfxshadowfilter.cpp
+++ /dev/null
@@ -1,214 +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 "qfxshadowfilter.h"
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glsave.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glbasicshaders.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QFxShadowFilterPrivate
-{
-public:
- QFxShadowFilterPrivate()
- : x(0), y(0)
- {
- }
-
- int x;
- int y;
-};
-
-/*!
- \qmlclass Shadow
- \brief The Shadow filter casts a drop shadow.
- \inherits Filter
-
- Shadows work on all visual elements - including transparent and masked
- images.
-
- \table
- \row
- \o \image shadow_example.png
- \o
- \qml
-Rect {
- radius: 5
- color: "lightsteelblue"
- width: 100
- height: 100
- filter: Shadow {
- yOffset: 8
- xOffset: 8
- }
-}
-
-Image {
- source: "pics/qtlogo.png"
- filter: Shadow {
- yOffset: 8
- xOffset: 8
- }
-}
- \endqml
- \endtable
-
- Shadows are only supported when Qt Qt Declarative is compiled for OpenGL ES 2.0.
- Otherwise the Shadow filter has no effect.
-*/
-
-/*!
- \internal
- \class QFxShadowFilter
- \ingroup group_effects
- \brief The QFxShadowFilter class allows you to add a shadow to an item.
-*/
-
-QFxShadowFilter::QFxShadowFilter(QObject *parent)
-: QSimpleCanvasFilter(parent), d(new QFxShadowFilterPrivate)
-{
-}
-
-QFxShadowFilter::~QFxShadowFilter()
-{
- delete d; d = 0;
-}
-
-/*!
- \qmlproperty int Shadow::xOffset
- \qmlproperty int Shadow::yOffset
-
- Specify the x and y offset of the shadow relative to the item.
-*/
-
-int QFxShadowFilter::xOffset() const
-{
- return d->x;
-}
-
-/*!
- \property QFxShadowFilter::xOffset
- \brief the x offset of the shadow relative to the item.
-*/
-void QFxShadowFilter::setXOffset(int offset)
-{
- if (d->x == offset) return;
- d->x = offset;
- emit offsetChanged(d->x, d->y);
-}
-
-/*!
- \property QFxShadowFilter::yOffset
- \brief the y offset of the shadow relative to the item.
-*/
-int QFxShadowFilter::yOffset() const
-{
- return d->y;
-}
-
-void QFxShadowFilter::setYOffset(int offset)
-{
- if (d->y == offset) return;
- d->y = offset;
- emit offsetChanged(d->x, d->y);
-}
-
-QRectF QFxShadowFilter::itemBoundingRect(const QRectF &r) const
-{
- QRectF rv = r;
- rv |= r.translated(xOffset(), yOffset());
- return rv;
-}
-
-void QFxShadowFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
-#if defined(QFX_RENDER_OPENGL2)
-
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
-
- QGLFramebufferObject *fbo = renderToFBO();
-
- float width = r.width();
- float height = r.height();
-
- float texWidth = width / float(fbo->width());
- float texHeight = height / float(fbo->height());
-
- GLfloat vertices[] = { d->x, height + d->y,
- width + d->x, height + d->y,
- d->x, d->y,
- d->x + width, d->y };
- GLfloat texVertices[] = { 0, 0,
- texWidth, 0,
- 0, texHeight,
- texWidth, texHeight };
-
- SingleTextureShadowShader *shader = item->basicShaders()->singleTextureShadow();
- shader->enable();
- shader->setOpacity(0.8 * p.activeOpacity);
- shader->setTransform(p.activeTransform);
-
- shader->setAttributeArray(SingleTextureShadowShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShadowShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- shader->disableAttributeArray(SingleTextureShadowShader::Vertices);
- shader->disableAttributeArray(SingleTextureShadowShader::TextureCoords);
-
- releaseFBO(fbo);
-
- renderToScreen();
-#else
- Q_UNUSED(p);
-#endif
-}
-
-QML_DEFINE_TYPE(QFxShadowFilter,Shadow)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxshadowfilter.h b/src/declarative/fx/qfxshadowfilter.h
deleted file mode 100644
index 1cbe54f..0000000
--- a/src/declarative/fx/qfxshadowfilter.h
+++ /dev/null
@@ -1,87 +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 QFXSHADOWFILTER_H
-#define QFXSHADOWFILTER_H
-
-#include <QtDeclarative/qsimplecanvasfilter.h>
-#include <QtDeclarative/qml.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QFxShadowFilterPrivate;
-class Q_DECLARATIVE_EXPORT QFxShadowFilter : public QSimpleCanvasFilter
-{
- Q_OBJECT
- Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
- Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
-public:
- QFxShadowFilter(QObject *parent=0);
- virtual ~QFxShadowFilter();
-
- int xOffset() const;
- void setXOffset(int offset);
-
- int yOffset() const;
- void setYOffset(int offset);
-
-Q_SIGNALS:
- void offsetChanged(int, int);
-
-protected:
- virtual QRectF itemBoundingRect(const QRectF &) const;
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
-
-private:
- QFxShadowFilterPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxShadowFilter)
-
-QT_END_HEADER
-
-#endif // QFXSHADOWFILTER_H
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index 57897ed..2bae53f 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -43,18 +43,13 @@
#include "qfxtext_p.h"
#include <private/qtextcontrol_p.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include "glbasicshaders.h"
-#endif
-
#include <private/qfxperf_p.h>
#include <QTextLayout>
#include <QTextLine>
#include <QTextDocument>
#include <QTextCursor>
#include <QGraphicsSceneMouseEvent>
-
+#include <QPainter>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxText,Text)
@@ -73,7 +68,7 @@ QML_DEFINE_TYPE(QFxText,Text)
\image declarative-text.png
- If height and width are not explicitly set, Text will attempt to determine how
+ If height and width are not explicitly set, Text will attempt to determine how
much room is needed and set it accordingly. Unless \c wrap is set, it will always
prefer width to height (all text will be placed on a single line).
@@ -91,7 +86,7 @@ QML_DEFINE_TYPE(QFxText,Text)
\brief The QFxText class provides a formatted text item that you can add to a QFxView.
- Text was designed for read-only text; it does not allow for any text editing.
+ Text was designed for read-only text; it does not allow for any text editing.
It can display both plain and rich text. For example:
\qml
@@ -101,7 +96,7 @@ QML_DEFINE_TYPE(QFxText,Text)
\image text.png
- If height and width are not explicitly set, Text will attempt to determine how
+ If height and width are not explicitly set, Text will attempt to determine how
much room is needed and set it accordingly. Unless \c wrap is set, it will always
prefer width to height (all text will be placed on a single line).
@@ -166,9 +161,9 @@ void QFxText::setText(const QString &n)
if (d->richText) {
if (!d->doc)
{
- d->control = new QTextControl(this);
+ d->control = new QTextControl(this);
d->control->setTextInteractionFlags(Qt::TextBrowserInteraction);
- d->doc = d->control->document();
+ d->doc = d->control->document();
d->doc->setDocumentMargin(0);
}
d->doc->setHtml(n);
@@ -304,8 +299,8 @@ QColor QFxText::styleColor() const
Sets the horizontal and vertical alignment of the text within the Text items
width and height. By default, the text is top-left aligned.
- The valid values for \c hAlign are \c AlignLeft, \c AlignRight and
- \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom
+ The valid values for \c hAlign are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom
and \c AlignVCenter.
*/
@@ -484,7 +479,7 @@ QString QFxText::activeLink() const
return d->activeLink;
}
-void QFxText::geometryChanged(const QRectF &newGeometry,
+void QFxText::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
Q_D(QFxText);
@@ -521,7 +516,7 @@ void QFxTextPrivate::updateSize()
QSize size(0, 0);
//setup instance of QTextLayout for all cases other than richtext
- if (!richText)
+ if (!richText)
{
tmp = text;
tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
@@ -550,7 +545,7 @@ void QFxTextPrivate::updateSize()
dy -= (int)doc->size().height();
} else {
dy -= size.height();
- }
+ }
int yoff = 0;
if (q->heightValid()) {
@@ -560,7 +555,7 @@ void QFxTextPrivate::updateSize()
yoff = dy/2;
}
q->setBaselineOffset(fm.ascent() + yoff);
-
+
if (!q->widthValid()) {
int newWidth = (richText ? (int)doc->idealWidth() : size.width());
q->setImplicitWidth(newWidth);
@@ -580,13 +575,6 @@ void QFxTextPrivate::updateSize()
// ### text layout handling should be profiled and optimized as needed
// what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine);
-void QFxText::dump(int depth)
-{
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << propertyInfo();
- QFxItem::dump(depth);
-}
-
QString QFxText::propertyInfo() const
{
Q_D(const QFxText);
@@ -657,7 +645,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout)
QTextLine line = layout->createLine();
if (!line.isValid())
break;
-
+
if ((wrap || elideMode != Qt::ElideNone) && q->widthValid())
line.setLineWidth(lineWidth);
}
@@ -698,7 +686,7 @@ QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle)
if (drawStyle) {
p.setPen(styleColor);
}
- else
+ else
p.setPen(color);
p.setFont(f);
layout.draw(&p, QPointF(0, 0));
@@ -765,10 +753,6 @@ void QFxTextPrivate::checkImgCache()
break;
}
-#if defined(QFX_RENDER_OPENGL)
- tex.setImage(imgCache.toImage(), GLTexture::PowerOfTwo);
-#endif
-
imgDirty = false;
}
@@ -787,7 +771,6 @@ void QFxText::setSmoothTransform(bool s)
update();
}
-#if defined(QFX_RENDER_QPAINTER)
void QFxText::paintContents(QPainter &p)
{
Q_D(QFxText);
@@ -830,7 +813,7 @@ void QFxText::paintContents(QPainter &p)
break;
}
- bool needClip = !clip() && (d->imgCache.width() > width() ||
+ bool needClip = !clip() && (d->imgCache.width() > width() ||
d->imgCache.height() > height());
if (needClip) {
@@ -847,85 +830,6 @@ void QFxText::paintContents(QPainter &p)
}
}
-#elif defined(QFX_RENDER_OPENGL2)
-void QFxText::paintGLContents(GLPainter &p)
-{
- //return;
- Q_D(QFxText);
- d->checkImgCache();
- if (d->imgCache.isNull())
- return;
-
- int w = width();
- int h = height();
-
- float x = 0;
- float y = 0;
-
- switch (d->hAlign) {
- case AlignLeft:
- x = 0;
- break;
- case AlignRight:
- x = w - d->imgCache.width();
- break;
- case AlignHCenter:
- x = (w - d->imgCache.width()) / 2;
- break;
- }
-
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->imgCache.height();
- break;
- case AlignVCenter:
- y = (h - d->imgCache.height()) / 2;
- break;
- }
-
- float widthV = d->imgCache.width();
- float heightV = d->imgCache.height();
- float glWidth = d->tex.glWidth();
- float glHeight = d->tex.glHeight();
-
- QGLShaderProgram *shader = p.useTextureShader();
-
- float deltaX = 0.5 / qreal(d->tex.glSize().width());
- float deltaY = 0.5 / qreal(d->tex.glSize().height());
- glWidth -= deltaX;
- glHeight -= deltaY;
-
- GLfloat vertices[] = { x, y + heightV,
- x + widthV, y + heightV,
- x, y,
-
- x + widthV, y + heightV,
- x, y,
- x + widthV, y };
-
- GLfloat texVertices[] = { deltaX, deltaY,
- glWidth, deltaY,
- deltaX, glHeight,
-
- glWidth, deltaY,
- deltaX, glHeight,
- glWidth, glHeight };
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, d->tex.texture());
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- shader->disableAttributeArray(SingleTextureShader::Vertices);
- shader->disableAttributeArray(SingleTextureShader::TextureCoords);
-}
-
-#endif
-
void QFxText::componentComplete()
{
Q_D(QFxText);
@@ -958,7 +862,7 @@ void QFxText::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!event->isAccepted())
QFxItem::mousePressEvent(event);
-
+
}
/*!
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index bd91f0e..b7ec333 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -125,14 +125,9 @@ public:
bool smoothTransform() const;
void setSmoothTransform(bool);
- virtual void dump(int depth);
virtual QString propertyInfo() const;
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &p);
-#elif defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
-#endif
virtual void componentComplete();
@@ -153,7 +148,7 @@ protected:
private:
Q_DISABLE_COPY(QFxText)
- Q_DECLARE_PRIVATE(QFxText)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxText)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h
index 670b685..6692d9e 100644
--- a/src/declarative/fx/qfxtext_p.h
+++ b/src/declarative/fx/qfxtext_p.h
@@ -58,10 +58,6 @@
#include "qml.h"
#include <QtGui/qtextlayout.h>
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
QT_BEGIN_NAMESPACE
class QTextLayout;
@@ -116,9 +112,6 @@ public:
QColor styleColor;
QString activeLink;
bool imgDirty;
-#if defined(QFX_RENDER_OPENGL)
- GLTexture tex;
-#endif
QPixmap imgCache;
QPixmap imgStyleCache;
QFxText::HAlignment hAlign;
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index c2bda6f..f9cde7c 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -41,13 +41,7 @@
#include <qfxtextedit.h>
#include "qfxtextedit_p.h"
-
#include <private/qtextcontrol_p.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include "glbasicshaders.h"
-#endif
-
#include <private/qfxperf_p.h>
#include "qfxevents_p.h"
#include <QTextLayout>
@@ -56,7 +50,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QDebug>
-
+#include <QPainter>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxTextEdit, TextEdit)
@@ -72,7 +66,6 @@ TextEdit {
id: edit
text: "<b>Hello</b> <i>World!</i>"
focus: true
- focusable: true
font.family: "Helvetica"
font.size: 20
color: "blue"
@@ -360,8 +353,8 @@ void QFxTextEdit::setHighlightedTextColor(const QColor &color)
Sets the horizontal and vertical alignment of the text within the TextEdit items
width and height. By default, the text is top-left aligned.
- The valid values for \c hAlign are \c AlignLeft, \c AlignRight and
- \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom
+ The valid values for \c hAlign are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom
and \c AlignVCenter.
*/
@@ -542,7 +535,7 @@ void QFxTextEdit::loadCursorDelegate()
d->cursor->setHeight(QFontMetrics(d->font.font()).height());
moveCursorDelegate();
}else{
- qWarning() << "Error loading cursor delegate for TextEdit:" + objectName();
+ qWarning() << QLatin1String("Error loading cursor delegate for TextEdit:") + objectName();
}
}
@@ -677,7 +670,7 @@ void QFxTextEdit::setTextMargin(qreal margin)
d->document->setDocumentMargin(d->textMargin);
}
-void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
+void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
if (newGeometry.width() != oldGeometry.width())
@@ -686,16 +679,6 @@ void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
}
/*!
- \internal
-*/
-void QFxTextEdit::dump(int depth)
-{
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << propertyInfo();
- QFxPaintedItem::dump(depth);
-}
-
-/*!
\internal
*/
QString QFxTextEdit::propertyInfo() const
@@ -779,7 +762,7 @@ Qt::TextInteractionFlags QFxTextEdit::textInteractionFlags() const
}
/*!
- Returns the cursor for the point at the given \a pos on the
+ Returns the cursor for the point at the given \a pos on the
text edit.
*/
QTextCursor QFxTextEdit::cursorForPosition(const QPoint &pos) const
@@ -1147,9 +1130,9 @@ void QFxTextEdit::updateSize()
if (!heightValid()) {
if (d->text.isEmpty()) {
setImplicitHeight(fm.height());
- } else {
+ } else {
setImplicitHeight((int)d->document->size().height());
- }
+ }
}
setContentsSize(QSize(width(), height()));
} else {
@@ -1163,7 +1146,7 @@ void QFxTextEditPrivate::updateDefaultTextOption()
QTextOption opt = document->defaultTextOption();
int oldAlignment = opt.alignment();
opt.setAlignment((Qt::Alignment)(int)(hAlign | vAlign));
-
+
QTextOption::WrapMode oldWrapMode = opt.wrapMode();
if (wrap)
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 80636e2..77fac29 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -161,7 +161,6 @@ public:
qreal textMargin() const;
void setTextMargin(qreal margin);
- virtual void dump(int depth);
virtual QString propertyInfo() const;
virtual void componentComplete();
@@ -229,7 +228,7 @@ private:
friend class QmlFont;
Q_DISABLE_COPY(QFxTextEdit)
- Q_DECLARE_PRIVATE(QFxTextEdit)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxTextEdit)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index b7d667e..45a8a60 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -71,7 +71,7 @@ public:
: 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), lastSelectionStart(0), lastSelectionEnd(0),
- cursor(0), cursorComponent(0), format(QFxTextEdit::AutoText), document(0)
+ cursorComponent(0), cursor(0), format(QFxTextEdit::AutoText), document(0)
{
}
@@ -89,9 +89,6 @@ public:
QString style;
QColor styleColor;
bool imgDirty;
-#if defined(QFX_RENDER_OPENGL)
- GLTexture texture;
-#endif
QPixmap imgCache;
QPixmap imgStyleCache;
QFxTextEdit::HAlignment hAlign;
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index 0f0ce80..f08d830 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -71,9 +71,9 @@ bool QFxTransform::isIdentity() const
return true;
}
-QSimpleCanvas::Matrix QFxTransform::transform() const
+QTransform QFxTransform::transform() const
{
- return QSimpleCanvas::Matrix();
+ return QTransform();
}
void QFxTransform::update()
@@ -181,7 +181,6 @@ bool QFxScale::isIdentity() const
return (_xScale == 1. && _yScale == 1.);
}
-#if defined(QFX_RENDER_QPAINTER)
QTransform QFxScale::transform() const
{
if (_dirty) {
@@ -193,19 +192,6 @@ QTransform QFxScale::transform() const
}
return _transform;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxScale::transform() const
-{
- if (_dirty) {
- _transform = QMatrix4x4();
- _dirty = false;
- _transform.translate(_originX, _originY);
- _transform.scale(_xScale, _yScale);
- _transform.translate(-_originX, -_originY);
- }
- return _transform;
-}
-#endif
void QFxScale::update()
{
@@ -387,7 +373,6 @@ bool QFxRotation::isIdentity() const
return (_angle == 0.);
}
-#if defined(QFX_RENDER_QPAINTER)
QTransform QFxRotation::transform() const
{
if (_dirty) {
@@ -399,19 +384,6 @@ QTransform QFxRotation::transform() const
}
return _transform;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxRotation::transform() const
-{
- if (_dirty) {
- _transform = QMatrix4x4();
- _dirty = false;
- _transform.translate(_originX, _originY);
- _transform.rotate(_angle, 0, 0, 1);
- _transform.translate(-_originX, -_originY);
- }
- return _transform;
-}
-#endif
void QFxRotation::update()
{
@@ -484,7 +456,6 @@ bool QFxRotation3D::isIdentity() const
return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
}
-#if defined(QFX_RENDER_QPAINTER)
const qreal inv_dist_to_plane = 1. / 1024.;
QTransform QFxRotation3D::transform() const
{
@@ -529,29 +500,6 @@ QTransform QFxRotation3D::transform() const
return _transform;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxRotation3D::transform() const
-{
- if (_dirty) {
- _dirty = false;
- _transform = QMatrix4x4();
-
- if (!isIdentity()) {
- if (angle() != 0.) {
- qreal x = _axis.endX() - _axis.startX();
- qreal y = _axis.endY() - _axis.startY();
- qreal z = _axis.endZ();
-
- _transform.translate(_axis.startX(), _axis.startY(), 0);
- _transform.rotate(angle(), x, y, z);
- _transform.translate(-_axis.startX(), -_axis.startY(), 0);
- }
- }
- }
-
- return _transform;
-}
-#endif
void QFxRotation3D::update()
{
@@ -639,7 +587,6 @@ bool QFxTranslation3D::isIdentity() const
return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
}
-#if defined(QFX_RENDER_QPAINTER)
QTransform QFxTranslation3D::transform() const
{
if (_dirty) {
@@ -659,35 +606,14 @@ QTransform QFxTranslation3D::transform() const
return _transform;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxTranslation3D::transform() const
-{
- if (_dirty) {
- _dirty = false;
- _transform = QMatrix4x4();
-
- if (!isIdentity()) {
- if (distance() != 0.)
- _transform.translate((_axis.endX() - _axis.startX()) * distance(),
- (_axis.endY() - _axis.startY()) * distance(),
- (_axis.endZ()) * distance());
-
- }
- }
-
- return _transform;
-}
-#endif
void QFxTranslation3D::update()
{
_dirty = true;
-#if !defined(QFX_RENDER_OPENGL)
if (_axis.endZ() != 0. && distance() != 0.) {
qmlInfo(this) << "QTransform cannot translate along Z-axis.";
}
-#endif
QFxTransform::update();
}
@@ -712,24 +638,6 @@ QFxPerspective::~QFxPerspective()
{
}
-#if defined(QFX_RENDER_OPENGL)
-bool QFxPerspective::isIdentity() const
-{
- return false;
-}
-
-QMatrix4x4 QFxPerspective::transform() const
-{
- QMatrix4x4 rv;
- rv.translate(_x, _y);
- rv.perspective(_angle, _aspect, 1, 1024 * 1024);
- rv.translate(-_x, -_y, -1);
- rv.scale(1, 1, 1. / _scale);
-
- return rv;
-}
-#endif
-
/*!
\qmlproperty real Perspective::angle
*/
@@ -996,7 +904,6 @@ bool QFxSquish::isIdentity() const
return false;
}
-#if defined(QFX_RENDER_QPAINTER)
QTransform QFxSquish::transform() const
{
QPolygonF poly;
@@ -1008,21 +915,5 @@ QTransform QFxSquish::transform() const
QTransform::quadToQuad(poly, poly2, t);
return t;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxSquish::transform() const
-{
- QPolygonF poly;
- poly << p << QPointF(p.x() + s.width(), p.y()) << QPointF(p.x() + s.width(), p.y() + s.height()) << QPointF(p.x(), p.y() + s.height());
- QPolygonF poly2;
- poly2 << p1 << p2 << p4 << p3;
-
- QTransform t;
- QMatrix4x4 rv;
- if (QTransform::quadToQuad(poly, poly2, t))
- rv = QMatrix4x4(t);
-
- return rv;
-}
-#endif
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
index e0bd276..fb49294 100644
--- a/src/declarative/fx/qfxtransform.h
+++ b/src/declarative/fx/qfxtransform.h
@@ -44,9 +44,6 @@
#include <QtCore/QObject>
#include <QtGui/QTransform>
-#if defined(QFX_RENDER_OPENGL)
-#include <QtGui/qmatrix4x4.h>
-#endif
#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
@@ -65,7 +62,7 @@ public:
void update();
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
};
class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform
@@ -93,7 +90,7 @@ public:
void setYScale(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
Q_SIGNALS:
void scaleChanged();
@@ -107,7 +104,7 @@ private:
qreal _yScale;
mutable bool _dirty;
- mutable QSimpleCanvas::Matrix _transform;
+ mutable QTransform _transform;
};
class Q_DECLARATIVE_EXPORT QFxAxis : public QObject
@@ -170,7 +167,7 @@ public:
void setAngle(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
Q_SIGNALS:
void angleChanged();
@@ -183,7 +180,7 @@ private:
qreal _angle;
mutable bool _dirty;
- mutable QSimpleCanvas::Matrix _transform;
+ mutable QTransform _transform;
};
class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform
@@ -202,7 +199,7 @@ public:
void setAngle(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
private Q_SLOTS:
void update();
@@ -211,7 +208,7 @@ private:
qreal _angle;
mutable bool _dirty;
- mutable QSimpleCanvas::Matrix _transform;
+ mutable QTransform _transform;
};
class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform
@@ -230,7 +227,7 @@ public:
void setDistance(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
private Q_SLOTS:
void update();
@@ -239,7 +236,7 @@ private:
qreal _distance;
mutable bool _dirty;
- mutable QSimpleCanvas::Matrix _transform;
+ mutable QTransform _transform;
};
class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform
@@ -270,10 +267,6 @@ public:
qreal scale() const { return _scale; }
void setScale(qreal v) { _scale = v; update(); }
-#if defined(QFX_RENDER_OPENGL)
- virtual bool isIdentity() const;
- virtual QMatrix4x4 transform() const;
-#endif
private:
qreal _scale;
qreal _x;
@@ -339,7 +332,7 @@ public:
void setbottomRight_x(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
private:
QPointF p;
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index 0682294..1b15a48 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -51,6 +51,7 @@
#include "qmlopenmetaobject.h"
#include "qmllistaccessor.h"
#include "qfxvisualitemmodel.h"
+#include <QtCore/qdebug.h>
QML_DECLARE_TYPE(QListModelInterface)
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index c6a8ebf..a3dca79e 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -43,6 +43,8 @@
#include <QPen>
#include <QFile>
#include <QEvent>
+#include <QMouseEvent>
+#include <QKeyEvent>
#include <QBasicTimer>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
@@ -56,19 +58,9 @@
#include "qmlstate.h"
#include "qfxtransform.h"
#include "qfxscalegrid.h"
-#include "qsimplecanvas.h"
#include "qlistmodelinterface.h"
-#if defined(QFX_RENDER_OPENGL2)
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glsave.h>
-#endif
-#if defined(QFX_RENDER_OPENGL)
-#include <gltexture.h>
-#endif
-
#include "qfxwebview.h"
-#include <qsimplecanvasfilter.h>
#include <private/qfxpainteditem_p.h>
QT_BEGIN_NAMESPACE
@@ -247,7 +239,6 @@ void QFxWebView::init()
setAcceptedMouseButtons(Qt::LeftButton);
setOptions(HasContents | MouseEvents);
- setFocusable(true);
d->page = 0;
}
@@ -465,11 +456,51 @@ void QFxWebView::paintPage(const QRect& r)
update();
}
-void QFxWebView::dump(int depth)
+/*!
+ \qmlproperty int WebView::cacheSize
+
+ This property holds the maximum number of pixels of image cache to
+ allow. The default is 0.1 megapixels. The cache will not be larger
+ than the (unscaled) size of the WebView.
+*/
+
+/*!
+ \property QFxWebView::cacheSize
+
+ The maximum number of pixels of image cache to allow. The default
+ is 0.1 megapixels. The cache will not be larger than the (unscaled)
+ size of the QFxWebView.
+*/
+int QFxWebView::cacheSize() const
{
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << "url:" << url();
- QFxPaintedItem::dump(depth);
+ Q_D(const QFxWebView);
+ return d->max_imagecache_size;
+}
+
+void QFxWebView::setCacheSize(int pixels)
+{
+ Q_D(QFxWebView);
+ if (pixels < d->max_imagecache_size) {
+ int cachesize=0;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ QRect area = d->imagecache[i]->area;
+ cachesize += area.width()*area.height();
+ }
+ while (d->imagecache.count() && cachesize > pixels) {
+ int oldest=-1;
+ int age=-1;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ int a = d->imagecache[i]->age;
+ if (a > age) {
+ oldest = i;
+ age = a;
+ }
+ }
+ cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
+ d->imagecache.removeAt(oldest);
+ }
+ }
+ d->max_imagecache_size = pixels;
}
void QFxWebView::drawContents(QPainter *p, const QRect &r)
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index f5fd721..ab20281 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -139,7 +139,6 @@ public:
QAction *forwardAction() const;
QAction *stopAction() const;
- virtual void dump(int depth);
virtual QString propertyInfo() const;
QWebPage *page() const;
@@ -160,6 +159,9 @@ public:
QString status() const;
+ int cacheSize() const;
+ void setCacheSize(int pixels);
+
Q_SIGNALS:
void idealWidthChanged();
void idealHeightChanged();
@@ -204,7 +206,7 @@ private:
void init();
virtual void componentComplete();
Q_DISABLE_COPY(QFxWebView)
- Q_DECLARE_PRIVATE(QFxWebView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxWebView)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxwidgetcontainer.cpp b/src/declarative/fx/qfxwidgetcontainer.cpp
deleted file mode 100644
index 421c2f7..0000000
--- a/src/declarative/fx/qfxwidgetcontainer.cpp
+++ /dev/null
@@ -1,108 +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 "qfxwidgetcontainer.h"
-#include <qsimplecanvas.h>
-#include <qgraphicswidget.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass WidgetContainer QFxWidgetContainer
- \brief The WidgetContainer element allows you to add QGraphicsWidgets into Fluid UI elements.
-*/
-
-/*!
- \internal
- \class QFxWidgetContainer
- \brief The QFxWidgetContainer class allows you to add QGraphicsWidgets into Fluid UI applications.
-*/
-
-QML_DEFINE_TYPE(QFxWidgetContainer, WidgetContainer)
-
-QFxWidgetContainer::QFxWidgetContainer(QFxItem *parent)
-: QFxItem(parent), _graphicsWidget(0)
-{
-}
-
-QFxWidgetContainer::~QFxWidgetContainer()
-{
-}
-
-QGraphicsWidget *QFxWidgetContainer::graphicsWidget() const
-{
- return _graphicsWidget;
-}
-
-/*!
- \qmlproperty QGraphicsWidget QFxWidgetContainer::graphicsWidget
- The QGraphicsWidget associated with this element.
-*/
-void QFxWidgetContainer::setGraphicsWidget(QGraphicsWidget *widget)
-{
- if (widget == _graphicsWidget)
- return;
-
- _graphicsWidget = widget;
-
- QSimpleCanvas *c = canvas();
- if (!c)
- return;
-
- if (c->canvasMode() != QSimpleCanvas::GraphicsView) {
- qWarning("QFxWidgetContainer: Cannot add a widget to a non-graphicsview canvas. You might need to set QFX_USE_GRAPHICSVIEW=1");
- return;
- }
-
- QGraphicsItem *item = (QGraphicsItem *)(*this);
- _graphicsWidget->setParentItem(item);
-}
-
-void QFxWidgetContainer::canvasChanged()
-{
- if (_graphicsWidget) {
- QGraphicsWidget *w = _graphicsWidget;
- _graphicsWidget = 0;
- setGraphicsWidget(w);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/opengl/glbasicshaders.cpp b/src/declarative/opengl/glbasicshaders.cpp
deleted file mode 100644
index 7c1d730..0000000
--- a/src/declarative/opengl/glbasicshaders.cpp
+++ /dev/null
@@ -1,707 +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 "glbasicshaders.h"
-#include <QDebug>
-#include <QColor>
-
-
-QT_BEGIN_NAMESPACE
-SingleTextureVertexOpacityShader::SingleTextureVertexOpacityShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- attribute highp vec4 myVertex;\
- attribute lowp float myOpacity;\
- attribute mediump vec4 myUV;\
- uniform mediump mat4 myPMVMatrix;\
- varying mediump vec2 myTexCoord;\
- varying lowp float myFragOpacity;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex;\
- myTexCoord = myUV.st;\
- myFragOpacity = myOpacity;\
- }"
- );
-
- frag.compile("\
- uniform sampler2D sampler2d;\
- varying mediump vec2 myTexCoord;\
- varying lowp float myFragOpacity;\
- void main(void)\
- {\
- mediump vec4 frag = texture2D(sampler2d,myTexCoord);\
- gl_FragColor = vec4(frag.rgb, frag.a * myFragOpacity);\
- }"
- );
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
- bindAttributeLocation("myUV", TextureCoords);
- bindAttributeLocation("myOpacity", OpacityCoords);
-}
-
-bool SingleTextureVertexOpacityShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- enable();
- setUniformValue("sampler2d", 0);
- disable();
- return true;
-}
-
-void SingleTextureVertexOpacityShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-BlurTextureShader::BlurTextureShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- attribute highp vec4 myVertex;\
- attribute mediump vec4 myUV;\
- uniform mediump mat4 myPMVMatrix;\
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex;\
- myTexCoord = myUV.st;\
- }"
- );
-
-#if 0
- frag.compile("\
- uniform sampler2D sampler2d;\
- uniform bool horizontal; \
- uniform mediump float blurStep; \
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- mediump vec4 accum = vec4(0, 0, 0, 0); \
- mediump vec2 offset; \
- if (horizontal) \
- offset = vec2(blurStep, 0); \
- else \
- offset = vec2(0, blurStep); \
- accum += texture2D(sampler2d, myTexCoord + 2.0 * offset); \
- accum += 2.0 * texture2D(sampler2d, myTexCoord + 1.0 * offset); \
- accum += 4.0 * texture2D(sampler2d, myTexCoord + 0.0 * offset); \
- accum += 2.0 * texture2D(sampler2d, myTexCoord - 1.0 * offset); \
- accum += texture2D(sampler2d, myTexCoord - 2.0 * offset); \
- gl_FragColor = accum / 10.0; \
- }"
- );
-#else
- frag.compile("\
- uniform sampler2D sampler2d;\
- uniform bool horizontal; \
- uniform mediump float blurStep; \
- uniform int blurSteps; \
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- mediump vec4 accum = vec4(0, 0, 0, 0); \
- mediump vec2 offset; \
- if (horizontal) \
- offset = vec2(blurStep, 0); \
- else \
- offset = vec2(0, blurStep); \
- mediump float sum = 0.0; \
- for (int ii = 0; ii < blurSteps; ++ii) { \
- mediump float frac = float(blurSteps - ii) / float(blurSteps); \
- mediump vec2 coord = myTexCoord + -float(ii) * offset; \
- if (coord.x >= 0.0 && coord.y >= 0.0 && coord.y <= 1.0 && coord.x <=1.0) \
- accum += texture2D(sampler2d, coord) * frac; \
- sum += frac; \
- } \
- for (int ii = 1; ii < blurSteps; ++ii) { \
- mediump float frac = float(blurSteps - ii) / float(blurSteps); \
- mediump vec2 coord = myTexCoord + float(ii) * offset; \
- if (coord.x <= 1.0 && coord.y <= 1.0 && coord.x >= 0.0 && coord.y >= 0.0) \
- accum += texture2D(sampler2d, coord) * frac; \
- sum += frac; \
- } \
- gl_FragColor = accum / sum; \
- }"
- );
-#endif
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
- bindAttributeLocation("myUV", TextureCoords);
-}
-
-bool BlurTextureShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- mode = uniformLocation("horizontal");
- step = uniformLocation("blurStep");
- steps = uniformLocation("blurSteps");
- enable();
- setUniformValue("sampler2d", 0);
- disable();
- return true;
-}
-
-void BlurTextureShader::setStep(float f)
-{
- setUniformValue(step, f);
-}
-
-void BlurTextureShader::setSteps(int s)
-{
- setUniformValue(steps, s);
-}
-
-void BlurTextureShader::setMode(Mode m)
-{
- if (m == Horizontal)
- setUniformValue(mode, 1);
- else
- setUniformValue(mode, 0);
-}
-
-void BlurTextureShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-DualTextureBlendShader::DualTextureBlendShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- attribute highp vec4 myVertex;\
- attribute mediump vec4 myUV;\
- attribute mediump vec4 myBlendUV;\
- uniform mediump mat4 myPMVMatrix;\
- varying mediump vec2 myTexCoord;\
- varying mediump vec2 myBlendTexCoord;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex;\
- myTexCoord = myUV.st;\
- myBlendTexCoord = myBlendUV.st;\
- }"
- );
-
- frag.compile("\
- uniform sampler2D sampler2d;\
- uniform sampler2D sampler2dBlend;\
- uniform lowp float myOpacity;\
- uniform lowp float myBlend; \
- varying mediump vec2 myTexCoord;\
- varying mediump vec2 myBlendTexCoord;\
- void main(void)\
- {\
- mediump vec4 tex = texture2D(sampler2d,myTexCoord);\
- mediump vec4 blendtex = texture2D(sampler2dBlend, myBlendTexCoord);\
- gl_FragColor = mix(tex, blendtex, myBlend) * myOpacity; \
- }"
- );
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
- bindAttributeLocation("myUV", TextureCoords);
- bindAttributeLocation("myBlendUV", BlendTextureCoords);
-}
-
-bool DualTextureBlendShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- opacity = uniformLocation("myOpacity");
- blend = uniformLocation("myBlend");
- enable();
- setUniformValue("sampler2d", 0);
- setUniformValue("sampler2dBlend", 1);
- disable();
- return true;
-}
-
-void DualTextureBlendShader::setOpacity(GLfloat o)
-{
- setUniformValue(opacity, o);
-}
-
-void DualTextureBlendShader::setBlend(GLfloat b)
-{
- setUniformValue(blend, b);
-}
-
-void DualTextureBlendShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-DualTextureAddShader::DualTextureAddShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- attribute highp vec4 myVertex;\
- attribute mediump vec4 myUV;\
- attribute mediump vec4 myAddUV;\
- uniform mediump mat4 myPMVMatrix;\
- varying mediump vec2 myTexCoord;\
- varying mediump vec2 myAddTexCoord;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex;\
- myTexCoord = myUV.st;\
- myAddTexCoord = myAddUV.st;\
- }"
- );
-
- frag.compile("\
- uniform sampler2D sampler2d;\
- uniform sampler2D sampler2dAdd;\
- uniform lowp float myOpacity;\
- varying mediump vec2 myTexCoord;\
- varying mediump vec2 myAddTexCoord;\
- void main(void)\
- {\
- mediump vec4 tex = texture2D(sampler2d,myTexCoord);\
- mediump vec4 addtex = texture2D(sampler2dAdd, myAddTexCoord);\
- tex = tex + vec4(addtex.rgb * addtex.a * tex.a, 0); \
- tex = min(tex, vec4(1, 1, 1, 1)); \
- gl_FragColor = vec4(tex.rgb, tex.a) * myOpacity;\
- }"
- );
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
- bindAttributeLocation("myUV", TextureCoords);
- bindAttributeLocation("myAddUV", AddTextureCoords);
-}
-
-void DualTextureAddShader::setOpacity(GLfloat f)
-{
- setUniformValue(opacity, f);
-}
-
-void DualTextureAddShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-bool DualTextureAddShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- opacity = uniformLocation("myOpacity");
- enable();
- setUniformValue("sampler2d", 0);
- setUniformValue("sampler2dAdd", 1);
- disable();
- return true;
-}
-
-SingleTextureShader::SingleTextureShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- attribute highp vec4 myVertex;\
- attribute mediump vec4 myUV;\
- uniform mediump mat4 myPMVMatrix;\
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex;\
- myTexCoord = myUV.st;\
- }"
- );
-
- frag.compile("\
- uniform sampler2D sampler2d;\
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- gl_FragColor = texture2D(sampler2d,myTexCoord);\
- }"
- );
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
- bindAttributeLocation("myUV", TextureCoords);
-}
-
-bool SingleTextureShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- enable();
- setUniformValue("sampler2d", 0);
- disable();
- return true;
-}
-
-void SingleTextureShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-ConstantColorShader::ConstantColorShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- uniform mediump mat4 myPMVMatrix;\
- attribute highp vec4 myVertex;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex; \
- }"
- );
-
- frag.compile("\
- uniform lowp vec4 myColor;\
- void main(void)\
- {\
- gl_FragColor = myColor;\
- }"
- );
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
-}
-
-void ConstantColorShader::setColor(const QColor &c)
-{
- setUniformValue(color, c);
-}
-
-void ConstantColorShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-bool ConstantColorShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- color = uniformLocation("myColor");
- return true;
-}
-
-ColorShader::ColorShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- uniform mediump mat4 myPMVMatrix;\
- attribute highp vec4 myVertex;\
- attribute lowp vec4 myColors;\
- varying lowp vec4 myColor;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex; \
- myColor = myColors; \
- }"
- );
-
- frag.compile("\
- varying lowp vec4 myColor;\
- void main(void)\
- {\
- gl_FragColor = myColor;\
- }"
- );
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
- bindAttributeLocation("myColors", Colors);
-}
-
-void ColorShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-bool ColorShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- return true;
-}
-
-class GLBasicShadersPrivate
-{
-public:
- GLBasicShadersPrivate();
- ~GLBasicShadersPrivate();
-
- BlurTextureShader *blurTexture;
- SingleTextureShader *singleTexture;
- SingleTextureOpacityShader *singleTextureOpacity;
- DualTextureAddShader *dualTextureAdd;
- SingleTextureShadowShader *singleTextureShadow;
- SingleTextureVertexOpacityShader *singleTextureVertexOpacity;
- ConstantColorShader *constantColor;
- ColorShader *color;
-};
-
-GLBasicShadersPrivate::GLBasicShadersPrivate()
-: blurTexture(0), singleTexture(0), singleTextureOpacity(0),
- dualTextureAdd(0), singleTextureShadow(0), singleTextureVertexOpacity(0),
- constantColor(0), color(0)
-{
-}
-
-GLBasicShadersPrivate::~GLBasicShadersPrivate()
-{
- delete blurTexture;
- delete singleTexture;
- delete singleTextureOpacity;
- delete dualTextureAdd;
- delete singleTextureVertexOpacity;
- delete singleTextureShadow;
- delete constantColor;
- delete color;
-}
-
-GLBasicShaders::GLBasicShaders()
-: d(new GLBasicShadersPrivate)
-{
-}
-
-GLBasicShaders::~GLBasicShaders()
-{
- delete d;
-}
-
-BlurTextureShader *GLBasicShaders::blurTexture()
-{
- if (!d->blurTexture) d->blurTexture = new BlurTextureShader();
- return d->blurTexture;
-}
-
-SingleTextureShader *GLBasicShaders::singleTexture()
-{
- if (!d->singleTexture) d->singleTexture = new SingleTextureShader();
- return d->singleTexture;
-}
-
-SingleTextureOpacityShader *GLBasicShaders::singleTextureOpacity()
-{
- if (!d->singleTextureOpacity) d->singleTextureOpacity = new SingleTextureOpacityShader();
- return d->singleTextureOpacity;
-}
-
-DualTextureAddShader *GLBasicShaders::dualTextureAdd()
-{
- if (!d->dualTextureAdd) d->dualTextureAdd = new DualTextureAddShader();
- return d->dualTextureAdd;
-}
-
-SingleTextureVertexOpacityShader *GLBasicShaders::singleTextureVertexOpacity()
-{
- if (!d->singleTextureVertexOpacity) d->singleTextureVertexOpacity = new SingleTextureVertexOpacityShader();
- return d->singleTextureVertexOpacity;
-}
-
-SingleTextureShadowShader *GLBasicShaders::singleTextureShadow()
-{
- if (!d->singleTextureShadow) d->singleTextureShadow = new SingleTextureShadowShader();
- return d->singleTextureShadow;
-}
-
-ConstantColorShader *GLBasicShaders::constantColor()
-{
- if (!d->constantColor) d->constantColor = new ConstantColorShader();
- return d->constantColor;
-}
-
-ColorShader *GLBasicShaders::color()
-{
- if (!d->color) d->color = new ColorShader();
- return d->color;
-}
-
-SingleTextureOpacityShader::SingleTextureOpacityShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- attribute highp vec4 myVertex;\
- attribute mediump vec4 myUV;\
- uniform mediump mat4 myPMVMatrix;\
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex;\
- myTexCoord = myUV.st;\
- }"
- );
-
- frag.compile("\
- uniform sampler2D sampler2d;\
- uniform lowp float myOpacity;\
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- mediump vec4 tex = texture2D(sampler2d,myTexCoord);\
- gl_FragColor = vec4(tex.rgb, myOpacity * tex.a);\
- }"
- );
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
- bindAttributeLocation("myUV", TextureCoords);
-}
-
-bool SingleTextureOpacityShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- opacity = uniformLocation("myOpacity");
- enable();
- setUniformValue("sampler2d", 0);
- disable();
- return true;
-}
-
-void SingleTextureOpacityShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-void SingleTextureOpacityShader::setOpacity(GLfloat f)
-{
- setUniformValue(opacity, f);
-}
-
-SingleTextureShadowShader::SingleTextureShadowShader()
-{
- QGLShader vert(QGLShader::VertexShader);
- QGLShader frag(QGLShader::FragmentShader);
-
- vert.compile("\
- attribute highp vec4 myVertex;\
- attribute mediump vec4 myUV;\
- uniform mediump mat4 myPMVMatrix;\
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- gl_Position = myPMVMatrix * myVertex;\
- myTexCoord = myUV.st;\
- }"
- );
-
- frag.compile("\
- uniform sampler2D sampler2d;\
- uniform lowp float myOpacity;\
- varying mediump vec2 myTexCoord;\
- void main(void)\
- {\
- mediump vec4 tex = texture2D(sampler2d,myTexCoord);\
- gl_FragColor = vec4(0, 0, 0, myOpacity * tex.a * .75);\
- }"
- );
-
- addShader(&vert);
- addShader(&frag);
-
- bindAttributeLocation("myVertex", Vertices);
- bindAttributeLocation("myUV", TextureCoords);
-}
-
-bool SingleTextureShadowShader::link()
-{
- if (!QGLShaderProgram::link())
- return false;
- transform = uniformLocation("myPMVMatrix");
- opacity = uniformLocation("myOpacity");
- enable();
- setUniformValue("sampler2d", 0);
- disable();
- return true;
-}
-
-void SingleTextureShadowShader::setTransform(const QMatrix4x4 &matrix)
-{
- setUniformValue(transform, matrix);
-}
-
-void SingleTextureShadowShader::setOpacity(GLfloat f)
-{
- setUniformValue(opacity, f);
-}
-QT_END_NAMESPACE
diff --git a/src/declarative/opengl/glbasicshaders.h b/src/declarative/opengl/glbasicshaders.h
deleted file mode 100644
index 877f0fc..0000000
--- a/src/declarative/opengl/glbasicshaders.h
+++ /dev/null
@@ -1,243 +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 _GLBASICSHADERS_H_
-#define _GLBASICSHADERS_H_
-
-#include <QtOpenGL/qglshaderprogram.h>
-#include <QtGui/qmatrix4x4.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class BlurTextureShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- BlurTextureShader();
-
- enum { Vertices = 0,
- TextureCoords = 1 };
-
- enum Mode { Horizontal, Vertical };
- void setMode(Mode);
- void setStep(float);
- void setSteps(int);
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint mode;
- GLint step;
- GLint steps;
- GLint transform;
-};
-
-class SingleTextureShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- SingleTextureShader();
-
- enum { Vertices = 0,
- TextureCoords = 1 };
-
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint transform;
-};
-
-class DualTextureBlendShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- DualTextureBlendShader();
- enum { Vertices = 0,
- TextureCoords = 1,
- BlendTextureCoords = 2 };
-
- void setOpacity(GLfloat);
- void setBlend(GLfloat);
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint transform;
- GLint opacity;
- GLint blend;
-};
-
-class DualTextureAddShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- DualTextureAddShader();
- enum { Vertices = 0,
- TextureCoords = 1,
- AddTextureCoords = 2 };
-
- void setOpacity(GLfloat);
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint transform;
- GLint opacity;
-};
-
-class SingleTextureOpacityShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- SingleTextureOpacityShader();
-
- enum { Vertices = 0,
- TextureCoords = 1 };
-
- void setOpacity(GLfloat);
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint transform;
- GLint opacity;
-};
-
-class SingleTextureVertexOpacityShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- SingleTextureVertexOpacityShader();
-
- enum { Vertices = 0,
- TextureCoords = 1,
- OpacityCoords = 2 };
-
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint transform;
-};
-
-
-class SingleTextureShadowShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- SingleTextureShadowShader();
-
- enum { Vertices = 0,
- TextureCoords = 1 };
-
- void setOpacity(GLfloat);
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint transform;
- GLint opacity;
-};
-
-
-class QColor;
-class ConstantColorShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- ConstantColorShader();
-
- enum { Vertices = 0 };
-
- void setColor(const QColor &);
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint transform;
- GLint color;
-};
-
-class ColorShader : public QGLShaderProgram
-{
- Q_OBJECT
-public:
- ColorShader();
-
- enum { Vertices = 0, Colors = 1 };
-
- void setTransform(const QMatrix4x4 &);
- virtual bool link();
-
-private:
- GLint transform;
-};
-
-class GLBasicShadersPrivate;
-class GLBasicShaders
-{
-public:
- GLBasicShaders();
- virtual ~GLBasicShaders();
-
- BlurTextureShader *blurTexture();
- SingleTextureShader *singleTexture();
- SingleTextureOpacityShader *singleTextureOpacity();
- DualTextureAddShader *dualTextureAdd();
- SingleTextureVertexOpacityShader *singleTextureVertexOpacity();
- SingleTextureShadowShader *singleTextureShadow();
- ConstantColorShader *constantColor();
- ColorShader *color();
-
-private:
- GLBasicShadersPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // _GLBASICSHADERS_H_
diff --git a/src/declarative/opengl/glheaders.h b/src/declarative/opengl/glheaders.h
deleted file mode 100644
index fd1da18..0000000
--- a/src/declarative/opengl/glheaders.h
+++ /dev/null
@@ -1,49 +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 _GLHEADERS_H_
-#define _GLHEADERS_H_
-
-#include <QtDeclarative/qfxglobal.h>
-#define GL_GLEXT_PROTOTYPES 1
-#include <QtOpenGL/qgl.h>
-
-#endif // _GLHEADERS_H_
diff --git a/src/declarative/opengl/glsave.cpp b/src/declarative/opengl/glsave.cpp
deleted file mode 100644
index 125e81b..0000000
--- a/src/declarative/opengl/glsave.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "glsave.h"
diff --git a/src/declarative/opengl/gltexture.cpp b/src/declarative/opengl/gltexture.cpp
deleted file mode 100644
index c2a02df..0000000
--- a/src/declarative/opengl/gltexture.cpp
+++ /dev/null
@@ -1,384 +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 "gltexture.h"
-#include <QImage>
-
-
-QT_BEGIN_NAMESPACE
-/*!
- \internal
- \class GLTexture
- \brief The GLTexture class simplifies the use of OpenGL textures.
-*/
-
-// Copied from QGLWidget::convertToGLFormat
-static QImage QGLWidget_convertToGLFormat(const QImage& img)
-{
- QImage res = img.convertToFormat(QImage::Format_ARGB32);
- res = res.mirrored();
-
- if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
- // Qt has ARGB; OpenGL wants RGBA
- for (int i=0; i < res.height(); i++) {
- uint *p = (uint*)res.scanLine(i);
- uint *end = p + res.width();
- while (p < end) {
- *p = (*p << 8) | ((*p >> 24) & 0xFF);
- p++;
- }
- }
- }
- else {
- // Qt has ARGB; OpenGL wants ABGR (i.e. RGBA backwards)
- res = res.rgbSwapped();
- }
- return res;
-}
-class GLTexturePrivate
-{
-public:
- GLTexturePrivate(GLTexture *_q)
- : q(_q), texture(0), width(0), height(0),
- horizWrap(GLTexture::Repeat), vertWrap(GLTexture::Repeat),
- minFilter(GLTexture::Linear), magFilter(GLTexture::Linear),
- glWidth(1.), glHeight(1.)
- {
- }
-
- GLTexture *q;
- GLuint texture;
- int width;
- int height;
- GLTexture::WrapMode horizWrap;
- GLTexture::WrapMode vertWrap;
- GLTexture::FilterMode minFilter;
- GLTexture::FilterMode magFilter;
-
- qreal glWidth;
- qreal glHeight;
- QSize glSize;
-
- void genTexture();
-};
-
-void GLTexturePrivate::genTexture()
-{
- if (texture)
- return;
-
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter);
- q->setHorizontalWrap(horizWrap);
- q->setVerticalWrap(vertWrap);
-}
-
-GLTexture::GLTexture()
-: d(new GLTexturePrivate(this))
-{
-}
-
-GLTexture::GLTexture(const QString &file)
-: d(new GLTexturePrivate(this))
-{
- QImage img(file);
- if (!img.isNull())
- setImage(img);
-}
-
-GLTexture::GLTexture(const QImage &img)
-: d(new GLTexturePrivate(this))
-{
- setImage(img);
-}
-
-GLTexture::~GLTexture()
-{
- if (d->texture)
- glDeleteTextures(1, &d->texture);
- delete d;
- d = 0;
-}
-
-bool GLTexture::isNull() const
-{
- return d->texture == 0;
-}
-
-void GLTexture::clear()
-{
- if (d->texture) {
- glDeleteTextures(1, &d->texture);
- d->texture = 0;
- d->width = 0;
- d->height = 0;
- }
-}
-
-static inline int npot(int size)
-{
- size--;
- size |= size >> 1;
- size |= size >> 2;
- size |= size >> 4;
- size |= size >> 8;
- size |= size >> 16;
- size++;
- return size;
-}
-
-/*!
- Set the texture to \a img. If the texture has already been created (either
- by explicitly setting the size, or by previously setting an image), it will
- be destroyed and a new texture created with \a img's contents and size.
- */
-void GLTexture::setImage(const QImage &img, ImageMode mode)
-{
- if (img.isNull())
- return;
-
- d->genTexture();
-
- glBindTexture(GL_TEXTURE_2D, d->texture);
-
- if (mode == NonPowerOfTwo) {
-
- if (img.format() == QImage::Format_RGB16) {
- QImage dataImage = img.mirrored();
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, dataImage.width(),
- dataImage.height(), 0,
- GL_RGB,
- GL_UNSIGNED_SHORT_5_6_5, dataImage.bits());
- } else {
- QImage dataImage = QGLWidget_convertToGLFormat(img);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dataImage.width(),
- dataImage.height(), 0,
- (dataImage.format() == QImage::Format_ARGB32)?GL_RGBA:GL_RGB,
- GL_UNSIGNED_BYTE, dataImage.bits());
- }
- d->glWidth = 1.;
- d->glHeight = 1.;
- d->glSize = img.size();
-
- } else {
- // mode == PowerOfTwo
- int max = (img.width() > img.height())?img.width():img.height();
- max = npot(max);
-
- if (img.format() == QImage::Format_RGB16) {
- QImage dataImage = img.mirrored();
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, max,
- max, 0,
- GL_RGB,
- GL_UNSIGNED_SHORT_5_6_5, 0);
-
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dataImage.width(),
- dataImage.height(), GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
- dataImage.bits());
-
- } else {
- QImage dataImage = QGLWidget_convertToGLFormat(img);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, max,
- max, 0,
- (dataImage.format() == QImage::Format_ARGB32)?GL_RGBA:GL_RGB,
- GL_UNSIGNED_BYTE, 0);
-
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dataImage.width(),
- dataImage.height(),
- (dataImage.format() == QImage::Format_ARGB32)?GL_RGBA:GL_RGB,
- GL_UNSIGNED_BYTE, dataImage.bits());
- }
-
- d->glWidth = qreal(img.width()) / qreal(max);
- d->glHeight = qreal(img.height()) / qreal(max);
- d->glSize = QSize(max, max);
- }
-
- d->width = img.width();
- d->height = img.height();
-}
-
-void GLTexture::copyImage(const QImage &img, const QPoint &point,
- const QRect &srcRect)
-{
- qFatal("Not implemented");
- Q_UNUSED(img);
- Q_UNUSED(point);
- Q_UNUSED(srcRect);
-}
-
-QSize GLTexture::size() const
-{
- return QSize(d->width, d->height);
-}
-
-int GLTexture::width() const
-{
- return d->width;
-}
-
-int GLTexture::height() const
-{
- return d->height;
-}
-
-qreal GLTexture::glWidth() const
-{
- return d->glWidth;
-}
-
-qreal GLTexture::glHeight() const
-{
- return d->glHeight;
-}
-
-QSize GLTexture::glSize() const
-{
- return d->glSize;
-}
-
-/*!
- Sets the \a size of the texture. This will destroy the current contents of
- the texture. If an image has been assigned, it will need to be reassigned
- using either setImage() or copyImage().
-
- If size is invalid (width or height is less than or equal to 0) the texture
- will be destroyed. This is equivalent to calling clear().
-*/
-void GLTexture::setSize(const QSize &size)
-{
- if (size.width() <= 0 || size.height() <= 0) {
- clear();
- return;
- }
-
- d->genTexture();
- glBindTexture(GL_TEXTURE_2D, d->texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
- d->width = size.width();
- d->height = size.height();
-}
-
-GLTexture::WrapMode GLTexture::horizontalWrap() const
-{
- return d->horizWrap;
-}
-
-GLTexture::WrapMode GLTexture::verticalWrap() const
-{
- return d->vertWrap;
-}
-
-void GLTexture::setHorizontalWrap(WrapMode mode)
-{
- d->horizWrap = mode;
- if (d->texture) {
- GLint last;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last);
- if (GLuint(last) != d->texture)
- glBindTexture(GL_TEXTURE_2D, d->texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode);
- if (GLuint(last) != d->texture)
- glBindTexture(GL_TEXTURE_2D, last);
- }
-}
-
-/*!
- Set the veritcal wrap mode to \a mode.
- */
-void GLTexture::setVerticalWrap(WrapMode mode)
-{
- d->vertWrap = mode;
- if (d->texture) {
- GLint last;
- glGetIntegerv(GL_TEXTURE_BINDING_2D, &last);
- if (GLuint(last) != d->texture)
- glBindTexture(GL_TEXTURE_2D, d->texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode);
- if (GLuint(last) != d->texture)
- glBindTexture(GL_TEXTURE_2D, last);
- }
-}
-
-GLTexture::FilterMode GLTexture::minFilter() const
-{
- return d->minFilter;
-}
-
-GLTexture::FilterMode GLTexture::magFilter() const
-{
- return d->magFilter;
-}
-
-void GLTexture::setMinFilter(FilterMode f)
-{
- if (d->minFilter == f)
- return;
- d->minFilter = f;
- if (d->texture) {
- glBindTexture(GL_TEXTURE_2D, d->texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, d->minFilter);
- }
-}
-
-void GLTexture::setMagFilter(FilterMode f)
-{
- if (d->magFilter == f)
- return;
- d->magFilter = f;
- if (d->texture) {
- glBindTexture(GL_TEXTURE_2D, d->texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, d->magFilter);
- }
-}
-
-GLuint GLTexture::texture() const
-{
- return d->texture;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/opengl/gltexture.h b/src/declarative/opengl/gltexture.h
deleted file mode 100644
index c08d68f..0000000
--- a/src/declarative/opengl/gltexture.h
+++ /dev/null
@@ -1,120 +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 _GLTEXTURE_H_
-#define _GLTEXTURE_H_
-
-#include <QtDeclarative/qfxglobal.h>
-
-#include <QtCore/QRect>
-#include <QtCore/QPoint>
-#include "glheaders.h"
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QString;
-class QImage;
-class GLTexturePrivate;
-class Q_DECLARATIVE_EXPORT GLTexture
-{
-public:
- GLTexture();
- GLTexture(const QString &file);
- GLTexture(const QImage &img);
- virtual ~GLTexture();
-
- bool isNull() const;
- void clear();
-
- enum ImageMode { NonPowerOfTwo, PowerOfTwo };
- void setImage(const QImage &, ImageMode = NonPowerOfTwo);
- void copyImage(const QImage &, const QPoint & = QPoint(0, 0), const QRect & = QRect());
-
- int width() const;
- int height() const;
- qreal glWidth() const;
- qreal glHeight() const;
- QSize glSize() const;
- QSize size() const;
- void setSize(const QSize &);
-
- enum WrapMode {
- Repeat = GL_REPEAT,
- ClampToEdge = GL_CLAMP_TO_EDGE,
-#if defined(QFX_RENDER_OPENGL2)
- MirroredRepeat = GL_MIRRORED_REPEAT,
-#else
- MirroredRepeat = Repeat
-#endif
- };
-
- WrapMode horizontalWrap() const;
- WrapMode verticalWrap() const;
- void setHorizontalWrap(WrapMode);
- void setVerticalWrap(WrapMode);
-
- enum FilterMode {
- Nearest = GL_NEAREST,
- Linear = GL_LINEAR,
- MipmapLinear = GL_LINEAR_MIPMAP_LINEAR
- };
-
- FilterMode minFilter() const;
- FilterMode magFilter() const;
- void setMinFilter(FilterMode);
- void setMagFilter(FilterMode);
-
- GLuint texture() const;
-private:
- Q_DISABLE_COPY(GLTexture)
- GLTexturePrivate *d;
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif // _GLTEXTURE_H_
diff --git a/src/declarative/opengl/opengl.pri b/src/declarative/opengl/opengl.pri
deleted file mode 100644
index c9ccefb..0000000
--- a/src/declarative/opengl/opengl.pri
+++ /dev/null
@@ -1,20 +0,0 @@
-DEPENDPATH += opengl
-INCLUDEPATH += opengl
-INCLUDEPATH += $$QMAKE_INCDIR_OPENGL
-QT += opengl
-
-contains(QT_CONFIG, opengles1) {
- SOURCES += gltexture.cpp \
- glsave.cpp
-
- HEADERS += gltexture.h \
- glsave.h
-} else:contains(QT_CONFIG, opengles2) {
- SOURCES += gltexture.cpp \
- glbasicshaders.cpp \
- glsave.cpp
-
- HEADERS += gltexture.h \
- glbasicshaders.h \
- glsave.h
-}
diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g
index 8297c08..20ee27d 100644
--- a/src/declarative/qml/parser/qmljs.g
+++ b/src/declarative/qml/parser/qmljs.g
@@ -86,11 +86,16 @@
%token T_IMPORT "import"
%token T_AS "as"
+--- feed tokens
+%token T_FEED_UI_PROGRAM
+%token T_FEED_JS_STATEMENT
+%token T_FEED_JS_EXPRESSION
+
%nonassoc SHIFT_THERE
%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY
%nonassoc REDUCE_HERE
-%start UiProgram
+%start TopLevel
/.
/****************************************************************************
@@ -272,10 +277,29 @@ public:
Parser(Engine *engine);
~Parser();
- bool parse();
+ // parse a UI program
+ bool parse() { return parse(T_FEED_UI_PROGRAM); }
+ bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
+ bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
+
+ AST::UiProgram *ast() const
+ { return AST::cast<AST::UiProgram *>(program); }
+
+ AST::Statement *statement() const
+ {
+ if (! program)
+ return 0;
+
+ return program->statementCast();
+ }
+
+ AST::ExpressionNode *expression() const
+ {
+ if (! program)
+ return 0;
- AST::UiProgram *ast()
- { return program; }
+ return program->expressionCast();
+ }
QList<DiagnosticMessage> diagnosticMessages() const
{ return diagnostic_messages; }
@@ -300,6 +324,8 @@ public:
{ return diagnosticMessage().loc.startColumn; }
protected:
+ bool parse(int startToken);
+
void reallocateStack();
inline Value &sym(int index)
@@ -318,7 +344,7 @@ protected:
int *state_stack;
AST::SourceLocation *location_stack;
- AST::UiProgram *program;
+ AST::Node *program;
// error recovery
enum { TOKEN_BUFFER_SIZE = 3 };
@@ -439,14 +465,16 @@ AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
return 0;
}
-bool Parser::parse()
+bool Parser::parse(int startToken)
{
Lexer *lexer = driver->lexer();
bool hadErrors = false;
int yytoken = -1;
int action = 0;
- first_token = last_token = 0;
+ token_buffer[0].token = startToken;
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
tos = -1;
program = 0;
@@ -494,12 +522,35 @@ bool Parser::parse()
-- Declarative UI
--------------------------------------------------------------------------------------------------------
+TopLevel: T_FEED_UI_PROGRAM UiProgram ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_STATEMENT Statement ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
+TopLevel: T_FEED_JS_EXPRESSION Expression ;
+/.
+case $rule_number: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
+./
+
UiProgram: UiImportListOpt UiRootMember ;
/.
case $rule_number: {
- program = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
+ sym(1).UiProgram = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
sym(2).UiObjectMemberList->finish());
- sym(1).UiProgram = program;
} break;
./
@@ -699,26 +750,6 @@ case $rule_number: {
} break;
./
-UiMultilineStringLiteral: T_MULTILINE_STRING_LITERAL ;
-/.
-case $rule_number: {
- AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-./
-
-UiMultilineStringStatement: UiMultilineStringLiteral T_AUTOMATIC_SEMICOLON ; -- automatic semicolon
-UiMultilineStringStatement: UiMultilineStringLiteral T_SEMICOLON ;
-/.
-case $rule_number: {
- AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-./
-
-
UiObjectMember: UiQualifiedId T_COLON Expression UiObjectInitializer ;
/.
case $rule_number: {
@@ -747,12 +778,6 @@ UiObjectMember: UiQualifiedId T_COLON EmptyStatement ;
UiObjectMember: UiQualifiedId T_COLON ExpressionStatement ;
/.case $rule_number:./
-UiObjectMember: UiQualifiedId T_COLON DebuggerStatement ;
-/.case $rule_number:./
-
-UiObjectMember: UiQualifiedId T_COLON UiMultilineStringStatement ;
-/.case $rule_number:./
-
UiObjectMember: UiQualifiedId T_COLON IfStatement ; --- ### do we really want if statement in a binding?
/.case $rule_number:./
@@ -1002,6 +1027,9 @@ case $rule_number: {
} break;
./
+PrimaryExpression: T_MULTILINE_STRING_LITERAL ;
+/.case $rule_number:./
+
PrimaryExpression: T_STRING_LITERAL ;
/.
case $rule_number: {
@@ -2962,7 +2990,8 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
}
for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
- if (tk == T_AUTOMATIC_SEMICOLON)
+ if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
+ tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION)
continue;
int a = t_action(errorState, tk);
diff --git a/src/declarative/qml/parser/qmljsgrammar.cpp b/src/declarative/qml/parser/qmljsgrammar.cpp
index ff25d65..1b23be6 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$
**
****************************************************************************/
@@ -52,930 +52,547 @@ const char *const QmlJSGrammar::spell [] = {
")", ";", 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", "as",
- 0, 0,
-#ifndef QLALR_NO_QMLJSGRAMMAR_DEBUG_INFO
-"UiProgram", "UiImportListOpt", "UiRootMember", "Empty", "UiImportList", "UiImport", "JsIdentifier", "UiQualifiedId",
- "UiObjectDefinition", "UiObjectMemberList", "UiObjectMember", "UiArrayMemberList", "UiObjectInitializer", "UiMultilineStringLiteral", "UiMultilineStringStatement", "Expression", "Block", "EmptyStatement",
- "ExpressionStatement", "DebuggerStatement", "IfStatement", "UiPropertyType", "UiParameterListOpt", "UiParameterList", "FunctionDeclaration", "VariableStatement", "PrimaryExpression", "Elision",
- "ElementList", "PropertyNameAndValueListOpt", "PropertyNameAndValueList", "AssignmentExpression", "PropertyName", "ReservedIdentifier", "PropertyIdentifier", "MemberExpression", "FunctionExpression", "ArgumentListOpt",
- "NewExpression", "CallExpression", "ArgumentList", "LeftHandSideExpression", "PostfixExpression", "UnaryExpression", "MultiplicativeExpression", "AdditiveExpression", "ShiftExpression", "RelationalExpression",
- "RelationalExpressionNotIn", "EqualityExpression", "EqualityExpressionNotIn", "BitwiseANDExpression", "BitwiseANDExpressionNotIn", "BitwiseXORExpression", "BitwiseXORExpressionNotIn", "BitwiseORExpression", "BitwiseORExpressionNotIn", "LogicalANDExpression",
- "LogicalANDExpressionNotIn", "LogicalORExpression", "LogicalORExpressionNotIn", "ConditionalExpression", "ConditionalExpressionNotIn", "AssignmentExpressionNotIn", "AssignmentOperator", "ExpressionOpt", "ExpressionNotIn", "ExpressionNotInOpt",
- "Statement", "IterationStatement", "ContinueStatement", "BreakStatement", "ReturnStatement", "WithStatement", "LabelledStatement", "SwitchStatement", "ThrowStatement", "TryStatement",
- "StatementListOpt", "StatementList", "VariableDeclarationKind", "VariableDeclarationList", "VariableDeclaration", "VariableDeclarationListNotIn", "VariableDeclarationNotIn", "InitialiserOpt", "InitialiserNotInOpt", "Initialiser",
- "InitialiserNotIn", "CaseBlock", "CaseClausesOpt", "DefaultClause", "CaseClauses", "CaseClause", "Catch", "Finally", "FormalParameterListOpt", "FunctionBodyOpt",
- "IdentifierOpt", "FormalParameterList", "FunctionBody", "SourceElements", "SourceElement", "$accept"
-#endif // QLALR_NO_QMLJSGRAMMAR_DEBUG_INFO
-};
+ 0, 0, 0, 0, 0};
const int QmlJSGrammar::lhs [] = {
- 92, 93, 93, 96, 96, 97, 97, 97, 97, 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};
+ 95, 95, 95, 96, 99, 99, 102, 102, 103, 103,
+ 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
+ 101, 100, 107, 107, 109, 109, 110, 110, 106, 108,
+ 108, 108, 108, 108, 108, 108, 115, 115, 115, 116,
+ 116, 117, 117, 108, 108, 108, 108, 108, 108, 108,
+ 108, 108, 108, 108, 108, 105, 105, 104, 104, 104,
+ 120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
+ 120, 120, 120, 120, 120, 120, 120, 120, 105, 105,
+ 122, 122, 122, 122, 121, 121, 124, 124, 126, 126,
+ 126, 126, 126, 126, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
+ 127, 127, 127, 127, 127, 128, 128, 129, 129, 129,
+ 129, 129, 132, 132, 133, 133, 133, 133, 131, 131,
+ 134, 134, 135, 135, 136, 136, 136, 137, 137, 137,
+ 137, 137, 137, 137, 137, 137, 137, 138, 138, 138,
+ 138, 139, 139, 139, 140, 140, 140, 140, 141, 141,
+ 141, 141, 141, 141, 141, 142, 142, 142, 142, 142,
+ 142, 143, 143, 143, 143, 143, 144, 144, 144, 144,
+ 144, 145, 145, 146, 146, 147, 147, 148, 148, 149,
+ 149, 150, 150, 151, 151, 152, 152, 153, 153, 154,
+ 154, 155, 155, 156, 156, 125, 125, 157, 157, 158,
+ 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
+ 158, 98, 98, 159, 159, 160, 160, 161, 161, 97,
+ 97, 97, 97, 97, 97, 97, 97, 97, 97, 97,
+ 97, 97, 97, 97, 111, 173, 173, 172, 172, 119,
+ 119, 174, 174, 175, 175, 177, 177, 176, 178, 181,
+ 179, 179, 182, 180, 180, 112, 113, 113, 114, 114,
+ 162, 162, 162, 162, 162, 162, 162, 163, 163, 163,
+ 163, 164, 164, 164, 164, 165, 165, 166, 168, 183,
+ 183, 186, 186, 184, 184, 187, 185, 167, 167, 167,
+ 169, 169, 170, 170, 170, 188, 189, 171, 171, 118,
+ 130, 193, 193, 190, 190, 191, 191, 194, 195, 195,
+ 196, 196, 192, 192, 123, 123, 197};
const int QmlJSGrammar:: rhs[] = {
- 2, 1, 1, 1, 2, 3, 3, 5, 5, 3,
- 3, 4, 4, 6, 6, 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,
+ 2, 2, 2, 2, 1, 1, 1, 2, 3, 3,
+ 5, 5, 3, 3, 4, 4, 6, 6, 5, 5,
+ 0, 1, 1, 2, 1, 3, 2, 3, 2, 1,
+ 5, 4, 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, 1,
- 1, 2, 3, 3, 4, 5, 3, 4, 3, 1,
- 3, 1, 2, 3, 4, 1, 2, 3, 5, 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,
+ 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,
- 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, 3, 0, 1, 1, 3, 0, 1, 1,
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};
-
-
-#ifndef QLALR_NO_QMLJSGRAMMAR_DEBUG_INFO
-const int QmlJSGrammar::rule_info [] = {
- 92, 93, 94
- , 93, 95
- , 93, 96
- , 96, 97
- , 96, 96, 97
- , 97, 88, 65, 62
- , 97, 88, 65, 61
- , 97, 88, 65, 89, 98, 62
- , 97, 88, 65, 89, 98, 61
- , 97, 88, 99, 62
- , 97, 88, 99, 61
- , 97, 88, 99, 47, 62
- , 97, 88, 99, 47, 61
- , 97, 88, 99, 47, 89, 98, 62
- , 97, 88, 99, 47, 89, 98, 61
- , 97, 88, 99, 89, 98, 62
- , 97, 88, 99, 89, 98, 61
- , 95
- , 94, 100
- , 101, 102
- , 101, 101, 102
- , 103, 100
- , 103, 103, 8, 100
- , 104, 33, 55
- , 104, 33, 101, 55
- , 100, 99, 104
- , 102, 100
- , 102, 99, 7, 34, 103, 56
- , 105, 86
- , 106, 105, 62
- , 106, 105, 61
- , 102, 99, 7, 107, 104
- , 102, 99, 7, 108
- , 102, 99, 7, 109
- , 102, 99, 7, 110
- , 102, 99, 7, 111
- , 102, 99, 7, 106
- , 102, 99, 7, 112
- , 113, 74
- , 113, 85
- , 113, 29
- , 114
- , 114, 115
- , 115, 113, 98
- , 115, 115, 8, 113, 98
- , 102, 67, 29, 36, 114, 60
- , 102, 67, 29
- , 102, 66, 113, 29, 62
- , 102, 66, 113, 29, 61
- , 102, 10, 66, 113, 29, 62
- , 102, 10, 66, 113, 29, 61
- , 102, 66, 113, 29, 7, 107, 62
- , 102, 66, 113, 29, 7, 107, 61
- , 102, 10, 66, 113, 29, 7, 107, 62
- , 102, 10, 66, 113, 29, 7, 107, 61
- , 102, 116
- , 102, 117
- , 99, 85
- , 99, 59
- , 98, 29
- , 98, 66
- , 98, 67
- , 118, 69
- , 118, 98
- , 118, 80
- , 118, 81
- , 118, 82
- , 118, 47
- , 118, 65
- , 118, 12
- , 118, 13
- , 118, 34, 56
- , 118, 34, 119, 56
- , 118, 34, 120, 56
- , 118, 34, 120, 8, 56
- , 118, 34, 120, 8, 119, 56
- , 118, 33, 121, 55
- , 118, 33, 122, 8, 55
- , 118, 36, 107, 60
- , 99, 98
- , 99, 99, 15, 98
- , 120, 123
- , 120, 119, 123
- , 120, 120, 8, 123
- , 120, 120, 8, 119, 123
- , 119, 8
- , 119, 119, 8
- , 122, 124, 7, 123
- , 122, 122, 8, 124, 7, 123
- , 124, 29
- , 124, 67
- , 124, 66
- , 124, 65
- , 124, 47
- , 124, 125
- , 125, 4
- , 125, 5
- , 125, 6
- , 125, 9
- , 125, 10
- , 125, 11
- , 125, 14
- , 125, 16
- , 125, 82
- , 125, 20
- , 125, 21
- , 125, 22
- , 125, 30
- , 125, 31
- , 125, 32
- , 125, 43
- , 125, 80
- , 125, 59
- , 125, 68
- , 125, 69
- , 125, 70
- , 125, 81
- , 125, 72
- , 125, 73
- , 125, 74
- , 125, 75
- , 125, 76
- , 125, 83
- , 125, 84
- , 125, 85
- , 125, 77
- , 126, 98
- , 126, 125
- , 127, 118
- , 127, 128
- , 127, 127, 34, 107, 56
- , 127, 127, 15, 126
- , 127, 43, 127, 36, 129, 60
- , 130, 127
- , 130, 43, 130
- , 131, 127, 36, 129, 60
- , 131, 131, 36, 129, 60
- , 131, 131, 34, 107, 56
- , 131, 131, 15, 126
- , 129
- , 129, 132
- , 132, 123
- , 132, 132, 8, 123
- , 133, 130
- , 133, 131
- , 134, 133
- , 134, 133, 53
- , 134, 133, 42
- , 135, 134
- , 135, 11, 135
- , 135, 75, 135
- , 135, 73, 135
- , 135, 53, 135
- , 135, 42, 135
- , 135, 51, 135
- , 135, 40, 135
- , 135, 71, 135
- , 135, 44, 135
- , 136, 135
- , 136, 136, 63, 135
- , 136, 136, 12, 135
- , 136, 136, 57, 135
- , 137, 136
- , 137, 137, 51, 136
- , 137, 137, 40, 136
- , 138, 137
- , 138, 138, 38, 137
- , 138, 138, 25, 137
- , 138, 138, 27, 137
- , 139, 138
- , 139, 139, 37, 138
- , 139, 139, 24, 138
- , 139, 139, 35, 138
- , 139, 139, 23, 138
- , 139, 139, 32, 138
- , 139, 139, 31, 138
- , 140, 138
- , 140, 140, 37, 138
- , 140, 140, 24, 138
- , 140, 140, 35, 138
- , 140, 140, 23, 138
- , 140, 140, 32, 138
- , 141, 139
- , 141, 141, 18, 139
- , 141, 141, 45, 139
- , 141, 141, 19, 139
- , 141, 141, 46, 139
- , 142, 140
- , 142, 142, 18, 140
- , 142, 142, 45, 140
- , 142, 142, 19, 140
- , 142, 142, 46, 140
- , 143, 141
- , 143, 143, 1, 141
- , 144, 142
- , 144, 144, 1, 142
- , 145, 143
- , 145, 145, 78, 143
- , 146, 144
- , 146, 146, 78, 144
- , 147, 145
- , 147, 147, 48, 145
- , 148, 146
- , 148, 148, 48, 146
- , 149, 147
- , 149, 149, 2, 147
- , 150, 148
- , 150, 150, 2, 148
- , 151, 149
- , 151, 151, 50, 149
- , 152, 150
- , 152, 152, 50, 150
- , 153, 151
- , 153, 151, 54, 123, 7, 123
- , 154, 152
- , 154, 152, 54, 155, 7, 155
- , 123, 153
- , 123, 133, 156, 123
- , 155, 154
- , 155, 133, 156, 155
- , 156, 17
- , 156, 64
- , 156, 13
- , 156, 58
- , 156, 52
- , 156, 41
- , 156, 39
- , 156, 26
- , 156, 28
- , 156, 3
- , 156, 79
- , 156, 49
- , 107, 123
- , 107, 107, 8, 123
- , 157
- , 157, 107
- , 158, 155
- , 158, 158, 8, 155
- , 159
- , 159, 158
- , 160, 108
- , 160, 117
- , 160, 109
- , 160, 110
- , 160, 112
- , 160, 161
- , 160, 162
- , 160, 163
- , 160, 164
- , 160, 165
- , 160, 166
- , 160, 167
- , 160, 168
- , 160, 169
- , 160, 111
- , 108, 33, 170, 55
- , 171, 160
- , 171, 171, 160
- , 170
- , 170, 171
- , 117, 172, 173, 62
- , 117, 172, 173, 61
- , 172, 83
- , 172, 74
- , 173, 174
- , 173, 173, 8, 174
- , 175, 176
- , 175, 175, 8, 176
- , 174, 98, 177
- , 176, 98, 178
- , 179, 17, 123
- , 177
- , 177, 179
- , 180, 17, 155
- , 178
- , 178, 180
- , 109, 61
- , 110, 107, 62
- , 110, 107, 61
- , 112, 30, 36, 107, 60, 160, 16, 160
- , 112, 30, 36, 107, 60, 160
- , 161, 14, 160, 76, 36, 107, 60, 62
- , 161, 14, 160, 76, 36, 107, 60, 61
- , 161, 76, 36, 107, 60, 160
- , 161, 21, 36, 159, 61, 157, 61, 157, 60, 160
- , 161, 21, 36, 74, 175, 61, 157, 61, 157, 60, 160
- , 161, 21, 36, 133, 31, 107, 60, 160
- , 161, 21, 36, 74, 176, 31, 107, 60, 160
- , 162, 9, 62
- , 162, 9, 61
- , 162, 9, 98, 62
- , 162, 9, 98, 61
- , 163, 4, 62
- , 163, 4, 61
- , 163, 4, 98, 62
- , 163, 4, 98, 61
- , 164, 59, 157, 62
- , 164, 59, 157, 61
- , 165, 77, 36, 107, 60, 160
- , 167, 68, 36, 107, 60, 181
- , 181, 33, 182, 55
- , 181, 33, 182, 183, 182, 55
- , 184, 185
- , 184, 184, 185
- , 182
- , 182, 184
- , 185, 5, 107, 7, 170
- , 183, 10, 7, 170
- , 166, 67, 7, 160
- , 166, 66, 7, 160
- , 166, 29, 7, 160
- , 168, 70, 107, 62
- , 168, 70, 107, 61
- , 169, 72, 108, 186
- , 169, 72, 108, 187
- , 169, 72, 108, 186, 187
- , 186, 6, 36, 98, 60, 108
- , 187, 20, 108
- , 111, 84, 62
- , 111, 84, 61
- , 116, 22, 98, 36, 188, 60, 33, 189, 55
- , 128, 22, 190, 36, 188, 60, 33, 189, 55
- , 191, 98
- , 191, 191, 8, 98
- , 188
- , 188, 191
- , 189
- , 189, 192
- , 192, 193
- , 193, 194
- , 193, 193, 194
- , 194, 160
- , 194, 116
- , 190
- , 190, 98
- , 121
- , 121, 122
- , 195, 92, 0};
-
-const int QmlJSGrammar::rule_index [] = {
- 0, 3, 5, 7, 9, 12, 16, 20, 26, 32,
- 36, 40, 45, 50, 57, 64, 70, 76, 77, 79,
- 81, 84, 86, 90, 93, 97, 100, 102, 108, 110,
- 113, 116, 121, 125, 129, 133, 137, 141, 145, 147,
- 149, 151, 152, 154, 157, 162, 168, 171, 176, 181,
- 187, 193, 200, 207, 215, 223, 225, 227, 229, 231,
- 233, 235, 237, 239, 241, 243, 245, 247, 249, 251,
- 253, 255, 258, 262, 266, 271, 277, 281, 286, 290,
- 292, 296, 298, 301, 305, 310, 312, 315, 319, 325,
- 327, 329, 331, 333, 335, 337, 339, 341, 343, 345,
- 347, 349, 351, 353, 355, 357, 359, 361, 363, 365,
- 367, 369, 371, 373, 375, 377, 379, 381, 383, 385,
- 387, 389, 391, 393, 395, 397, 399, 401, 403, 405,
- 407, 412, 416, 422, 424, 427, 432, 437, 442, 446,
- 447, 449, 451, 455, 457, 459, 461, 464, 467, 469,
- 472, 475, 478, 481, 484, 487, 490, 493, 496, 498,
- 502, 506, 510, 512, 516, 520, 522, 526, 530, 534,
- 536, 540, 544, 548, 552, 556, 560, 562, 566, 570,
- 574, 578, 582, 584, 588, 592, 596, 600, 602, 606,
- 610, 614, 618, 620, 624, 626, 630, 632, 636, 638,
- 642, 644, 648, 650, 654, 656, 660, 662, 666, 668,
- 672, 674, 678, 680, 686, 688, 694, 696, 700, 702,
- 706, 708, 710, 712, 714, 716, 718, 720, 722, 724,
- 726, 728, 730, 732, 736, 737, 739, 741, 745, 746,
- 748, 750, 752, 754, 756, 758, 760, 762, 764, 766,
- 768, 770, 772, 774, 776, 778, 782, 784, 787, 788,
- 790, 794, 798, 800, 802, 804, 808, 810, 814, 817,
- 820, 823, 824, 826, 829, 830, 832, 834, 837, 840,
- 848, 854, 862, 870, 876, 886, 897, 905, 914, 917,
- 920, 924, 928, 931, 934, 938, 942, 946, 950, 956,
- 962, 966, 972, 974, 977, 978, 980, 985, 989, 993,
- 997, 1001, 1005, 1009, 1013, 1017, 1022, 1028, 1031, 1034,
- 1037, 1046, 1055, 1057, 1061, 1062, 1064, 1065, 1067, 1069,
- 1071, 1074, 1076, 1078, 1079, 1081, 1082, 1084};
-#endif // QLALR_NO_QMLJSGRAMMAR_DEBUG_INFO
+ 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};
const int QmlJSGrammar::action_default [] = {
- 18, 2, 0, 4, 3, 0, 0, 80, 60, 61,
- 58, 59, 62, 0, 0, 0, 6, 7, 0, 8,
- 9, 0, 10, 0, 0, 11, 0, 16, 17, 81,
- 0, 12, 13, 0, 14, 15, 5, 19, 0, 1,
- 0, 26, 56, 263, 0, 0, 61, 24, 62, 264,
- 27, 20, 0, 0, 0, 57, 0, 41, 40, 39,
- 0, 0, 50, 0, 51, 166, 233, 197, 205, 201,
- 145, 217, 193, 0, 130, 64, 146, 209, 213, 134,
- 163, 144, 149, 129, 183, 170, 0, 70, 71, 67,
- 334, 336, 0, 0, 0, 0, 0, 0, 65, 68,
- 0, 0, 69, 63, 0, 66, 0, 0, 159, 0,
- 0, 146, 165, 148, 147, 0, 0, 0, 161, 162,
- 160, 164, 0, 194, 0, 0, 0, 0, 184, 0,
- 0, 0, 0, 0, 0, 174, 0, 0, 0, 168,
- 169, 167, 172, 176, 175, 173, 171, 186, 185, 187,
- 0, 202, 0, 198, 0, 0, 140, 127, 139, 128,
- 96, 97, 98, 123, 99, 124, 100, 101, 102, 103,
- 104, 105, 106, 107, 108, 109, 110, 111, 112, 125,
- 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
- 126, 0, 0, 138, 234, 141, 0, 142, 0, 143,
- 137, 54, 55, 0, 230, 223, 221, 228, 229, 227,
- 226, 232, 225, 224, 222, 231, 218, 0, 206, 0,
- 0, 210, 0, 0, 214, 0, 0, 140, 132, 0,
- 131, 0, 136, 150, 0, 335, 325, 326, 0, 323,
- 0, 324, 0, 327, 241, 248, 247, 255, 243, 0,
- 244, 328, 0, 333, 245, 246, 251, 249, 330, 329,
- 332, 252, 0, 0, 0, 0, 0, 334, 60, 0,
- 336, 61, 235, 277, 62, 0, 0, 0, 0, 0,
- 253, 254, 242, 250, 278, 279, 322, 331, 0, 293,
- 294, 295, 296, 0, 289, 290, 291, 292, 319, 320,
- 0, 0, 0, 0, 0, 282, 283, 239, 237, 199,
- 207, 203, 219, 195, 240, 0, 146, 211, 215, 188,
- 177, 0, 0, 196, 0, 0, 0, 0, 189, 0,
- 0, 0, 0, 0, 181, 179, 182, 180, 178, 191,
- 190, 192, 0, 204, 0, 200, 0, 238, 146, 0,
- 220, 235, 236, 0, 235, 0, 0, 285, 0, 0,
- 0, 287, 0, 208, 0, 0, 212, 0, 0, 216,
- 275, 0, 267, 276, 270, 0, 274, 0, 235, 268,
- 0, 235, 0, 0, 286, 0, 0, 0, 288, 335,
- 325, 0, 0, 327, 0, 321, 0, 311, 0, 0,
- 0, 281, 0, 280, 0, 337, 0, 95, 257, 260,
- 0, 96, 263, 99, 124, 101, 102, 67, 106, 107,
- 60, 108, 111, 65, 68, 61, 235, 62, 69, 114,
- 63, 116, 66, 118, 119, 264, 121, 122, 126, 0,
- 88, 0, 0, 90, 94, 92, 78, 91, 93, 0,
- 89, 77, 258, 256, 134, 135, 140, 0, 133, 0,
- 310, 0, 297, 298, 0, 309, 0, 0, 0, 300,
- 305, 303, 306, 0, 0, 304, 305, 0, 301, 0,
- 302, 259, 308, 0, 259, 307, 0, 312, 313, 0,
- 259, 314, 315, 0, 0, 316, 0, 0, 0, 317,
- 318, 152, 151, 0, 0, 0, 284, 0, 0, 0,
- 299, 82, 0, 0, 86, 72, 0, 74, 84, 0,
- 75, 85, 87, 76, 83, 73, 0, 79, 156, 154,
- 158, 155, 153, 157, 0, 0, 0, 48, 0, 49,
- 0, 52, 53, 47, 42, 43, 0, 0, 0, 0,
- 45, 46, 44, 25, 21, 0, 33, 36, 34, 0,
- 35, 38, 259, 0, 29, 0, 37, 32, 96, 263,
- 99, 124, 101, 102, 67, 106, 107, 60, 108, 111,
- 65, 68, 61, 235, 62, 69, 114, 63, 116, 66,
- 118, 119, 264, 121, 122, 126, 64, 0, 22, 0,
- 28, 23, 30, 31, 272, 265, 0, 273, 269, 0,
- 271, 261, 0, 262, 266, 338};
+ 0, 0, 0, 21, 0, 165, 232, 196, 204, 200,
+ 144, 216, 192, 3, 129, 62, 145, 208, 212, 133,
+ 162, 143, 148, 128, 182, 169, 0, 69, 70, 65,
+ 333, 58, 335, 0, 0, 0, 0, 67, 0, 0,
+ 63, 66, 0, 0, 59, 60, 68, 61, 0, 64,
+ 0, 0, 158, 0, 0, 145, 164, 147, 146, 0,
+ 0, 0, 160, 161, 159, 163, 0, 193, 0, 0,
+ 0, 0, 183, 0, 0, 0, 0, 0, 0, 173,
+ 0, 0, 0, 167, 168, 166, 171, 175, 174, 172,
+ 170, 185, 184, 186, 0, 201, 0, 197, 0, 0,
+ 139, 126, 138, 127, 95, 96, 97, 122, 98, 123,
+ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
+ 109, 110, 111, 124, 112, 113, 114, 115, 116, 117,
+ 118, 119, 120, 121, 125, 0, 0, 137, 233, 140,
+ 0, 141, 0, 142, 136, 0, 229, 222, 220, 227,
+ 228, 226, 225, 231, 224, 223, 221, 230, 217, 0,
+ 205, 0, 0, 209, 0, 0, 213, 0, 0, 139,
+ 131, 0, 130, 0, 135, 149, 0, 334, 324, 325,
+ 0, 322, 0, 323, 0, 326, 240, 247, 246, 254,
+ 242, 0, 243, 327, 0, 332, 244, 245, 250, 248,
+ 329, 328, 331, 251, 0, 262, 0, 0, 0, 0,
+ 333, 58, 0, 335, 59, 234, 276, 60, 0, 0,
+ 0, 263, 0, 0, 252, 253, 0, 241, 249, 277,
+ 278, 321, 330, 0, 292, 293, 294, 295, 0, 288,
+ 289, 290, 291, 318, 319, 0, 0, 0, 0, 0,
+ 281, 282, 238, 236, 198, 206, 202, 218, 194, 239,
+ 0, 145, 210, 214, 187, 176, 0, 0, 195, 0,
+ 0, 0, 0, 188, 0, 0, 0, 0, 0, 180,
+ 178, 181, 179, 177, 190, 189, 191, 0, 203, 0,
+ 199, 0, 237, 145, 0, 219, 234, 235, 0, 234,
+ 0, 0, 284, 0, 0, 0, 286, 0, 207, 0,
+ 0, 211, 0, 0, 215, 274, 0, 266, 275, 269,
+ 0, 273, 0, 234, 267, 0, 234, 0, 0, 285,
+ 0, 0, 0, 287, 334, 324, 0, 0, 326, 0,
+ 320, 0, 310, 0, 0, 0, 280, 0, 279, 0,
+ 336, 0, 94, 256, 259, 0, 95, 262, 98, 123,
+ 100, 101, 65, 105, 106, 58, 107, 110, 63, 66,
+ 59, 234, 60, 68, 113, 61, 115, 64, 117, 118,
+ 263, 120, 121, 125, 0, 87, 0, 0, 89, 93,
+ 91, 77, 90, 92, 0, 88, 76, 257, 255, 133,
+ 134, 139, 0, 132, 0, 309, 0, 296, 297, 0,
+ 308, 0, 0, 0, 299, 304, 302, 305, 0, 0,
+ 303, 304, 0, 300, 0, 301, 258, 307, 0, 258,
+ 306, 0, 311, 312, 0, 258, 313, 314, 0, 0,
+ 315, 0, 0, 0, 316, 317, 151, 150, 0, 0,
+ 0, 283, 0, 0, 0, 298, 271, 264, 0, 272,
+ 268, 0, 270, 260, 0, 261, 265, 81, 0, 0,
+ 85, 71, 0, 73, 83, 0, 74, 84, 86, 75,
+ 82, 72, 0, 78, 155, 153, 157, 154, 152, 156,
+ 2, 5, 0, 7, 6, 0, 1, 79, 56, 57,
+ 0, 0, 0, 9, 10, 0, 11, 12, 0, 13,
+ 0, 0, 14, 0, 19, 20, 80, 0, 15, 16,
+ 0, 17, 18, 8, 22, 0, 4, 0, 29, 54,
+ 0, 0, 59, 27, 60, 30, 23, 0, 0, 55,
+ 0, 39, 38, 37, 0, 0, 48, 0, 49, 0,
+ 52, 53, 0, 0, 0, 46, 0, 47, 0, 50,
+ 51, 45, 40, 41, 0, 0, 0, 0, 43, 44,
+ 42, 28, 24, 0, 33, 34, 0, 35, 36, 258,
+ 0, 32, 95, 262, 98, 123, 100, 101, 65, 105,
+ 106, 58, 107, 110, 63, 66, 59, 234, 60, 68,
+ 113, 61, 115, 64, 117, 118, 263, 120, 121, 125,
+ 62, 0, 25, 0, 31, 26, 337};
const int QmlJSGrammar::goto_default [] = {
- 6, 5, 39, 1, 4, 3, 75, 38, 50, 52,
- 51, 597, 41, 565, 566, 249, 244, 248, 250, 247,
- 254, 535, 546, 545, 253, 282, 83, 513, 512, 406,
- 405, 66, 404, 407, 158, 79, 74, 196, 81, 70,
- 195, 76, 82, 108, 80, 65, 85, 84, 319, 72,
- 313, 67, 309, 69, 311, 68, 310, 77, 317, 78,
- 318, 71, 312, 308, 349, 461, 314, 315, 408, 255,
- 246, 245, 257, 283, 256, 261, 280, 281, 410, 409,
- 54, 606, 605, 371, 372, 608, 374, 607, 373, 469,
- 473, 476, 472, 471, 491, 492, 238, 252, 234, 237,
- 251, 259, 258, 0};
+ 4, 496, 353, 191, 495, 526, 491, 494, 493, 15,
+ 525, 535, 537, 536, 611, 528, 186, 190, 192, 196,
+ 553, 564, 563, 195, 227, 23, 469, 468, 351, 350,
+ 6, 349, 352, 102, 19, 14, 140, 21, 10, 139,
+ 16, 22, 52, 20, 5, 25, 24, 264, 12, 258,
+ 7, 254, 9, 256, 8, 255, 17, 262, 18, 263,
+ 11, 257, 253, 294, 406, 259, 260, 197, 188, 187,
+ 199, 228, 198, 203, 224, 225, 189, 355, 354, 226,
+ 458, 457, 316, 317, 460, 319, 459, 318, 414, 418,
+ 421, 417, 416, 436, 437, 180, 194, 176, 179, 193,
+ 201, 200, 0};
const int QmlJSGrammar::action_index [] = {
- 7, -92, 389, -92, -10, 343, 168, -92, -92, -92,
- -92, -92, -92, 233, 308, 178, -92, -92, 86, -92,
- -92, 173, -92, 151, 137, -92, 108, -92, -92, -92,
- 184, -92, -92, 105, -92, -92, -92, -92, 82, -92,
- 456, -92, -92, -92, 44, 190, 195, -92, -27, -92,
- -92, -92, 431, 208, 187, -92, 214, -92, -92, -92,
- -15, 224, -92, 764, -92, 109, -92, 8, -47, -78,
- 194, -92, 376, 143, -92, -92, 603, 6, 85, 186,
- 213, -92, -92, -92, 514, 302, 764, -92, -92, -92,
- 237, 1607, 1014, 764, 764, 764, 683, 764, -92, -92,
- 764, 764, -92, -92, 764, -92, 764, 764, -92, 764,
- 764, 133, 220, -92, -92, 764, 764, 764, -92, -92,
- -92, 149, 764, 376, 764, 764, 764, 764, 412, 764,
- 764, 764, 764, 764, 764, 302, 764, 764, 764, 131,
- 152, 145, 302, 235, 235, 302, 235, 514, 427, 392,
- 764, -73, 764, 11, 1519, 764, 764, -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, 94, 764, -92, -92, 91, 78, -92, 764, -92,
- -92, -92, -92, 764, -92, -92, -92, -92, -92, -92,
- -92, -92, -92, -92, -92, -92, -92, 764, -41, 764,
- 764, 45, 37, 764, -92, 1519, 764, 764, -92, 120,
- -92, 41, -92, -92, 73, -92, 171, 54, 26, -92,
- 258, -92, 52, 1871, -92, -92, -92, -92, -92, 253,
- -92, -92, 2, -92, -92, -92, -92, -92, -92, 1871,
- -92, -92, 346, 364, 126, 1783, 30, 250, 56, 25,
- 2047, 58, 764, -92, 61, 40, 764, 39, 35, 34,
- -92, -92, -92, -92, -92, -92, -92, -92, 122, -92,
- -92, -92, -92, 128, -92, -92, -92, -92, -92, -92,
- 27, 70, 764, 118, 132, -92, -92, 930, -92, 89,
- 65, 67, -92, 320, 83, -2, 516, 92, 141, 445,
- 235, 192, 764, 312, 764, 764, 764, 764, 445, 764,
- 764, 764, 764, 764, 235, 235, 235, 235, 235, 336,
- 445, 445, 764, -67, 764, 76, 764, -92, 603, 764,
- -92, 764, -4, -37, 764, -12, 1783, -92, 764, 119,
- 1783, -92, 764, 3, 764, 764, 50, 46, 764, -92,
- 33, 136, 9, -92, -92, 764, -92, 245, 764, -92,
- -30, 764, -22, 1783, -92, 764, 117, 1783, -92, -3,
- 234, 69, 12, 1871, -23, -92, 1783, -92, 764, 97,
- 1783, 20, 1783, -92, 28, 29, -13, -92, -92, 1783,
- -21, 280, 18, 372, 81, 764, 1783, 19, -9, 284,
- 23, -8, 683, 22, 36, -92, 849, -92, 42, 24,
- 49, 764, 48, 21, 764, 32, 764, 5, 10, 764,
- -92, 1695, 16, -92, -92, -92, -92, -92, -92, 764,
- -92, -92, -92, -92, 193, -92, 764, -57, -92, 1783,
- -92, 111, -92, -92, 1783, -92, 764, 114, -16, -92,
- 13, -92, 17, 110, 764, -92, 15, 14, -92, -45,
- -92, 1783, -92, 116, 1783, -92, 206, -92, -92, 112,
- 1783, -7, -92, -20, -14, -92, 205, -54, -18, -92,
- -92, -92, -92, 764, 99, 1783, -92, 764, 103, 1783,
- -92, -92, 106, 1266, -92, -92, 1098, -92, -92, 1182,
- -92, -92, -92, -92, -92, -92, 104, -92, -92, -92,
- -92, -92, -92, -92, 60, 64, 174, -92, 764, -92,
- 203, -92, -92, 72, 217, 90, 71, 226, 204, 181,
- -92, -92, -92, -92, -92, 1431, -92, -92, -92, 274,
- -92, -92, 1959, 1350, -92, 79, -92, -92, 323, 80,
- 325, 93, 764, 1783, 62, 38, 297, 51, 31, 683,
- 57, 66, -92, 849, -92, 68, 43, 74, 764, 75,
- 59, 764, 77, 764, 53, 47, 55, 96, -92, 315,
- -92, -92, -92, -92, 63, -92, 244, -92, -92, 764,
- -92, -92, 252, -92, -92, -92,
+ 208, 808, 1863, 61, 100, 76, -95, 95, 59, 54,
+ 261, -95, 405, 86, -95, -95, 641, 91, 67, 187,
+ 200, -95, -95, -95, 446, 206, 808, -95, -95, -95,
+ 188, -95, 1681, 1412, 808, 808, 808, -95, 724, 808,
+ -95, -95, 808, 808, -95, -95, -95, -95, 808, -95,
+ 808, 808, -95, 808, 808, 131, 212, -95, -95, 808,
+ 808, 808, -95, -95, -95, 157, 808, 405, 808, 808,
+ 808, 808, 471, 808, 808, 808, 808, 808, 808, 161,
+ 808, 808, 808, 112, 119, 117, 154, 178, 173, 234,
+ 233, 456, 549, 409, 808, 9, 808, 72, 1590, 808,
+ 808, -95, -95, -95, -95, -95, -95, -95, -95, -95,
+ -95, -95, -95, -95, -95, -95, -95, -95, -95, -95,
+ -95, -95, -95, -95, -95, -95, -95, -95, -95, -95,
+ -95, -95, -95, -95, -95, 139, 808, -95, -95, 66,
+ 23, -95, 808, -95, -95, 808, -95, -95, -95, -95,
+ -95, -95, -95, -95, -95, -95, -95, -95, -95, 808,
+ 33, 808, 808, 69, 57, 808, -95, 1590, 808, 808,
+ -95, 126, -95, 8, -95, -95, 29, -95, 186, 62,
+ 60, -95, 207, -95, 36, 1954, -95, -95, -95, -95,
+ -95, 205, -95, -95, 35, -95, -95, -95, -95, -95,
+ -95, 1954, -95, -95, 386, -95, 398, 77, 1863, 50,
+ 162, 78, 42, 2136, 73, 808, -95, 85, 48, 808,
+ 56, -95, 43, 39, -95, -95, 328, -95, -95, -95,
+ -95, -95, -95, 75, -95, -95, -95, -95, 84, -95,
+ -95, -95, -95, -95, -95, 38, 55, 808, 102, 79,
+ -95, -95, 892, -95, 175, 47, 34, -95, 324, 74,
+ 16, 551, 65, 68, 477, 278, 328, 808, 292, 808,
+ 808, 808, 808, 402, 808, 808, 808, 808, 808, 302,
+ 306, 303, 282, 307, 385, 477, 477, 808, -2, 808,
+ 71, 808, -95, 641, 808, -95, 808, 58, 63, 808,
+ 51, 1863, -95, 808, 147, 1863, -95, 808, 14, 808,
+ 808, 96, 92, 808, -95, 80, 105, 70, -95, -95,
+ 808, -95, 255, 808, -95, -58, 808, -39, 1863, -95,
+ 808, 120, 1863, -95, -20, 259, -47, -21, 1954, -36,
+ -95, 1863, -95, 808, 101, 1863, 11, 1863, -95, 15,
+ 3, -45, -95, -95, 1863, -54, 401, 2, 337, 116,
+ 808, 1863, 0, -32, 318, -1, -28, 724, 81, -5,
+ -95, 980, -95, 45, 19, 46, 808, 44, 17, 808,
+ 41, 808, 13, -8, 808, -95, 1772, 49, -95, -95,
+ -95, -95, -95, -95, 808, -95, -95, -95, -95, 272,
+ -95, 808, -13, -95, 1863, -95, 64, -95, -95, 1863,
+ -95, 808, 98, 4, -95, 25, -95, 31, 93, 808,
+ -95, 40, 37, -95, -12, -95, 1863, -95, 123, 1863,
+ -95, 288, -95, -95, 109, 1863, 20, -95, -4, 1,
+ -95, 328, -14, 21, -95, -95, -95, -95, 808, 115,
+ 1863, -95, 808, 125, 1863, -95, 12, -95, 185, -95,
+ -95, 808, -95, -95, 252, -95, -95, -95, 97, 1154,
+ -95, -95, 1067, -95, -95, 1241, -95, -95, -95, -95,
+ -95, -95, 94, -95, -95, -95, -95, -95, -95, -95,
+ -95, -95, 407, -95, -73, 376, -95, -95, -95, -95,
+ 179, 321, 198, -95, -95, 110, -95, -95, 227, -95,
+ 248, 228, -95, 89, -95, -95, -95, 219, -95, -95,
+ 103, -95, -95, -95, -95, 127, -95, 475, -95, -95,
+ -46, 168, 165, -95, -6, -95, -95, 500, 189, -95,
+ 158, -95, -95, -95, 32, 176, -95, 808, -95, 262,
+ -95, -95, 6, 10, 128, -95, 808, -95, 148, -95,
+ -95, 5, 145, 30, -3, 213, 177, 216, -95, -95,
+ -95, -95, -95, 1325, -95, -95, 327, -95, -95, 2045,
+ 1499, -95, 345, 26, 330, 82, 808, 1863, 28, 22,
+ 310, 52, 27, 584, 81, 53, -95, 980, -95, 24,
+ -31, -7, 808, 7, -9, 808, 18, 808, -10, -19,
+ -15, 111, -95, 334, -95, -95, -95,
- -104, -104, 82, -104, 6, 78, -104, -104, -104, -104,
- -104, -104, -104, -104, -104, 28, -104, -104, -104, -104,
- -104, 15, -104, 11, -104, -104, -104, -104, -104, -104,
- 19, -104, -104, -104, -104, -104, -104, -104, -104, -104,
- 343, -104, -104, -104, -104, 27, -104, -104, -104, -104,
- -104, -104, 260, -104, 26, -104, -6, -104, -104, -104,
- -104, -104, -104, -11, -104, -104, -104, -104, -104, -104,
- -104, -104, -104, -104, -104, -104, -56, -104, -104, -104,
- -104, -104, -104, -104, -104, -104, 137, -104, -104, -104,
- 60, -104, 50, 64, 141, 144, 90, 147, -104, -104,
- 126, 106, -104, -104, 109, -104, 105, 110, -104, 182,
- 121, -104, -104, -104, -104, 113, 101, 171, -104, -104,
- -104, -104, 164, -104, 170, 152, 150, 151, -104, 154,
- 99, 155, 161, 81, 55, -104, 57, 66, 63, -104,
- -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
- 80, -104, 69, -104, 93, 36, 38, -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, 41, -104, -104, -104, -104, -104, -12, -104,
- -104, -104, -104, -17, -104, -104, -104, -104, -104, -104,
- -104, -104, -104, -104, -104, -104, -104, 118, -104, 165,
- -2, -104, -104, 25, -104, 209, 16, 172, -104, -104,
- -104, -104, -104, -104, -104, -104, 17, -104, -104, -104,
- 18, -104, -104, -46, -104, -104, -104, -104, -104, -104,
- -104, -104, -104, -104, -104, -104, -104, -104, -104, 56,
- -104, -104, 0, 30, -104, -65, -104, 12, -104, -104,
- -104, -104, 119, -104, -104, -104, 13, 14, -104, -104,
- -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
- -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
- -104, -104, 23, -104, -104, -104, -104, 148, -104, -104,
- -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
- -104, 7, 178, -104, 179, 188, 245, 191, -104, 133,
- 131, 129, 140, 130, -104, -104, -104, -104, -104, -104,
- -104, -104, 207, -104, 205, -104, 217, -104, -104, 199,
- -104, 70, -104, -104, 65, -104, -10, -104, 45, -104,
- -16, -104, 203, -104, 223, 219, -104, -104, 192, -104,
- -104, -104, -104, -104, -104, 189, -104, 77, 76, -104,
- -104, 72, -104, 2, -104, 47, -104, 49, -104, -104,
- 87, -104, -104, 71, -104, -104, 10, -104, 34, -104,
- -1, -104, -20, -104, -104, -104, -104, -104, -104, -5,
- -104, 48, -104, 53, -104, 73, 3, -104, -104, 39,
- -104, -104, 68, -104, -104, -104, 119, -104, -104, -104,
- -104, 58, -104, 59, 54, -104, 114, -104, -104, 46,
- -104, 44, -104, -104, -104, -104, -104, -104, -104, 43,
- -104, -104, -104, -104, -104, -104, 173, -104, -104, -4,
- -104, -104, -104, -104, -7, -104, 42, -104, -104, -104,
- -104, -104, -49, -104, 40, -104, -40, -104, -104, -104,
- -104, -31, -104, -104, 4, -104, -104, -104, -104, -104,
- -104, -30, -104, -104, 52, -104, 37, -104, -15, -104,
- -104, -104, -104, -13, -104, -68, -104, -3, -104, -63,
- -104, -104, -104, -24, -104, -104, 92, -104, -104, -22,
- -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
- -104, -104, -104, -104, -104, -104, -104, -104, 22, -104,
- -104, -104, -104, -104, 21, -104, -104, 35, 32, 33,
- -104, -104, -104, -104, -104, 256, -104, -104, -104, 8,
- -104, -104, -104, 210, -104, -104, -104, -104, 20, -104,
- 30, -104, 51, -41, -104, -104, 29, -104, -104, 74,
- -104, -104, -104, 1, -104, -104, -104, -104, 31, -104,
- 24, 88, -104, 95, -104, -104, -104, -104, -104, 107,
- -104, -104, -104, -104, -104, -104, -104, -104, -104, -21,
- -104, -104, 84, -104, -104, -104};
+ -103, 37, 13, -103, -103, -103, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, -55, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, 89, -103, -103, -103,
+ 24, -103, -103, 6, 15, 92, 100, -103, 154, 66,
+ -103, -103, 86, 143, -103, -103, -103, -103, 152, -103,
+ 144, 140, -103, 134, 135, -103, -103, -103, -103, 161,
+ 170, 176, -103, -103, -103, -103, 174, -103, 169, 153,
+ 162, 167, -103, 128, 126, 112, 116, 119, 113, -103,
+ 111, 104, 110, -103, -103, -103, -103, -103, -103, -103,
+ -103, -103, -103, -103, 63, -103, 120, -103, 88, 77,
+ 57, -103, -103, -103, -103, -103, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, 28, -103, -103, -103,
+ -103, -103, 31, -103, -103, 36, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, -103, -103, -103, 157,
+ -103, 125, -24, -103, -103, -14, -103, 210, 27, 160,
+ -103, -103, -103, -103, -103, -103, -103, -103, 8, -103,
+ -103, -103, -5, -103, -103, 74, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
+ -103, 94, -103, -103, 44, -103, 35, -103, 81, -103,
+ 61, -103, -103, -103, -103, 75, -103, -103, -103, 4,
+ -7, -103, -103, -103, -103, -103, 26, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, -103, 68, -103, -103,
+ -103, -103, 90, -103, -103, -103, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, 70, 220, -103, 208,
+ 231, 230, 234, -103, 101, 82, 60, 76, 79, -103,
+ -103, -103, -103, -103, -103, -103, -103, 211, -103, 194,
+ -103, 192, -103, -103, 204, -103, 166, -103, -103, 197,
+ -103, 23, -103, -1, -103, 9, -103, 180, -103, 181,
+ 223, -103, -103, 227, -103, -103, -103, -103, -103, -103,
+ 184, -103, 93, 98, -103, -103, 108, -103, 83, -103,
+ 78, -103, 40, -103, -103, 109, -103, -103, 102, -103,
+ -103, 41, -103, 43, -103, 52, -103, 62, -103, -103,
+ -103, -103, -103, -103, 55, -103, 50, -103, 51, -103,
+ 107, 49, -103, -103, 73, -103, -103, 154, -103, -103,
+ -103, 64, -103, -103, -103, -103, 16, -103, 12, 147,
+ -103, 103, -103, -103, -4, -103, 0, -103, -103, -103,
+ -103, -103, -103, -103, 7, -103, -103, -103, -103, -103,
+ -103, 187, -103, -103, 25, -103, -103, -103, -103, 71,
+ -103, 65, -103, -103, -103, -103, -103, -44, -103, 46,
+ -103, -34, -103, -103, -103, -103, -21, -103, -103, -45,
+ -103, -103, -103, -103, -103, -103, -32, -103, -103, 53,
+ -103, 56, -103, 47, -103, -103, -103, -103, 42, -103,
+ 45, -103, 38, -103, 48, -103, -103, -103, -103, -103,
+ -103, 22, -103, -103, 124, -103, -103, -103, -103, 59,
+ -103, -103, 137, -103, -103, 54, -103, -103, -103, -103,
+ -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
+ -103, -103, 248, -103, -3, 114, -103, -103, -103, -103,
+ -103, -103, 5, -103, -103, -103, -103, -103, -8, -103,
+ 85, -103, -103, -103, -103, -103, -103, 11, -103, -103,
+ -103, -103, -103, -103, -103, -103, -103, 342, -103, -103,
+ -103, 29, -103, -103, -103, -103, -103, 273, -103, -103,
+ 3, -103, -103, -103, -103, -103, -103, 18, -103, -103,
+ -103, -103, -103, -103, -103, -103, 21, -103, -103, -103,
+ -103, -103, 2, -103, -103, 20, 14, 30, -103, -103,
+ -103, -103, -103, 284, -103, -103, -2, -103, -103, -103,
+ 222, -103, -9, -103, -6, -103, 96, 10, -103, -103,
+ 1, -103, -103, 80, -103, -103, -103, 72, -103, -103,
+ -103, -103, 69, -103, 58, 67, -103, 97, -103, -103,
+ -103, -103, -103, 84, -103, -103, -103};
const int QmlJSGrammar::action_info [] = {
- 152, 150, 543, 458, 192, 152, 498, 150, 217, 122,
- 480, 344, 122, 494, 61, 490, 496, 470, 474, 490,
- 474, 481, 474, 449, 354, -123, -104, 307, 398, -112,
- -90, 381, 395, 390, 453, 439, 402, 441, 383, -120,
- 385, 503, 451, -94, 223, 393, 507, 217, 356, -93,
- 375, 342, 362, 368, 490, -117, -115, 286, -90, 351,
- 466, 398, 240, 396, -112, 459, 307, 398, 464, -104,
- 507, 503, 490, -94, 307, -93, 466, 322, 2, 466,
- 609, -115, -117, 507, -120, 243, 242, -123, -80, 503,
- 322, 346, 490, 536, 362, 2, 390, 23, 548, 198,
- 0, 232, 192, 301, 599, 192, 302, 192, 544, 236,
- 56, 192, 192, 342, 516, 40, 0, 0, 493, 0,
- 477, 0, 192, 484, 192, 192, 192, 192, 192, 392,
- 0, 551, 494, 0, 0, 219, 0, 0, 200, 220,
- 603, 602, 299, 298, 377, 344, 0, 20, 19, 109,
- 193, 192, 600, 0, 299, 298, 0, 400, 0, 505,
- 110, 115, 517, 509, 527, 478, 35, 34, 615, 28,
- 27, 109, 463, 462, 468, 113, 230, 387, 304, 360,
- 8, 538, 110, 292, 291, 109, 114, 299, 298, 297,
- 296, 364, 109, 306, 305, 365, 110, 378, 32, 31,
- 8, 225, 8, 110, 202, 201, 116, 8, 225, 154,
- 8, 192, 117, 8, 192, 555, 8, 9, 12, 8,
- 226, 8, 227, 23, 57, 115, 30, 226, 155, 456,
- 156, 63, 115, 57, 8, 539, 537, 9, 12, 9,
- 12, 40, 0, 57, 9, 12, 57, 9, 12, 0,
- 9, 12, 612, 9, 12, 8, 9, 12, 9, 12,
- 136, 192, 137, 8, 542, 541, 8, 488, 487, 59,
- 116, 9, 12, 138, 8, 0, 117, 116, 59, 8,
- 58, 8, 192, 117, 0, 64, 62, 8, 59, 58,
- 0, 59, 9, 12, 17, 16, 0, 0, 0, 58,
- 9, 12, 58, 9, 12, 613, 611, 40, 0, 8,
- 0, 9, 12, 8, 285, 284, 9, 12, 9, 12,
- -334, 0, 15, 23, 9, 12, 8, 136, 0, 137,
- 324, 325, 0, -334, 0, 285, 284, 0, 324, 325,
- 138, 290, 289, 0, 8, 0, 9, 12, 0, 0,
- 9, 12, 8, 0, 8, 24, 0, 326, 327, 329,
- 330, 0, 0, 9, 12, 326, 327, 0, 331, 25,
- 22, 332, 8, 333, 11, 8, 0, 0, 0, 0,
- 0, 9, 12, 0, 290, 289, 295, 294, 0, 9,
- 12, 9, 12, 8, 124, 125, 0, 21, 0, 0,
- 10, 8, 11, 0, 0, 0, 0, 290, 289, 9,
- 12, 0, 9, 12, 0, 129, 130, 0, 8, 0,
- 0, 126, 127, 131, 132, 295, 294, 133, 10, 134,
- 9, 12, 0, 295, 294, 129, 130, 0, 9, 12,
- 0, 44, 0, 131, 132, 0, 0, 133, 11, 134,
- 129, 130, 0, 45, 13, 9, 12, 0, 131, 132,
- 8, 0, 133, 0, 134, 0, 44, 0, 329, 330,
- 0, 0, 0, 0, 10, 0, 0, 331, 45, 0,
- 332, 0, 333, 0, 0, 8, 553, 0, 0, 0,
- 11, 0, 0, 0, 0, 0, 0, 46, 48, 0,
- 0, 0, 0, 0, 0, 49, 0, 0, 0, 0,
- 0, 47, 0, 0, 43, 11, 10, 0, 0, 204,
- 0, 0, 46, 48, 0, 0, 0, 0, 0, 205,
- 49, 0, 0, 206, 0, 0, 0, 129, 130, 43,
- 0, 10, 207, 0, 208, 131, 132, 358, 0, 133,
- 0, 134, 0, 0, 0, 209, 0, 210, 113, 0,
- 0, 0, 0, 0, 0, 211, 0, 0, 212, 114,
- 0, 0, 0, 0, 213, 0, 0, 0, 0, 0,
- 214, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 215, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 204, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 205, 0, 0, 0,
- 206, 0, 0, 0, 0, 0, 0, 0, 0, 207,
- 0, 208, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 209, 0, 210, 113, 0, 0, 0, 0,
- 0, 0, 211, 0, 0, 212, 114, 0, 0, 0,
- 0, 213, 0, 0, 0, 0, 0, 214, 0, 0,
+ -114, 398, -93, 326, 252, 411, -89, -103, 343, -122,
+ 396, 386, 338, 337, -116, 492, 335, 452, -79, 340,
+ 540, 328, 384, 561, 435, -119, 448, 347, 452, 461,
+ 419, -92, 441, -122, 435, -103, 419, 415, 566, 554,
+ 439, 562, 335, 425, 426, 419, 443, 403, -119, 448,
+ 435, -116, -92, -114, 435, 411, 394, 569, 252, -89,
+ -93, 545, 287, 343, 165, 178, 136, 307, 174, 185,
+ 182, 159, 267, 66, 142, 452, 289, 296, 343, 448,
+ 404, 94, 291, 144, 411, 341, 252, 96, -111, 435,
+ 231, 247, 409, 159, 136, 287, 66, 320, 307, 313,
+ 616, 330, 136, 422, 0, 472, 136, 94, 0, 136,
+ 136, 301, 289, 322, 246, 438, 53, 161, 309, 613,
+ 184, 162, 310, 136, 299, 408, 407, 54, 136, 439,
+ 429, 136, 96, 136, 136, 556, 237, 236, 244, 243,
+ 251, 250, 510, 244, 243, 242, 241, 136, 423, 492,
+ 515, 514, 53, 473, 483, 136, 136, 53, 413, 53,
+ 527, 345, 249, 54, 522, 521, 323, 614, 54, 59,
+ 54, 507, 506, 57, 541, 450, 267, 244, 243, 80,
+ 332, 81, 172, 547, 58, 454, 80, 541, 81, 557,
+ 555, 31, 82, 464, 541, 137, 573, 31, 80, 82,
+ 81, 0, 167, 80, 510, 81, 541, 305, 0, 560,
+ 559, 82, 59, 136, 60, 31, 82, 31, 0, 543,
+ 61, 168, 527, 169, 59, 0, 0, 31, 44, 45,
+ 542, 80, 543, 81, 44, 45, 31, 548, 546, 543,
+ 504, 503, 31, 542, 82, 31, 465, 463, 31, 0,
+ 542, 543, 44, 45, 44, 45, 31, 60, 80, 80,
+ 81, 81, 542, 61, 44, 45, 230, 229, 502, 60,
+ 136, 82, 82, 44, 45, 61, 98, 31, 0, 44,
+ 45, 31, 44, 45, 31, 44, 45, 167, 31, 519,
+ 518, 0, 0, 44, 45, 99, 136, 100, 3, 2,
+ 1, 0, 0, 80, 0, 81, 168, 80, 401, 81,
+ 269, 270, 0, 0, 44, 45, 82, 517, 44, 45,
+ 82, 44, 45, 551, 550, 44, 45, 80, 80, 81,
+ 81, 80, 80, 81, 81, 136, 510, 271, 272, 31,
+ 82, 82, 269, 270, 82, 82, -333, 31, 0, 433,
+ 432, 0, 0, 0, -333, 0, 0, 31, 0, 31,
+ 527, 0, 0, 31, 0, 0, 31, 0, 511, 271,
+ 272, 0, 0, 0, 31, 0, 44, 45, 0, 0,
+ 0, 0, 512, 509, 44, 45, 0, 0, 230, 229,
+ 0, 240, 239, 499, 44, 45, 44, 45, 240, 239,
+ 44, 45, 0, 44, 45, 31, 235, 234, 274, 275,
+ 508, 44, 45, 0, 0, 31, 0, 276, 0, 498,
+ 277, 0, 278, 68, 69, 274, 275, 31, 0, 0,
+ 31, 0, 73, 74, 276, 499, 31, 277, 0, 278,
+ 75, 76, 44, 45, 77, 0, 78, 235, 234, 0,
+ 70, 71, 44, 45, 0, 0, 0, 0, 0, 240,
+ 239, 498, 235, 234, 44, 45, 499, 44, 45, 73,
+ 74, 0, 500, 44, 45, 0, 0, 75, 76, 73,
+ 74, 77, 0, 78, 0, 530, 0, 75, 76, 0,
+ 0, 77, 498, 78, 73, 74, 0, 531, 0, 0,
+ 274, 275, 75, 76, 31, 0, 77, 0, 78, 276,
+ 530, 0, 277, 0, 278, 0, 0, 0, 0, 0,
+ 0, 0, 531, 0, 0, 0, 0, 0, 0, 31,
+ 533, 0, 0, 0, 499, 0, 0, 0, 0, 0,
+ 0, 532, 534, 0, 0, 0, 0, 0, 0, 221,
+ 0, 0, 0, 0, 146, 571, 0, 0, 205, 499,
+ 498, 0, 0, 0, 147, 0, 532, 534, 148, 0,
+ 0, 0, 73, 74, 221, 0, 0, 149, 0, 150,
+ 75, 76, 303, 205, 77, 498, 78, 0, 0, 0,
+ 151, 0, 152, 57, 0, 0, 27, 28, 0, 0,
+ 153, 0, 0, 154, 58, 0, 30, 0, 0, 155,
+ 0, 0, 0, 31, 0, 156, 0, 32, 33, 0,
+ 34, 0, 0, 0, 0, 0, 0, 38, 0, 0,
+ 157, 41, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 146, 0, 0, 0, 0, 46,
+ 44, 45, 0, 47, 147, 0, 0, 0, 148, 0,
+ 0, 0, 0, 0, 40, 49, 29, 149, 0, 150,
+ 37, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 151, 0, 152, 57, 0, 0, 0, 0, 0, 0,
+ 153, 0, 0, 154, 58, 0, 0, 0, 0, 155,
+ 0, 0, 0, 0, 0, 156, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 215, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 87, 88, 0, 0, 0,
- 0, 0, 0, 0, 0, 90, 0, 0, 0, 0,
- 0, 0, 8, 0, 0, 0, 91, 92, 0, 93,
- 0, 0, 0, 0, 0, 0, 96, 0, 0, 0,
- 99, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 102, 9,
- 12, 0, 103, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 98, 105, 89, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 86, 87, 88, 0, 0,
- 0, 0, 0, 0, 0, 0, 90, 0, 0, 0,
- 0, 0, 0, 8, 0, 0, 0, 91, 92, 0,
- 93, 0, 0, 0, 94, 0, 95, 96, 97, 0,
- 0, 99, 0, 0, 0, 100, 0, 101, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 102,
- 9, 12, 0, 103, 0, 104, 0, 106, 0, 107,
- 0, 0, 0, 0, 98, 105, 89, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -113, 0, 0, 0,
- 86, 87, 88, 0, 0, 0, 0, 0, 0, 0,
- 0, 90, 0, 0, 0, 0, 0, 0, 8, 0,
- 0, 0, 91, 92, 0, 93, 0, 0, 0, 94,
- 0, 95, 96, 97, 0, 0, 99, 0, 0, 0,
- 100, 0, 101, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 102, 9, 12, 0, 103, 0,
- 104, 0, 106, 0, 107, 0, 0, 0, 0, 98,
- 105, 89, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 86, 87, 88, 0, 0, 0, 0, 0, 0,
- 0, 0, 90, 0, 0, 0, 0, 0, 0, 8,
- 0, 0, 0, 91, 92, 0, 93, 0, 0, 0,
- 94, 0, 95, 96, 97, 0, 0, 99, 0, 0,
- 0, 100, 0, 101, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 102, 9, 12, 0, 103,
- 0, 104, 0, 106, 321, 107, 0, 0, 0, 0,
- 98, 105, 89, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 514, 0, 0, 86, 87, 88, 0, 0,
- 0, 0, 0, 0, 0, 0, 90, 0, 0, 0,
- 0, 0, 0, 8, 0, 0, 0, 91, 92, 0,
- 93, 0, 0, 0, 94, 0, 95, 96, 97, 0,
- 0, 99, 0, 0, 0, 100, 0, 101, 0, 0,
- 515, 0, 0, 0, 0, 0, 0, 0, 0, 102,
- 9, 12, 0, 103, 0, 104, 0, 106, 0, 107,
- 0, 0, 0, 0, 98, 105, 89, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 514, 0, 0, 86,
- 87, 88, 0, 0, 0, 0, 0, 0, 0, 0,
- 90, 0, 0, 0, 0, 0, 0, 8, 0, 0,
- 0, 91, 92, 0, 93, 0, 0, 0, 94, 0,
- 95, 96, 97, 0, 0, 99, 0, 0, 0, 100,
- 0, 101, 0, 0, 520, 0, 0, 0, 0, 0,
- 0, 0, 0, 102, 9, 12, 0, 103, 0, 104,
- 0, 106, 0, 107, 0, 0, 0, 0, 98, 105,
- 89, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 522, 0, 0, 86, 87, 88, 0, 0, 0, 0,
- 0, 0, 0, 0, 90, 0, 0, 0, 0, 0,
- 0, 8, 0, 0, 0, 91, 92, 0, 93, 0,
- 0, 0, 94, 0, 95, 96, 97, 0, 0, 99,
- 0, 0, 0, 100, 0, 101, 0, 0, 523, 0,
- 0, 0, 0, 0, 0, 0, 0, 102, 9, 12,
- 0, 103, 0, 104, 0, 106, 0, 107, 0, 0,
- 0, 0, 98, 105, 89, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 522, 0, 0, 86, 87, 88,
- 0, 0, 0, 0, 0, 0, 0, 0, 90, 0,
- 0, 0, 0, 0, 0, 8, 0, 0, 0, 91,
- 92, 0, 93, 0, 0, 0, 94, 0, 95, 96,
- 97, 0, 0, 99, 0, 0, 0, 100, 0, 101,
- 0, 0, 525, 0, 0, 0, 0, 0, 0, 0,
- 0, 102, 9, 12, 0, 103, 0, 104, 0, 106,
- 0, 107, 0, 0, 0, 0, 98, 105, 89, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 514, 0,
- 0, 86, 87, 88, 0, 0, 0, 0, 0, 0,
- 0, 0, 90, 0, 0, 0, 0, 0, 0, 8,
- 0, 0, 0, 91, 92, 0, 93, 0, 0, 0,
- 94, 0, 95, 96, 97, 0, 0, 99, 0, 0,
- 0, 100, 0, 101, 0, 0, 515, 0, 0, 11,
- 0, 0, 0, 0, 0, 102, 9, 12, 0, 103,
- 0, 104, 0, 106, 0, 107, 0, 0, 0, 0,
- 98, 105, 89, 0, 0, 10, 0, 0, 0, 0,
- 0, 0, 86, 87, 88, 0, 0, 0, 0, 0,
- 0, 0, 0, 90, 0, 0, 0, 0, 0, 0,
- 8, 269, 0, 0, 562, 563, 0, 93, 0, 0,
- 0, 94, 0, 95, 96, 97, 0, 0, 99, 0,
- 0, 0, 100, 0, 101, 0, 0, 0, 0, 0,
- 0, 0, 273, 0, 0, 0, 102, 9, 12, 0,
- 103, 0, 104, 0, 106, 0, 107, 0, 0, 0,
- 0, 98, 105, 89, 0, 264, 0, 564, 0, 0,
- 0, 0, 0, 160, 161, 162, 0, 0, 164, 166,
- 167, 0, 0, 168, 0, 169, 0, 0, 0, 171,
- 172, 173, 0, 0, 0, 0, 0, 0, 8, 174,
- 175, 176, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 177, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 180, 0,
- 0, 0, 0, 0, 0, 9, 12, 181, 182, 183,
- 0, 185, 186, 187, 188, 189, 190, 0, 0, 178,
- 184, 170, 163, 165, 179, 0, 0, 0, 0, 0,
- 0, 160, 161, 162, 0, 0, 164, 166, 167, 0,
- 0, 168, 0, 169, 0, 0, 0, 171, 172, 173,
- 0, 0, 0, 0, 0, 0, 443, 174, 175, 176,
+ 157, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 27, 28, 0, 0,
+ 0, 0, 0, 0, 0, 0, 30, 0, 0, 0,
+ 0, 0, 0, 31, 0, 0, 0, 32, 33, 0,
+ 34, 0, 0, 0, 0, 0, 0, 38, 0, 0,
+ 0, 41, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 46,
+ 44, 45, 0, 47, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 40, 49, 29, 0, 0, 0,
+ 37, 0, 0, 0, 0, 0, 0, 0, 0, 26,
+ 27, 28, 0, 0, 0, 0, 0, 0, 0, 0,
+ 30, 0, 0, 0, 0, 0, 0, 31, 0, 0,
+ 0, 32, 33, 0, 34, 0, 0, 0, 35, 0,
+ 36, 38, 39, 0, 0, 41, 0, 0, 0, 42,
+ 0, 43, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 46, 44, 45, 0, 47, 0, 48,
+ 0, 50, 0, 51, 0, 0, 0, 0, 40, 49,
+ 29, 0, 0, 0, 37, 0, 0, 0, 0, 0,
+ 0, 0, 0, 26, 27, 28, 0, 0, 0, 0,
+ 0, 0, 0, 0, 30, 0, 0, 0, 0, 0,
+ 0, 31, 0, 0, 0, 32, 33, 0, 34, 0,
+ 0, 0, 35, 0, 36, 38, 39, 0, 0, 41,
+ 0, 0, 0, 42, 0, 43, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 46, 44, 45,
+ 0, 47, 0, 48, 0, 50, 266, 51, 0, 0,
+ 0, 0, 40, 49, 29, 0, 0, 0, 37, 0,
+ 0, 0, 0, 0, 0, 0, 0, -112, 0, 0,
+ 0, 26, 27, 28, 0, 0, 0, 0, 0, 0,
+ 0, 0, 30, 0, 0, 0, 0, 0, 0, 31,
+ 0, 0, 0, 32, 33, 0, 34, 0, 0, 0,
+ 35, 0, 36, 38, 39, 0, 0, 41, 0, 0,
+ 0, 42, 0, 43, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 46, 44, 45, 0, 47,
+ 0, 48, 0, 50, 0, 51, 0, 0, 0, 0,
+ 40, 49, 29, 0, 0, 0, 37, 0, 0, 0,
+ 0, 0, 0, 0, 0, 470, 0, 0, 26, 27,
+ 28, 0, 0, 0, 0, 0, 0, 0, 0, 30,
+ 0, 0, 0, 0, 0, 0, 31, 0, 0, 0,
+ 32, 33, 0, 34, 0, 0, 0, 35, 0, 36,
+ 38, 39, 0, 0, 41, 0, 0, 0, 42, 0,
+ 43, 0, 0, 476, 0, 0, 0, 0, 0, 0,
+ 0, 0, 46, 44, 45, 0, 47, 0, 48, 0,
+ 50, 0, 51, 0, 0, 0, 0, 40, 49, 29,
+ 0, 0, 0, 37, 0, 0, 0, 0, 0, 0,
+ 0, 0, 478, 0, 0, 26, 27, 28, 0, 0,
+ 0, 0, 0, 0, 0, 0, 30, 0, 0, 0,
+ 0, 0, 0, 31, 0, 0, 0, 32, 33, 0,
+ 34, 0, 0, 0, 35, 0, 36, 38, 39, 0,
+ 0, 41, 0, 0, 0, 42, 0, 43, 0, 0,
+ 481, 0, 0, 0, 0, 0, 0, 0, 0, 46,
+ 44, 45, 0, 47, 0, 48, 0, 50, 0, 51,
+ 0, 0, 0, 0, 40, 49, 29, 0, 0, 0,
+ 37, 0, 0, 0, 0, 0, 0, 0, 0, 478,
+ 0, 0, 26, 27, 28, 0, 0, 0, 0, 0,
+ 0, 0, 0, 30, 0, 0, 0, 0, 0, 0,
+ 31, 0, 0, 0, 32, 33, 0, 34, 0, 0,
+ 0, 35, 0, 36, 38, 39, 0, 0, 41, 0,
+ 0, 0, 42, 0, 43, 0, 0, 479, 0, 0,
+ 0, 0, 0, 0, 0, 0, 46, 44, 45, 0,
+ 47, 0, 48, 0, 50, 0, 51, 0, 0, 0,
+ 0, 40, 49, 29, 0, 0, 0, 37, 0, 0,
+ 0, 0, 0, 0, 0, 0, 26, 27, 28, 0,
+ 0, 0, 0, 0, 0, 0, 0, 30, 0, 0,
+ 0, 0, 0, 0, 31, 212, 0, 0, 579, 580,
+ 0, 34, 0, 0, 0, 35, 0, 36, 38, 39,
+ 0, 0, 41, 0, 0, 0, 42, 0, 43, 0,
+ 0, 0, 0, 0, 0, 0, 216, 0, 0, 0,
+ 46, 44, 45, 0, 47, 0, 48, 0, 50, 0,
+ 51, 0, 0, 0, 0, 40, 49, 29, 0, 0,
+ 0, 37, 0, 0, 0, 0, 0, 0, 0, 0,
+ 470, 0, 0, 26, 27, 28, 0, 0, 0, 0,
+ 0, 0, 0, 0, 30, 0, 0, 0, 0, 0,
+ 0, 31, 0, 0, 0, 32, 33, 0, 34, 0,
+ 0, 0, 35, 0, 36, 38, 39, 0, 0, 41,
+ 0, 0, 0, 42, 0, 43, 0, 0, 471, 0,
+ 0, 0, 0, 0, 0, 0, 0, 46, 44, 45,
+ 0, 47, 0, 48, 0, 50, 0, 51, 0, 0,
+ 0, 0, 40, 49, 29, 0, 0, 0, 37, 0,
+ 0, 0, 0, 0, 0, 0, 0, 470, 0, 0,
+ 26, 27, 28, 0, 0, 0, 0, 0, 0, 0,
+ 0, 30, 0, 0, 0, 0, 0, 0, 31, 0,
+ 0, 0, 32, 33, 0, 34, 0, 0, 0, 35,
+ 0, 36, 38, 39, 0, 0, 41, 0, 0, 0,
+ 42, 0, 43, 0, 0, 471, 0, 0, 499, 0,
+ 0, 0, 0, 0, 46, 44, 45, 0, 47, 0,
+ 48, 0, 50, 0, 51, 0, 0, 0, 0, 40,
+ 49, 29, 0, 0, 498, 37, 0, 0, 0, 0,
+ 0, 0, 0, 0, 104, 105, 106, 0, 0, 108,
+ 110, 111, 0, 0, 112, 0, 113, 0, 0, 0,
+ 115, 116, 117, 0, 0, 0, 0, 0, 0, 31,
+ 118, 119, 120, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 121, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 124,
+ 0, 0, 0, 0, 0, 0, 44, 45, 125, 126,
+ 127, 0, 129, 130, 131, 132, 133, 134, 0, 0,
+ 122, 128, 114, 107, 109, 123, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 104, 105, 106, 0, 0,
+ 108, 110, 111, 0, 0, 112, 0, 113, 0, 0,
+ 0, 115, 116, 117, 0, 0, 0, 0, 0, 0,
+ 388, 118, 119, 120, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 121, 0, 0, 0, 389, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 177, 0, 0, 0, 444, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 180, 0, 0, 0,
- 0, 0, 448, 445, 447, 181, 182, 183, 0, 185,
- 186, 187, 188, 189, 190, 0, 0, 178, 184, 170,
- 163, 165, 179, 0, 0, 0, 0, 0, 0, 160,
- 161, 162, 0, 0, 164, 166, 167, 0, 0, 168,
- 0, 169, 0, 0, 0, 171, 172, 173, 0, 0,
- 0, 0, 0, 0, 443, 174, 175, 176, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 177, 0,
- 0, 0, 444, 0, 0, 0, 0, 0, 0, 0,
- 446, 0, 0, 0, 180, 0, 0, 0, 0, 0,
- 448, 445, 447, 181, 182, 183, 0, 185, 186, 187,
- 188, 189, 190, 0, 0, 178, 184, 170, 163, 165,
- 179, 0, 0, 0, 0, 0, 0, 262, 0, 0,
- 0, 0, 263, 0, 86, 87, 88, 265, 0, 0,
- 0, 0, 0, 0, 266, 90, 0, 0, 0, 0,
- 0, 0, 268, 269, 0, 0, 270, 92, 0, 93,
- 0, 0, 0, 94, 0, 95, 96, 97, 0, 0,
- 99, 0, 0, 0, 100, 0, 101, 0, 0, 0,
- 0, 0, 272, 0, 273, 0, 0, 0, 102, 271,
- 274, 275, 103, 276, 104, 277, 106, 49, 107, 278,
- 279, 0, 0, 98, 105, 89, 43, 264, 0, 0,
- 0, 0, 0, 0, 0, 262, 0, 0, 0, 0,
- 263, 0, 86, 87, 88, 265, 0, 0, 0, 0,
- 0, 0, 266, 267, 0, 0, 0, 0, 0, 0,
- 268, 269, 0, 0, 270, 92, 0, 93, 0, 0,
- 0, 94, 0, 95, 96, 97, 0, 0, 99, 0,
- 0, 0, 100, 0, 101, 0, 0, 0, 0, 0,
- 272, 0, 273, 0, 0, 0, 102, 271, 274, 275,
- 103, 276, 104, 277, 106, 49, 107, 278, 279, 0,
- 0, 98, 105, 89, 43, 264, 0, 0, 0, 0,
- 0, 0, 0, 568, 161, 162, 0, 0, 570, 166,
- 572, 87, 88, 573, 0, 169, 0, 0, 0, 171,
- 575, 576, 0, 0, 0, 0, 0, 0, 577, 578,
- 175, 176, 270, 92, 0, 93, 0, 0, 0, 94,
- 0, 95, 579, 97, 0, 0, 581, 0, 0, 0,
- 100, 0, 101, 0, 0, 0, 0, 0, 583, 0,
- 273, 0, 0, 0, 585, 582, 584, 586, 587, 588,
- 104, 590, 591, 592, 593, 594, 595, 0, 0, 580,
- 589, 574, 569, 571, 179, 0, 0, 0, 0, 0,
- 0, 411, 161, 162, 0, 0, 413, 166, 415, 87,
- 88, 416, 0, 169, 0, 0, 0, 171, 418, 419,
- 0, 0, 0, 0, 0, 0, 420, 421, 175, 176,
- 270, 92, 0, 93, 0, 0, 0, 94, 0, 95,
- 422, 97, 0, 0, 424, 0, 0, 0, 100, 0,
- 101, 0, -259, 0, 0, 0, 426, 0, 273, 0,
- 0, 0, 428, 425, 427, 429, 430, 431, 104, 433,
- 434, 435, 436, 437, 438, 0, 0, 423, 432, 417,
- 412, 414, 179, 0, 0, 0, 0, 0, 0,
+ 124, 0, 0, 0, 0, 0, 393, 390, 392, 125,
+ 126, 127, 0, 129, 130, 131, 132, 133, 134, 0,
+ 0, 122, 128, 114, 107, 109, 123, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 104, 105, 106, 0,
+ 0, 108, 110, 111, 0, 0, 112, 0, 113, 0,
+ 0, 0, 115, 116, 117, 0, 0, 0, 0, 0,
+ 0, 388, 118, 119, 120, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 121, 0, 0, 0, 389,
+ 0, 0, 0, 0, 0, 0, 0, 391, 0, 0,
+ 0, 124, 0, 0, 0, 0, 0, 393, 390, 392,
+ 125, 126, 127, 0, 129, 130, 131, 132, 133, 134,
+ 0, 0, 122, 128, 114, 107, 109, 123, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 204, 0, 0,
+ 0, 0, 206, 0, 26, 27, 28, 208, 0, 0,
+ 0, 0, 0, 0, 209, 30, 0, 0, 0, 0,
+ 0, 0, 211, 212, 0, 0, 213, 33, 0, 34,
+ 0, 0, 0, 35, 0, 36, 38, 39, 0, 0,
+ 41, 0, 0, 0, 42, 0, 43, 0, 0, 0,
+ 0, 0, 215, 0, 216, 0, 0, 0, 46, 214,
+ 217, 218, 47, 219, 48, 220, 50, 221, 51, 222,
+ 223, 0, 0, 40, 49, 29, 205, 207, 0, 37,
+ 0, 0, 0, 0, 0, 0, 0, 0, 204, 0,
+ 0, 0, 0, 206, 0, 26, 27, 28, 208, 0,
+ 0, 0, 0, 0, 0, 209, 210, 0, 0, 0,
+ 0, 0, 0, 211, 212, 0, 0, 213, 33, 0,
+ 34, 0, 0, 0, 35, 0, 36, 38, 39, 0,
+ 0, 41, 0, 0, 0, 42, 0, 43, 0, 0,
+ 0, 0, 0, 215, 0, 216, 0, 0, 0, 46,
+ 214, 217, 218, 47, 219, 48, 220, 50, 221, 51,
+ 222, 223, 0, 0, 40, 49, 29, 205, 207, 0,
+ 37, 0, 0, 0, 0, 0, 0, 0, 0, 582,
+ 105, 106, 0, 0, 584, 110, 586, 27, 28, 587,
+ 0, 113, 0, 0, 0, 115, 589, 590, 0, 0,
+ 0, 0, 0, 0, 591, 592, 119, 120, 213, 33,
+ 0, 34, 0, 0, 0, 35, 0, 36, 593, 39,
+ 0, 0, 595, 0, 0, 0, 42, 0, 43, 0,
+ 0, 0, 0, 0, 597, 0, 216, 0, 0, 0,
+ 599, 596, 598, 600, 601, 602, 48, 604, 605, 606,
+ 607, 608, 609, 0, 0, 594, 603, 588, 583, 585,
+ 123, 37, 0, 0, 0, 0, 0, 0, 0, 0,
+ 356, 105, 106, 0, 0, 358, 110, 360, 27, 28,
+ 361, 0, 113, 0, 0, 0, 115, 363, 364, 0,
+ 0, 0, 0, 0, 0, 365, 366, 119, 120, 213,
+ 33, 0, 34, 0, 0, 0, 35, 0, 36, 367,
+ 39, 0, 0, 369, 0, 0, 0, 42, 0, 43,
+ 0, -258, 0, 0, 0, 371, 0, 216, 0, 0,
+ 0, 373, 370, 372, 374, 375, 376, 48, 378, 379,
+ 380, 381, 382, 383, 0, 0, 368, 377, 362, 357,
+ 359, 123, 37, 0, 0, 0, 0, 0, 0, 0,
+ 0,
- 506, 499, 504, 300, 73, 510, 288, 524, 203, 521,
- 610, 36, 508, 370, 216, 60, 352, 29, 389, 199,
- 567, 26, 260, 239, 241, 33, 288, 300, 486, 222,
- 489, 229, 604, 534, 18, 235, 293, 540, 303, 550,
- 489, 552, 547, 497, 475, 235, 486, 482, 403, 399,
- 479, 191, 361, 549, 288, 483, 224, 467, 357, 293,
- 359, 465, 386, 452, 460, 495, 235, 401, 500, 197,
- 384, 300, 194, 486, 450, 489, 442, 440, 397, 526,
- 352, 511, 485, 370, 7, 352, 37, 352, 7, 14,
- 604, 352, 111, 239, 233, 111, 111, 501, 111, 157,
- 0, 146, 139, 454, 111, 0, 455, 111, 141, 454,
- 111, 140, 455, 7, 111, 601, 233, 388, 0, 519,
- 153, 111, 111, 518, 260, 454, 159, 145, 455, 111,
- 355, 501, 0, 151, 352, 353, 111, 382, 502, 260,
- 111, 380, 111, 0, 119, 142, 111, 111, 501, 532,
- 111, 111, 533, 502, 111, 111, 118, 502, 287, 111,
- 0, 379, 111, 0, 0, 121, 614, 111, 394, 531,
- 111, 111, 111, 218, 111, 336, 338, 335, 111, 334,
- 233, 111, 111, 391, 528, 111, 337, 529, 111, 316,
- 530, 111, 111, 111, 320, 111, 111, 148, 149, 147,
- 135, 143, 111, 197, 197, 111, 111, 144, 0, 231,
- 457, 111, 111, 123, 120, 157, 596, 128, 598, 111,
- 111, 0, 221, 111, 320, 320, 112, 328, 323, 111,
- 348, 0, 111, 348, 320, 320, 339, 320, 320, 341,
- 348, 511, 159, 228, 111, 320, 111, 0, 111, 320,
- 0, 320, 376, 320, 0, 369, 0, 345, 348, 363,
- 348, 343, 350, 320, 111, 320, 7, 53, 0, 320,
- 554, 559, 556, 558, 560, 557, 561, 0, 0, 0,
- 347, 366, 367, 0, 42, 55, 111, 0, 0, 0,
- 0, 320, 0, 340, 0, 0, 0, 0, 0, 0,
+ 233, 513, 304, 238, 183, 523, 164, 431, 145, 434,
+ 177, 306, 245, 581, 505, 490, 166, 181, 482, 431,
+ 520, 549, 565, 544, 558, 302, 385, 405, 434, 570,
+ 171, 387, 430, 177, 567, 456, 467, 395, 552, 568,
+ 13, 453, 333, 342, 238, 449, 344, 451, 420, 428,
+ 455, 245, 462, 233, 346, 424, 427, 397, 138, 233,
+ 238, 143, 440, 444, 348, 442, 158, 297, 412, 445,
+ 334, 248, 431, 410, 434, 297, 202, 0, 297, 315,
+ 135, 331, 177, 245, 477, 329, 0, 141, 0, 480,
+ 0, 0, 0, 497, 516, 615, 202, 101, 0, 0,
+ 55, 297, 315, 55, 202, 281, 55, 55, 486, 446,
+ 0, 297, 0, 0, 399, 95, 55, 400, 181, 55,
+ 103, 282, 55, 497, 283, 524, 55, 280, 487, 55,
+ 261, 175, 55, 456, 484, 265, 55, 55, 175, 447,
+ 55, 55, 485, 55, 55, 447, 279, 55, 84, 175,
+ 55, 55, 55, 55, 85, 83, 55, 87, 90, 55,
+ 55, 88, 325, 475, 89, 55, 55, 474, 55, 297,
+ 97, 86, 327, 79, 55, 55, 324, 56, 65, 0,
+ 55, 163, 447, 55, 55, 488, 446, 55, 399, 446,
+ 141, 400, 55, 55, 489, 232, 173, 55, 339, 91,
+ 297, 55, 55, 62, 336, 466, 0, 55, 92, 55,
+ 55, 160, 63, 93, 55, 72, 55, 141, 64, 101,
+ 55, 55, 67, 402, 293, 265, 265, 0, 0, 265,
+ 298, 610, 293, 612, 55, 308, 0, 265, 311, 265,
+ 0, 0, 103, 170, 293, 290, 321, 0, 55, 265,
+ 0, 55, 467, 265, 292, 273, 265, 497, 501, 0,
+ 55, 300, 0, 293, 288, 265, 295, 293, 265, 268,
+ 55, 55, 265, 0, 55, 265, 265, 285, 284, 265,
+ 0, 286, 497, 538, 0, 312, 572, 576, 0, 314,
+ 0, 0, 0, 0, 0, 0, 529, 539, 0, 0,
+ 574, 575, 577, 578, 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, 7,
- 53, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 42, 55, 0,
+ 0, 497, 538, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 529, 539, 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,
@@ -983,111 +600,125 @@ const int QmlJSGrammar::action_info [] = {
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 [] = {
- 78, 48, 29, 60, 8, 78, 60, 48, 2, 1,
- 55, 78, 1, 20, 29, 33, 36, 33, 5, 33,
- 5, 7, 5, 7, 61, 7, 7, 36, 36, 7,
- 7, 61, 55, 36, 55, 7, 16, 8, 60, 7,
- 31, 36, 55, 7, 7, 33, 36, 2, 60, 7,
- 17, 48, 2, 7, 33, 7, 7, 55, 7, 61,
- 36, 36, 8, 7, 7, 7, 36, 36, 7, 7,
- 36, 36, 33, 7, 36, 7, 36, 1, 88, 36,
- 17, 7, 7, 36, 7, 33, 60, 7, 33, 36,
- 1, 8, 33, 29, 2, 88, 36, 15, 8, 8,
- -1, 60, 8, 76, 8, 8, 36, 8, 36, 36,
- 66, 8, 8, 48, 8, 33, -1, -1, 6, -1,
- 10, -1, 8, 7, 8, 8, 8, 8, 8, 60,
- -1, 60, 20, -1, -1, 50, -1, -1, 60, 54,
- 61, 62, 61, 62, 8, 78, -1, 61, 62, 40,
- 56, 8, 56, -1, 61, 62, -1, 60, -1, 60,
- 51, 12, 56, 60, 60, 55, 61, 62, 0, 61,
- 62, 40, 61, 62, 60, 42, 56, 60, 60, 60,
- 29, 7, 51, 61, 62, 40, 53, 61, 62, 61,
- 62, 50, 40, 61, 62, 54, 51, 61, 61, 62,
- 29, 15, 29, 51, 61, 62, 57, 29, 15, 15,
- 29, 8, 63, 29, 8, 7, 29, 66, 67, 29,
- 34, 29, 36, 15, 29, 12, 89, 34, 34, 36,
- 36, 7, 12, 29, 29, 61, 62, 66, 67, 66,
- 67, 33, -1, 29, 66, 67, 29, 66, 67, -1,
- 66, 67, 8, 66, 67, 29, 66, 67, 66, 67,
- 25, 8, 27, 29, 61, 62, 29, 61, 62, 74,
- 57, 66, 67, 38, 29, -1, 63, 57, 74, 29,
- 85, 29, 8, 63, -1, 61, 62, 29, 74, 85,
- -1, 74, 66, 67, 61, 62, -1, -1, -1, 85,
- 66, 67, 85, 66, 67, 61, 62, 33, -1, 29,
- -1, 66, 67, 29, 61, 62, 66, 67, 66, 67,
- 36, -1, 89, 15, 66, 67, 29, 25, -1, 27,
- 18, 19, -1, 36, -1, 61, 62, -1, 18, 19,
- 38, 61, 62, -1, 29, -1, 66, 67, -1, -1,
- 66, 67, 29, -1, 29, 47, -1, 45, 46, 23,
- 24, -1, -1, 66, 67, 45, 46, -1, 32, 61,
- 62, 35, 29, 37, 59, 29, -1, -1, -1, -1,
- -1, 66, 67, -1, 61, 62, 61, 62, -1, 66,
- 67, 66, 67, 29, 18, 19, -1, 89, -1, -1,
- 85, 29, 59, -1, -1, -1, -1, 61, 62, 66,
- 67, -1, 66, 67, -1, 23, 24, -1, 29, -1,
- -1, 45, 46, 31, 32, 61, 62, 35, 85, 37,
- 66, 67, -1, 61, 62, 23, 24, -1, 66, 67,
- -1, 10, -1, 31, 32, -1, -1, 35, 59, 37,
- 23, 24, -1, 22, 65, 66, 67, -1, 31, 32,
- 29, -1, 35, -1, 37, -1, 10, -1, 23, 24,
- -1, -1, -1, -1, 85, -1, -1, 32, 22, -1,
- 35, -1, 37, -1, -1, 29, 55, -1, -1, -1,
- 59, -1, -1, -1, -1, -1, -1, 66, 67, -1,
- -1, -1, -1, -1, -1, 74, -1, -1, -1, -1,
- -1, 55, -1, -1, 83, 59, 85, -1, -1, 3,
- -1, -1, 66, 67, -1, -1, -1, -1, -1, 13,
- 74, -1, -1, 17, -1, -1, -1, 23, 24, 83,
- -1, 85, 26, -1, 28, 31, 32, 31, -1, 35,
- -1, 37, -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, 3, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 13, -1, -1, -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,
+ 7, 55, 7, 61, 36, 36, 7, 7, 36, 7,
+ 55, 8, 33, 60, 7, 88, 36, 36, 33, 55,
+ 66, 60, 7, 29, 33, 7, 36, 16, 36, 17,
+ 5, 7, 36, 7, 33, 7, 5, 33, 8, 29,
+ 20, 36, 36, 55, 7, 5, 60, 60, 7, 36,
+ 33, 7, 7, 7, 33, 36, 7, 60, 36, 7,
+ 7, 29, 48, 36, 7, 36, 8, 2, 60, 33,
+ 8, 2, 1, 1, 8, 36, 78, 61, 36, 36,
+ 7, 48, 8, 60, 36, 7, 36, 78, 7, 33,
+ 55, 36, 7, 2, 8, 48, 1, 17, 2, 7,
+ 0, 31, 8, 10, -1, 8, 8, 48, -1, 8,
+ 8, 60, 78, 8, 76, 6, 40, 50, 50, 8,
+ 60, 54, 54, 8, 61, 61, 62, 51, 8, 20,
+ 7, 8, 78, 8, 8, 7, 61, 62, 61, 62,
+ 61, 62, 15, 61, 62, 61, 62, 8, 55, 88,
+ 61, 62, 40, 56, 60, 8, 8, 40, 60, 40,
+ 33, 60, 60, 51, 61, 62, 61, 56, 51, 12,
+ 51, 61, 62, 42, 29, 60, 1, 61, 62, 25,
+ 60, 27, 56, 7, 53, 60, 25, 29, 27, 61,
+ 62, 29, 38, 8, 29, 56, 7, 29, 25, 38,
+ 27, -1, 15, 25, 15, 27, 29, 60, -1, 61,
+ 62, 38, 12, 8, 57, 29, 38, 29, -1, 74,
+ 63, 34, 33, 36, 12, -1, -1, 29, 66, 67,
+ 85, 25, 74, 27, 66, 67, 29, 61, 62, 74,
+ 61, 62, 29, 85, 38, 29, 61, 62, 29, -1,
+ 85, 74, 66, 67, 66, 67, 29, 57, 25, 25,
+ 27, 27, 85, 63, 66, 67, 61, 62, 89, 57,
+ 8, 38, 38, 66, 67, 63, 15, 29, -1, 66,
+ 67, 29, 66, 67, 29, 66, 67, 15, 29, 61,
+ 62, -1, -1, 66, 67, 34, 8, 36, 90, 91,
+ 92, -1, -1, 25, -1, 27, 34, 25, 36, 27,
+ 18, 19, -1, -1, 66, 67, 38, 89, 66, 67,
+ 38, 66, 67, 61, 62, 66, 67, 25, 25, 27,
+ 27, 25, 25, 27, 27, 8, 15, 45, 46, 29,
+ 38, 38, 18, 19, 38, 38, 36, 29, -1, 61,
+ 62, -1, -1, -1, 36, -1, -1, 29, -1, 29,
+ 33, -1, -1, 29, -1, -1, 29, -1, 47, 45,
+ 46, -1, -1, -1, 29, -1, 66, 67, -1, -1,
+ -1, -1, 61, 62, 66, 67, -1, -1, 61, 62,
+ -1, 61, 62, 59, 66, 67, 66, 67, 61, 62,
+ 66, 67, -1, 66, 67, 29, 61, 62, 23, 24,
+ 89, 66, 67, -1, -1, 29, -1, 32, -1, 85,
+ 35, -1, 37, 18, 19, 23, 24, 29, -1, -1,
+ 29, -1, 23, 24, 32, 59, 29, 35, -1, 37,
+ 31, 32, 66, 67, 35, -1, 37, 61, 62, -1,
+ 45, 46, 66, 67, -1, -1, -1, -1, -1, 61,
+ 62, 85, 61, 62, 66, 67, 59, 66, 67, 23,
+ 24, -1, 65, 66, 67, -1, -1, 31, 32, 23,
+ 24, 35, -1, 37, -1, 10, -1, 31, 32, -1,
+ -1, 35, 85, 37, 23, 24, -1, 22, -1, -1,
+ 23, 24, 31, 32, 29, -1, 35, -1, 37, 32,
+ 10, -1, 35, -1, 37, -1, -1, -1, -1, -1,
+ -1, -1, 22, -1, -1, -1, -1, -1, -1, 29,
+ 55, -1, -1, -1, 59, -1, -1, -1, -1, -1,
+ -1, 66, 67, -1, -1, -1, -1, -1, -1, 74,
+ -1, -1, -1, -1, 3, 55, -1, -1, 83, 59,
+ 85, -1, -1, -1, 13, -1, 66, 67, 17, -1,
+ -1, -1, 23, 24, 74, -1, -1, 26, -1, 28,
+ 31, 32, 31, 83, 35, 85, 37, -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, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 3, -1, -1, -1, -1, 65,
+ 66, 67, -1, 69, 13, -1, -1, -1, 17, -1,
+ -1, -1, -1, -1, 80, 81, 82, 26, -1, 28,
+ 86, -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,
- -1, -1, 79, -1, -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, -1, 11, 12, 13, -1, -1,
+ 79, -1, -1, -1, -1, -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, 40, -1, 42, 43, 44, -1,
- -1, 47, -1, -1, -1, 51, -1, 53, -1, -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, 71, -1, 73, -1, 75,
+ 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, 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, 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,
+ 86, -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, 86, -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, 86, -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, 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, 71, -1, 73, -1, 75, -1, -1, -1, -1,
+ 80, 81, 82, -1, -1, -1, 86, -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, 86, -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,
@@ -1096,15 +727,24 @@ const int QmlJSGrammar::action_check [] = {
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,
+ 86, -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, 86, -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, 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, -1,
+ -1, 86, -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,
@@ -1112,59 +752,44 @@ const int QmlJSGrammar::action_check [] = {
-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, -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, -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, 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, 80, 81, 82, -1, -1, -1, 86, -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, 86, -1, -1, -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, -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, -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,
- 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,
+ 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, -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, -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,
@@ -1172,72 +797,74 @@ const int QmlJSGrammar::action_check [] = {
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, -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, 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,
+ 77, -1, -1, 80, 81, 82, 83, 84, -1, 86,
+ -1, -1, -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,
+ 86, -1, -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, 86, -1, -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, 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, 86, -1, -1, -1, -1, -1, -1, -1,
+ -1,
- 68, 16, 15, 68, 15, 68, 6, 31, 64, 31,
- 31, 5, 15, 6, 31, 21, 15, 6, 6, 31,
- 12, 6, 68, 6, 6, 6, 6, 68, 15, 31,
- 16, 15, 6, 6, 6, 6, 6, 15, 15, 6,
- 16, 6, 21, 6, 93, 6, 15, 78, 68, 15,
- 90, 15, 68, 21, 6, 15, 31, 15, 68, 6,
- 15, 68, 15, 68, 68, 95, 6, 68, 16, 31,
- 68, 68, 31, 15, 31, 16, 32, 31, 68, 15,
- 15, 31, 78, 6, 6, 15, 8, 15, 6, 7,
- 6, 15, 41, 6, 43, 41, 41, 43, 41, 6,
- -1, 46, 45, 35, 41, -1, 38, 41, 45, 35,
- 41, 45, 38, 6, 41, 8, 43, 68, -1, 27,
- 51, 41, 41, 31, 68, 35, 33, 46, 38, 41,
- 65, 43, -1, 53, 15, 65, 41, 65, 43, 68,
- 41, 65, 41, -1, 43, 46, 41, 41, 43, 43,
- 41, 41, 43, 43, 41, 41, 43, 43, 102, 41,
- -1, 84, 41, -1, -1, 44, 82, 41, 97, 43,
- 41, 41, 41, 55, 41, 46, 46, 46, 41, 46,
- 43, 41, 41, 96, 43, 41, 46, 43, 41, 41,
- 43, 41, 41, 41, 46, 41, 41, 47, 47, 47,
- 46, 46, 41, 31, 31, 41, 41, 46, -1, 37,
- 37, 41, 41, 49, 43, 6, 6, 47, 8, 41,
- 41, -1, 57, 41, 46, 46, 44, 48, 50, 41,
- 41, -1, 41, 41, 46, 46, 48, 46, 46, 48,
- 41, 31, 33, 34, 41, 46, 41, -1, 41, 46,
- -1, 46, 63, 46, -1, 63, -1, 52, 41, 56,
- 41, 54, 63, 46, 41, 46, 6, 7, -1, 46,
- 10, 15, 16, 17, 18, 19, 20, -1, -1, -1,
- 63, 58, 63, -1, 24, 25, 41, -1, -1, -1,
- -1, 46, -1, 48, -1, -1, -1, -1, -1, -1,
+ 9, 9, 3, 9, 9, 8, 30, 3, 63, 16,
+ 9, 2, 2, 15, 9, 2, 30, 9, 3, 3,
+ 9, 3, 20, 20, 3, 2, 30, 2, 16, 9,
+ 3, 31, 77, 9, 20, 9, 30, 30, 9, 9,
+ 3, 3, 2, 2, 9, 3, 3, 2, 92, 3,
+ 2, 2, 30, 9, 2, 89, 77, 2, 30, 9,
+ 9, 30, 94, 16, 2, 9, 30, 3, 3, 16,
+ 9, 3, 3, 2, 16, 3, 2, -1, 3, 9,
+ 3, 3, 9, 2, 30, 2, -1, 30, -1, 30,
+ -1, -1, -1, 9, 9, 11, 2, 9, -1, -1,
+ 40, 3, 9, 40, 2, 45, 40, 40, 42, 42,
+ -1, 3, -1, -1, 34, 52, 40, 37, 9, 40,
+ 32, 45, 40, 9, 45, 11, 40, 45, 42, 40,
+ 40, 42, 40, 9, 42, 45, 40, 40, 42, 42,
+ 40, 40, 42, 40, 40, 42, 45, 40, 44, 42,
+ 40, 40, 40, 40, 44, 44, 40, 45, 45, 40,
+ 40, 45, 64, 26, 45, 40, 40, 30, 40, 3,
+ 50, 45, 64, 45, 40, 40, 83, 43, 43, -1,
+ 40, 56, 42, 40, 40, 42, 42, 40, 34, 42,
+ 30, 37, 40, 40, 42, 101, 36, 40, 96, 46,
+ 3, 40, 40, 42, 95, 81, -1, 40, 46, 40,
+ 40, 54, 42, 46, 40, 46, 40, 30, 42, 9,
+ 40, 40, 48, 36, 40, 45, 45, -1, -1, 45,
+ 64, 9, 40, 11, 40, 55, -1, 45, 57, 45,
+ -1, -1, 32, 33, 40, 51, 62, -1, 40, 45,
+ -1, 40, 30, 45, 62, 47, 45, 9, 10, -1,
+ 40, 64, -1, 40, 53, 45, 62, 40, 45, 49,
+ 40, 40, 45, -1, 40, 45, 45, 47, 47, 45,
+ -1, 47, 9, 10, -1, 62, 13, 3, -1, 62,
+ -1, -1, -1, -1, -1, -1, 23, 24, -1, -1,
+ 16, 17, 18, 19, -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, 6,
- 7, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 24, 25, -1,
+ -1, 9, 10, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 23, 24, -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,
@@ -1245,5 +872,5 @@ const int QmlJSGrammar::action_check [] = {
-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 1590274..c760564 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,8 +59,8 @@ class QmlJSGrammar
public:
enum {
EOF_SYMBOL = 0,
- REDUCE_HERE = 91,
- SHIFT_THERE = 90,
+ REDUCE_HERE = 94,
+ SHIFT_THERE = 93,
T_AND = 1,
T_AND_AND = 2,
T_AND_EQ = 3,
@@ -85,6 +85,9 @@ public:
T_EQ_EQ = 18,
T_EQ_EQ_EQ = 19,
T_FALSE = 82,
+ T_FEED_JS_EXPRESSION = 92,
+ T_FEED_JS_STATEMENT = 91,
+ T_FEED_UI_PROGRAM = 90,
T_FINALLY = 20,
T_FOR = 21,
T_FUNCTION = 22,
@@ -151,26 +154,20 @@ public:
T_XOR = 78,
T_XOR_EQ = 79,
- ACCEPT_STATE = 615,
- RULE_COUNT = 338,
- STATE_COUNT = 616,
- TERMINAL_COUNT = 92,
- NON_TERMINAL_COUNT = 104,
+ ACCEPT_STATE = 616,
+ RULE_COUNT = 337,
+ STATE_COUNT = 617,
+ TERMINAL_COUNT = 95,
+ NON_TERMINAL_COUNT = 103,
- GOTO_INDEX_OFFSET = 616,
- GOTO_INFO_OFFSET = 2139,
- GOTO_CHECK_OFFSET = 2139
+ GOTO_INDEX_OFFSET = 617,
+ GOTO_INFO_OFFSET = 2231,
+ GOTO_CHECK_OFFSET = 2231
};
static const char *const spell [];
static const int lhs [];
static const int rhs [];
-
-#ifndef QLALR_NO_QMLJSGRAMMAR_DEBUG_INFO
- static const int rule_index [];
- static const int rule_info [];
-#endif // QLALR_NO_QMLJSGRAMMAR_DEBUG_INFO
-
static const int goto_default [];
static const int action_default [];
static const int action_index [];
diff --git a/src/declarative/qml/parser/qmljsparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp
index a13b425..a1236d5 100644
--- a/src/declarative/qml/parser/qmljsparser.cpp
+++ b/src/declarative/qml/parser/qmljsparser.cpp
@@ -1,7 +1,5 @@
// This file was generated by qlalr - DO NOT EDIT!
-#line 95 "qmljs.g"
-
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
@@ -53,8 +51,6 @@
#include "qmljsnodepool_p.h"
-#line 349 "qmljs.g"
-
#include "qmljsparser_p.h"
#include <QVarLengthArray>
@@ -147,14 +143,16 @@ AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
return 0;
}
-bool Parser::parse()
+bool Parser::parse(int startToken)
{
Lexer *lexer = driver->lexer();
bool hadErrors = false;
int yytoken = -1;
int action = 0;
- first_token = last_token = 0;
+ token_buffer[0].token = startToken;
+ first_token = &token_buffer[0];
+ last_token = &token_buffer[1];
tos = -1;
program = 0;
@@ -197,36 +195,40 @@ bool Parser::parse()
switch (r) {
-#line 498 "qmljs.g"
-
case 0: {
- program = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
- sym(2).UiObjectMemberList->finish());
- sym(1).UiProgram = program;
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
} break;
-#line 508 "qmljs.g"
+case 1: {
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
+} break;
case 2: {
- sym(1).Node = sym(1).UiImportList->finish();
+ sym(1).Node = sym(2).Node;
+ program = sym(1).Node;
} break;
-#line 515 "qmljs.g"
-
case 3: {
- sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(), sym(1).UiImport);
+ sym(1).UiProgram = makeAstNode<AST::UiProgram> (driver->nodePool(), sym(1).UiImportList,
+ sym(2).UiObjectMemberList->finish());
} break;
-#line 522 "qmljs.g"
+case 5: {
+ sym(1).Node = sym(1).UiImportList->finish();
+} break;
+
+case 6: {
+ sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(), sym(1).UiImport);
+} break;
-case 4: {
+case 7: {
sym(1).Node = makeAstNode<AST::UiImportList> (driver->nodePool(),
sym(1).UiImportList, sym(2).UiImport);
} break;
-#line 531 "qmljs.g"
-
-case 6: {
+case 9: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).sval);
node->importToken = loc(1);
node->fileNameToken = loc(2);
@@ -234,9 +236,7 @@ case 6: {
sym(1).Node = node;
} break;
-#line 543 "qmljs.g"
-
-case 8: {
+case 11: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).sval);
node->importId = sym(4).sval;
node->importToken = loc(1);
@@ -247,9 +247,7 @@ case 8: {
sym(1).Node = node;
} break;
-#line 558 "qmljs.g"
-
-case 10: {
+case 13: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importToken = loc(1);
node->fileNameToken = loc(2);
@@ -257,9 +255,7 @@ case 10: {
sym(1).Node = node;
} break;
-#line 570 "qmljs.g"
-
-case 12: {
+case 15: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importToken = loc(1);
node->fileNameToken = loc(2);
@@ -268,9 +264,7 @@ case 12: {
sym(1).Node = node;
} break;
-#line 583 "qmljs.g"
-
-case 14: {
+case 17: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importId = sym(5).sval;
node->importToken = loc(1);
@@ -282,9 +276,7 @@ case 14: {
sym(1).Node = node;
} break;
-#line 599 "qmljs.g"
-
-case 16: {
+case 19: {
AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId->finish());
node->importId = sym(4).sval;
node->importToken = loc(1);
@@ -295,76 +287,56 @@ case 16: {
sym(1).Node = node;
} break;
-#line 613 "qmljs.g"
-
-case 17: {
+case 20: {
sym(1).Node = 0;
} break;
-#line 620 "qmljs.g"
-
-case 18: {
+case 21: {
sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
} break;
-#line 627 "qmljs.g"
-
-case 19: {
+case 22: {
sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember);
} break;
-#line 634 "qmljs.g"
-
-case 20: {
+case 23: {
AST::UiObjectMemberList *node = makeAstNode<AST:: UiObjectMemberList> (driver->nodePool(),
sym(1).UiObjectMemberList, sym(2).UiObjectMember);
sym(1).Node = node;
} break;
-#line 643 "qmljs.g"
-
-case 21: {
+case 24: {
sym(1).Node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiObjectMember);
} break;
-#line 650 "qmljs.g"
-
-case 22: {
+case 25: {
AST::UiArrayMemberList *node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(),
sym(1).UiArrayMemberList, sym(3).UiObjectMember);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-#line 660 "qmljs.g"
-
-case 23: {
+case 26: {
AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), (AST::UiObjectMemberList*)0);
node->lbraceToken = loc(1);
node->rbraceToken = loc(2);
sym(1).Node = node;
} break;
-#line 670 "qmljs.g"
-
-case 24: {
+case 27: {
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;
-#line 680 "qmljs.g"
-
-case 25: {
+case 28: {
AST::UiObjectDefinition *node = makeAstNode<AST::UiObjectDefinition> (driver->nodePool(), sym(1).UiQualifiedId->finish(),
sym(2).UiObjectInitializer);
sym(1).Node = node;
} break;
-#line 691 "qmljs.g"
-
-case 27: {
+case 30: {
AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(), sym(1).UiQualifiedId->finish(),
sym(4).UiArrayMemberList->finish());
node->colonToken = loc(2);
@@ -373,24 +345,6 @@ case 27: {
sym(1).Node = node;
} break;
-#line 703 "qmljs.g"
-
-case 28: {
- AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
- node->literalToken = loc(1);
- sym(1).Node = node;
-} break;
-
-#line 713 "qmljs.g"
-
-case 30: {
- AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
- node->semicolonToken = loc(2);
- sym(1).Node = node;
-} break;
-
-#line 723 "qmljs.g"
-
case 31: {
if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(3).Expression)) {
AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(),
@@ -406,21 +360,7 @@ case 31: {
return false; // ### recover
}
} break;
-
-#line 742 "qmljs.g"
-case 32:
-#line 745 "qmljs.g"
-case 33:
-#line 748 "qmljs.g"
-case 34:
-#line 751 "qmljs.g"
-case 35:
-#line 754 "qmljs.g"
-case 36:
-#line 757 "qmljs.g"
-case 37:
-#line 759 "qmljs.g"
-
+case 32:case 33:case 34:case 35:
{
AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(), sym(1).UiQualifiedId->finish(),
sym(3).Statement);
@@ -428,49 +368,35 @@ case 37:
sym(1).Node = node;
} break;
-#line 769 "qmljs.g"
-
-case 38:
-
-#line 773 "qmljs.g"
+case 36:
-case 39: {
+case 37: {
sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
break;
}
-#line 783 "qmljs.g"
-
-case 41: {
+case 39: {
sym(1).Node = 0;
} break;
-#line 790 "qmljs.g"
-
-case 42: {
+case 40: {
sym(1).Node = sym(1).UiParameterList->finish ();
} break;
-#line 797 "qmljs.g"
-
-case 43: {
+case 41: {
AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval);
node->identifierToken = loc(2);
sym(1).Node = node;
} break;
-#line 806 "qmljs.g"
-
-case 44: {
+case 42: {
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;
-#line 816 "qmljs.g"
-
-case 45: {
+case 43: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
@@ -480,9 +406,7 @@ case 45: {
sym(1).Node = node;
} break;
-#line 829 "qmljs.g"
-
-case 46: {
+case 44: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval);
node->type = AST::UiPublicMember::Signal;
node->propertyToken = loc(1);
@@ -491,9 +415,7 @@ case 46: {
sym(1).Node = node;
} break;
-#line 842 "qmljs.g"
-
-case 48: {
+case 46: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval);
node->propertyToken = loc(1);
node->typeToken = loc(2);
@@ -502,9 +424,7 @@ case 48: {
sym(1).Node = node;
} break;
-#line 855 "qmljs.g"
-
-case 50: {
+case 48: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval);
node->isDefaultMember = true;
node->defaultToken = loc(1);
@@ -515,9 +435,7 @@ case 50: {
sym(1).Node = node;
} break;
-#line 870 "qmljs.g"
-
-case 52: {
+case 50: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval,
sym(5).Expression);
node->propertyToken = loc(1);
@@ -528,9 +446,7 @@ case 52: {
sym(1).Node = node;
} break;
-#line 885 "qmljs.g"
-
-case 54: {
+case 52: {
AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval,
sym(6).Expression);
node->isDefaultMember = true;
@@ -543,104 +459,76 @@ case 54: {
sym(1).Node = node;
} break;
-#line 901 "qmljs.g"
-
-case 55: {
+case 53: {
sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
} break;
-#line 908 "qmljs.g"
-
-case 56: {
+case 54: {
sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node);
} break;
-
-#line 915 "qmljs.g"
-case 57:
-#line 918 "qmljs.g"
-
-case 58:
+case 55:
+case 56:
{
AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()));
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-#line 930 "qmljs.g"
-
-case 60: {
+case 58: {
QString s = QLatin1String(QmlJSGrammar::spell[T_PROPERTY]);
sym(1).sval = driver->intern(s.constData(), s.length());
break;
}
-#line 939 "qmljs.g"
-
-case 61: {
+case 59: {
QString s = QLatin1String(QmlJSGrammar::spell[T_SIGNAL]);
sym(1).sval = driver->intern(s.constData(), s.length());
break;
}
-#line 952 "qmljs.g"
-
-case 62: {
+case 60: {
AST::ThisExpression *node = makeAstNode<AST::ThisExpression> (driver->nodePool());
node->thisToken = loc(1);
sym(1).Node = node;
} break;
-#line 961 "qmljs.g"
-
-case 63: {
+case 61: {
AST::IdentifierExpression *node = makeAstNode<AST::IdentifierExpression> (driver->nodePool(), sym(1).sval);
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-#line 970 "qmljs.g"
-
-case 64: {
+case 62: {
AST::NullExpression *node = makeAstNode<AST::NullExpression> (driver->nodePool());
node->nullToken = loc(1);
sym(1).Node = node;
} break;
-#line 979 "qmljs.g"
-
-case 65: {
+case 63: {
AST::TrueLiteral *node = makeAstNode<AST::TrueLiteral> (driver->nodePool());
node->trueToken = loc(1);
sym(1).Node = node;
} break;
-#line 988 "qmljs.g"
-
-case 66: {
+case 64: {
AST::FalseLiteral *node = makeAstNode<AST::FalseLiteral> (driver->nodePool());
node->falseToken = loc(1);
sym(1).Node = node;
} break;
-#line 997 "qmljs.g"
-
-case 67: {
+case 65: {
AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval, lexer->flags);
node->literalToken = loc(1);
sym(1).Node = node;
} break;
-
-#line 1006 "qmljs.g"
-
-case 68: {
+case 66:
+case 67: {
AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval);
node->literalToken = loc(1);
sym(1).Node = node;
} break;
-#line 1018 "qmljs.g"
-
-case 69: {
+case 68: {
bool rx = lexer->scanRegExp(Lexer::NoPrefix);
if (!rx) {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
@@ -651,9 +539,7 @@ case 69: {
sym(1).Node = node;
} break;
-#line 1035 "qmljs.g"
-
-case 70: {
+case 69: {
bool rx = lexer->scanRegExp(Lexer::EqualPrefix);
if (!rx) {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage()));
@@ -664,36 +550,28 @@ case 70: {
sym(1).Node = node;
} break;
-#line 1049 "qmljs.g"
-
-case 71: {
+case 70: {
AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), (AST::Elision *) 0);
node->lbracketToken = loc(1);
node->rbracketToken = loc(2);
sym(1).Node = node;
} break;
-#line 1059 "qmljs.g"
-
-case 72: {
+case 71: {
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;
-#line 1069 "qmljs.g"
-
-case 73: {
+case 72: {
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;
-#line 1079 "qmljs.g"
-
-case 74: {
+case 73: {
AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
(AST::Elision *) 0);
node->lbracketToken = loc(1);
@@ -702,9 +580,7 @@ case 74: {
sym(1).Node = node;
} break;
-#line 1091 "qmljs.g"
-
-case 75: {
+case 74: {
AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (),
sym(4).Elision->finish());
node->lbracketToken = loc(1);
@@ -713,9 +589,7 @@ case 75: {
sym(1).Node = node;
} break;
-#line 1110 "qmljs.g"
-
-case 76: {
+case 75: {
AST::ObjectLiteral *node = 0;
if (sym(2).Node)
node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
@@ -727,9 +601,7 @@ case 76: {
sym(1).Node = node;
} break;
-#line 1125 "qmljs.g"
-
-case 77: {
+case 76: {
AST::ObjectLiteral *node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
sym(2).PropertyNameAndValueList->finish ());
node->lbraceToken = loc(1);
@@ -737,89 +609,67 @@ case 77: {
sym(1).Node = node;
} break;
-#line 1136 "qmljs.g"
-
-case 78: {
+case 77: {
AST::NestedExpression *node = makeAstNode<AST::NestedExpression>(driver->nodePool(), sym(2).Expression);
node->lparenToken = loc(1);
node->rparenToken = loc(3);
sym(1).Node = node;
} break;
-#line 1146 "qmljs.g"
-
-case 79: {
+case 78: {
AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), sym(1).sval);
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-#line 1155 "qmljs.g"
-
-case 80: {
+case 79: {
AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), sym(1).UiQualifiedId, sym(3).sval);
node->identifierToken = loc(3);
sym(1).Node = node;
} break;
-#line 1164 "qmljs.g"
-
-case 81: {
+case 80: {
sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), (AST::Elision *) 0, sym(1).Expression);
} break;
-#line 1171 "qmljs.g"
-
-case 82: {
+case 81: {
sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).Elision->finish(), sym(2).Expression);
} break;
-#line 1178 "qmljs.g"
-
-case 83: {
+case 82: {
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;
-#line 1188 "qmljs.g"
-
-case 84: {
+case 83: {
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;
-#line 1198 "qmljs.g"
-
-case 85: {
+case 84: {
AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool());
node->commaToken = loc(1);
sym(1).Node = node;
} break;
-#line 1207 "qmljs.g"
-
-case 86: {
+case 85: {
AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool(), sym(1).Elision);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-#line 1216 "qmljs.g"
-
-case 87: {
+case 86: {
AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
sym(1).PropertyName, sym(3).Expression);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
-#line 1226 "qmljs.g"
-
-case 88: {
+case 87: {
AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(),
sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression);
node->commaToken = loc(2);
@@ -827,196 +677,116 @@ case 88: {
sym(1).Node = node;
} break;
-#line 1237 "qmljs.g"
-
-case 89: {
+case 88: {
AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-
-#line 1246 "qmljs.g"
-case 90:
-#line 1249 "qmljs.g"
-
-case 91: {
+case 89:
+case 90: {
AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()));
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-#line 1258 "qmljs.g"
-
-case 92: {
+case 91: {
AST::StringLiteralPropertyName *node = makeAstNode<AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval);
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-#line 1267 "qmljs.g"
-
-case 93: {
+case 92: {
AST::NumericLiteralPropertyName *node = makeAstNode<AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval);
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-#line 1276 "qmljs.g"
-
-case 94: {
+case 93: {
AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval);
node->propertyNameToken = loc(1);
sym(1).Node = node;
} break;
-#line 1285 "qmljs.g"
+case 94:
case 95:
-#line 1289 "qmljs.g"
-
case 96:
-#line 1293 "qmljs.g"
-
case 97:
-#line 1297 "qmljs.g"
-
case 98:
-#line 1301 "qmljs.g"
-
case 99:
-#line 1305 "qmljs.g"
-
case 100:
-#line 1309 "qmljs.g"
-
case 101:
-#line 1313 "qmljs.g"
-
case 102:
-#line 1317 "qmljs.g"
-
case 103:
-#line 1321 "qmljs.g"
-
case 104:
-#line 1325 "qmljs.g"
-
case 105:
-#line 1329 "qmljs.g"
-
case 106:
-#line 1333 "qmljs.g"
-
case 107:
-#line 1337 "qmljs.g"
-
case 108:
-#line 1341 "qmljs.g"
-
case 109:
-#line 1345 "qmljs.g"
-
case 110:
-#line 1349 "qmljs.g"
-
case 111:
-#line 1353 "qmljs.g"
-
case 112:
-#line 1357 "qmljs.g"
-
case 113:
-#line 1361 "qmljs.g"
-
case 114:
-#line 1365 "qmljs.g"
-
case 115:
-#line 1369 "qmljs.g"
-
case 116:
-#line 1373 "qmljs.g"
-
case 117:
-#line 1377 "qmljs.g"
-
case 118:
-#line 1381 "qmljs.g"
-
case 119:
-#line 1385 "qmljs.g"
-
case 120:
-#line 1389 "qmljs.g"
-
case 121:
-#line 1393 "qmljs.g"
-
case 122:
-#line 1397 "qmljs.g"
-
case 123:
-#line 1401 "qmljs.g"
-
case 124:
-
-#line 1405 "qmljs.g"
-
-case 125:
{
sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount());
} break;
-#line 1419 "qmljs.g"
-
-case 130: {
+case 129: {
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;
-#line 1429 "qmljs.g"
-
-case 131: {
+case 130: {
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;
-#line 1439 "qmljs.g"
-
-case 132: {
+case 131: {
AST::NewMemberExpression *node = makeAstNode<AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(4).ArgumentList);
node->newToken = loc(1);
node->lparenToken = loc(3);
@@ -1024,500 +794,384 @@ case 132: {
sym(1).Node = node;
} break;
-#line 1452 "qmljs.g"
-
-case 134: {
+case 133: {
AST::NewExpression *node = makeAstNode<AST::NewExpression> (driver->nodePool(), sym(2).Expression);
node->newToken = loc(1);
sym(1).Node = node;
} break;
-#line 1461 "qmljs.g"
-
-case 135: {
+case 134: {
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;
-#line 1471 "qmljs.g"
-
-case 136: {
+case 135: {
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;
-#line 1481 "qmljs.g"
-
-case 137: {
+case 136: {
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;
-#line 1491 "qmljs.g"
-
-case 138: {
+case 137: {
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;
-#line 1501 "qmljs.g"
-
-case 139: {
+case 138: {
sym(1).Node = 0;
} break;
-#line 1508 "qmljs.g"
-
-case 140: {
+case 139: {
sym(1).Node = sym(1).ArgumentList->finish();
} break;
-#line 1515 "qmljs.g"
-
-case 141: {
+case 140: {
sym(1).Node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).Expression);
} break;
-#line 1522 "qmljs.g"
-
-case 142: {
+case 141: {
AST::ArgumentList *node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-#line 1535 "qmljs.g"
-
-case 146: {
+case 145: {
AST::PostIncrementExpression *node = makeAstNode<AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression);
node->incrementToken = loc(2);
sym(1).Node = node;
} break;
-#line 1544 "qmljs.g"
-
-case 147: {
+case 146: {
AST::PostDecrementExpression *node = makeAstNode<AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression);
node->decrementToken = loc(2);
sym(1).Node = node;
} break;
-#line 1555 "qmljs.g"
-
-case 149: {
+case 148: {
AST::DeleteExpression *node = makeAstNode<AST::DeleteExpression> (driver->nodePool(), sym(2).Expression);
node->deleteToken = loc(1);
sym(1).Node = node;
} break;
-#line 1564 "qmljs.g"
-
-case 150: {
+case 149: {
AST::VoidExpression *node = makeAstNode<AST::VoidExpression> (driver->nodePool(), sym(2).Expression);
node->voidToken = loc(1);
sym(1).Node = node;
} break;
-#line 1573 "qmljs.g"
-
-case 151: {
+case 150: {
AST::TypeOfExpression *node = makeAstNode<AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression);
node->typeofToken = loc(1);
sym(1).Node = node;
} break;
-#line 1582 "qmljs.g"
-
-case 152: {
+case 151: {
AST::PreIncrementExpression *node = makeAstNode<AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression);
node->incrementToken = loc(1);
sym(1).Node = node;
} break;
-#line 1591 "qmljs.g"
-
-case 153: {
+case 152: {
AST::PreDecrementExpression *node = makeAstNode<AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression);
node->decrementToken = loc(1);
sym(1).Node = node;
} break;
-#line 1600 "qmljs.g"
-
-case 154: {
+case 153: {
AST::UnaryPlusExpression *node = makeAstNode<AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression);
node->plusToken = loc(1);
sym(1).Node = node;
} break;
-#line 1609 "qmljs.g"
-
-case 155: {
+case 154: {
AST::UnaryMinusExpression *node = makeAstNode<AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression);
node->minusToken = loc(1);
sym(1).Node = node;
} break;
-#line 1618 "qmljs.g"
-
-case 156: {
+case 155: {
AST::TildeExpression *node = makeAstNode<AST::TildeExpression> (driver->nodePool(), sym(2).Expression);
node->tildeToken = loc(1);
sym(1).Node = node;
} break;
-#line 1627 "qmljs.g"
-
-case 157: {
+case 156: {
AST::NotExpression *node = makeAstNode<AST::NotExpression> (driver->nodePool(), sym(2).Expression);
node->notToken = loc(1);
sym(1).Node = node;
} break;
-#line 1638 "qmljs.g"
-
-case 159: {
+case 158: {
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;
-#line 1648 "qmljs.g"
-
-case 160: {
+case 159: {
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;
-#line 1658 "qmljs.g"
-
-case 161: {
+case 160: {
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;
-#line 1670 "qmljs.g"
-
-case 163: {
+case 162: {
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;
-#line 1680 "qmljs.g"
-
-case 164: {
+case 163: {
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;
-#line 1692 "qmljs.g"
-
-case 166: {
+case 165: {
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;
-#line 1702 "qmljs.g"
-
-case 167: {
+case 166: {
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;
-#line 1712 "qmljs.g"
-
-case 168: {
+case 167: {
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;
-#line 1724 "qmljs.g"
-
-case 170: {
+case 169: {
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;
-#line 1734 "qmljs.g"
-
-case 171: {
+case 170: {
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;
-#line 1744 "qmljs.g"
-
-case 172: {
+case 171: {
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;
-#line 1754 "qmljs.g"
-
-case 173: {
+case 172: {
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;
-#line 1764 "qmljs.g"
-
-case 174: {
+case 173: {
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;
-#line 1774 "qmljs.g"
-
-case 175: {
+case 174: {
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;
-#line 1786 "qmljs.g"
-
-case 177: {
+case 176: {
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;
-#line 1796 "qmljs.g"
-
-case 178: {
+case 177: {
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;
-#line 1806 "qmljs.g"
-
-case 179: {
+case 178: {
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;
-#line 1816 "qmljs.g"
-
-case 180: {
+case 179: {
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;
-#line 1826 "qmljs.g"
-
-case 181: {
+case 180: {
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;
-#line 1838 "qmljs.g"
-
-case 183: {
+case 182: {
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;
-#line 1848 "qmljs.g"
-
-case 184: {
+case 183: {
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;
-#line 1858 "qmljs.g"
-
-case 185: {
+case 184: {
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;
-#line 1868 "qmljs.g"
-
-case 186: {
+case 185: {
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;
-#line 1880 "qmljs.g"
-
-case 188: {
+case 187: {
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;
-#line 1890 "qmljs.g"
-
-case 189: {
+case 188: {
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;
-#line 1900 "qmljs.g"
-
-case 190: {
+case 189: {
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;
-#line 1910 "qmljs.g"
-
-case 191: {
+case 190: {
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;
-#line 1922 "qmljs.g"
-
-case 193: {
+case 192: {
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;
-#line 1934 "qmljs.g"
-
-case 195: {
+case 194: {
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;
-#line 1946 "qmljs.g"
-
-case 197: {
+case 196: {
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;
-#line 1958 "qmljs.g"
-
-case 199: {
+case 198: {
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;
-#line 1970 "qmljs.g"
-
-case 201: {
+case 200: {
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;
-#line 1982 "qmljs.g"
-
-case 203: {
+case 202: {
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;
-#line 1994 "qmljs.g"
-
-case 205: {
+case 204: {
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;
-#line 2006 "qmljs.g"
-
-case 207: {
+case 206: {
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;
-#line 2018 "qmljs.g"
-
-case 209: {
+case 208: {
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;
-#line 2030 "qmljs.g"
-
-case 211: {
+case 210: {
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;
-#line 2042 "qmljs.g"
-
-case 213: {
+case 212: {
AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
sym(3).Expression, sym(5).Expression);
node->questionToken = loc(2);
@@ -1525,9 +1179,7 @@ case 213: {
sym(1).Node = node;
} break;
-#line 2055 "qmljs.g"
-
-case 215: {
+case 214: {
AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression,
sym(3).Expression, sym(5).Expression);
node->questionToken = loc(2);
@@ -1535,160 +1187,112 @@ case 215: {
sym(1).Node = node;
} break;
-#line 2068 "qmljs.g"
-
-case 217: {
+case 216: {
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;
-#line 2080 "qmljs.g"
-
-case 219: {
+case 218: {
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;
-#line 2090 "qmljs.g"
-
-case 220: {
+case 219: {
sym(1).ival = QSOperator::Assign;
} break;
-#line 2097 "qmljs.g"
-
-case 221: {
+case 220: {
sym(1).ival = QSOperator::InplaceMul;
} break;
-#line 2104 "qmljs.g"
-
-case 222: {
+case 221: {
sym(1).ival = QSOperator::InplaceDiv;
} break;
-#line 2111 "qmljs.g"
-
-case 223: {
+case 222: {
sym(1).ival = QSOperator::InplaceMod;
} break;
-#line 2118 "qmljs.g"
-
-case 224: {
+case 223: {
sym(1).ival = QSOperator::InplaceAdd;
} break;
-#line 2125 "qmljs.g"
-
-case 225: {
+case 224: {
sym(1).ival = QSOperator::InplaceSub;
} break;
-#line 2132 "qmljs.g"
-
-case 226: {
+case 225: {
sym(1).ival = QSOperator::InplaceLeftShift;
} break;
-#line 2139 "qmljs.g"
-
-case 227: {
+case 226: {
sym(1).ival = QSOperator::InplaceRightShift;
} break;
-#line 2146 "qmljs.g"
-
-case 228: {
+case 227: {
sym(1).ival = QSOperator::InplaceURightShift;
} break;
-#line 2153 "qmljs.g"
-
-case 229: {
+case 228: {
sym(1).ival = QSOperator::InplaceAnd;
} break;
-#line 2160 "qmljs.g"
-
-case 230: {
+case 229: {
sym(1).ival = QSOperator::InplaceXor;
} break;
-#line 2167 "qmljs.g"
-
-case 231: {
+case 230: {
sym(1).ival = QSOperator::InplaceOr;
} break;
-#line 2176 "qmljs.g"
-
-case 233: {
+case 232: {
AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-#line 2185 "qmljs.g"
-
-case 234: {
+case 233: {
sym(1).Node = 0;
} break;
-#line 2196 "qmljs.g"
-
-case 237: {
+case 236: {
AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-#line 2205 "qmljs.g"
-
-case 238: {
+case 237: {
sym(1).Node = 0;
} break;
-#line 2231 "qmljs.g"
-
-case 255: {
+case 254: {
AST::Block *node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList);
node->lbraceToken = loc(1);
node->rbraceToken = loc(3);
sym(1).Node = node;
} break;
-#line 2241 "qmljs.g"
-
-case 256: {
+case 255: {
sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).Statement);
} break;
-#line 2248 "qmljs.g"
-
-case 257: {
+case 256: {
sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement);
} break;
-#line 2255 "qmljs.g"
-
-case 258: {
+case 257: {
sym(1).Node = 0;
} break;
-#line 2262 "qmljs.g"
-
-case 259: {
+case 258: {
sym(1).Node = sym(1).StatementList->finish ();
} break;
-#line 2270 "qmljs.g"
-
-case 261: {
+case 260: {
AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(),
sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST));
node->declarationKindToken = loc(1);
@@ -1696,106 +1300,76 @@ case 261: {
sym(1).Node = node;
} break;
-#line 2281 "qmljs.g"
-
-case 262: {
+case 261: {
sym(1).ival = T_CONST;
} break;
-#line 2288 "qmljs.g"
-
-case 263: {
+case 262: {
sym(1).ival = T_VAR;
} break;
-#line 2295 "qmljs.g"
-
-case 264: {
+case 263: {
sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
} break;
-#line 2302 "qmljs.g"
-
-case 265: {
+case 264: {
AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(),
sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
node->commaToken = loc(2);
sym(1).Node = node;
} break;
-#line 2312 "qmljs.g"
-
-case 266: {
+case 265: {
sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration);
} break;
-#line 2319 "qmljs.g"
-
-case 267: {
+case 266: {
sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration);
} break;
-#line 2326 "qmljs.g"
-
-case 268: {
+case 267: {
AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-#line 2335 "qmljs.g"
-
-case 269: {
+case 268: {
AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression);
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-#line 2344 "qmljs.g"
-
-case 270: {
+case 269: {
// ### TODO: AST for initializer
sym(1) = sym(2);
} break;
-#line 2352 "qmljs.g"
-
-case 271: {
+case 270: {
sym(1).Node = 0;
} break;
-#line 2361 "qmljs.g"
-
-case 273: {
+case 272: {
// ### TODO: AST for initializer
sym(1) = sym(2);
} break;
-#line 2369 "qmljs.g"
-
-case 274: {
+case 273: {
sym(1).Node = 0;
} break;
-#line 2378 "qmljs.g"
-
-case 276: {
+case 275: {
AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool());
node->semicolonToken = loc(1);
sym(1).Node = node;
} break;
-#line 2388 "qmljs.g"
-
-case 278: {
+case 277: {
AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
-#line 2397 "qmljs.g"
-
-case 279: {
+case 278: {
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);
@@ -1804,9 +1378,7 @@ case 279: {
sym(1).Node = node;
} break;
-#line 2409 "qmljs.g"
-
-case 280: {
+case 279: {
AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
node->ifToken = loc(1);
node->lparenToken = loc(2);
@@ -1814,9 +1386,7 @@ case 280: {
sym(1).Node = node;
} break;
-#line 2422 "qmljs.g"
-
-case 282: {
+case 281: {
AST::DoWhileStatement *node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression);
node->doToken = loc(1);
node->whileToken = loc(3);
@@ -1826,9 +1396,7 @@ case 282: {
sym(1).Node = node;
} break;
-#line 2435 "qmljs.g"
-
-case 283: {
+case 282: {
AST::WhileStatement *node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
node->whileToken = loc(1);
node->lparenToken = loc(2);
@@ -1836,9 +1404,7 @@ case 283: {
sym(1).Node = node;
} break;
-#line 2446 "qmljs.g"
-
-case 284: {
+case 283: {
AST::ForStatement *node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression,
sym(5).Expression, sym(7).Expression, sym(9).Statement);
node->forToken = loc(1);
@@ -1849,9 +1415,7 @@ case 284: {
sym(1).Node = node;
} break;
-#line 2460 "qmljs.g"
-
-case 285: {
+case 284: {
AST::LocalForStatement *node = makeAstNode<AST::LocalForStatement> (driver->nodePool(),
sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression,
sym(8).Expression, sym(10).Statement);
@@ -1864,9 +1428,7 @@ case 285: {
sym(1).Node = node;
} break;
-#line 2476 "qmljs.g"
-
-case 286: {
+case 285: {
AST:: ForEachStatement *node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression,
sym(5).Expression, sym(7).Statement);
node->forToken = loc(1);
@@ -1876,9 +1438,7 @@ case 286: {
sym(1).Node = node;
} break;
-#line 2489 "qmljs.g"
-
-case 287: {
+case 286: {
AST::LocalForEachStatement *node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(),
sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement);
node->forToken = loc(1);
@@ -1889,18 +1449,14 @@ case 287: {
sym(1).Node = node;
} break;
-#line 2504 "qmljs.g"
-
-case 289: {
+case 288: {
AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool());
node->continueToken = loc(1);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
-#line 2515 "qmljs.g"
-
-case 291: {
+case 290: {
AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval);
node->continueToken = loc(1);
node->identifierToken = loc(2);
@@ -1908,18 +1464,14 @@ case 291: {
sym(1).Node = node;
} break;
-#line 2527 "qmljs.g"
-
-case 293: {
+case 292: {
AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool());
node->breakToken = loc(1);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
-#line 2538 "qmljs.g"
-
-case 295: {
+case 294: {
AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval);
node->breakToken = loc(1);
node->identifierToken = loc(2);
@@ -1927,18 +1479,14 @@ case 295: {
sym(1).Node = node;
} break;
-#line 2550 "qmljs.g"
-
-case 297: {
+case 296: {
AST::ReturnStatement *node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression);
node->returnToken = loc(1);
node->semicolonToken = loc(3);
sym(1).Node = node;
} break;
-#line 2560 "qmljs.g"
-
-case 298: {
+case 297: {
AST::WithStatement *node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement);
node->withToken = loc(1);
node->lparenToken = loc(2);
@@ -1946,9 +1494,7 @@ case 298: {
sym(1).Node = node;
} break;
-#line 2571 "qmljs.g"
-
-case 299: {
+case 298: {
AST::SwitchStatement *node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock);
node->switchToken = loc(1);
node->lparenToken = loc(2);
@@ -1956,122 +1502,90 @@ case 299: {
sym(1).Node = node;
} break;
-#line 2582 "qmljs.g"
-
-case 300: {
+case 299: {
AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses);
node->lbraceToken = loc(1);
node->rbraceToken = loc(3);
sym(1).Node = node;
} break;
-#line 2592 "qmljs.g"
-
-case 301: {
+case 300: {
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;
-#line 2602 "qmljs.g"
-
-case 302: {
+case 301: {
sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause);
} break;
-#line 2609 "qmljs.g"
-
-case 303: {
+case 302: {
sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause);
} break;
-#line 2616 "qmljs.g"
-
-case 304: {
+case 303: {
sym(1).Node = 0;
} break;
-#line 2623 "qmljs.g"
-
-case 305: {
+case 304: {
sym(1).Node = sym(1).CaseClauses->finish ();
} break;
-#line 2630 "qmljs.g"
-
-case 306: {
+case 305: {
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;
-#line 2640 "qmljs.g"
-
-case 307: {
+case 306: {
AST::DefaultClause *node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList);
node->defaultToken = loc(1);
node->colonToken = loc(2);
sym(1).Node = node;
} break;
-
-#line 2650 "qmljs.g"
-case 308:
-#line 2653 "qmljs.g"
-
-case 309: {
+case 307:
+case 308: {
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;
-#line 2663 "qmljs.g"
-
-case 310: {
+case 309: {
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;
-#line 2674 "qmljs.g"
-
-case 312: {
+case 311: {
AST::ThrowStatement *node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression);
node->throwToken = loc(1);
node->semicolonToken = loc(3);
sym(1).Node = node;
} break;
-#line 2684 "qmljs.g"
-
-case 313: {
+case 312: {
AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch);
node->tryToken = loc(1);
sym(1).Node = node;
} break;
-#line 2693 "qmljs.g"
-
-case 314: {
+case 313: {
AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally);
node->tryToken = loc(1);
sym(1).Node = node;
} break;
-#line 2702 "qmljs.g"
-
-case 315: {
+case 314: {
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;
-#line 2711 "qmljs.g"
-
-case 316: {
+case 315: {
AST::Catch *node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Block);
node->catchToken = loc(1);
node->lparenToken = loc(2);
@@ -2080,26 +1594,20 @@ case 316: {
sym(1).Node = node;
} break;
-#line 2723 "qmljs.g"
-
-case 317: {
+case 316: {
AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Block);
node->finallyToken = loc(1);
sym(1).Node = node;
} break;
-#line 2733 "qmljs.g"
-
-case 319: {
+case 318: {
AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool());
node->debuggerToken = loc(1);
node->semicolonToken = loc(2);
sym(1).Node = node;
} break;
-#line 2743 "qmljs.g"
-
-case 320: {
+case 319: {
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);
@@ -2110,9 +1618,7 @@ case 320: {
sym(1).Node = node;
} break;
-#line 2757 "qmljs.g"
-
-case 321: {
+case 320: {
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)
@@ -2124,85 +1630,59 @@ case 321: {
sym(1).Node = node;
} break;
-#line 2772 "qmljs.g"
-
-case 322: {
+case 321: {
AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).sval);
node->identifierToken = loc(1);
sym(1).Node = node;
} break;
-#line 2781 "qmljs.g"
-
-case 323: {
+case 322: {
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;
-#line 2791 "qmljs.g"
-
-case 324: {
+case 323: {
sym(1).Node = 0;
} break;
-#line 2798 "qmljs.g"
-
-case 325: {
+case 324: {
sym(1).Node = sym(1).FormalParameterList->finish ();
} break;
-#line 2805 "qmljs.g"
-
-case 326: {
+case 325: {
sym(1).Node = 0;
} break;
-#line 2814 "qmljs.g"
-
-case 328: {
+case 327: {
sym(1).Node = makeAstNode<AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ());
} break;
-#line 2829 "qmljs.g"
-
-case 329: {
+case 328: {
sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElement);
} break;
-#line 2836 "qmljs.g"
-
-case 330: {
+case 329: {
sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement);
} break;
-#line 2843 "qmljs.g"
-
-case 331: {
+case 330: {
sym(1).Node = makeAstNode<AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement);
} break;
-#line 2850 "qmljs.g"
-
-case 332: {
+case 331: {
sym(1).Node = makeAstNode<AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration);
} break;
-#line 2857 "qmljs.g"
-
-case 333: {
+case 332: {
sym(1).sval = 0;
} break;
-#line 2866 "qmljs.g"
-
-case 335: {
+case 334: {
sym(1).Node = 0;
} break;
-#line 2874 "qmljs.g"
-
} // switch
action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT);
} // if
@@ -2293,7 +1773,8 @@ case 335: {
}
for (int tk = 1; tk < TERMINAL_COUNT; ++tk) {
- if (tk == T_AUTOMATIC_SEMICOLON)
+ if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM ||
+ tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION)
continue;
int a = t_action(errorState, tk);
diff --git a/src/declarative/qml/parser/qmljsparser_p.h b/src/declarative/qml/parser/qmljsparser_p.h
index e4ca20a..6f36484 100644
--- a/src/declarative/qml/parser/qmljsparser_p.h
+++ b/src/declarative/qml/parser/qmljsparser_p.h
@@ -1,7 +1,5 @@
// This file was generated by qlalr - DO NOT EDIT!
-#line 148 "qmljs.g"
-
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
@@ -128,10 +126,29 @@ public:
Parser(Engine *engine);
~Parser();
- bool parse();
+ // parse a UI program
+ bool parse() { return parse(T_FEED_UI_PROGRAM); }
+ bool parseStatement() { return parse(T_FEED_JS_STATEMENT); }
+ bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); }
+
+ AST::UiProgram *ast() const
+ { return AST::cast<AST::UiProgram *>(program); }
+
+ AST::Statement *statement() const
+ {
+ if (! program)
+ return 0;
- AST::UiProgram *ast()
- { return program; }
+ return program->statementCast();
+ }
+
+ AST::ExpressionNode *expression() const
+ {
+ if (! program)
+ return 0;
+
+ return program->expressionCast();
+ }
QList<DiagnosticMessage> diagnosticMessages() const
{ return diagnostic_messages; }
@@ -156,6 +173,8 @@ public:
{ return diagnosticMessage().loc.startColumn; }
protected:
+ bool parse(int startToken);
+
void reallocateStack();
inline Value &sym(int index)
@@ -174,7 +193,7 @@ protected:
int *state_stack;
AST::SourceLocation *location_stack;
- AST::UiProgram *program;
+ AST::Node *program;
// error recovery
enum { TOKEN_BUFFER_SIZE = 3 };
@@ -200,15 +219,9 @@ protected:
-#line 1015 "qmljs.g"
-
-#define J_SCRIPT_REGEXPLITERAL_RULE1 69
-
-#line 1032 "qmljs.g"
-
-#define J_SCRIPT_REGEXPLITERAL_RULE2 70
+#define J_SCRIPT_REGEXPLITERAL_RULE1 68
-#line 2994 "qmljs.g"
+#define J_SCRIPT_REGEXPLITERAL_RULE2 69
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h
index cd01f6a..d43e693 100644
--- a/src/declarative/qml/qml.h
+++ b/src/declarative/qml/qml.h
@@ -73,14 +73,17 @@ QT_MODULE(Declarative)
QT_BEGIN_NAMESPACE
+//#define QML_FORCE_NAMESPACE "Qt/4.6/"
+#define QML_FORCE_NAMESPACE
+
#define QML_DEFINE_INTERFACE(INTERFACE) \
template<> QmlPrivate::InstanceType QmlPrivate::Define<INTERFACE *>::instance(qmlRegisterInterface<INTERFACE>(#INTERFACE));
#define QML_DEFINE_EXTENDED_TYPE(TYPE, NAME, EXTENSION) \
- template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#NAME, #TYPE));
+ template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(QML_FORCE_NAMESPACE #NAME, #TYPE));
#define QML_DEFINE_TYPE(TYPE, NAME) \
- template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterType<TYPE>(#NAME, #TYPE));
+ template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterType<TYPE>(QML_FORCE_NAMESPACE #NAME, #TYPE));
#define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \
template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#TYPE));
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index f549a5e..eecf8cd 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -12,7 +12,7 @@ SOURCES += qml/qmlparser.cpp \
qml/qmlproxymetaobject.cpp \
qml/qmlvme.cpp \
qml/qmlcompiler.cpp \
- qml/qmlcompiledcomponent.cpp \
+ qml/qmlcompileddata.cpp \
qml/qmlboundsignal.cpp \
qml/qmldom.cpp \
qml/qmlrefcount.cpp \
@@ -26,6 +26,7 @@ SOURCES += qml/qmlparser.cpp \
qml/qmlerror.cpp \
qml/qmlscriptparser.cpp \
qml/qmlenginedebug.cpp \
+ qml/qmlrewrite.cpp \
qml/qmlbasicscript.cpp
HEADERS += qml/qmlparser_p.h \
@@ -43,7 +44,6 @@ HEADERS += qml/qmlparser_p.h \
qml/qmlboundsignal_p.h \
qml/qmlparserstatus.h \
qml/qmlproxymetaobject_p.h \
- qml/qmlcompiledcomponent_p.h \
qml/qmlvme_p.h \
qml/qmlcompiler_p.h \
qml/qmlengine_p.h \
@@ -68,10 +68,11 @@ HEADERS += qml/qmlparser_p.h \
qml/qmlscriptparser_p.h \
qml/qmlbasicscript_p.h \
qml/qmlenginedebug_p.h \
+ qml/qmlrewrite_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 478491f..40ffffe 100644
--- a/src/declarative/qml/qmlbasicscript.cpp
+++ b/src/declarative/qml/qmlbasicscript.cpp
@@ -64,12 +64,7 @@ struct ScriptInstruction {
FetchD0Constant, // constant
FetchD1Constant, // constant
-
- Add, // NA
- Subtract, // NA
- Multiply, // NA
Equals, // NA
- And, // NA
Int, // integer
Bool, // boolean
@@ -181,6 +176,9 @@ static QVariant toObjectOrVariant(const QVariant &v)
static QVariant fetch_value(QObject *o, int idx, int type)
{
+ if (!o)
+ return QVariant();
+
switch(type) {
case QVariant::String:
{
@@ -291,7 +289,7 @@ struct QmlBasicScriptCompiler
QmlParser::Object *context;
QmlParser::Object *component;
- QHash<QString, QPair<QmlParser::Object *, int> > ids;
+ QHash<QString, QmlParser::Object *> ids;
bool compile(QmlJS::AST::Node *);
@@ -445,15 +443,6 @@ void QmlBasicScript::dump()
qWarning().nospace() << "FETCH\t\t" << instr.fetch.idx << "\t\t"
<< QByteArray(data + instr.fetch.idx);
break;
- case ScriptInstruction::Add:
- qWarning().nospace() << "ADD";
- break;
- case ScriptInstruction::Subtract:
- qWarning().nospace() << "SUBTRACT";
- break;
- case ScriptInstruction::Multiply:
- qWarning().nospace() << "MULTIPLY";
- break;
case ScriptInstruction::Equals:
qWarning().nospace() << "EQUALS";
break;
@@ -588,10 +577,10 @@ bool QmlBasicScriptCompiler::parseName(AST::Node *node,
if (ids.contains(name)) {
instr.type = ScriptInstruction::LoadIdObject;
- instr.fetch.idx = ids.value(name).second;
+ instr.fetch.idx = ids.value(name)->idIndex;
if (type)
- *type = ids.value(name).first;
+ *type = ids.value(name);
} else {
int d0Idx = context->metaObject()->indexOfProperty(name.toUtf8().constData());
@@ -679,11 +668,7 @@ bool QmlBasicScriptCompiler::tryBinaryExpression(AST::Node *node)
AST::BinaryExpression *expr =
static_cast<AST::BinaryExpression *>(node);
- if (expr->op == QSOperator::Add ||
- expr->op == QSOperator::Sub ||
- expr->op == QSOperator::Equal ||
- expr->op == QSOperator::And ||
- expr->op == QSOperator::Mul)
+ if (expr->op == QSOperator::Equal)
return true;
}
return false;
@@ -700,21 +685,9 @@ bool QmlBasicScriptCompiler::compileBinaryExpression(AST::Node *node)
ScriptInstruction instr;
switch (expr->op) {
- case QSOperator::Add:
- instr.type = ScriptInstruction::Add;
- break;
- case QSOperator::Sub:
- instr.type = ScriptInstruction::Subtract;
- break;
case QSOperator::Equal:
instr.type = ScriptInstruction::Equals;
break;
- case QSOperator::And:
- instr.type = ScriptInstruction::And;
- break;
- case QSOperator::Mul:
- instr.type = ScriptInstruction::Multiply;
- break;
default:
return false;
}
@@ -823,7 +796,7 @@ 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));
- if (instr.constant.notify != 0)
+ if (obj && instr.constant.notify != 0)
enginePrivate->capturedProperties <<
QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify);
state = Reset;
@@ -835,7 +808,7 @@ 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));
- if (instr.constant.notify != 0)
+ if (obj && instr.constant.notify != 0)
enginePrivate->capturedProperties <<
QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify);
state = Reset;
@@ -848,7 +821,7 @@ 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));
- if (instr.constant.notify != 0)
+ if (obj && instr.constant.notify != 0)
enginePrivate->capturedProperties <<
QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify);
state = Reset;
@@ -913,30 +886,6 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c
case ScriptInstruction::Bool:
stack.push(QVariant(instr.boolean.value));
break;
- case ScriptInstruction::Add:
- {
- QVariant rhs = stack.pop();
- QVariant lhs = stack.pop();
-
- stack.push(rhs.toDouble() + lhs.toDouble());
- }
- break;
- case ScriptInstruction::Subtract:
- {
- QVariant rhs = stack.pop();
- QVariant lhs = stack.pop();
-
- stack.push(lhs.toDouble() - rhs.toDouble());
- }
- break;
- case ScriptInstruction::Multiply:
- {
- QVariant rhs = stack.pop();
- QVariant lhs = stack.pop();
-
- stack.push(rhs.toDouble() * lhs.toDouble());
- }
- break;
case ScriptInstruction::Equals:
{
QVariant rhs = stack.pop();
@@ -945,14 +894,6 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c
stack.push(rhs == lhs);
}
break;
- case ScriptInstruction::And:
- {
- QVariant rhs = stack.pop();
- QVariant lhs = stack.pop();
-
- stack.push(rhs.toBool() && lhs.toBool());
- }
- break;
default:
break;
}
diff --git a/src/declarative/qml/qmlbasicscript_p.h b/src/declarative/qml/qmlbasicscript_p.h
index 0c69397..77d59eb 100644
--- a/src/declarative/qml/qmlbasicscript_p.h
+++ b/src/declarative/qml/qmlbasicscript_p.h
@@ -85,7 +85,7 @@ public:
QmlParser::Object *context;
QmlParser::Property *property;
QmlParser::Variant expression;
- QHash<QString, QPair<QmlParser::Object *, int> > ids;
+ QHash<QString, QmlParser::Object *> ids;
};
bool compile(const Expression &);
diff --git a/src/declarative/qml/qmlcompiledcomponent.cpp b/src/declarative/qml/qmlcompiledcomponent.cpp
deleted file mode 100644
index bea736a..0000000
--- a/src/declarative/qml/qmlcompiledcomponent.cpp
+++ /dev/null
@@ -1,96 +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 "qmlcompiledcomponent_p.h"
-#include "qmlparser_p.h"
-#include <QtCore/qdebug.h>
-#include <QmlComponent>
-using namespace QmlParser;
-
-QT_BEGIN_NAMESPACE
-
-DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
-
-QmlCompiledComponent::QmlCompiledComponent()
-: dumpStatus(NoDump)
-{
-}
-
-QmlCompiledComponent::~QmlCompiledComponent()
-{
- for (int ii = 0; ii < synthesizedMetaObjects.count(); ++ii)
- qFree(synthesizedMetaObjects.at(ii));
-}
-
-
-void QmlCompiledComponent::dumpInstructions()
-{
- if (!compilerDump())
- return;
-
- if (!name.isEmpty())
- qWarning() << name;
- qWarning() << "Index\tLine\tOperation\t\tData1\tData2\t\tComments";
- qWarning() << "-------------------------------------------------------------------------------";
- for (int ii = 0; ii < bytecode.count(); ++ii) {
- dump(&bytecode[ii], ii);
- }
- qWarning() << "-------------------------------------------------------------------------------";
-}
-
-void QmlCompiledComponent::dumpPre()
-{
- if (!(dumpStatus & DumpPre)) {
- dumpInstructions();
- dumpStatus = (DumpStatus)(dumpStatus | DumpPre);
- }
-}
-
-void QmlCompiledComponent::dumpPost()
-{
- if (!(dumpStatus & DumpPost)) {
- dumpInstructions();
- dumpStatus = (DumpStatus)(dumpStatus | DumpPost);
- }
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompileddata.cpp b/src/declarative/qml/qmlcompileddata.cpp
new file mode 100644
index 0000000..0563891
--- /dev/null
+++ b/src/declarative/qml/qmlcompileddata.cpp
@@ -0,0 +1,205 @@
+/****************************************************************************
+**
+** 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 "qmlcompiler_p.h"
+#include "qmlengine.h"
+#include "qmlcomponent.h"
+#include "qmlcomponent_p.h"
+#include "qmlcontext.h"
+#include "qmlcontext_p.h"
+#include <private/qobject_p.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+int QmlCompiledData::pack(const char *data, size_t size)
+{
+ const char *p = packData.constData();
+ unsigned int ps = packData.size();
+
+ for (unsigned int ii = 0; (ii + size) <= ps; ii += sizeof(int)) {
+ if (0 == ::memcmp(p + ii, data, size))
+ return ii;
+ }
+
+ int rv = packData.size();
+ packData.append(data, size);
+ return rv;
+}
+
+int QmlCompiledData::indexForString(const QString &data)
+{
+ int idx = primitives.indexOf(data);
+ if (idx == -1) {
+ idx = primitives.count();
+ primitives << data;
+ }
+ return idx;
+}
+
+int QmlCompiledData::indexForByteArray(const QByteArray &data)
+{
+ int idx = datas.indexOf(data);
+ if (idx == -1) {
+ idx = datas.count();
+ datas << data;
+ }
+ return idx;
+}
+
+int QmlCompiledData::indexForFloat(float *data, int count)
+{
+ Q_ASSERT(count > 0);
+
+ for (int ii = 0; ii <= floatData.count() - count; ++ii) {
+ bool found = true;
+ for (int jj = 0; jj < count; ++jj) {
+ if (floatData.at(ii + jj) != data[jj]) {
+ found = false;
+ break;
+ }
+ }
+
+ if (found)
+ return ii;
+ }
+
+ int idx = floatData.count();
+ for (int ii = 0; ii < count; ++ii)
+ floatData << data[ii];
+
+ return idx;
+}
+
+int QmlCompiledData::indexForInt(int *data, int count)
+{
+ Q_ASSERT(count > 0);
+
+ for (int ii = 0; ii <= intData.count() - count; ++ii) {
+ bool found = true;
+ for (int jj = 0; jj < count; ++jj) {
+ if (intData.at(ii + jj) != data[jj]) {
+ found = false;
+ break;
+ }
+ }
+
+ if (found)
+ return ii;
+ }
+
+ int idx = intData.count();
+ for (int ii = 0; ii < count; ++ii)
+ intData << data[ii];
+
+ return idx;
+}
+
+int QmlCompiledData::indexForLocation(const QmlParser::Location &l)
+{
+ // ### FIXME
+ int rv = locations.count();
+ locations << l;
+ return rv;
+}
+
+int QmlCompiledData::indexForLocation(const QmlParser::LocationSpan &l)
+{
+ // ### FIXME
+ int rv = locations.count();
+ locations << l.start << l.end;
+ return rv;
+}
+
+QmlCompiledData::QmlCompiledData()
+{
+}
+
+QmlCompiledData::~QmlCompiledData()
+{
+ for (int ii = 0; ii < types.count(); ++ii) {
+ if (types.at(ii).ref)
+ types.at(ii).ref->release();
+ }
+}
+
+QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt) const
+{
+ if (type) {
+ QObject *rv = type->create();
+ if (rv)
+ QmlEngine::setContextForObject(rv, ctxt);
+ return rv;
+ } else {
+ Q_ASSERT(component);
+ QObject *rv = component->create(ctxt);
+ QmlContext *ctxt = qmlContext(rv);
+ if(ctxt) {
+ static_cast<QmlContextPrivate *>(QObjectPrivate::get(ctxt))->typeName = className;
+ }
+ return rv;
+ }
+}
+
+const QMetaObject *QmlCompiledData::TypeReference::metaObject() const
+{
+ if (type) {
+ return type->metaObject();
+ } else {
+ Q_ASSERT(component);
+ return &static_cast<QmlComponentPrivate *>(QObjectPrivate::get(component))->cc->root;
+ }
+}
+
+void QmlCompiledData::dumpInstructions()
+{
+ if (!name.isEmpty())
+ qWarning() << name;
+ qWarning() << "Index\tLine\tOperation\t\tData1\tData2\t\tComments";
+ qWarning() << "-------------------------------------------------------------------------------";
+ for (int ii = 0; ii < bytecode.count(); ++ii) {
+ dump(&bytecode[ii], ii);
+ }
+ qWarning() << "-------------------------------------------------------------------------------";
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index b04c932..138be29 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -52,7 +52,6 @@
#include <QPointF>
#include <QSizeF>
#include <QRectF>
-#include <private/qmlcompiledcomponent_p.h>
#include <private/qmlstringconverters_p.h>
#include <private/qmlengine_p.h>
#include <qmlengine.h>
@@ -69,107 +68,43 @@
QT_BEGIN_NAMESPACE
-using namespace QmlParser;
-
-int QmlCompiledData::indexForString(const QString &data)
-{
- int idx = primitives.indexOf(data);
- if (idx == -1) {
- idx = primitives.count();
- primitives << data;
- }
- return idx;
-}
+DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP);
-int QmlCompiledData::indexForByteArray(const QByteArray &data)
-{
- int idx = datas.indexOf(data);
- if (idx == -1) {
- idx = datas.count();
- datas << data;
- }
- return idx;
-}
-
-int QmlCompiledData::indexForFloat(float *data, int count)
-{
- Q_ASSERT(count > 0);
-
- for (int ii = 0; ii <= floatData.count() - count; ++ii) {
- bool found = true;
- for (int jj = 0; jj < count; ++jj) {
- if (floatData.at(ii + jj) != data[jj]) {
- found = false;
- break;
- }
- }
-
- if (found)
- return ii;
- }
-
- int idx = floatData.count();
- for (int ii = 0; ii < count; ++ii)
- floatData << data[ii];
-
- return idx;
-}
-
-int QmlCompiledData::indexForInt(int *data, int count)
-{
- Q_ASSERT(count > 0);
-
- for (int ii = 0; ii <= intData.count() - count; ++ii) {
- bool found = true;
- for (int jj = 0; jj < count; ++jj) {
- if (intData.at(ii + jj) != data[jj]) {
- found = false;
- break;
- }
- }
-
- if (found)
- return ii;
- }
-
- int idx = intData.count();
- for (int ii = 0; ii < count; ++ii)
- intData << data[ii];
-
- return idx;
-}
-
-int QmlCompiledData::indexForLocation(const QmlParser::Location &l)
-{
- // ### FIXME
- int rv = locations.count();
- locations << l;
- return rv;
-}
-
-int QmlCompiledData::indexForLocation(const QmlParser::LocationSpan &l)
-{
- // ### FIXME
- int rv = locations.count();
- locations << l.start << l.end;
- return rv;
-}
+using namespace QmlParser;
+/*!
+ Instantiate a new QmlCompiler.
+*/
QmlCompiler::QmlCompiler()
: output(0)
{
}
+/*!
+ Returns true if the last call to compile() caused errors.
+
+ \sa errors()
+*/
bool QmlCompiler::isError() const
{
return !exceptions.isEmpty();
}
+/*!
+ Return the list of errors from the last call to compile(), or an empty list
+ if there were no errors.
+*/
QList<QmlError> QmlCompiler::errors() const
{
return exceptions;
}
+/*!
+ Returns true if \a val is a legal object id, false otherwise.
+
+ Legal ids must start with a letter or underscore, and contain only
+ letters, numbers and underscores.
+*/
bool QmlCompiler::isValidId(const QString &val)
{
if (val.isEmpty())
@@ -207,27 +142,26 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name)
'A' <= name.at(2) && 'Z' >= name.at(2);
}
-#define COMPILE_EXCEPTION2(token, desc) \
- { \
- QString exceptionDescription; \
- QmlError error; \
- error.setUrl(output->url); \
- error.setLine(token->location.start.line); \
- error.setColumn(token->location.start.column); \
- QDebug d(&exceptionDescription); \
- d << desc; \
- error.setDescription(exceptionDescription.trimmed()); \
- exceptions << error; \
- return false; \
- }
+/*!
+ Inserts an error into the QmlCompiler error list, and returns false
+ (failure).
+
+ \a token is used to source the error line and column, and \a desc is the
+ error itself. \a desc can be an expression that can be piped into QDebug.
-#define COMPILE_EXCEPTION(desc) \
+ For example:
+
+ \code
+ COMPILE_EXCEPTION(property, "Error for property" << property->name);
+ \endcode
+*/
+#define COMPILE_EXCEPTION(token, desc) \
{ \
QString exceptionDescription; \
QmlError error; \
error.setUrl(output->url); \
- error.setLine(obj->location.start.line); \
- error.setColumn(obj->location.start.column); \
+ error.setLine((token)->location.start.line); \
+ error.setColumn((token)->location.start.column); \
QDebug d(&exceptionDescription); \
d << desc; \
error.setDescription(exceptionDescription.trimmed()); \
@@ -235,20 +169,28 @@ bool QmlCompiler::isSignalPropertyName(const QByteArray &name)
return false; \
}
+/*!
+ Returns false if \a is false, otherwise does nothing.
+*/
#define COMPILE_CHECK(a) \
{ \
if (!a) return false; \
}
-// Compile a simple assignment of v to prop into instr
-bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
- const QMetaProperty &prop,
- QmlParser::Value *v)
+/*!
+ Returns true if literal \a v can be assigned to property \a prop, otherwise
+ false.
+
+ This test corresponds to action taken by genLiteralAssignment(). Any change
+ made here, must have a corresponding action in genLiteralAssigment().
+*/
+bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop,
+ QmlParser::Value *v)
{
QString string = v->value.asScript();
if (!prop.isWritable())
- COMPILE_EXCEPTION2(v, "Cannot assign literal value to read-only property" << prop.name());
+ COMPILE_EXCEPTION(v, "Invalid property assignment: read-only property");
if (prop.isEnumType()) {
int value;
@@ -257,12 +199,142 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
} else
value = prop.enumerator().keyToValue(string.toLatin1().constData());
if (value == -1)
- COMPILE_EXCEPTION2(v, "Cannot assign unknown enumeration to property" << prop.name());
+ COMPILE_EXCEPTION(v, "Invalid property assignment: unknown enumeration");
+ return true;
+ }
+ int type = prop.userType();
+ switch(type) {
+ case -1:
+ break;
+ case QVariant::String:
+ if (!v->value.isString()) COMPILE_EXCEPTION(v, "Invalid property assignment: string expected");
+ break;
+ case QVariant::Url:
+ if (!v->value.isString()) COMPILE_EXCEPTION(v, "Invalid property assignment: url expected");
+ break;
+ case QVariant::UInt:
+ {
+ bool ok;
+ string.toUInt(&ok);
+ if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, "Invalid property assignment: unsigned int expected");
+ }
+ break;
+ case QVariant::Int:
+ {
+ bool ok;
+ string.toInt(&ok);
+ if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, "Invalid property assignment: int expected");
+ }
+ break;
+ case QMetaType::Float:
+ {
+ bool ok;
+ string.toFloat(&ok);
+ if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, "Invalid property assignment: float expected");
+ }
+ break;
+ case QVariant::Double:
+ {
+ bool ok;
+ string.toDouble(&ok);
+ if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, "Invalid property assignment: double expected");
+ }
+ break;
+ case QVariant::Color:
+ {
+ QColor c = QmlStringConverters::colorFromString(string);
+ if (!c.isValid()) COMPILE_EXCEPTION(v, "Invalid property assignment: color expected");
+ }
+ break;
+ case QVariant::Date:
+ {
+ QDate d = QDate::fromString(string, Qt::ISODate);
+ if (!d.isValid()) COMPILE_EXCEPTION(v, "Invalid property assignment: date expected");
+ }
+ break;
+ case QVariant::Time:
+ {
+ QTime time = QTime::fromString(string, Qt::ISODate);
+ if (!time.isValid()) COMPILE_EXCEPTION(v, "Invalid property assignment: time expected");
+ }
+ break;
+ case QVariant::DateTime:
+ {
+ QDateTime dateTime = QDateTime::fromString(string, Qt::ISODate);
+ if (!dateTime.isValid()) COMPILE_EXCEPTION(v, "Invalid property assignment: datetime expected");
+ }
+ break;
+ case QVariant::Point:
+ case QVariant::PointF:
+ {
+ bool ok;
+ QPointF point = QmlStringConverters::pointFFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, "Invalid property assignment: point expected");
+ }
+ break;
+ case QVariant::Size:
+ case QVariant::SizeF:
+ {
+ bool ok;
+ QSizeF size = QmlStringConverters::sizeFFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, "Invalid property assignment: size expected");
+ }
+ break;
+ case QVariant::Rect:
+ case QVariant::RectF:
+ {
+ bool ok;
+ QRectF rect = QmlStringConverters::rectFFromString(string, &ok);
+ if (!ok) COMPILE_EXCEPTION(v, "Invalid property assignment: rect expected");
+ }
+ break;
+ case QVariant::Bool:
+ {
+ if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, "Invalid property assignment: boolean expected");
+ }
+ break;
+ default:
+ {
+ int t = prop.type();
+ if (t == QVariant::UserType)
+ t = prop.userType();
+ QmlMetaType::StringConverter converter =
+ QmlMetaType::customStringConverter(t);
+ if (!converter)
+ COMPILE_EXCEPTION(v, "Invalid property assignment: unknown type" << prop.type());
+ }
+ break;
+ }
+ return true;
+}
+
+/*!
+ Generate a store instruction for assigning literal \a v to property \a prop.
+
+ Any literal assignment that is approved in testLiteralAssignment() must have
+ a corresponding action in this method.
+*/
+void QmlCompiler::genLiteralAssignment(const QMetaProperty &prop,
+ QmlParser::Value *v)
+{
+ QString string = v->value.asScript();
+
+ QmlInstruction instr;
+ instr.line = v->location.start.line;
+ if (prop.isEnumType()) {
+ int value;
+ if (prop.isFlagType()) {
+ value = prop.enumerator().keysToValue(string.toLatin1().constData());
+ } else
+ value = prop.enumerator().keyToValue(string.toLatin1().constData());
+
instr.type = QmlInstruction::StoreInteger;
instr.storeInteger.propertyIndex = prop.propertyIndex();
instr.storeInteger.value = value;
- return true;
+ output->bytecode << instr;
+ return;
}
+
int type = prop.userType();
switch(type) {
case -1:
@@ -291,51 +363,33 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
{
instr.type = QmlInstruction::StoreInteger;
instr.storeInteger.propertyIndex = prop.propertyIndex();
- bool ok;
- int value = string.toUInt(&ok);
- if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to unsigned integer");
- instr.storeInteger.value = value;
+ instr.storeInteger.value = string.toUInt();
}
break;
case QVariant::Int:
{
instr.type = QmlInstruction::StoreInteger;
instr.storeInteger.propertyIndex = prop.propertyIndex();
- bool ok;
- int value = string.toInt(&ok);
- if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to integer");
- instr.storeInteger.value = value;
+ instr.storeInteger.value = string.toInt();
}
break;
case QMetaType::Float:
{
instr.type = QmlInstruction::StoreFloat;
instr.storeFloat.propertyIndex = prop.propertyIndex();
- bool ok;
- float value = string.toFloat(&ok);
- if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to float number");
- instr.storeFloat.value = value;
+ instr.storeFloat.value = string.toFloat();
}
break;
case QVariant::Double:
{
instr.type = QmlInstruction::StoreDouble;
instr.storeDouble.propertyIndex = prop.propertyIndex();
- bool ok;
- double value = string.toDouble(&ok);
- if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to double number");
- instr.storeDouble.value = value;
+ instr.storeDouble.value = string.toDouble();
}
break;
case QVariant::Color:
{
QColor c = QmlStringConverters::colorFromString(string);
- if (!c.isValid())
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to color");
instr.type = QmlInstruction::StoreColor;
instr.storeColor.propertyIndex = prop.propertyIndex();
instr.storeColor.value = c.rgba();
@@ -344,8 +398,6 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
case QVariant::Date:
{
QDate d = QDate::fromString(string, Qt::ISODate);
- if (!d.isValid())
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to date");
instr.type = QmlInstruction::StoreDate;
instr.storeDate.propertyIndex = prop.propertyIndex();
instr.storeDate.value = d.toJulianDay();
@@ -354,9 +406,8 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
case QVariant::Time:
{
QTime time = QTime::fromString(string, Qt::ISODate);
- if (!time.isValid())
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to time");
- int data[] = { time.hour(), time.minute(), time.second(), time.msec() };
+ int data[] = { time.hour(), time.minute(),
+ time.second(), time.msec() };
int index = output->indexForInt(data, 4);
instr.type = QmlInstruction::StoreTime;
instr.storeTime.propertyIndex = prop.propertyIndex();
@@ -366,8 +417,6 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
case QVariant::DateTime:
{
QDateTime dateTime = QDateTime::fromString(string, Qt::ISODate);
- if (!dateTime.isValid())
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to date and time");
int data[] = { dateTime.date().toJulianDay(),
dateTime.time().hour(),
dateTime.time().minute(),
@@ -382,111 +431,106 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
case QVariant::Point:
case QVariant::PointF:
{
- bool ok;
- QPointF point = QmlStringConverters::pointFFromString(string, &ok);
- if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to point");
- float data[] = { point.x(), point.y() };
- int index = output->indexForFloat(data, 2);
- if (type == QVariant::PointF)
- instr.type = QmlInstruction::StorePointF;
- else
- instr.type = QmlInstruction::StorePoint;
- instr.storeRealPair.propertyIndex = prop.propertyIndex();
- instr.storeRealPair.valueIndex = index;
+ bool ok;
+ QPointF point =
+ QmlStringConverters::pointFFromString(string, &ok);
+ float data[] = { point.x(), point.y() };
+ int index = output->indexForFloat(data, 2);
+ if (type == QVariant::PointF)
+ instr.type = QmlInstruction::StorePointF;
+ else
+ instr.type = QmlInstruction::StorePoint;
+ instr.storeRealPair.propertyIndex = prop.propertyIndex();
+ instr.storeRealPair.valueIndex = index;
}
break;
case QVariant::Size:
case QVariant::SizeF:
{
- bool ok;
- QSizeF size = QmlStringConverters::sizeFFromString(string, &ok);
- if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to size");
- float data[] = { size.width(), size.height() };
- int index = output->indexForFloat(data, 2);
- if (type == QVariant::SizeF)
- instr.type = QmlInstruction::StoreSizeF;
- else
- instr.type = QmlInstruction::StoreSize;
- instr.storeRealPair.propertyIndex = prop.propertyIndex();
- instr.storeRealPair.valueIndex = index;
+ bool ok;
+ QSizeF size = QmlStringConverters::sizeFFromString(string, &ok);
+ float data[] = { size.width(), size.height() };
+ int index = output->indexForFloat(data, 2);
+ if (type == QVariant::SizeF)
+ instr.type = QmlInstruction::StoreSizeF;
+ else
+ instr.type = QmlInstruction::StoreSize;
+ instr.storeRealPair.propertyIndex = prop.propertyIndex();
+ instr.storeRealPair.valueIndex = index;
}
break;
case QVariant::Rect:
case QVariant::RectF:
{
- bool ok;
- QRectF rect = QmlStringConverters::rectFFromString(string, &ok);
- if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to rect");
- float data[] = { rect.x(), rect.y(),
- rect.width(), rect.height() };
- int index = output->indexForFloat(data, 4);
- if (type == QVariant::RectF)
- instr.type = QmlInstruction::StoreRectF;
- else
- instr.type = QmlInstruction::StoreRect;
- instr.storeRect.propertyIndex = prop.propertyIndex();
- instr.storeRect.valueIndex = index;
+ bool ok;
+ QRectF rect = QmlStringConverters::rectFFromString(string, &ok);
+ float data[] = { rect.x(), rect.y(),
+ rect.width(), rect.height() };
+ int index = output->indexForFloat(data, 4);
+ if (type == QVariant::RectF)
+ instr.type = QmlInstruction::StoreRectF;
+ else
+ instr.type = QmlInstruction::StoreRect;
+ instr.storeRect.propertyIndex = prop.propertyIndex();
+ instr.storeRect.valueIndex = index;
}
break;
case QVariant::Bool:
{
- bool ok;
- bool b = QmlStringConverters::boolFromString(string, &ok);
- if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to boolean");
- instr.type = QmlInstruction::StoreBool;
- instr.storeBool.propertyIndex = prop.propertyIndex();
- instr.storeBool.value = b;
+ bool b = v->value.asBoolean();
+ instr.type = QmlInstruction::StoreBool;
+ instr.storeBool.propertyIndex = prop.propertyIndex();
+ instr.storeBool.value = b;
}
break;
default:
{
- int t = prop.type();
- if (t == QVariant::UserType)
- t = prop.userType();
- QmlMetaType::StringConverter converter =
- QmlMetaType::customStringConverter(t);
- if (converter) {
- int index = output->customTypeData.count();
- instr.type = QmlInstruction::AssignCustomType;
- instr.assignCustomType.propertyIndex = prop.propertyIndex();
- instr.assignCustomType.valueIndex = index;
-
- QmlCompiledData::CustomTypeData data;
- data.index = output->indexForString(string);
- data.type = t;
- output->customTypeData << data;
- break;
- }
+ int t = prop.type();
+ if (t == QVariant::UserType)
+ t = prop.userType();
+ int index = output->customTypeData.count();
+ instr.type = QmlInstruction::AssignCustomType;
+ instr.assignCustomType.propertyIndex = prop.propertyIndex();
+ instr.assignCustomType.valueIndex = index;
+
+ QmlCompiledData::CustomTypeData data;
+ data.index = output->indexForString(string);
+ data.type = t;
+ output->customTypeData << data;
}
- COMPILE_EXCEPTION2(v, "Cannot assign to property" << prop.name() << "of unknown type" << prop.type());
break;
}
- return true;
+ output->bytecode << instr;
}
-void QmlCompiler::reset(QmlCompiledComponent *cc, bool deleteMemory)
+/*!
+ Resets data by clearing the lists that the QmlCompiler modifies.
+*/
+void QmlCompiler::reset(QmlCompiledData *data)
{
- cc->types.clear();
- cc->primitives.clear();
- cc->floatData.clear();
- cc->intData.clear();
- cc->customTypeData.clear();
- cc->datas.clear();
- if (deleteMemory) {
- for (int ii = 0; ii < cc->synthesizedMetaObjects.count(); ++ii)
- qFree(cc->synthesizedMetaObjects.at(ii));
- }
- cc->synthesizedMetaObjects.clear();
- cc->bytecode.clear();
+ data->types.clear();
+ data->primitives.clear();
+ data->floatData.clear();
+ data->intData.clear();
+ data->customTypeData.clear();
+ data->datas.clear();
+ data->bytecode.clear();
}
+/*!
+ Compile \a unit, and store the output in \a out. \a engine is the QmlEngine
+ with which the QmlCompiledData will be associated.
+
+ Returns true on success, false on failure. On failure, the compile errors
+ are available from errors().
+
+ If the environment variant QML_COMPILER_DUMP is set
+ (eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr
+ on a successful compiler.
+*/
bool QmlCompiler::compile(QmlEngine *engine,
QmlCompositeTypeData *unit,
- QmlCompiledComponent *out)
+ QmlCompiledData *out)
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxPerfTimer<QFxPerf::Compilation> pc;
@@ -494,14 +538,14 @@ bool QmlCompiler::compile(QmlEngine *engine,
exceptions.clear();
Q_ASSERT(out);
- reset(out, true);
+ reset(out);
output = out;
// Compile types
for (int ii = 0; ii < unit->types.count(); ++ii) {
QmlCompositeTypeData::TypeReference &tref = unit->types[ii];
- QmlCompiledComponent::TypeReference ref;
+ QmlCompiledData::TypeReference ref;
if (tref.type)
ref.type = tref.type;
else if (tref.unit) {
@@ -514,7 +558,7 @@ bool QmlCompiler::compile(QmlEngine *engine,
unit->data.types().at(ii));
exceptions << error;
exceptions << ref.component->errors();
- reset(out, true);
+ reset(out);
return false;
}
ref.ref = tref.unit;
@@ -530,11 +574,14 @@ bool QmlCompiler::compile(QmlEngine *engine,
compileTree(root);
if (!isError()) {
- out->dumpPre();
+ if (compilerDump())
+ out->dumpInstructions();
} else {
- reset(out, true);
+ reset(out);
}
+ compileState = ComponentCompileState();
+ savedCompileStates.clear();
output = 0;
return !isError();
@@ -544,24 +591,23 @@ void QmlCompiler::compileTree(Object *tree)
{
compileState.root = tree;
+ if (!buildObject(tree, BindingContext()) || !completeComponentBuild())
+ return;
+
QmlInstruction init;
init.type = QmlInstruction::Init;
init.line = 0;
- init.init.dataSize = 0;
- init.init.bindingsSize = 0;
- init.init.parserStatusSize = 0;
+ init.init.bindingsSize = compileState.bindings.count();
+ init.init.parserStatusSize = compileState.parserStatusCount;
output->bytecode << init;
- if (!compileObject(tree, 0)) // Compile failed
- return;
+ genObject(tree);
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
@@ -569,55 +615,35 @@ void QmlCompiler::compileTree(Object *tree)
}
-bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt)
+bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
{
Q_ASSERT (obj->type != -1);
- const QmlCompiledData::TypeReference &tr = output->types.at(obj->type);
+ 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));
+ // This object is a "Component" element
+ if (obj->metatype == &QmlComponent::staticMetaObject) {
+ COMPILE_CHECK(buildComponent(obj, ctxt));
return true;
}
+ // Object instantiations reset the binding context
BindingContext objCtxt(obj);
- int createInstrIdx = output->bytecode.count();
- // Create the object
- QmlInstruction create;
- create.type = QmlInstruction::CreateObject;
- create.line = obj->location.start.line;
- create.create.data = -1;
- create.create.type = obj->type;
- output->bytecode << create;
-
- // Create the synthesized meta object
- COMPILE_CHECK(compileDynamicMeta(obj));
+ // Create the synthesized meta object, ignoring aliases
+ COMPILE_CHECK(mergeDynamicMetaProperties(obj));
+ COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases));
// Find the native type and check for the QmlParserStatus interface
- // ### Optimize
- const QMetaObject *mo = obj->metatype;
- QmlType *type = 0;
- while (!type && mo) {
- type = QmlMetaType::qmlType(mo);
- mo = mo->superClass();
- }
+ QmlType *type = toQmlType(obj);
Q_ASSERT(type);
- int parserStatusCast = type->parserStatusCast();
-
- // If the type support the QmlParserStatusInterface we need to invoke
- // classBegin()
- if (parserStatusCast != -1) {
- QmlInstruction begin;
- begin.type = QmlInstruction::BeginObject;
- begin.begin.castValue = parserStatusCast;
- begin.line = obj->location.start.line;
- output->bytecode << begin;
-
+ obj->parserStatusCast = type->parserStatusCast();
+ if (obj->parserStatusCast != -1)
compileState.parserStatusCount++;
- }
// Check if this is a custom parser type. Custom parser types allow
// assignments to non-existant properties. These assignments are then
@@ -626,57 +652,72 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt)
output->types.at(obj->type).type->customParser() != 0;
QList<QmlCustomParserProperty> customProps;
- QStringList deferred = deferredProperties(obj);
- QList<Property *> deferredProps;
+ // Fetch the list of deferred properties
+ QStringList deferredList = deferredProperties(obj);
+
+ // Must do id property first. This is to ensure that the id given to any
+ // id reference created matches the order in which the objects are
+ // instantiated
+ foreach(Property *prop, obj->properties) {
+ if (prop->name == "id") {
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ break;
+ }
+ }
- // Compile all explicit properties specified
+ // Build all explicit properties specified
foreach(Property *prop, obj->properties) {
+ if (prop->name == "id")
+ continue;
+
+ bool canDefer = false;
if (isCustomParser) {
- // Custom parser types don't support signal properties
- if (testProperty(prop, obj)) {
- if (deferred.contains(QString::fromLatin1(prop->name.constData())))
- deferredProps << prop;
- else
- COMPILE_CHECK(compileProperty(prop, obj, objCtxt));
+ if (doesPropertyExist(prop, obj)) {
+ int ids = compileState.ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState.ids.count();
} else {
customProps << QmlCustomParserNodePrivate::fromProperty(prop);
}
} else {
- if (isSignalPropertyName(prop->name)) {
- COMPILE_CHECK(compileSignal(prop,obj));
+ if (isSignalPropertyName(prop->name)) {
+ COMPILE_CHECK(buildSignal(prop,obj,objCtxt));
} else {
- if (deferred.contains(QString::fromLatin1(prop->name.constData())))
- deferredProps << prop;
- else
- COMPILE_CHECK(compileProperty(prop, obj, objCtxt));
+ int ids = compileState.ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState.ids.count();
}
}
+ if (canDefer && !deferredList.isEmpty() &&
+ deferredList.contains(prop->name))
+ prop->isDeferred = true;
+
}
- // Compile the default property
+ // Build the default property
if (obj->defaultProperty) {
Property *prop = obj->defaultProperty;
+ bool canDefer = false;
if (isCustomParser) {
- if (testProperty(prop, obj)) {
- QMetaProperty p = deferred.isEmpty()?QMetaProperty():QmlMetaType::defaultProperty(obj->metaObject());
- if (deferred.contains(QString::fromLatin1(p.name())))
- deferredProps << prop;
- else
- COMPILE_CHECK(compileProperty(prop, obj, objCtxt));
+ if (doesPropertyExist(prop, obj)) {
+ int ids = compileState.ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState.ids.count();
} else {
customProps << QmlCustomParserNodePrivate::fromProperty(prop);
}
} else {
- QMetaProperty p = deferred.isEmpty()?QMetaProperty():QmlMetaType::defaultProperty(obj->metaObject());
- if (deferred.contains(QString::fromLatin1(p.name())))
- deferredProps << prop;
- else
- COMPILE_CHECK(compileProperty(prop, obj, objCtxt));
+ int ids = compileState.ids.count();
+ COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
+ canDefer = ids == compileState.ids.count();
}
+ if (canDefer && !deferredList.isEmpty() &&
+ deferredList.contains(prop->name))
+ prop->isDeferred = true;
}
// Compile custom parser parts
@@ -684,16 +725,83 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt)
// ### Check for failure
bool ok = false;
QmlCustomParser *cp = output->types.at(obj->type).type->customParser();
- QByteArray customData = cp->compile(customProps, &ok);
+ obj->custom = cp->compile(customProps, &ok);
if(!ok)
- COMPILE_EXCEPTION("Failure compiling custom type");
- if(!customData.isEmpty())
- output->bytecode[createInstrIdx].create.data =
- output->indexForByteArray(customData);
+ COMPILE_EXCEPTION(obj, "Failure compiling custom type");
+ }
+
+ return true;
+}
+
+void QmlCompiler::genObject(QmlParser::Object *obj)
+{
+ if (obj->metatype == &QmlComponent::staticMetaObject) {
+ genComponent(obj);
+ return;
+ }
+
+ // Create the object
+ QmlInstruction create;
+ create.type = QmlInstruction::CreateObject;
+ create.line = obj->location.start.line;
+ create.create.data = -1;
+ if (!obj->custom.isEmpty())
+ create.create.data = output->indexForByteArray(obj->custom);
+ create.create.type = obj->type;
+ output->bytecode << create;
+
+ // Setup the synthesized meta object if necessary
+ if (!obj->metadata.isEmpty()) {
+ QmlInstruction meta;
+ meta.type = QmlInstruction::StoreMetaObject;
+ meta.line = -1;
+ meta.storeMeta.data = output->indexForByteArray(obj->metadata);
+ meta.storeMeta.aliasData = output->indexForByteArray(obj->synthdata);
+ meta.storeMeta.slotData = -1;
+ output->bytecode << meta;
+ }
+
+ // Set the object id
+ if (!obj->id.isEmpty()) {
+ QmlInstruction id;
+ id.type = QmlInstruction::SetId;
+ id.line = -1;
+ id.setId.value = output->indexForString(obj->id);
+ output->bytecode << id;
}
- // Build the deferred block
- if (!deferredProps.isEmpty()) {
+ // Begin the class
+ if (obj->parserStatusCast != -1) {
+ QmlInstruction begin;
+ begin.type = QmlInstruction::BeginObject;
+ begin.begin.castValue = obj->parserStatusCast;
+ begin.line = obj->location.start.line;
+ output->bytecode << begin;
+ }
+
+ genObjectBody(obj);
+
+ // Complete the the class
+ if (obj->parserStatusCast != -1) {
+ QmlInstruction complete;
+ complete.type = QmlInstruction::CompleteObject;
+ complete.complete.castValue = obj->parserStatusCast;
+ complete.line = obj->location.start.line;
+ output->bytecode << complete;
+ }
+}
+
+void QmlCompiler::genObjectBody(QmlParser::Object *obj)
+{
+ bool seenDefer = false;
+ foreach(Property *prop, obj->valueProperties) {
+ if (prop->isDeferred) {
+ seenDefer = true;
+ continue;
+ }
+ genValueProperty(prop, obj);
+ }
+ if (seenDefer) {
QmlInstruction defer;
defer.type = QmlInstruction::Defer;
defer.line = 0;
@@ -701,130 +809,221 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt)
int deferIdx = output->bytecode.count();
output->bytecode << defer;
- // ### This is lame, we should check if individual properties have
- // ids defined within them
- int idCount = compileState.ids.count();
- foreach (Property *prop, deferredProps) {
- COMPILE_CHECK(compileProperty(prop, obj, objCtxt));
+ foreach(Property *prop, obj->valueProperties) {
+ if (!prop->isDeferred)
+ continue;
+ genValueProperty(prop, obj);
}
- if (idCount == compileState.ids.count())
- output->bytecode[deferIdx].defer.deferCount =
- output->bytecode.count() - deferIdx - 1;
+
+ output->bytecode[deferIdx].defer.deferCount =
+ output->bytecode.count() - deferIdx - 1;
}
- // If the type support the QmlParserStatusInterface we need to invoke
- // classComplete()
- if (parserStatusCast != -1) {
- QmlInstruction complete;
- complete.type = QmlInstruction::CompleteObject;
- complete.complete.castValue = parserStatusCast;
- complete.line = obj->location.start.line;
- output->bytecode << complete;
- }
+ foreach(Property *prop, obj->signalProperties) {
- return true;
+ QmlParser::Value *v = prop->values.at(0);
+
+ if (v->type == Value::SignalObject) {
+
+ genObject(v->object);
+
+ QmlInstruction assign;
+ assign.type = QmlInstruction::AssignSignalObject;
+ assign.line = v->location.start.line;
+ assign.assignSignalObject.signal =
+ output->indexForByteArray(prop->name);
+ output->bytecode << assign;
+
+ } else if (v->type == Value::SignalExpression) {
+
+ QmlInstruction store;
+ store.type = QmlInstruction::StoreSignal;
+ store.line = v->location.start.line;
+ store.storeSignal.signalIndex = prop->index;
+ store.storeSignal.value =
+ output->indexForString(v->value.asScript().trimmed());
+ output->bytecode << store;
+
+ }
+
+ }
+
+ foreach(Property *prop, obj->attachedProperties) {
+ QmlInstruction fetch;
+ fetch.type = QmlInstruction::FetchAttached;
+ fetch.line = prop->location.start.line;
+ fetch.fetchAttached.id = prop->index;
+ output->bytecode << fetch;
+
+ genObjectBody(prop->value);
+
+ QmlInstruction pop;
+ pop.type = QmlInstruction::PopFetchedObject;
+ pop.line = prop->location.start.line;
+ output->bytecode << pop;
+ }
+
+ foreach(Property *prop, obj->groupedProperties) {
+ QmlInstruction fetch;
+ fetch.type = QmlInstruction::FetchObject;
+ fetch.fetch.property = prop->index;
+ fetch.line = prop->location.start.line;
+ output->bytecode << fetch;
+
+ genObjectBody(prop->value);
+
+ QmlInstruction pop;
+ pop.type = QmlInstruction::PopFetchedObject;
+ pop.line = prop->location.start.line;
+ output->bytecode << pop;
+ }
}
-bool QmlCompiler::compileComponent(Object *obj, const BindingContext &ctxt)
+void QmlCompiler::genComponent(QmlParser::Object *obj)
{
+ QmlParser::Object *root = obj->defaultProperty->values.at(0)->object;
+ Q_ASSERT(root);
+
+ QmlInstruction create;
+ create.type = QmlInstruction::CreateComponent;
+ create.line = root->location.start.line;
+ create.createComponent.endLine = root->location.end.line;
+ output->bytecode << create;
+ int count = output->bytecode.count();
+
+ ComponentCompileState oldCompileState = compileState;
+ compileState = componentState(root);
+
+ QmlInstruction init;
+ init.type = QmlInstruction::Init;
+ init.init.bindingsSize = compileState.bindings.count();
+ init.init.parserStatusSize = compileState.parserStatusCount;
+ init.line = obj->location.start.line;
+ output->bytecode << init;
+
+ genObject(root);
+
+ QmlInstruction def;
+ init.line = 0;
+ def.type = QmlInstruction::SetDefault;
+ output->bytecode << def;
+
+ output->bytecode[count - 1].createComponent.count =
+ output->bytecode.count() - count;
+
+ compileState = oldCompileState;
+
+ if (!obj->id.isEmpty()) {
+ QmlInstruction id;
+ id.type = QmlInstruction::SetId;
+ id.line = -1;
+ id.setId.value = output->indexForString(obj->id);;
+ output->bytecode << id;
+ }
+}
+
+bool QmlCompiler::buildComponent(QmlParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ // The special "Component" element can only have the id property and a
+ // default property, that actually defines the component's tree
+
+ // Find, check and set the "id" property (if any)
Property *idProp = 0;
if (obj->properties.count() > 1 ||
(obj->properties.count() == 1 && obj->properties.begin().key() != "id"))
- COMPILE_EXCEPTION("Invalid component specification");
+ COMPILE_EXCEPTION(obj, "Invalid component specification");
+
+ if (obj->properties.count())
+ idProp = *obj->properties.begin();
+ if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
+ COMPILE_EXCEPTION(obj, "Invalid component id specification");
+
+ if (idProp) {
+ QString idVal = idProp->values.first()->primitive().toUtf8();
+
+ if (compileState.ids.contains(idVal))
+ COMPILE_EXCEPTION(obj, "id is not unique");
+
+ obj->id = idVal;
+ addId(idVal, obj);
+ }
+
+ // Check the Component tree is well formed
if (obj->defaultProperty &&
(obj->defaultProperty->value || obj->defaultProperty->values.count() > 1 ||
(obj->defaultProperty->values.count() == 1 && !obj->defaultProperty->values.first()->object)))
- COMPILE_EXCEPTION("Invalid component body specification");
- if (obj->properties.count())
- idProp = *obj->properties.begin();
- if (idProp && (idProp->value || idProp->values.count() > 1))
- COMPILE_EXCEPTION("Invalid component id specification");
+ COMPILE_EXCEPTION(obj, "Invalid component body specification");
Object *root = 0;
if (obj->defaultProperty && obj->defaultProperty->values.count())
root = obj->defaultProperty->values.first()->object;
if (!root)
- COMPILE_EXCEPTION("Cannot create empty component specification");
+ COMPILE_EXCEPTION(obj, "Cannot create empty component specification");
- COMPILE_CHECK(compileComponentFromRoot(root, ctxt));
-
- if (idProp && idProp->values.count()) {
- QString val = idProp->values.at(0)->primitive();
- if (!isValidId(val))
- COMPILE_EXCEPTION("Invalid id property value");
-
- if (compileState.ids.contains(val))
- COMPILE_EXCEPTION("id is not unique");
-
- IdReference reference;
- reference.id = val;
- reference.object = obj;
- reference.instructionIdx = output->bytecode.count();
- reference.idx = compileState.ids.count();
- compileState.ids.insert(val, reference);
-
- int pref = output->indexForString(val);
- QmlInstruction id;
- id.type = QmlInstruction::SetId;
- id.line = idProp->location.start.line;
- id.setId.value = pref;
- id.setId.save = -1;
-
- output->bytecode << id;
- }
+ // Build the component tree
+ COMPILE_CHECK(buildComponentFromRoot(root, ctxt));
return true;
}
-bool QmlCompiler::compileComponentFromRoot(Object *obj, const BindingContext &ctxt)
+bool QmlCompiler::buildComponentFromRoot(QmlParser::Object *obj,
+ const BindingContext &ctxt)
{
- output->bytecode.push_back(QmlInstruction());
- QmlInstruction &create = output->bytecode.last();
- create.type = QmlInstruction::CreateComponent;
- create.line = obj->location.start.line;
- create.createComponent.endLine = obj->location.end.line;
- int count = output->bytecode.count();
-
- QmlInstruction init;
- init.type = QmlInstruction::Init;
- init.init.dataSize = 0;
- init.init.bindingsSize = 0;
- init.init.parserStatusSize = 0;
- init.line = obj->location.start.line;
- output->bytecode << init;
-
ComponentCompileState oldComponentCompileState = compileState;
compileState = ComponentCompileState();
compileState.root = obj;
+
if (obj)
- COMPILE_CHECK(compileObject(obj, ctxt));
+ COMPILE_CHECK(buildObject(obj, ctxt));
+
+ COMPILE_CHECK(completeComponentBuild());
- COMPILE_CHECK(finalizeComponent(count));
- create.createComponent.count = output->bytecode.count() - count;
compileState = oldComponentCompileState;
+
return true;
}
-bool QmlCompiler::compileFetchedObject(Object *obj, const BindingContext &ctxt)
+
+// Build a sub-object. A sub-object is one that was not created directly by
+// QML - such as a grouped property object, or an attached object. Sub-object's
+// can't have an id, involve a custom parser, have attached properties etc.
+bool QmlCompiler::buildSubObject(Object *obj, const BindingContext &ctxt)
{
Q_ASSERT(obj->metatype);
+ Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding
+ // sub-context
if (obj->defaultProperty)
- COMPILE_CHECK(compileProperty(obj->defaultProperty, obj, ctxt));
+ COMPILE_CHECK(buildProperty(obj->defaultProperty, obj, ctxt));
foreach(Property *prop, obj->properties) {
if (isSignalPropertyName(prop->name)) {
- COMPILE_CHECK(compileSignal(prop, obj));
+ COMPILE_CHECK(buildSignal(prop, obj, ctxt));
} else {
- COMPILE_CHECK(compileProperty(prop, obj, ctxt));
+ COMPILE_CHECK(buildProperty(prop, obj, ctxt));
}
}
return true;
}
-int QmlCompiler::signalByName(const QMetaObject *mo, const QByteArray &name)
+int QmlCompiler::componentTypeRef()
+{
+ QmlType *t = QmlMetaType::qmlType("Component");
+ for (int ii = output->types.count() - 1; ii >= 0; --ii) {
+ if (output->types.at(ii).type == t)
+ return ii;
+ }
+ QmlCompiledData::TypeReference ref;
+ ref.className = "Component";
+ ref.type = t;
+ output->types << ref;
+ return output->types.count() - 1;
+}
+
+int QmlCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name)
{
int methods = mo->methodCount();
for (int ii = methods - 1; ii >= 0; --ii) {
@@ -839,15 +1038,13 @@ int QmlCompiler::signalByName(const QMetaObject *mo, const QByteArray &name)
return -1;
}
-bool QmlCompiler::compileSignal(Property *prop, Object *obj)
+bool QmlCompiler::buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
+ const BindingContext &ctxt)
{
Q_ASSERT(obj->metaObject());
- if (prop->values.isEmpty() && !prop->value)
- return true;
-
- if (prop->value || prop->values.count() > 1)
- COMPILE_EXCEPTION("Incorrectly specified signal");
+ if (prop->isEmpty())
+ COMPILE_EXCEPTION(prop, "Empty property assignment");
QByteArray name = prop->name;
Q_ASSERT(name.startsWith("on"));
@@ -855,47 +1052,26 @@ bool QmlCompiler::compileSignal(Property *prop, Object *obj)
if(name[0] >= 'A' && name[0] <= 'Z')
name[0] = name[0] - 'A' + 'a';
- int sigIdx = signalByName(obj->metaObject(), name);
+ int sigIdx = findSignalByName(obj->metaObject(), name);
if (sigIdx == -1) {
- COMPILE_CHECK(compileProperty(prop, obj, 0));
+ // If the "on<Signal>" name doesn't resolve into a signal, try it as a
+ // property.
+ COMPILE_CHECK(buildProperty(prop, obj, ctxt));
} else {
- if (prop->values.at(0)->object) {
- int pr = output->indexForByteArray(prop->name);
-
- bool rv = compileObject(prop->values.at(0)->object, 0);
-
- if (rv) {
- QmlInstruction assign;
- assign.type = QmlInstruction::AssignSignalObject;
- assign.line = prop->values.at(0)->location.start.line;
- assign.assignSignalObject.signal = pr;
-
- output->bytecode << assign;
-
- prop->values.at(0)->type = Value::SignalObject;
- }
+ if (prop->value || prop->values.count() > 1)
+ COMPILE_EXCEPTION(prop, "Incorrectly specified signal");
- return rv;
+ prop->index = sigIdx;
+ obj->addSignalProperty(prop);
+ if (prop->values.at(0)->object) {
+ COMPILE_CHECK(buildObject(prop->values.at(0)->object, ctxt));
+ prop->values.at(0)->type = Value::SignalObject;
} else {
- QString script = prop->values.at(0)->value.asScript().trimmed();
- if (script.isEmpty())
- return true;
-
- int idx = output->indexForString(script);
-
- QmlInstruction store;
- store.line = prop->values.at(0)->location.start.line;
- store.type = QmlInstruction::StoreSignal;
- store.storeSignal.signalIndex = sigIdx;
- store.storeSignal.value = idx;
-
- output->bytecode << store;
-
prop->values.at(0)->type = Value::SignalExpression;
}
}
@@ -903,9 +1079,12 @@ bool QmlCompiler::compileSignal(Property *prop, Object *obj)
return true;
}
-// Returns true if prop exists on obj, false otherwise
-bool QmlCompiler::testProperty(QmlParser::Property *prop,
- QmlParser::Object *obj)
+
+/*!
+ Returns true if (value) property \a prop exists on obj, false otherwise.
+*/
+bool QmlCompiler::doesPropertyExist(QmlParser::Property *prop,
+ QmlParser::Object *obj)
{
if(isAttachedPropertyName(prop->name) || prop->name == "id")
return true;
@@ -924,23 +1103,33 @@ bool QmlCompiler::testProperty(QmlParser::Property *prop,
return false;
}
-bool QmlCompiler::compileProperty(Property *prop, Object *obj, const BindingContext &ctxt)
+bool QmlCompiler::buildProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt)
{
- if (prop->values.isEmpty() && !prop->value)
- COMPILE_EXCEPTION2(prop, "Empty property assignment");
+ if (prop->isEmpty())
+ COMPILE_EXCEPTION(prop, "Empty property assignment");
const QMetaObject *metaObject = obj->metaObject();
Q_ASSERT(metaObject);
if (isAttachedPropertyName(prop->name)) {
// Setup attached property data
+
+ if (ctxt.isSubContext()) {
+ // Attached properties cannot be used on sub-objects. Sub-objects
+ // always exist in a binding sub-context, which is what we test
+ // for here.
+ COMPILE_EXCEPTION(prop, "Attached properties cannot be used here");
+ }
+
QmlType *type = QmlMetaType::qmlType(prop->name);
if (!type || !type->attachedPropertiesType())
- COMPILE_EXCEPTION2(prop, "Non-existant attached object");
+ COMPILE_EXCEPTION(prop, "Non-existant attached object");
if (!prop->value)
- COMPILE_EXCEPTION2(prop, "Cannot assign directly to attached object");
+ COMPILE_EXCEPTION(prop, "Invalid attached object assignment");
prop->value->metatype = type->attachedPropertiesType();
} else {
@@ -976,125 +1165,256 @@ bool QmlCompiler::compileProperty(Property *prop, Object *obj, const BindingCont
}
}
- if (!prop->isDefault && prop->name == "id") {
+ if (!prop->isDefault && prop->name == "id" && !ctxt.isSubContext()) {
- COMPILE_CHECK(compileIdProperty(prop, obj));
+ // The magic "id" behaviour doesn't apply when "id" is resolved as a
+ // default property or to sub-objects (which are always in binding
+ // sub-contexts)
+ COMPILE_CHECK(buildIdProperty(prop, obj));
+ if (prop->type == QVariant::String &&
+ prop->values.at(0)->value.isString())
+ COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
} else if (isAttachedPropertyName(prop->name)) {
- COMPILE_CHECK(compileAttachedProperty(prop, ctxt));
+ COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt));
} else if (prop->index == -1) {
if (prop->isDefault) {
- COMPILE_EXCEPTION2(prop, "Cannot assign to non-existant default property");
+ COMPILE_EXCEPTION(prop->values.first(), "Cannot assign to non-existant default property");
} else {
- COMPILE_EXCEPTION2(prop, "Cannot assign to non-existant property" << prop->name);
+ COMPILE_EXCEPTION(prop, "Cannot assign to non-existant property" << prop->name);
}
} else if (prop->value) {
- COMPILE_CHECK(compileNestedProperty(prop, ctxt));
+ COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt));
} else if (QmlMetaType::isQmlList(prop->type) ||
QmlMetaType::isList(prop->type)) {
- COMPILE_CHECK(compileListProperty(prop, obj, ctxt));
+ COMPILE_CHECK(buildListProperty(prop, obj, ctxt));
} else {
- COMPILE_CHECK(compilePropertyAssignment(prop, obj, ctxt));
+ COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
}
return true;
}
-bool QmlCompiler::compileIdProperty(QmlParser::Property *prop,
- QmlParser::Object *obj)
+void QmlCompiler::genValueProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj)
+{
+ if (QmlMetaType::isQmlList(prop->type) || QmlMetaType::isList(prop->type)) {
+ genListProperty(prop, obj);
+ } else {
+ genPropertyAssignment(prop, obj);
+ }
+}
+
+void QmlCompiler::genListProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj)
{
- if (prop->value)
- COMPILE_EXCEPTION2(prop,"The id property cannot be fetched");
- if (prop->values.count() > 1)
- COMPILE_EXCEPTION2(prop, "The object id may only be set once");
+ QmlInstruction::Type fetchType;
+ QmlInstruction::Type storeType;
+ int listType;
+
+ if (QmlMetaType::isQmlList(prop->type)) {
+ fetchType = QmlInstruction::FetchQmlList;
+ storeType = QmlInstruction::StoreObjectQmlList;
+ listType = QmlMetaType::qmlListType(prop->type);
+ } else {
+ fetchType = QmlInstruction::FetchQList;
+ storeType = QmlInstruction::StoreObjectQList;
+ listType = QmlMetaType::listType(prop->type);
+ }
+
+ QmlInstruction fetch;
+ fetch.type = fetchType;
+ fetch.line = prop->location.start.line;
+ fetch.fetchQmlList.property = prop->index;
+ bool listTypeIsInterface = QmlMetaType::isInterface(listType);
+ fetch.fetchQmlList.type = listType;
+ output->bytecode << fetch;
+
+ for (int ii = 0; ii < prop->values.count(); ++ii) {
+ Value *v = prop->values.at(ii);
+
+ if (v->type == Value::CreatedObject) {
+
+ genObject(v->object);
+ if (listTypeIsInterface) {
+ QmlInstruction assign;
+ assign.type = QmlInstruction::AssignObjectList;
+ assign.line = prop->location.start.line;
+ output->bytecode << assign;
+ } else {
+ QmlInstruction store;
+ store.type = storeType;
+ store.line = prop->location.start.line;
+ output->bytecode << store;
+ }
+
+ } else if (v->type == Value::PropertyBinding) {
+
+ genBindingAssignment(v, prop, obj);
+
+ }
+
+ }
+
+ QmlInstruction pop;
+ pop.type = QmlInstruction::PopQList;
+ pop.line = prop->location.start.line;
+ output->bytecode << pop;
+}
+
+void QmlCompiler::genPropertyAssignment(QmlParser::Property *prop,
+ QmlParser::Object *obj)
+{
+ for (int ii = 0; ii < prop->values.count(); ++ii) {
+ QmlParser::Value *v = prop->values.at(ii);
+
+ if (v->type == Value::CreatedObject) {
+
+ genObject(v->object);
+
+ if (QmlMetaType::isInterface(prop->type)) {
+
+ QmlInstruction store;
+ store.type = QmlInstruction::StoreInterface;
+ store.line = v->object->location.start.line;
+ store.storeObject.propertyIndex = prop->index;
+ output->bytecode << store;
+
+ } else if (prop->type == -1) {
+
+ QmlInstruction store;
+ store.type = QmlInstruction::StoreVariantObject;
+ store.line = v->object->location.start.line;
+ store.storeObject.propertyIndex = prop->index;
+ output->bytecode << store;
+
+ } else {
+
+ QmlInstruction store;
+ store.type = QmlInstruction::StoreObject;
+ store.line = v->object->location.start.line;
+ store.storeObject.propertyIndex = prop->index;
+ output->bytecode << store;
+
+ }
+ } else if (v->type == Value::ValueSource) {
+
+ genObject(v->object);
+
+ QmlInstruction store;
+ store.type = QmlInstruction::StoreValueSource;
+ store.line = v->object->location.start.line;
+ store.assignValueSource.property = prop->index;
+ output->bytecode << store;
+
+ } else if (v->type == Value::PropertyBinding) {
+
+ genBindingAssignment(v, prop, obj);
+
+ } else if (v->type == Value::Literal) {
+
+ QMetaProperty mp = obj->metaObject()->property(prop->index);
+ genLiteralAssignment(mp, v);
+
+ }
+
+ }
+}
+
+bool QmlCompiler::buildIdProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj)
+{
+ if (prop->value ||
+ prop->values.count() > 1 ||
+ prop->values.at(0)->object)
+ COMPILE_EXCEPTION(prop, "Invalid use of id property");
- if (prop->values.at(0)->object)
- COMPILE_EXCEPTION("Cannot assign an object as an id");
QString val = prop->values.at(0)->primitive();
+
if (!isValidId(val))
- COMPILE_EXCEPTION(val << "is not a valid id");
+ COMPILE_EXCEPTION(prop, val << "is not a valid object id");
+
if (compileState.ids.contains(val))
- COMPILE_EXCEPTION("id is not unique");
+ COMPILE_EXCEPTION(prop, "id is not unique");
- int pref = output->indexForString(val);
+ prop->values.at(0)->type = Value::Id;
- if (prop->type == QVariant::String) {
- QmlInstruction assign;
- assign.type = QmlInstruction::StoreString;
- assign.storeString.propertyIndex = prop->index;
- assign.storeString.value = pref;
- assign.line = prop->values.at(0)->location.start.line;
- output->bytecode << assign;
+ obj->id = val;
+ addId(val, obj);
- prop->values.at(0)->type = Value::Id;
- } else {
- prop->values.at(0)->type = Value::Literal;
- }
+ return true;
+}
- IdReference reference;
- reference.id = val;
- reference.object = obj;
- reference.instructionIdx = output->bytecode.count();
- reference.idx = compileState.ids.count();
- compileState.ids.insert(val, reference);
+void QmlCompiler::addId(const QString &id, QmlParser::Object *obj)
+{
+ Q_ASSERT(!compileState.ids.contains(id));
+ Q_ASSERT(obj->id == id);
+ obj->idIndex = compileState.ids.count();
+ compileState.ids.insert(id, obj);
+}
+
+void QmlCompiler::addBindingReference(const BindingReference &ref)
+{
+ Q_ASSERT(ref.value && !compileState.bindings.contains(ref.value));
+ compileState.bindings.insert(ref.value, ref);
+}
- QmlInstruction id;
- id.type = QmlInstruction::SetId;
- id.line = prop->values.at(0)->location.start.line;
- id.setId.value = pref;
- id.setId.save = -1;
- output->bytecode << id;
+void QmlCompiler::saveComponentState()
+{
+ Q_ASSERT(compileState.root);
+ Q_ASSERT(!savedCompileStates.contains(compileState.root));
- obj->id = val.toLatin1();
+ savedCompileStates.insert(compileState.root, compileState);
+}
- return true;
+QmlCompiler::ComponentCompileState
+QmlCompiler::componentState(QmlParser::Object *obj)
+{
+ Q_ASSERT(savedCompileStates.contains(obj));
+ return savedCompileStates.value(obj);
}
-// Compile attached property object. In this example,
+// Build attached property object. In this example,
// Text {
// GridView.row: 10
// }
// GridView is an attached property object.
-bool QmlCompiler::compileAttachedProperty(QmlParser::Property *prop,
- const BindingContext &ctxt)
+bool QmlCompiler::buildAttachedProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->value);
int id = QmlMetaType::attachedPropertiesFuncId(prop->name);
Q_ASSERT(id != -1); // This is checked in compileProperty()
- QmlInstruction fetch;
- fetch.type = QmlInstruction::FetchAttached;
- fetch.line = prop->location.start.line;
- fetch.fetchAttached.id = id;
- output->bytecode << fetch;
-
- COMPILE_CHECK(compileFetchedObject(prop->value, ctxt.incr()));
+ prop->index = id;
+ obj->addAttachedProperty(prop);
- QmlInstruction pop;
- pop.type = QmlInstruction::PopFetchedObject;
- pop.line = prop->location.start.line;
- output->bytecode << pop;
+ COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
return true;
}
-// Compile "nested" properties. In this example:
+
+// Build "grouped" properties. In this example:
// Text {
// font.size: 12
+// font.family: "Helvetica"
// }
-// font is a nested property. size is not.
-bool QmlCompiler::compileNestedProperty(QmlParser::Property *prop,
- const BindingContext &ctxt)
+// font is a nested property. size and family are not.
+bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->type != 0);
Q_ASSERT(prop->index != -1);
@@ -1102,134 +1422,92 @@ bool QmlCompiler::compileNestedProperty(QmlParser::Property *prop,
// Load the nested property's meta type
prop->value->metatype = QmlMetaType::metaObjectForType(prop->type);
if (!prop->value->metatype)
- COMPILE_EXCEPTION2(prop, "Cannot nest non-QObject property" << prop->name);
+ COMPILE_EXCEPTION(prop, "Cannot nest non-QObject property" << prop->name);
- QmlInstruction fetch;
- fetch.type = QmlInstruction::FetchObject;
- fetch.fetch.property = prop->index;
- fetch.fetch.isObject = true;
- fetch.line = prop->location.start.line;
- output->bytecode << fetch;
+ obj->addGroupedProperty(prop);
- COMPILE_CHECK(compileFetchedObject(prop->value, ctxt.incr()));
-
- QmlInstruction pop;
- pop.type = QmlInstruction::PopFetchedObject;
- pop.line = prop->location.start.line;
- output->bytecode << pop;
+ COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
return true;
}
-// Compile assignments to QML lists. QML lists are properties of type
+
+// Build assignments to QML lists. QML lists are properties of type
// QList<T *> * and QmlList<T *> *.
//
// QList<T *> * types can accept a list of objects, or a single binding
// QmlList<T *> * types can accept a list of objects
-bool QmlCompiler::compileListProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
+bool QmlCompiler::buildListProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt)
{
Q_ASSERT(QmlMetaType::isList(prop->type) ||
QmlMetaType::isQmlList(prop->type));
int t = prop->type;
+ obj->addValueProperty(prop);
+
if (QmlMetaType::isQmlList(t)) {
- QmlInstruction fetch;
- fetch.line = prop->location.start.line;
- fetch.type = QmlInstruction::FetchQmlList;
- fetch.fetchQmlList.property = prop->index;
int listType = QmlMetaType::qmlListType(t);
bool listTypeIsInterface = QmlMetaType::isInterface(listType);
- fetch.fetchQmlList.type = listType;
- output->bytecode << fetch;
for (int ii = 0; ii < prop->values.count(); ++ii) {
Value *v = prop->values.at(ii);
if (v->object) {
v->type = Value::CreatedObject;
- COMPILE_CHECK(compileObject(v->object, ctxt));
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+ // We check object coercian here. We check interface assignment
+ // at runtime.
if (!listTypeIsInterface) {
- if (canConvert(listType, v->object)) {
- QmlInstruction store;
- store.type = QmlInstruction::StoreObjectQmlList;
- store.line = prop->location.start.line;
- output->bytecode << store;
- } else {
- COMPILE_EXCEPTION("Cannot assign object to list");
+ if (!canCoerce(listType, v->object)) {
+ COMPILE_EXCEPTION(v, "Cannot assign object to list");
}
-
- } else {
- QmlInstruction assign;
- assign.type = QmlInstruction::AssignObjectList;
- assign.line = prop->location.start.line;
- output->bytecode << assign;
}
+
} else {
- COMPILE_EXCEPTION("Cannot assign primitives to lists");
+ COMPILE_EXCEPTION(v, "Cannot assign primitives to lists");
}
}
- QmlInstruction pop;
- pop.type = QmlInstruction::PopQList;
- pop.line = prop->location.start.line;
- output->bytecode << pop;
} else {
- QmlInstruction fetch;
- fetch.type = QmlInstruction::FetchQList;
- fetch.line = prop->location.start.line;
- fetch.fetchQmlList.property = prop->index;
int listType = QmlMetaType::listType(t);
bool listTypeIsInterface = QmlMetaType::isInterface(listType);
- fetch.fetchQmlList.type = listType;
- output->bytecode << fetch;
bool assignedBinding = false;
for (int ii = 0; ii < prop->values.count(); ++ii) {
Value *v = prop->values.at(ii);
if (v->object) {
v->type = Value::CreatedObject;
- COMPILE_CHECK(compileObject(v->object, ctxt));
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+ // We check object coercian here. We check interface assignment
+ // at runtime.
if (!listTypeIsInterface) {
- if (canConvert(listType, v->object)) {
- QmlInstruction store;
- store.type = QmlInstruction::StoreObjectQList;
- store.line = prop->location.start.line;
- output->bytecode << store;
- } else {
- COMPILE_EXCEPTION("Cannot assign object to list");
+ if (!canCoerce(listType, v->object)) {
+ COMPILE_EXCEPTION(v, "Cannot assign object to list");
}
- } else {
- QmlInstruction assign;
- assign.type = QmlInstruction::AssignObjectList;
- assign.line = v->location.start.line;
- output->bytecode << assign;
- }
+ }
+
} else if (v->value.isScript()) {
if (assignedBinding)
- COMPILE_EXCEPTION("Can only assign one binding to lists");
+ COMPILE_EXCEPTION(v, "Can only assign one binding to lists");
assignedBinding = true;
- COMPILE_CHECK(compileBinding(v, prop, ctxt));
+ COMPILE_CHECK(buildBinding(v, prop, ctxt));
v->type = Value::PropertyBinding;
} else {
- COMPILE_EXCEPTION("Cannot assign primitives to lists");
+ COMPILE_EXCEPTION(v, "Cannot assign primitives to lists");
}
}
- QmlInstruction pop;
- pop.line = prop->location.start.line;
- pop.type = QmlInstruction::PopQList;
- output->bytecode << pop;
}
return true;
}
-// Compile regular property assignments of the form property: <value>
+// Compile regular property assignments of the form "property: <value>"
//
// ### The following problems exist
//
@@ -1244,19 +1522,21 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop,
// }
//
// We allow assignming multiple values to single value properties
-bool QmlCompiler::compilePropertyAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt)
+bool QmlCompiler::buildPropertyAssignment(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt)
{
+ obj->addValueProperty(prop);
+
for (int ii = 0; ii < prop->values.count(); ++ii) {
Value *v = prop->values.at(ii);
if (v->object) {
- COMPILE_CHECK(compilePropertyObjectAssignment(prop, v, ctxt));
+ COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
} else {
- COMPILE_CHECK(compilePropertyLiteralAssignment(prop, obj, v, ctxt));
+ COMPILE_CHECK(buildPropertyLiteralAssignment(prop, obj, v, ctxt));
}
}
@@ -1265,9 +1545,10 @@ bool QmlCompiler::compilePropertyAssignment(QmlParser::Property *prop,
}
// Compile assigning a single object instance to a regular property
-bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop,
- QmlParser::Value *v,
- const BindingContext &ctxt)
+bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ QmlParser::Value *v,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->index != -1);
Q_ASSERT(v->object->type != -1);
@@ -1275,30 +1556,18 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop,
if (QmlMetaType::isInterface(prop->type)) {
// Assigning an object to an interface ptr property
- COMPILE_CHECK(compileObject(v->object, ctxt));
-
- QmlInstruction assign;
- assign.type = QmlInstruction::StoreInterface;
- assign.line = v->object->location.start.line;
- assign.storeObject.propertyIndex = prop->index;
- output->bytecode << assign;
+ COMPILE_CHECK(buildObject(v->object, ctxt));
v->type = Value::CreatedObject;
} else if (prop->type == -1) {
// Assigning an object to a QVariant
- COMPILE_CHECK(compileObject(v->object, ctxt));
-
- QmlInstruction assign;
- assign.type = QmlInstruction::StoreVariantObject;
- assign.line = v->object->location.start.line;
- assign.storeObject.propertyIndex = prop->index;
- output->bytecode << assign;
+ COMPILE_CHECK(buildObject(v->object, ctxt));
v->type = Value::CreatedObject;
} else {
- // Normally compileObject() will set this up, but we need the static
+ // Normally buildObject() will set this up, but we need the static
// meta object earlier to test for assignability. It doesn't matter
// that there may still be outstanding synthesized meta object changes
// on this type, as they are not relevant for assignability testing
@@ -1333,39 +1602,29 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop,
if (isAssignable) {
// Simple assignment
- COMPILE_CHECK(compileObject(v->object, ctxt));
-
- QmlInstruction assign;
- assign.type = QmlInstruction::StoreObject;
- assign.line = v->object->location.start.line;
- assign.storeObject.propertyIndex = prop->index;
- output->bytecode << assign;
+ COMPILE_CHECK(buildObject(v->object, ctxt));
v->type = Value::CreatedObject;
} else if (propertyMetaObject == &QmlComponent::staticMetaObject) {
// Automatic "Component" insertion
- COMPILE_CHECK(compileComponentFromRoot(v->object, ctxt));
-
- QmlInstruction assign;
- assign.type = QmlInstruction::StoreObject;
- assign.line = v->object->location.start.line;
- assign.storeObject.propertyIndex = prop->index;
- output->bytecode << assign;
-
- v->type = Value::Component;
+ QmlParser::Object *root = v->object;
+ QmlParser::Object *component = new QmlParser::Object;
+ component->type = componentTypeRef();
+ component->typeName = "Component";
+ component->metatype = &QmlComponent::staticMetaObject;
+ component->location = root->location;
+ QmlParser::Value *componentValue = new QmlParser::Value;
+ componentValue->object = root;
+ component->getDefaultProperty()->addValue(componentValue);
+ v->object = component;
+ COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
} else if (isPropertyValue) {
// Assign as a property value source
- COMPILE_CHECK(compileObject(v->object, ctxt));
-
- QmlInstruction assign;
- assign.type = QmlInstruction::StoreValueSource;
- assign.line = v->object->location.start.line;
- assign.assignValueSource.property = prop->index;
- output->bytecode << assign;
+ COMPILE_CHECK(buildObject(v->object, ctxt));
v->type = Value::ValueSource;
} else {
- COMPILE_EXCEPTION2(v->object, "Unassignable object");
+ COMPILE_EXCEPTION(v->object, "Cannot assign object to property");
}
}
@@ -1373,25 +1632,22 @@ bool QmlCompiler::compilePropertyObjectAssignment(QmlParser::Property *prop,
}
// Compile assigning a literal or binding to a regular property
-bool QmlCompiler::compilePropertyLiteralAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Value *v,
- const BindingContext &ctxt)
+bool QmlCompiler::buildPropertyLiteralAssignment(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ QmlParser::Value *v,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->index != -1);
if (v->value.isScript()) {
- COMPILE_CHECK(compileBinding(v, prop, ctxt));
+ COMPILE_CHECK(buildBinding(v, prop, ctxt));
v->type = Value::PropertyBinding;
} else {
- QmlInstruction assign;
- assign.line = v->location.start.line;
- COMPILE_CHECK(compileStoreInstruction(assign, obj->metaObject()->property(prop->index), v));
- output->bytecode << assign;
+ COMPILE_CHECK(testLiteralAssignment(obj->metaObject()->property(prop->index), v));
v->type = Value::Literal;
}
@@ -1399,31 +1655,107 @@ bool QmlCompiler::compilePropertyLiteralAssignment(QmlParser::Property *prop,
return true;
}
-bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj, int preAlias)
+// Ensures that the dynamic meta specification on obj is valid
+bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj)
+{
+ QSet<QByteArray> propNames;
+ QSet<QByteArray> methodNames;
+ bool seenDefaultProperty = false;
+
+ // Check properties
+ for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
+ const QmlParser::Object::DynamicProperty &prop =
+ obj->dynamicProperties.at(ii);
+
+ if (prop.isDefaultProperty) {
+ if (seenDefaultProperty)
+ COMPILE_EXCEPTION(obj, "Duplicate default property");
+ seenDefaultProperty = true;
+ }
+
+ if (propNames.contains(prop.name))
+ COMPILE_EXCEPTION(obj, "Duplicate property name");
+
+ propNames.insert(prop.name);
+ }
+
+ for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) {
+ QByteArray name = obj->dynamicSignals.at(ii).name;
+ if (methodNames.contains(name))
+ COMPILE_EXCEPTION(obj, "Duplicate signal name");
+ methodNames.insert(name);
+ }
+ for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
+ QByteArray name = obj->dynamicSlots.at(ii).name;
+ if (methodNames.contains(name))
+ COMPILE_EXCEPTION(obj, "Duplicate method name");
+ methodNames.insert(name);
+ }
+
+ return true;
+}
+
+bool QmlCompiler::mergeDynamicMetaProperties(QmlParser::Object *obj)
+{
+ for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
+ const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
+
+ if (!p.defaultValue || p.type == Object::DynamicProperty::Alias)
+ continue;
+
+ Property *property = 0;
+ if (p.isDefaultProperty)
+ property = obj->getDefaultProperty();
+ else
+ property = obj->getProperty(p.name);
+
+ if (property->value)
+ COMPILE_EXCEPTION(property, "Invalid property nesting");
+
+ for (int ii = 0; ii < p.defaultValue->values.count(); ++ii) {
+ Value *v = p.defaultValue->values.at(ii);
+ v->addref();
+ property->values.append(v);
+ }
+ }
+ return true;
+}
+
+bool QmlCompiler::buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode)
{
- // ### FIXME - Check that there is only one default property etc.
if (obj->dynamicProperties.isEmpty() &&
obj->dynamicSignals.isEmpty() &&
obj->dynamicSlots.isEmpty())
return true;
+ COMPILE_CHECK(checkDynamicMeta(obj));
+
QByteArray dynamicData(sizeof(QmlVMEMetaData), (char)0);
QMetaObjectBuilder builder;
if (obj->metatype)
- builder.setClassName(QByteArray(obj->metatype->className()) + "QML");
-
+ 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);
+ int propIdx =
+ obj->metaObject()->indexOfProperty(p.name.constData());
+ if (-1 != propIdx) {
+ QMetaProperty prop = obj->metaObject()->property(propIdx);
+ if (prop.isFinal())
+ COMPILE_EXCEPTION(&p, "Cannot override FINAL property");
+ }
+
if (p.isDefaultProperty &&
- (p.type != Object::DynamicProperty::Alias || preAlias != -1))
+ (p.type != Object::DynamicProperty::Alias ||
+ mode == ResolveAliases))
builder.addClassInfo("DefaultProperty", p.name);
QByteArray type;
- int propertyType;
+ int propertyType = 0;
switch(p.type) {
case Object::DynamicProperty::Alias:
hasAlias = true;
@@ -1471,7 +1803,7 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj, int preAlias)
builder.addProperty(p.name, type, ii);
}
- if (preAlias != -1) {
+ if (mode == ResolveAliases) {
for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
@@ -1495,8 +1827,6 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj, int preAlias)
((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);
QByteArray sig(s.name + "(");
@@ -1509,56 +1839,30 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj, int preAlias)
b.setParameterNames(s.parameterNames);
((QmlVMEMetaData *)dynamicData.data())->methodCount++;
- QmlVMEMetaData::MethodData methodData = { s.parameterNames.count() };
- dynamicData.append((char *)&methodData, sizeof(methodData));
+ QmlVMEMetaData::MethodData methodData =
+ { s.parameterNames.count(), 0, s.body.length(), 0 };
- if (preAlias == -1)
- output->primitives << s.body;
+ dynamicData.append((char *)&methodData, sizeof(methodData));
}
- if (obj->metatype)
- builder.setSuperClass(obj->metatype);
-
- obj->extObjectData = builder.toMetaObject();
- static_cast<QMetaObject &>(obj->extObject) = *obj->extObjectData;
-
- 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->dynamicSlots.count(); ++ii) {
+ const Object::DynamicSlot &s = obj->dynamicSlots.at(ii);
+ QmlVMEMetaData::MethodData *data =
+ ((QmlVMEMetaData *)dynamicData.data())->methodData() + ii;
+
+ data->bodyOffset = dynamicData.size();
+
+ dynamicData.append((const char *)s.body.constData(),
+ (s.body.length() * sizeof(QChar)));
}
- for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) {
- const Object::DynamicProperty &p = obj->dynamicProperties.at(ii);
+ obj->metadata = builder.toRelocatableData();
+ builder.fromRelocatableData(&obj->extObject, obj->metatype, obj->metadata);
- if (p.type == Object::DynamicProperty::Alias)
- continue;
+ if (mode == IgnoreAliases && hasAlias)
+ compileState.aliasingObjects << obj;
- if (p.defaultValue) {
- p.defaultValue->name = p.name;
- p.defaultValue->isDefault = false;
- COMPILE_CHECK(compileProperty(p.defaultValue, obj, 0));
- }
- }
+ obj->synthdata = dynamicData;
return true;
}
@@ -1588,34 +1892,34 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder,
const Object::DynamicProperty &prop)
{
if (!prop.defaultValue)
- COMPILE_EXCEPTION("No property alias location");
+ COMPILE_EXCEPTION(obj, "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");
+ COMPILE_EXCEPTION(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?
+ COMPILE_EXCEPTION(obj, "No property alias location"); // ### Can this happen?
QStringList alias = astNodeToStringList(node);
if (alias.count() != 2)
- COMPILE_EXCEPTION2(prop.defaultValue, "Invalid alias location");
+ COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location");
if (!compileState.ids.contains(alias.at(0)))
- COMPILE_EXCEPTION2(prop.defaultValue, "Invalid alias location");
+ COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location");
- const IdReference &id = compileState.ids[alias.at(0)];
- int propIdx = id.object->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData());
+ Object *idObject = compileState.ids[alias.at(0)];
+ int propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData());
if (-1 == propIdx)
- COMPILE_EXCEPTION2(prop.defaultValue, "Invalid alias location");
+ COMPILE_EXCEPTION(prop.defaultValue, "Invalid alias location");
- QMetaProperty aliasProperty = id.object->metaObject()->property(propIdx);
+ QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx);
- data.append((const char *)&id.idx, sizeof(id.idx));
+ data.append((const char *)&idObject->idIndex, sizeof(idObject->idIndex));
data.append((const char *)&propIdx, sizeof(propIdx));
builder.addSignal(prop.name + "Changed()");
@@ -1623,9 +1927,9 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder,
return true;
}
-bool QmlCompiler::compileBinding(QmlParser::Value *value,
- QmlParser::Property *prop,
- const BindingContext &ctxt)
+bool QmlCompiler::buildBinding(QmlParser::Value *value,
+ QmlParser::Property *prop,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->index);
Q_ASSERT(prop->parent);
@@ -1633,193 +1937,106 @@ bool QmlCompiler::compileBinding(QmlParser::Value *value,
QMetaProperty mp = prop->parent->metaObject()->property(prop->index);
if (!mp.isWritable() && !QmlMetaType::isList(prop->type))
- COMPILE_EXCEPTION2(prop, "Cannot assign binding to read-only property");
+ COMPILE_EXCEPTION(prop, "Invalid property assignment: read-only property");
BindingReference reference;
reference.expression = value->value;
reference.property = prop;
reference.value = value;
- reference.instructionIdx = output->bytecode.count();
reference.bindingContext = ctxt;
- compileState.bindings << reference;
-
- output->bytecode << QmlInstruction();;
+ addBindingReference(reference);
return true;
}
-#if 0
-
-#include <iostream>
-#ifdef Q_CC_GNU
-#include <cxxabi.h>
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// AST Dump
-////////////////////////////////////////////////////////////////////////////////
-class Dump: protected QmlJS::AST::Visitor
-{
- std::ostream &out;
- int depth;
-
-public:
- Dump(std::ostream &out)
- : out(out), depth(-1)
- { }
-
- void operator()(QmlJS::AST::Node *node)
- { QmlJS::AST::Node::acceptChild(node, this); }
-
-protected:
- virtual bool preVisit(QmlJS::AST::Node *node)
- {
- const char *name = typeid(*node).name();
-#ifdef Q_CC_GNU
- name = abi::__cxa_demangle(name, 0, 0, 0) + 17;
-#endif
- std::cout << std::string(++depth, ' ') << name << std::endl;
- return true;
- }
-
- virtual void postVisit(QmlJS::AST::Node *)
- {
- --depth;
- }
-};
-#endif
-
-// Update the init instruction with final data, and optimize some simple
-// bindings
-bool QmlCompiler::finalizeComponent(int patch)
+void QmlCompiler::genBindingAssignment(QmlParser::Value *binding,
+ QmlParser::Property *prop,
+ QmlParser::Object *obj)
{
- for (int ii = 0; ii < compileState.bindings.count(); ++ii) {
- const BindingReference &binding = compileState.bindings.at(ii);
- finalizeBinding(binding);
- }
+ Q_ASSERT(compileState.bindings.contains(binding));
- for (int ii = 0; ii < compileState.aliases.count(); ++ii) {
- const AliasReference &alias = compileState.aliases.at(ii);
- COMPILE_CHECK(finalizeAlias(alias));
+ const BindingReference &ref = compileState.bindings.value(binding);
+
+ QMetaProperty mp = obj->metaObject()->property(prop->index);
+
+ QmlInstruction store;
+ int dataRef;
+ if (ref.compiledData.isEmpty()) {
+ dataRef = output->indexForString(ref.expression.asScript());
+ store.type = QmlInstruction::StoreBinding;
+ } else {
+ dataRef = output->indexForByteArray(ref.compiledData);
+ store.type = QmlInstruction::StoreCompiledBinding;
}
- output->bytecode[patch].init.dataSize = compileState.savedObjects;;
- output->bytecode[patch].init.bindingsSize = compileState.bindings.count();
- output->bytecode[patch].init.parserStatusSize =
- compileState.parserStatusCount;
+ store.assignBinding.property = prop->index;
+ store.assignBinding.value = dataRef;
+ store.assignBinding.category = QmlMetaProperty::propertyCategory(mp);
+ store.assignBinding.context = ref.bindingContext.stack;
- return true;
+ output->bytecode << store;
}
-bool QmlCompiler::finalizeAlias(const AliasReference &alias)
+bool QmlCompiler::completeComponentBuild()
{
- COMPILE_CHECK(compileDynamicMeta(alias.object, alias.instructionIdx));
-}
+ saveComponentState();
+
+ for (int ii = 0; ii < compileState.aliasingObjects.count(); ++ii) {
+ Object *aliasObject = compileState.aliasingObjects.at(ii);
+ COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
+ }
-void QmlCompiler::finalizeBinding(const BindingReference &binding)
-{
- QmlBasicScript bs;
QmlBasicScript::Expression expr;
expr.component = compileState.root;
- expr.context = binding.bindingContext.object;
- expr.property = binding.property;
- expr.expression = binding.expression;
- foreach (const IdReference &id, compileState.ids)
- expr.ids.insert(id.id, qMakePair(id.object, id.idx));
-
- bs.compile(expr);
-
- QmlInstruction &instr = output->bytecode[binding.instructionIdx];
- instr.line = binding.value->location.start.line;
-
- // Single load optimization
- if (bs.isValid() && bs.isSingleLoad()) {
-
- QString singleLoadTarget = QLatin1String(bs.singleLoadTarget());
-
- if (singleLoadTarget.at(0).isUpper() &&
- compileState.ids.contains(singleLoadTarget) &&
- QmlMetaType::isObject(binding.property->type)) {
-
- IdReference reference = compileState.ids[singleLoadTarget];
-
- const QMetaObject *idMo = reference.object->metaObject();
- const QMetaObject *storeMo =
- QmlMetaType::rawMetaObjectForType(binding.property->type);
+ expr.ids = compileState.ids;
- Q_ASSERT(idMo);
- Q_ASSERT(storeMo);
+ for (QHash<QmlParser::Value*,BindingReference>::Iterator iter = compileState.bindings.begin(); iter != compileState.bindings.end(); ++iter) {
+ BindingReference &binding = *iter;
- bool canAssign = false;
- while (!canAssign && idMo) {
- if (idMo == storeMo)
- canAssign = true;
- else
- idMo = idMo->superClass();
- }
-
- if (canAssign) {
- int instructionIdx = reference.instructionIdx;
- if (output->bytecode.at(instructionIdx).setId.save == -1) {
- output->bytecode[instructionIdx].setId.save =
- compileState.savedObjects++;
- }
- int saveId = output->bytecode.at(instructionIdx).setId.save;
-
- instr.type = QmlInstruction::PushProperty;
- instr.pushProperty.property = binding.property->index;
-
- QmlInstruction store;
- store.type = QmlInstruction::StoreStackObject;
- store.line = 0;
- store.assignStackObject.property =
- compileState.pushedProperties++;
- store.assignStackObject.object = saveId;
- output->bytecode << store;
- return;
- }
- }
- }
+ QmlBasicScript bs;
+ expr.context = binding.bindingContext.object;
+ expr.property = binding.property;
+ expr.expression = binding.expression;
- // General binding fallback
- int bref;
- if (bs.isValid()) {
- bref = output->indexForByteArray(QByteArray(bs.compileData(), bs.compileDataSize()));
- } else {
- bref = output->indexForString(binding.expression.asScript());
+ bs.compile(expr);
+ if (bs.isValid())
+ binding.compiledData =
+ QByteArray(bs.compileData(), bs.compileDataSize());
}
- instr.assignBinding.context = binding.bindingContext.stack;
-
- if (bs.isValid())
- instr.type = QmlInstruction::StoreCompiledBinding;
- else
- instr.type = QmlInstruction::StoreBinding;
-
- instr.assignBinding.property = binding.property->index;
- instr.assignBinding.value = bref;
- QMetaProperty mp = binding.property->parent->metaObject()->property(binding.property->index);
- instr.assignBinding.category = QmlMetaProperty::propertyCategory(mp);
+ return true;
}
/*!
- Returns true if object can be assigned to a (QObject) property of type
- convertType.
+ Returns true if from can be assigned to a (QObject) property of type
+ to.
*/
-bool QmlCompiler::canConvert(int convertType, QmlParser::Object *object)
+bool QmlCompiler::canCoerce(int to, QmlParser::Object *from)
{
- const QMetaObject *convertTypeMo =
- QmlMetaType::rawMetaObjectForType(convertType);
- const QMetaObject *objectMo = object->metaObject();
+ const QMetaObject *toMo =
+ QmlMetaType::rawMetaObjectForType(to);
+ const QMetaObject *fromMo = from->metaObject();
- while (objectMo) {
- if (objectMo == convertTypeMo)
+ while (fromMo) {
+ if (fromMo == toMo)
return true;
- objectMo = objectMo->superClass();
+ fromMo = fromMo->superClass();
}
return false;
}
+QmlType *QmlCompiler::toQmlType(QmlParser::Object *from)
+{
+ // ### Optimize
+ const QMetaObject *mo = from->metatype;
+ QmlType *type = 0;
+ while (!type && mo) {
+ type = QmlMetaType::qmlType(mo);
+ mo = mo->superClass();
+ }
+ return type;
+}
+
QStringList QmlCompiler::deferredProperties(QmlParser::Object *obj)
{
const QMetaObject *mo = obj->metatype;
@@ -1833,63 +2050,4 @@ QStringList QmlCompiler::deferredProperties(QmlParser::Object *obj)
return rv;
}
-QmlCompiledData::QmlCompiledData()
-{
-}
-
-QmlCompiledData::QmlCompiledData(const QmlCompiledData &other)
-{
- *this = other;
-}
-
-QmlCompiledData::~QmlCompiledData()
-{
- for (int ii = 0; ii < types.count(); ++ii) {
- if (types.at(ii).ref)
- types.at(ii).ref->release();
- }
-}
-
-QmlCompiledData &QmlCompiledData::operator=(const QmlCompiledData &other)
-{
- types = other.types;
- root = other.root;
- primitives = other.primitives;
- floatData = other.floatData;
- intData = other.intData;
- customTypeData = other.customTypeData;
- datas = other.datas;
- synthesizedMetaObjects = other.synthesizedMetaObjects;
- bytecode = other.bytecode;
- return *this;
-}
-
-QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt) const
-{
- if (type) {
- QObject *rv = type->create();
- if (rv)
- QmlEngine::setContextForObject(rv, ctxt);
- return rv;
- } else {
- Q_ASSERT(component);
- QObject *rv = component->create(ctxt);
- QmlContext *ctxt = qmlContext(rv);
- if(ctxt) {
- static_cast<QmlContextPrivate *>(QObjectPrivate::get(ctxt))->typeName = className;
- }
- return rv;
- }
-}
-
-const QMetaObject *QmlCompiledData::TypeReference::metaObject() const
-{
- if (type) {
- return type->metaObject();
- } else {
- Q_ASSERT(component);
- return &static_cast<QmlComponentPrivate *>(QObjectPrivate::get(component))->cc->root;
- }
-}
-
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h
index 1c45f57..86e6590 100644
--- a/src/declarative/qml/qmlcompiler_p.h
+++ b/src/declarative/qml/qmlcompiler_p.h
@@ -65,15 +65,12 @@ QT_BEGIN_NAMESPACE
class QmlEngine;
class QmlComponent;
-class QmlCompiledComponent;
class QmlContext;
-class QmlCompiledData
+class QmlCompiledData : public QmlRefCount
{
public:
QmlCompiledData();
- QmlCompiledData(const QmlCompiledData &other);
- QmlCompiledData &operator=(const QmlCompiledData &other);
virtual ~QmlCompiledData();
QByteArray name;
@@ -104,12 +101,18 @@ public:
QList<int> intData;
QList<CustomTypeData> customTypeData;
QList<QByteArray> datas;
- QList<QMetaObject *> synthesizedMetaObjects;
QList<QmlParser::Location> locations;
QList<QmlInstruction> bytecode;
+ void dumpInstructions();
private:
+ void dump(QmlInstruction *, int idx = -1);
+ QmlCompiledData(const QmlCompiledData &other);
+ QmlCompiledData &operator=(const QmlCompiledData &other);
+ QByteArray packData;
friend class QmlCompiler;
+ int pack(const char *, size_t);
+
int indexForString(const QString &);
int indexForByteArray(const QByteArray &);
int indexForFloat(float *, int);
@@ -124,7 +127,7 @@ class Q_DECLARATIVE_EXPORT QmlCompiler
public:
QmlCompiler();
- bool compile(QmlEngine *, QmlCompositeTypeData *, QmlCompiledComponent *);
+ bool compile(QmlEngine *, QmlCompositeTypeData *, QmlCompiledData *);
bool isError() const;
QList<QmlError> errors() const;
@@ -134,7 +137,7 @@ public:
static bool isSignalPropertyName(const QByteArray &);
private:
- void reset(QmlCompiledComponent *, bool);
+ static void reset(QmlCompiledData *);
struct BindingContext {
BindingContext()
@@ -146,97 +149,115 @@ private:
rv.stack = stack + 1;
return rv;
}
+ bool isSubContext() const { return stack != 0; }
int stack;
QmlParser::Object *object;
};
void compileTree(QmlParser::Object *tree);
- bool compileObject(QmlParser::Object *obj, const BindingContext &);
- bool compileComponent(QmlParser::Object *obj, const BindingContext &);
- bool compileComponentFromRoot(QmlParser::Object *obj, const BindingContext &);
- bool compileFetchedObject(QmlParser::Object *obj, const BindingContext &);
- bool compileSignal(QmlParser::Property *prop, QmlParser::Object *obj);
- bool testProperty(QmlParser::Property *prop, QmlParser::Object *obj);
- int signalByName(const QMetaObject *, const QByteArray &name);
- bool compileProperty(QmlParser::Property *prop, QmlParser::Object *obj, const BindingContext &);
- bool compileIdProperty(QmlParser::Property *prop,
- QmlParser::Object *obj);
- bool compileAttachedProperty(QmlParser::Property *prop,
- const BindingContext &ctxt);
- bool compileNestedProperty(QmlParser::Property *prop,
+
+
+ bool buildObject(QmlParser::Object *obj, const BindingContext &);
+ bool buildComponent(QmlParser::Object *obj, const BindingContext &);
+ bool buildSubObject(QmlParser::Object *obj, const BindingContext &);
+ bool buildSignal(QmlParser::Property *prop, QmlParser::Object *obj,
+ const BindingContext &);
+ bool buildProperty(QmlParser::Property *prop, QmlParser::Object *obj,
+ const BindingContext &);
+ bool buildIdProperty(QmlParser::Property *prop, QmlParser::Object *obj);
+ bool buildAttachedProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
const BindingContext &ctxt);
- bool compileListProperty(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt);
- bool compilePropertyAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- const BindingContext &ctxt);
- bool compilePropertyObjectAssignment(QmlParser::Property *prop,
- QmlParser::Value *value,
- const BindingContext &ctxt);
- bool compilePropertyLiteralAssignment(QmlParser::Property *prop,
- QmlParser::Object *obj,
- QmlParser::Value *value,
- const BindingContext &ctxt);
- bool compileStoreInstruction(QmlInstruction &instr,
- const QMetaProperty &prop,
- QmlParser::Value *value);
-
- bool compileDynamicMeta(QmlParser::Object *obj, int preAlias = -1);
+ bool buildGroupedProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt);
+ bool buildListProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt);
+ bool buildPropertyAssignment(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt);
+ bool buildPropertyObjectAssignment(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ QmlParser::Value *value,
+ const BindingContext &ctxt);
+ bool buildPropertyLiteralAssignment(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ QmlParser::Value *value,
+ const BindingContext &ctxt);
+ bool doesPropertyExist(QmlParser::Property *prop, QmlParser::Object *obj);
+ bool testLiteralAssignment(const QMetaProperty &prop,
+ QmlParser::Value *value);
+ enum DynamicMetaMode { IgnoreAliases, ResolveAliases };
+ bool mergeDynamicMetaProperties(QmlParser::Object *obj);
+ bool buildDynamicMeta(QmlParser::Object *obj, DynamicMetaMode mode);
+ bool checkDynamicMeta(QmlParser::Object *obj);
+ bool buildBinding(QmlParser::Value *, QmlParser::Property *prop,
+ const BindingContext &ctxt);
+ bool buildComponentFromRoot(QmlParser::Object *obj, const BindingContext &);
bool compileAlias(QMetaObjectBuilder &,
QByteArray &data,
QmlParser::Object *obj,
const QmlParser::Object::DynamicProperty &);
- bool compileBinding(QmlParser::Value *, QmlParser::Property *prop,
- const BindingContext &ctxt);
+ bool completeComponentBuild();
- 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 *);
+ void genObject(QmlParser::Object *obj);
+ void genObjectBody(QmlParser::Object *obj);
+ void genComponent(QmlParser::Object *obj);
+ void genValueProperty(QmlParser::Property *prop, QmlParser::Object *obj);
+ void genListProperty(QmlParser::Property *prop, QmlParser::Object *obj);
+ void genPropertyAssignment(QmlParser::Property *prop,
+ QmlParser::Object *obj);
+ void genLiteralAssignment(const QMetaProperty &prop,
+ QmlParser::Value *value);
+ void genBindingAssignment(QmlParser::Value *binding,
+ QmlParser::Property *prop,
+ QmlParser::Object *obj);
- struct IdReference {
- QString id;
- QmlParser::Object *object;
- int instructionIdx;
- int idx;
- };
- struct AliasReference {
- QmlParser::Object *object;
- int instructionIdx;
- };
+ int componentTypeRef();
+
+ static int findSignalByName(const QMetaObject *, const QByteArray &name);
+ static bool canCoerce(int to, QmlParser::Object *from);
+ static QmlType *toQmlType(QmlParser::Object *from);
+
+ QStringList deferredProperties(QmlParser::Object *);
+
+ void addId(const QString &, QmlParser::Object *);
struct BindingReference {
QmlParser::Variant expression;
QmlParser::Property *property;
QmlParser::Value *value;
- int instructionIdx;
+ QByteArray compiledData;
BindingContext bindingContext;
};
+ void addBindingReference(const BindingReference &);
struct ComponentCompileState
{
- ComponentCompileState() : parserStatusCount(0), savedObjects(0), pushedProperties(0), root(0) {}
- QHash<QString, IdReference> ids;
+ ComponentCompileState()
+ : parserStatusCount(0), savedObjects(0),
+ pushedProperties(0), root(0) {}
+ QHash<QString, QmlParser::Object *> ids;
int parserStatusCount;
int savedObjects;
int pushedProperties;
- QList<BindingReference> bindings;
- QList<AliasReference> aliases;
+
+ QHash<QmlParser::Value *, BindingReference> bindings;
+ QList<QmlParser::Object *> aliasingObjects;
QmlParser::Object *root;
};
ComponentCompileState compileState;
+ void saveComponentState();
+ ComponentCompileState componentState(QmlParser::Object *);
+ QHash<QmlParser::Object *, ComponentCompileState> savedCompileStates;
+
QList<QmlError> exceptions;
QmlCompiledData *output;
-
};
-
QT_END_NAMESPACE
#endif // QMLCOMPILER_P_H
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 52315f9..c7d45fd 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -41,6 +41,7 @@
#include "qmlcomponent.h"
#include "qmlcomponent_p.h"
+#include "qmlcompiler_p.h"
#include "private/qmlcontext_p.h"
#include "private/qmlengine_p.h"
#include "qmlvme_p.h"
@@ -51,7 +52,6 @@
#include <qmlengine.h>
#include <QFileInfo>
#include <qmlbindablevalue.h>
-#include "qmlcompiledcomponent_p.h"
#include <QtCore/qdebug.h>
#include <QApplication>
@@ -123,7 +123,7 @@ void QmlComponentPrivate::typeDataReady()
void QmlComponentPrivate::fromTypeData(QmlCompositeTypeData *data)
{
url = data->imports.baseUrl();
- QmlCompiledComponent *c = data->toCompiledComponent(engine);
+ QmlCompiledData *c = data->toCompiledComponent(engine);
if (!c) {
Q_ASSERT(data->status == QmlCompositeTypeData::Error);
@@ -303,7 +303,7 @@ QmlComponent::QmlComponent(QmlEngine *engine, const QByteArray &data, const QUrl
/*!
\internal
*/
-QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledComponent *cc, int start, int count, QObject *parent)
+QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledData *cc, int start, int count, QObject *parent)
: QObject(*(new QmlComponentPrivate), parent)
{
Q_D(QmlComponent);
@@ -405,9 +405,10 @@ QString QmlComponent::errorsString() const
QString ret;
if(!isError())
return ret;
- foreach(const QmlError &e, d->errors){
- ret += e.url().toString() + ":" + QString::number(e.line()) + " "
- + e.description() + "\n";
+ foreach(const QmlError &e, d->errors) {
+ ret += e.url().toString() + QLatin1String(":") +
+ QString::number(e.line()) + QLatin1String(" ") +
+ e.description() + QLatin1String("\n");
}
return ret;
}
@@ -532,7 +533,6 @@ QObject *QmlComponent::beginCreate(QmlContext *context)
static_cast<QmlContextPrivate*>(ctxt->d_ptr)->startLine = d->cc->bytecode.at(d->start - 1).line;
static_cast<QmlContextPrivate*>(ctxt->d_ptr)->endLine = d->cc->bytecode.at(d->start - 1).createComponent.endLine;
}
- ctxt->activate();
QmlVME vme;
QObject *rv = vme.run(ctxt, d->cc, d->start, d->count);
@@ -540,8 +540,6 @@ QObject *QmlComponent::beginCreate(QmlContext *context)
if (vme.isError())
d->errors = vme.errors();
- ctxt->deactivate();
-
QmlEnginePrivate *ep = d->engine->d_func();
if (ep->rootComponent == this) {
ep->rootComponent = 0;
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
index 5e6dce9..9c712df 100644
--- a/src/declarative/qml/qmlcomponent.h
+++ b/src/declarative/qml/qmlcomponent.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QmlCompiledComponent;
+class QmlCompiledData;
class QByteArray;
class QmlComponentPrivate;
class QmlEngine;
@@ -102,7 +102,7 @@ protected:
QmlComponent(QmlComponentPrivate &dd, QObject* parent);
private:
- QmlComponent(QmlEngine *, QmlCompiledComponent *, int, int, QObject *parent);
+ QmlComponent(QmlEngine *, QmlCompiledData *, int, int, QObject *parent);
friend class QmlVME;
friend struct QmlCompositeTypeData;
diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h
index 0be3dc6..25af342 100644
--- a/src/declarative/qml/qmlcomponent_p.h
+++ b/src/declarative/qml/qmlcomponent_p.h
@@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
class QmlComponent;
class QmlEngine;
-class QmlCompiledComponent;
+class QmlCompiledData;
class QmlComponentPrivate : public QObjectPrivate
{
@@ -86,7 +86,7 @@ public:
int start;
int count;
- QmlCompiledComponent *cc;
+ QmlCompiledData *cc;
QList<QmlEnginePrivate::SimpleList<QmlBindableValue> > bindValues;
QList<QmlEnginePrivate::SimpleList<QmlParserStatus> > parserStatus;
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index 5be86c2..9af5c3c 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -41,7 +41,6 @@
#include <private/qmlcompositetypemanager_p.h>
#include <private/qmlscriptparser_p.h>
-#include <private/qmlcompiledcomponent_p.h>
#include <QtDeclarative/qmlengine.h>
#include <QtNetwork/qnetworkreply.h>
#include <private/qmlengine_p.h>
@@ -49,6 +48,7 @@
#include <QtCore/qfile.h>
#include <QtDeclarative/qmlcomponent.h>
#include <private/qmlcomponent_p.h>
+#include <private/qmlcompiler_p.h>
QT_BEGIN_NAMESPACE
@@ -83,7 +83,7 @@ QmlComponent *QmlCompositeTypeData::toComponent(QmlEngine *engine)
{
if (!component) {
- QmlCompiledComponent *cc = toCompiledComponent(engine);
+ QmlCompiledData *cc = toCompiledComponent(engine);
if (cc) {
component = new QmlComponent(engine, cc, -1, -1, 0);
} else {
@@ -97,12 +97,12 @@ QmlComponent *QmlCompositeTypeData::toComponent(QmlEngine *engine)
return component;
}
-QmlCompiledComponent *
+QmlCompiledData *
QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine)
{
if (status == Complete && !compiledComponent) {
- compiledComponent = new QmlCompiledComponent;
+ compiledComponent = new QmlCompiledData;
compiledComponent->url = imports.baseUrl();
compiledComponent->name = compiledComponent->url.toString().toLatin1(); // ###
@@ -110,8 +110,6 @@ QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine)
if (!compiler.compile(engine, this, compiledComponent)) {
status = Error;
errors = compiler.errors();
- for(int ii = 0; ii < errors.count(); ++ii)
- errors[ii].setUrl(compiledComponent->url);
compiledComponent->release();
compiledComponent = 0;
}
diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h
index a393da4..0685b03 100644
--- a/src/declarative/qml/qmlcompositetypemanager_p.h
+++ b/src/declarative/qml/qmlcompositetypemanager_p.h
@@ -61,7 +61,7 @@
QT_BEGIN_NAMESPACE
-class QmlCompiledComponent;
+class QmlCompiledData;
class QmlComponentPrivate;
class QmlComponent;
class QmlDomDocument;
@@ -94,9 +94,9 @@ struct QmlCompositeTypeData : public QmlRefCount
// state. The QmlComponent is owned by the QmlCompositeTypeData, so a
// reference should be kept to keep the QmlComponent alive.
QmlComponent *toComponent(QmlEngine *);
- // Return a QmlCompiledComponent if possible, or 0 if an error
+ // Return a QmlCompiledData if possible, or 0 if an error
// occurs
- QmlCompiledComponent *toCompiledComponent(QmlEngine *);
+ QmlCompiledData *toCompiledComponent(QmlEngine *);
struct TypeReference
{
@@ -123,7 +123,7 @@ private:
QmlScriptParser data;
QList<QmlComponentPrivate *> waiters;
QmlComponent *component;
- QmlCompiledComponent *compiledComponent;
+ QmlCompiledData *compiledComponent;
};
class QmlCompositeTypeManager : public QObject
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index 980e1df..5bc70bc 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -73,6 +73,8 @@ void QmlContextPrivate::dump(int depth)
void QmlContextPrivate::destroyed(QObject *obj)
{
+ Q_Q(QmlContext);
+
defaultObjects.removeAll(obj);
QVariant variantObject = QVariant::fromValue(obj);
@@ -84,10 +86,16 @@ void QmlContextPrivate::destroyed(QObject *obj)
}
}
- // ### Work around bug in shutdown
- // for (int ii = 0; ii < notifies.count(); ++ii) {
- // QMetaObject::activate(q, notifies[ii] + notifyIndex, 0);
- // }
+ // There is no need to emit these notifications if our parent is in the
+ // process of being deleted (which is *probably* why obj has been destroyed
+ // anyway), as we're about to get deleted which will invalidate all the
+ // expressions that could depend on us
+ QObject *parent = q->parent();
+ if (!parent || !QObjectPrivate::get(parent)->wasDeleted) {
+ for (int ii = 0; ii < notifies.count(); ++ii) {
+ QMetaObject::activate(q, notifies[ii] + notifyIndex, 0);
+ }
+ }
}
void QmlContextPrivate::init()
@@ -397,56 +405,6 @@ void QmlContext::setContextProperty(const QString &name, QObject *value)
}
/*!
- Activate this bind context.
-
- \sa QmlEngine::activeContext() QmlContext::activeContext()
-*/
-void QmlContext::activate()
-{
- QmlEnginePrivate *ep = engine()->d_func();
- ep->activeContexts.push(this);
- ep->setCurrentBindContext(this);
- ep->contextActivated(this);
-}
-
-/*!
- Deactivate this bind context. The previously active bind context will
- become active, or, if there was no previously active bind context, no
- context will be active.
-
- \sa QmlEngine::activeContext() QmlContext::activeContext()
-*/
-void QmlContext::deactivate()
-{
- QmlEnginePrivate *ep = engine()->d_func();
- Q_ASSERT(ep->activeContexts.top() == this);
- ep->activeContexts.pop();
- if (ep->activeContexts.isEmpty())
- ep->setCurrentBindContext(0);
- else
- ep->setCurrentBindContext(ep->activeContexts.top());
- ep->contextDeactivated(this);
-}
-
-/*!
- Returns the currently active context, or 0 if no context is active.
-
- This method is thread-safe. The active context is maintained individually
- for each thread. This method is equivalent to
- \code
- QmlEngine::activeEngine()->activeContext()
- \endcode
-*/
-QmlContext *QmlContext::activeContext()
-{
- QmlEngine *engine = QmlEngine::activeEngine();
- if (engine)
- return engine->activeContext();
- else
- return 0;
-}
-
-/*!
Resolves the URL \a src relative to the URL of the
containing component. If \a src is absolute, it is
simply returned. If there is no containing component,
diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h
index 77f6634..877ff0f 100644
--- a/src/declarative/qml/qmlcontext.h
+++ b/src/declarative/qml/qmlcontext.h
@@ -73,11 +73,6 @@ public:
void setContextProperty(const QString &, QObject *);
void setContextProperty(const QString &, const QVariant &);
- void activate();
- void deactivate();
-
- static QmlContext *activeContext();
-
QUrl resolvedUrl(const QUrl &);
void setBaseUrl(const QUrl &);
diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h
index f896873..fc615b6 100644
--- a/src/declarative/qml/qmlcontext_p.h
+++ b/src/declarative/qml/qmlcontext_p.h
@@ -66,7 +66,6 @@ class QmlContext;
class QmlExpression;
class QmlEngine;
class QmlExpression;
-class QmlCompiledComponent;
class QmlContextPrivate : public QObjectPrivate
{
diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h
index 559f0ee..b473e77 100644
--- a/src/declarative/qml/qmldeclarativedata_p.h
+++ b/src/declarative/qml/qmldeclarativedata_p.h
@@ -71,7 +71,7 @@ public:
bool create = false);
};
-class QmlCompiledComponent;
+class QmlCompiledData;
class QmlInstanceDeclarativeData : public QmlSimpleDeclarativeData
{
public:
@@ -79,7 +79,7 @@ public:
virtual void destroyed(QObject *);
- QmlCompiledComponent *deferredComponent;
+ QmlCompiledData *deferredComponent;
unsigned int deferredIdx;
static inline QmlInstanceDeclarativeData *get(QObject *object,
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index e293a93..293ea6a 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -43,7 +43,6 @@
#include "qmldom_p.h"
#include "private/qmlcompiler_p.h"
#include "private/qmlengine_p.h"
-#include "qmlcompiledcomponent_p.h"
#include <QtCore/QByteArray>
#include <QtCore/QDebug>
#include <QtCore/QString>
@@ -165,7 +164,7 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
d->errors.clear();
d->imports.clear();
- QmlCompiledComponent component;
+ QmlCompiledData component;
QmlCompiler compiler;
QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, url);
@@ -588,7 +587,7 @@ QmlDomProperty QmlDomDynamicProperty::defaultValue() const
int QmlDomDynamicProperty::position() const
{
if (isValid()) {
- return d->property.range.offset;
+ return d->property.location.range.offset;
} else
return -1;
}
@@ -600,7 +599,7 @@ int QmlDomDynamicProperty::position() const
int QmlDomDynamicProperty::length() const
{
if (isValid())
- return d->property.range.length;
+ return d->property.location.range.length;
else
return -1;
}
@@ -770,7 +769,7 @@ QByteArray QmlDomObject::objectType() const
Text { id: MyText }
\endqml
*/
-QByteArray QmlDomObject::objectId() const
+QString QmlDomObject::objectId() const
{
if (d->object) return d->object->id;
else return QByteArray();
@@ -1384,7 +1383,6 @@ QmlDomValue::Type QmlDomValue::type() const
return PropertyBinding;
case QmlParser::Value::ValueSource:
return ValueSource;
- case QmlParser::Value::Component:
case QmlParser::Value::CreatedObject:
return Object;
case QmlParser::Value::SignalObject:
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index 456202a..339570b 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -150,7 +150,7 @@ public:
bool isValid() const;
QByteArray objectType() const;
- QByteArray objectId() const;
+ QString objectId() const;
void setObjectId(const QByteArray &);
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 46c8b30..a6f5b28 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -1,4 +1,4 @@
- /****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
@@ -39,10 +39,13 @@
**
****************************************************************************/
+#undef QT3_SUPPORT // don't want it here - it just causes bugs (which is why we removed it)
+
#include <QMetaProperty>
#include <private/qmlengine_p.h>
#include <private/qmlcontext_p.h>
#include <private/qobject_p.h>
+#include <private/qmlcompiler_p.h>
#ifdef QT_SCRIPTTOOLS_LIB
#include <QScriptEngineDebugger>
@@ -60,7 +63,6 @@
#include <private/qfxperf_p.h>
#include <QStack>
#include "private/qmlbasicscript_p.h"
-#include "private/qmlcompiledcomponent_p.h"
#include "qmlengine.h"
#include "qmlcontext.h"
#include "qmlexpression.h"
@@ -90,49 +92,6 @@ struct StaticQtMetaObject : public QObject
{ return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
};
-
-struct QmlEngineStack {
- QmlEngineStack();
-
- QStack<QmlEngine *> mainThreadEngines;
- QThread *mainThread;
-
- QThreadStorage<QStack<QmlEngine *> *> storage;
-
- QStack<QmlEngine *> *engines();
-};
-
-Q_GLOBAL_STATIC(QmlEngineStack, engineStack);
-
-QmlEngineStack::QmlEngineStack()
-: mainThread(0)
-{
-}
-
-QStack<QmlEngine *> *QmlEngineStack::engines()
-{
- if (mainThread== 0) {
- if (!QCoreApplication::instance())
- return 0;
- mainThread = QCoreApplication::instance()->thread();
- }
-
- // Note: This is very slightly faster than just using the thread storage
- // for everything.
- QStack<QmlEngine *> *engines = 0;
- if (QThread::currentThread() == mainThread) {
- engines = &mainThreadEngines;
- } else {
- engines = storage.localData();
- if (!engines) {
- engines = new QStack<QmlEngine *>;
- storage.setLocalData(engines);
- }
- }
- return engines;
-}
-
-
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
: rootContext(0), currentBindContext(0), currentExpression(0), q(e),
isDebugging(false), rootComponent(0), networkAccessManager(0), typeManager(e),
@@ -295,30 +254,6 @@ QScriptValue QmlEnginePrivate::propertyObject(const QScriptString &propName,
return QScriptValue();
}
-void QmlEnginePrivate::contextActivated(QmlContext *)
-{
- Q_Q(QmlEngine);
- QmlEngineStack *stack = engineStack();
- if (!stack)
- return;
- QStack<QmlEngine *> *engines = stack->engines();
- if (engines)
- engines->push(q);
-}
-
-void QmlEnginePrivate::contextDeactivated(QmlContext *)
-{
- QmlEngineStack *stack = engineStack();
- if (!stack)
- return;
- QStack<QmlEngine *> *engines = stack->engines();
- if (engines) {
- Q_ASSERT(engines->top() == q_func());
- engines->pop();
- }
-}
-
-
////////////////////////////////////////////////////////////////////
bool QmlEnginePrivate::fetchCache(QmlBasicScriptNodeCache &cache, const QString &propName, QObject *obj)
@@ -469,40 +404,12 @@ QmlContext *QmlEngine::rootContext()
}
/*!
- Returns this engine's active context, or 0 if no context is active on this
- engine.
-
- Contexts are activated and deactivated by calling QmlContext::activate() and
- QmlContext::deactivate() respectively.
-
- Context activation holds no special semantic, other than it allows types
- instantiated by QML to access "their" context without having it passed as
- a parameter in their constructor, as shown below.
- \code
- class MyClass : ... {
- ...
- MyClass() {
- qWarning() << "I was instantiated in this context:"
- << QmlContext::activeContext();
- }
- };
- \endcode
-*/
-QmlContext *QmlEngine::activeContext()
-{
- Q_D(QmlEngine);
- if (d->currentBindContext)
- return d->currentBindContext;
- else
- return 0;
-}
-
-/*!
- Sets the common QNetworkAccessManager, \a network, used by all QML elements instantiated
- by this engine.
+ Sets the common QNetworkAccessManager, \a network, used by all QML elements
+ instantiated by this engine.
- Any previously set manager is deleted and \a network is owned by the QmlEngine. This
- method should only be called before any QmlComponents are instantiated.
+ Any previously set manager is deleted and \a network is owned by the
+ QmlEngine. This method should only be called before any QmlComponents are
+ instantiated.
*/
void QmlEngine::setNetworkAccessManager(QNetworkAccessManager *network)
{
@@ -669,30 +576,6 @@ QScriptEngine *QmlEngine::scriptEngine()
}
/*!
- Returns the currently active QmlEngine.
-
- The active engine is the engine associated with the last activated
- QmlContext. This method is thread-safe - the "active" engine is maintained
- independently for each thread.
-*/
-QmlEngine *QmlEngine::activeEngine()
-{
- QmlEngineStack *stack = engineStack();
- if (!stack) return 0;
-
- QStack<QmlEngine *> *engines = stack->engines();
- if (!engines) {
- qWarning("QmlEngine::activeEngine() cannot be called before the construction of QCoreApplication");
- return 0;
- }
-
- if (engines->isEmpty())
- return 0;
- else
- return engines->top();
-}
-
-/*!
Creates a QScriptValue allowing you to use \a object in QML script.
\a engine is the QmlEngine it is to be created in.
@@ -777,7 +660,6 @@ QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *eng
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);
@@ -1113,11 +995,73 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object,
}
+struct QmlEngine::ImportedNamespace {
+ QStringList urls;
+ QStringList versions;
+ QList<bool> isLibrary;
+
+ QUrl find(const QString& type) const
+ {
+ for (int i=0; i<urls.count(); ++i) {
+ QUrl url = QUrl(urls.at(i) + QLatin1String("/") + type + QLatin1String(".qml"));
+ QString version = versions.at(i);
+ // XXX search non-files too! (eg. zip files, see QT-524)
+ QFileInfo f(url.toLocalFile());
+ if (f.exists()) {
+ bool ok=true;
+ if (!version.isEmpty()) {
+ ok=false;
+ // Check version file - XXX cache these in QmlEngine!
+ QFile qmldir(urls.at(i)+QLatin1String("/qmldir"));
+ if (qmldir.open(QIODevice::ReadOnly)) {
+ do {
+ QString line = QString::fromUtf8(qmldir.readLine());
+ if (line.at(0) == QLatin1Char('#'))
+ continue;
+ int space1 = line.indexOf(QLatin1Char(' '));
+ int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1;
+ QStringRef maptype = line.leftRef(space1);
+ QStringRef mapversion = line.midRef(space1+1,space2<0?line.length()-space1-2:space2-space1-1);
+ QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-2);
+ if (maptype==type && mapversion==version) {
+ if (mapfile.isEmpty())
+ return url;
+ else
+ return url.resolved(mapfile.toString());
+ }
+ } while (!qmldir.atEnd());
+ }
+ }
+ if (ok)
+ return url;
+ }
+ }
+ return QUrl();
+ }
+
+ QmlType *findBuiltin(const QByteArray& type, QByteArray* found=0) const
+ {
+ for (int i=0; i<urls.count(); ++i) {
+ QByteArray version = versions.at(i).toLatin1();
+ QByteArray qt = urls.at(i).toLatin1();
+ if (version.isEmpty())
+ qt += "/";
+ else
+ qt += "/" + version + "/";
+ qt += type;
+ QmlType *t = QmlMetaType::qmlType(qt);
+ if (found) *found = qt;
+ if (t) return t;
+ }
+ return 0;
+ }
+};
+
class QmlImportsPrivate {
public:
- bool add(const QString& uri, const QString& prefix, const QString& version, QmlEngine::ImportType importType, const QStringList& importPath)
+ bool add(const QUrl& base, const QString& uri, const QString& prefix, const QString& version, QmlEngine::ImportType importType, const QStringList& importPath)
{
- TypeSet *s;
+ QmlEngine::ImportedNamespace *s;
if (prefix.isEmpty()) {
if (importType == QmlEngine::LibraryImport && version.isEmpty()) {
// unversioned library imports are always qualified - if only by final URI component
@@ -1125,14 +1069,14 @@ public:
QString defaultprefix = uri.mid(lastdot+1);
s = set.value(defaultprefix);
if (!s)
- set.insert(defaultprefix,(s=new TypeSet));
+ set.insert(defaultprefix,(s=new QmlEngine::ImportedNamespace));
} else {
s = &unqualifiedset;
}
} else {
s = set.value(prefix);
if (!s)
- set.insert(prefix,(s=new TypeSet));
+ set.insert(prefix,(s=new QmlEngine::ImportedNamespace));
}
QString url = uri;
if (importType == QmlEngine::LibraryImport) {
@@ -1146,8 +1090,11 @@ public:
break;
}
}
- if (!found)
- return false;
+ if (!found) {
+ // XXX assume it is a built-in type qualifier
+ }
+ } else {
+ url = base.resolved(QUrl(url)).toString();
}
s->urls.append(url);
s->versions.append(version);
@@ -1155,9 +1102,9 @@ public:
return true;
}
- QUrl find(const QUrl& base, const QString& type)
+ QUrl find(const QString& type) const
{
- TypeSet *s = 0;
+ const QmlEngine::ImportedNamespace *s = 0;
int slash = type.indexOf(QLatin1Char('/'));
if (slash >= 0) {
while (!s) {
@@ -1172,48 +1119,16 @@ public:
s = &unqualifiedset;
}
QString unqualifiedtype = type.mid(slash+1);
- if (s) {
- for (int i=0; i<s->urls.count(); ++i) {
- QUrl url = base.resolved(QUrl(s->urls.at(i) +QLatin1String("/")+ unqualifiedtype + QLatin1String(".qml")));
- QString version = s->versions.at(i);
- // XXX search non-files too! (eg. zip files, see QT-524)
- QFileInfo f(url.toLocalFile());
- if (f.exists()) {
- bool ok=true;
- if (!version.isEmpty()) {
- ok=false;
- // Check version file - XXX cache these in QmlEngine!
- QFile qmldir(s->urls.at(i)+QLatin1String("/qmldir"));
- if (qmldir.open(QIODevice::ReadOnly)) {
- do {
- QString line = QString::fromUtf8(qmldir.readLine());
- if (line.at(0) == QLatin1Char('#'))
- continue;
- int space1 = line.indexOf(QLatin1Char(' '));
- int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1;
- QStringRef maptype = line.leftRef(space1);
- QStringRef mapversion = line.midRef(space1+1,space2<0?line.length()-space1-2:space2-space1-1);
- QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-2);
- if (maptype==unqualifiedtype && mapversion==version) {
- if (mapfile.isEmpty())
- return url;
- else
- return url.resolved(mapfile.toString());
- }
- } while (!qmldir.atEnd());
- }
- }
- if (ok)
- return url;
- }
- }
- }
- return base.resolved(QUrl(type + QLatin1String(".qml")));
+ if (s)
+ return s->find(unqualifiedtype);
+ else
+ return QUrl();
}
- QmlType *findBuiltin(const QUrl& base, const QByteArray& type)
+
+ QmlType *findBuiltin(const QByteArray& type, QByteArray* found=0)
{
- TypeSet *s = 0;
+ QmlEngine::ImportedNamespace *s = 0;
int slash = type.indexOf('/');
if (slash >= 0) {
while (!s) {
@@ -1228,23 +1143,20 @@ public:
s = &unqualifiedset;
}
QByteArray unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
- if (s) {
- for (int i=0; i<s->urls.count(); ++i) {
- QmlType *t = QmlMetaType::qmlType(s->urls.at(i).toLatin1()+"/"+unqualifiedtype);
- if (t) return t;
- }
- }
- return QmlMetaType::qmlType(type);
+ if (s)
+ return s->findBuiltin(unqualifiedtype,found);
+ else
+ return 0;
+ }
+
+ QmlEngine::ImportedNamespace *findNamespace(const QString& type)
+ {
+ return set.value(type);
}
private:
- struct TypeSet {
- QStringList urls;
- QStringList versions;
- QList<bool> isLibrary;
- };
- TypeSet unqualifiedset;
- QHash<QString,TypeSet* > set;
+ QmlEngine::ImportedNamespace unqualifiedset;
+ QHash<QString,QmlEngine::ImportedNamespace* > set;
};
QmlEngine::Imports::Imports() :
@@ -1256,11 +1168,24 @@ QmlEngine::Imports::~Imports()
{
}
+/*!
+ Sets the base URL to be used for all relative file imports added.
+*/
void QmlEngine::Imports::setBaseUrl(const QUrl& url)
{
base = url;
}
+/*!
+ Adds \a path as a directory where installed QML components are
+ defined in a URL-based directory structure.
+
+ For example, if you add \c /opt/MyApp/lib/qml and then load QML
+ that imports \c com.mycompany.Feature, then QmlEngine will look
+ in \c /opt/MyApp/lib/qml/com/mycompany/Feature/ for the components
+ provided by that module (and in the case of versioned imports,
+ for the \c qmldir file definiting the type version mapping.
+*/
void QmlEngine::addImportPath(const QString& path)
{
if (qmlImportTrace())
@@ -1269,36 +1194,87 @@ void QmlEngine::addImportPath(const QString& path)
d->fileImportPath.prepend(path);
}
+/*!
+ Adds information to \a imports such that subsequent calls to resolveType()
+ will resolve types qualified by \a prefix by considering types found at the given \a uri.
+
+ The uri is either a directory (if importType is FileImport), or a URI resolved using paths
+ added via addImportPath() (if importType is LibraryImport).
+
+ The \a prefix may be empty, in which case the import location is considered for
+ unqualified types.
+
+ The base URL must already have been set with Import::setBaseUrl().
+*/
bool QmlEngine::addToImport(Imports* imports, const QString& uri, const QString& prefix, const QString& version, ImportType importType) const
{
Q_D(const QmlEngine);
- bool ok = imports->d->add(uri,prefix,version,importType,d->fileImportPath);
+ bool ok = imports->d->add(imports->base,uri,prefix,version,importType,d->fileImportPath);
if (qmlImportTrace())
qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << version << (importType==LibraryImport ? "Library" : "File") << ": " << ok;
return ok;
}
-bool QmlEngine::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return) const
+/*!
+ Using the given \a imports, the given (namespace qualified) \a type is resolved to either
+ an ImportedNamespace stored at \a ns_return,
+ a QmlType stored at \a type_return, or
+ a component located at \a url_return.
+
+ If any return pointer is 0, the corresponding search is not done.
+
+ \sa addToImport()
+*/
+bool QmlEngine::resolveType(const Imports& imports, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return) const
{
- Q_D(const QmlEngine);
- QmlType* t = imports.d->findBuiltin(imports.base,type);
- if (t) {
- if (type_return) *type_return = t;
- if (qmlImportTrace())
- qDebug() << "QmlEngine::resolveType" << type << "= (builtin)";
- return true;
+ if (ns_return) {
+ *ns_return = imports.d->findNamespace(QLatin1String(type));
+ if (*ns_return)
+ return true;
}
- QUrl url = imports.d->find(imports.base,type);
- if (url.isValid()) {
- if (url_return) *url_return = url;
- if (qmlImportTrace())
- qDebug() << "QmlEngine::resolveType" << type << "=" << url;
- return true;
+ if (type_return) {
+ QmlType* t = imports.d->findBuiltin(type);
+ if (!t) t = QmlMetaType::qmlType(type);
+ if (t) {
+ if (type_return) *type_return = t;
+ if (qmlImportTrace())
+ qDebug() << "QmlEngine::resolveType" << type << "= (builtin)";
+ return true;
+ }
+ }
+ if (url_return) {
+ QUrl url = imports.d->find(QLatin1String(type));
+ if (!url.isValid())
+ url = imports.base.resolved(QUrl(QLatin1String(type + ".qml")));
+
+ if (url.isValid()) {
+ if (url_return) *url_return = url;
+ if (qmlImportTrace())
+ qDebug() << "QmlEngine::resolveType" << type << "=" << url;
+ return true;
+ }
}
if (qmlImportTrace())
qDebug() << "QmlEngine::resolveType" << type << " not found";
return false;
}
+/*!
+ Searching \e only in the namespace \a ns (previously returned in a call to
+ resolveType(), \a type is found and returned to either
+ a QmlType stored at \a type_return, or
+ a component located at \a url_return.
+
+ If either return pointer is 0, the corresponding search is not done.
+*/
+void QmlEngine::resolveTypeInNamespace(ImportedNamespace* ns, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const
+{
+ if (type_return) {
+ *type_return = ns->findBuiltin(type);
+ }
+ if (url_return) {
+ *url_return = ns->find(QLatin1String(type));
+ }
+}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h
index 6a418b5..98deba7 100644
--- a/src/declarative/qml/qmlengine.h
+++ b/src/declarative/qml/qmlengine.h
@@ -70,10 +70,7 @@ public:
QmlEngine(QObject *p = 0);
virtual ~QmlEngine();
- static QmlEngine *activeEngine();
-
QmlContext *rootContext();
- QmlContext *activeContext();
void clearComponentCache();
@@ -87,10 +84,13 @@ public:
QUrl base;
QmlImportsPrivate *d;
};
+ struct ImportedNamespace;
+
void addImportPath(const QString& dir);
enum ImportType { LibraryImport, FileImport };
bool addToImport(Imports*, const QString& uri, const QString& prefix, const QString& version, ImportType type) const;
- bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const;
+ bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return=0) const;
+ void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const;
void setNetworkAccessManager(QNetworkAccessManager *);
QNetworkAccessManager *networkAccessManager() const;
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index e0824cc..f459dc5 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -93,9 +93,6 @@ public:
void init();
- void contextActivated(QmlContext *);
- void contextDeactivated(QmlContext *);
-
bool fetchCache(QmlBasicScriptNodeCache &cache, const QString &propName, QObject *);
bool loadCache(QmlBasicScriptNodeCache &cache, const QString &propName, QmlContextPrivate *context);
diff --git a/src/declarative/qml/qmlerror.cpp b/src/declarative/qml/qmlerror.cpp
index 149e173..5ee9144 100644
--- a/src/declarative/qml/qmlerror.cpp
+++ b/src/declarative/qml/qmlerror.cpp
@@ -168,6 +168,21 @@ void QmlError::setColumn(int column)
}
/*!
+ Return the error as a human readable string.
+*/
+QString QmlError::toString() const
+{
+ QString rv;
+ rv = url().toString() + QLatin1String(":") + QString::number(line());
+ if(column() != -1)
+ rv += QLatin1String(":") + QString::number(column());
+
+ rv += QLatin1String(": ") + description();
+
+ return rv;
+}
+
+/*!
\relates QmlError
\fn QDebug operator<<(QDebug debug, const QmlError &error)
@@ -176,19 +191,9 @@ void QmlError::setColumn(int column)
QDebug operator<<(QDebug debug, const QmlError &error)
{
- QUrl url = error.url();
-
- QString output;
-
- output = url.toString() + QLatin1String(":") +
- QString::number(error.line());
+ debug << qPrintable(error.toString());
- if(error.column() != -1)
- output += QLatin1String(":") + QString::number(error.column());
-
- output += QLatin1String(": ") + error.description();
-
- debug << qPrintable(output);
+ QUrl url = error.url();
if (error.line() > 0 && url.scheme() == QLatin1String("file")) {
QString file = url.toLocalFile();
diff --git a/src/declarative/qml/qmlerror.h b/src/declarative/qml/qmlerror.h
index 57d2f8f..c1a8720 100644
--- a/src/declarative/qml/qmlerror.h
+++ b/src/declarative/qml/qmlerror.h
@@ -69,6 +69,8 @@ public:
void setLine(int);
int column() const;
void setColumn(int);
+
+ QString toString() const;
private:
QmlErrorPrivate *d;
};
diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp
index 84352b8..2aa1a8a 100644
--- a/src/declarative/qml/qmlexpression.cpp
+++ b/src/declarative/qml/qmlexpression.cpp
@@ -43,6 +43,7 @@
#include "qmlexpression_p.h"
#include "qmlengine_p.h"
#include "qmlcontext_p.h"
+#include "qmlrewrite_p.h"
#include "QtCore/qdebug.h"
Q_DECLARE_METATYPE(QList<QObject *>);
@@ -52,17 +53,17 @@ 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)
+: q(b), ctxt(0), expressionFunctionValid(false), 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)
+: q(b), ctxt(0), expressionFunctionValid(false), 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)
+: q(b), ctxt(0), expression(expr), expressionFunctionValid(false), sseData(0), proxy(0), me(0), trackChange(true), line(-1), id(0), log(0)
{
}
@@ -77,7 +78,7 @@ QmlExpressionPrivate::~QmlExpressionPrivate()
/*!
Create an invalid QmlExpression.
- As the expression will not have an associated QmlContext, this will be a
+ 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()
@@ -86,7 +87,7 @@ QmlExpression::QmlExpression()
}
/*! \internal */
-QmlExpression::QmlExpression(QmlContext *ctxt, void *expr,
+QmlExpression::QmlExpression(QmlContext *ctxt, void *expr,
QmlRefCount *rc, QObject *me)
: d(new QmlExpressionPrivate(this, expr, rc))
{
@@ -105,7 +106,7 @@ QmlExpression::QmlExpression(QmlContext *ctxt, void *expr,
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,
+QmlExpression::QmlExpression(QmlContext *ctxt, const QString &expression,
QObject *scope)
: d(new QmlExpressionPrivate(this, expression))
{
@@ -177,13 +178,15 @@ void QmlExpression::setExpression(const QString &expression)
delete d->proxy; d->proxy = 0;
d->expression = expression;
+ d->expressionFunctionValid = false;
+ d->expressionFunction = QScriptValue();
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
+ last time it was evaluated. The expression must have been evaluated at
least once (by calling QmlExpression::value()) before this callback will
be made.
@@ -226,16 +229,24 @@ QVariant QmlExpressionPrivate::evalQtScript()
ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount, me);
QScriptEngine *scriptEngine = engine->scriptEngine();
- QScriptValueList oldScopeChain =
+ 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)
+ 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 (!expressionFunctionValid) {
+ QmlRewrite::RewriteBinding rewriteBinding;
+
+ const QString code = rewriteBinding(expression);
+ expressionFunction = scriptEngine->evaluate(code, fileName.toString(), line);
+ expressionFunctionValid = true;
+ }
+
+ QScriptValue svalue = expressionFunction.call();
+
if (scriptEngine->hasUncaughtException()) {
if (scriptEngine->uncaughtException().isError()){
@@ -262,7 +273,7 @@ QVariant QmlExpressionPrivate::evalQtScript()
QList<QObject *> list;
for (int ii = 0; ii < length; ++ii) {
QScriptValue arrayItem = svalue.property(ii);
- QObject *d =
+ QObject *d =
qvariant_cast<QObject *>(arrayItem.data().toVariant());
if (d) {
list << d;
@@ -272,11 +283,11 @@ QVariant QmlExpressionPrivate::evalQtScript()
}
rv = QVariant::fromValue(list);
}
- } else if (svalue.isObject() &&
+ } else if (svalue.isObject() &&
!svalue.isNumber() &&
!svalue.isString() &&
- !svalue.isDate() &&
- !svalue.isError() &&
+ !svalue.isDate() &&
+ !svalue.isError() &&
!svalue.isFunction() &&
!svalue.isNull() &&
!svalue.isQMetaObject() &&
@@ -290,19 +301,19 @@ QVariant QmlExpressionPrivate::evalQtScript()
rv = var;
}
}
- if (rv.isNull())
+ if (rv.isNull())
rv = svalue.toVariant();
- for (int i = 0; i < ctxtPriv->scopeChain.size(); ++i)
+ for (int i = 0; i < ctxtPriv->scopeChain.size(); ++i)
scriptEngine->currentContext()->popScope();
- for (int i = oldScopeChain.size() - 1; i > -1; --i)
+ 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
+ Returns the value of the expression, or an invalid QVariant if the
expression is invalid or has an error.
*/
QVariant QmlExpression::value()
@@ -358,12 +369,12 @@ QVariant QmlExpression::value()
d->proxy, changedIndex);
} else {
const QMetaObject *metaObj = prop.object->metaObject();
- QMetaProperty metaProp =
+ QMetaProperty metaProp =
metaObj->property(prop.coreIndex);
- QString warn = QLatin1String("Expression depends on non-NOTIFYable property: ") +
- QLatin1String(metaObj->className()) +
- QLatin1String("::") +
+ QString warn = QLatin1String("Expression depends on non-NOTIFYable property: ") +
+ QLatin1String(metaObj->className()) +
+ QLatin1String("::") +
QLatin1String(metaProp.name());
log.addWarning(warn);
}
@@ -386,10 +397,10 @@ QVariant QmlExpression::value()
}
const QMetaObject *metaObj = prop.object->metaObject();
- QMetaProperty metaProp =
+ QMetaProperty metaProp =
metaObj->property(prop.coreIndex);
- qWarning().nospace() << " " << metaObj->className()
+ qWarning().nospace() << " " << metaObj->className()
<< "::" << metaProp.name();
}
}
@@ -438,14 +449,14 @@ bool QmlExpression::trackChange() const
/*!
Set whether changes are tracked in the expression's value to \a trackChange.
- If true, the QmlExpression will monitor properties involved in the
+ 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"
+ called. This is more efficient if an application wants a "one off"
evaluation of the expression.
By default, trackChange is true.
@@ -468,7 +479,7 @@ void QmlExpression::setSourceLocation(const QUrl &fileName, int line)
/*!
Returns the expression's scope object, if provided, otherwise 0.
- In addition to data provided by the expression's QmlContext, the scope
+ 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
@@ -498,13 +509,13 @@ quint32 QmlExpression::id() const
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::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
+ 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)
@@ -531,7 +542,7 @@ QmlExpressionObject::QmlExpressionObject(QmlContext *ctxt, void *d, QmlRefCount
}
/*!
- Returns the value of the expression, or an invalid QVariant if the
+ Returns the value of the expression, or an invalid QVariant if the
expression is invalid or has an error.
*/
QVariant QmlExpressionObject::value()
@@ -543,8 +554,8 @@ QVariant QmlExpressionObject::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.
+ 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)
diff --git a/src/declarative/qml/qmlexpression_p.h b/src/declarative/qml/qmlexpression_p.h
index 5883125..09745a3 100644
--- a/src/declarative/qml/qmlexpression_p.h
+++ b/src/declarative/qml/qmlexpression_p.h
@@ -55,6 +55,7 @@
#include "qmlbasicscript_p.h"
#include "qmlexpression.h"
+#include <QtScript/qscriptvalue.h>
QT_BEGIN_NAMESPACE
@@ -73,6 +74,9 @@ public:
QmlExpression *q;
QmlContext *ctxt;
QString expression;
+ bool expressionFunctionValid;
+ QScriptValue expressionFunction;
+
QmlBasicScript sse;
void *sseData;
QmlExpressionBindProxy *proxy;
diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp
index 1647a12..83fb18b 100644
--- a/src/declarative/qml/qmlinstruction.cpp
+++ b/src/declarative/qml/qmlinstruction.cpp
@@ -39,13 +39,13 @@
**
****************************************************************************/
-#include "private/qmlinstruction_p.h"
-#include "private/qmlcompiledcomponent_p.h"
-#include <QDebug>
+#include "qmlinstruction_p.h"
+#include "qmlcompiler_p.h"
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
-void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
+void QmlCompiledData::dump(QmlInstruction *instr, int idx)
{
QByteArray lineNumber = QByteArray::number(instr->line);
if (instr->line == (unsigned short)-1)
@@ -54,13 +54,13 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
switch(instr->type) {
case QmlInstruction::Init:
- qWarning() << idx << "\t" << line << "\t" << "INIT\t\t\t" << instr->init.dataSize;
+ qWarning() << idx << "\t" << line << "\t" << "INIT";
break;
case QmlInstruction::CreateObject:
qWarning() << idx << "\t" << line << "\t" << "CREATE\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className;
break;
case QmlInstruction::SetId:
- qWarning() << idx << "\t" << line << "\t" << "SETID\t\t\t" << instr->setId.value << "\t" << instr->setId.save << "\t\t" << primitives.at(instr->setId.value);
+ qWarning() << idx << "\t" << line << "\t" << "SETID\t\t\t" << instr->setId.value << "\t\t\t\t" << primitives.at(instr->setId.value);
break;
case QmlInstruction::SetDefault:
qWarning() << idx << "\t" << line << "\t" << "SET_DEFAULT";
@@ -125,8 +125,11 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
case QmlInstruction::StoreObject:
qWarning() << idx << "\t" << line << "\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
break;
- case QmlInstruction::AssignCustomType:
- qWarning() << idx << "\t" << line << "\t" << "ASSIGN_CUSTOMTYPE\t\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.valueIndex;
+ case QmlInstruction::StoreVariantObject:
+ qWarning() << idx << "\t" << line << "\t" << "STORE_VARIANT_OBJECT\t" << instr->storeObject.propertyIndex;
+ break;
+ case QmlInstruction::StoreInterface:
+ qWarning() << idx << "\t" << line << "\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex;
break;
case QmlInstruction::StoreSignal:
qWarning() << idx << "\t" << line << "\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value << "\t\t" << primitives.at(instr->storeSignal.value);
@@ -134,6 +137,9 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
case QmlInstruction::AssignSignalObject:
qWarning() << idx << "\t" << line << "\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << datas.at(instr->assignSignalObject.signal);
break;
+ case QmlInstruction::AssignCustomType:
+ qWarning() << idx << "\t" << line << "\t" << "ASSIGN_CUSTOMTYPE\t\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.valueIndex;
+ break;
case QmlInstruction::StoreBinding:
qWarning() << idx << "\t" << line << "\t" << "STORE_BINDING\t\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t\t" << instr->assignBinding.context << primitives.at(instr->assignBinding.value);
break;
@@ -149,6 +155,12 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
case QmlInstruction::CompleteObject:
qWarning() << idx << "\t" << line << "\t" << "COMPLETE\t\t" << instr->complete.castValue;
break;
+ case QmlInstruction::StoreObjectQmlList:
+ qWarning() << idx << "\t" << line << "\t" << "STORE_OBJECT_QMLLIST";
+ break;
+ case QmlInstruction::StoreObjectQList:
+ qWarning() << idx << "\t" << line << "\t" << "STORE_OBJECT_QLIST";
+ break;
case QmlInstruction::AssignObjectList:
qWarning() << idx << "\t" << line << "\t" << "ASSIGN_OBJECT_LIST\t";
break;
@@ -170,14 +182,11 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
case QmlInstruction::PopQList:
qWarning() << idx << "\t" << line << "\t" << "POP_QLIST";
break;
- case QmlInstruction::PushProperty:
- qWarning() << idx << "\t" << line << "\t" << "PUSH_PROPERTY" << "\t\t" << instr->pushProperty.property;
- break;
- case QmlInstruction::StoreStackObject:
- qWarning() << idx << "\t" << line << "\t" << "STORE_STACK_OBJ" << "\t" << instr->assignStackObject.property << "\t" << instr->assignStackObject.object;
+ case QmlInstruction::Defer:
+ qWarning() << idx << "\t" << line << "\t" << "DEFER" << "\t\t" << instr->defer.deferCount;
break;
default:
- qWarning() << idx << "\t" << line << "\t" << "XXX UNKOWN INSTRUCTION";
+ qWarning() << idx << "\t" << line << "\t" << "XXX UNKOWN INSTRUCTION" << "\t" << instr->type;
break;
}
}
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 40f9a32..a7221c0 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
-class QmlCompiledComponent;
+class QmlCompiledData;
class Q_DECLARATIVE_EXPORT QmlInstruction
{
public:
@@ -118,8 +118,6 @@ public:
StoreSignal, /* storeSignal */
- // XXX need to handle storing objects in variants
-
//
// Unresolved single assignment
//
@@ -154,14 +152,6 @@ public:
// Deferred creation
//
Defer, /* defer */
-
- //
- // Expression optimizations
- //
- // PushProperty - Save the property for later use
- // StoreStackObject - Assign the stack object (no checks)
- PushProperty, /* pushProperty */
- StoreStackObject /* assignStackObject */
};
QmlInstruction()
: line(0) {}
@@ -170,7 +160,6 @@ public:
unsigned short line;
union {
struct {
- int dataSize;
int bindingsSize;
int parserStatusSize;
} init;
@@ -185,7 +174,6 @@ public:
} storeMeta;
struct {
int value;
- int save;
} setId;
struct {
int property;
@@ -198,7 +186,6 @@ public:
} assignBinding;
struct {
int property;
- bool isObject;
} fetch;
struct {
int property;
@@ -281,18 +268,11 @@ public:
int id;
} fetchAttached;
struct {
- int property;
- } pushProperty;
- struct {
- int property;
- int object;
- } assignStackObject;
- struct {
int deferCount;
} defer;
};
- void dump(QmlCompiledComponent *);
+ void dump(QmlCompiledData *);
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index e158adf..dea3467 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -643,8 +643,7 @@ void QmlMetaPropertyPrivate::writeSignalProperty(const QVariant &value)
if (!expr.isEmpty()) {
// XXX scope
- (void *)new QmlBoundSignal(QmlContext::activeContext(), expr, object,
- coreIdx, object);
+ (void *)new QmlBoundSignal(qmlContext(object), expr, object, coreIdx, object);
}
}
@@ -663,9 +662,6 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value)
return;
}
- if (!value.isValid())
- return;
-
int t = propertyType();
int vt = value.userType();
int category = propertyCategory();
@@ -684,19 +680,22 @@ void QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value)
QObject *o = QmlMetaType::toQObject(value);
- if (!o)
- return;
+ const QMetaObject *valMo = 0;
- const QMetaObject *valMo = o->metaObject();
- const QMetaObject *propMo = QmlMetaType::rawMetaObjectForType(t);
+ if (o) {
+
+ valMo = o->metaObject();
+ const QMetaObject *propMo = QmlMetaType::rawMetaObjectForType(t);
+
+ while (valMo) {
+ if (valMo == propMo)
+ break;
+ valMo = valMo->superClass();
+ }
- while (valMo) {
- if (valMo == propMo)
- break;
- valMo = valMo->superClass();
}
- if (valMo) {
+ if (valMo || !o) {
void *args[] = { &o, 0 };
QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx,
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index e6c7376..16baf08 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -426,7 +426,7 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun
for (int ii = 0; ii < name.count(); ++ii) {
QChar ch = name.at(ii);
- if (!ch.isLetterOrNumber() && ch != QChar::fromLatin1('/')) {
+ if (!ch.isLetterOrNumber() && ch != QChar::fromLatin1('/') && ch != QChar::fromLatin1('.')) {
qWarning("QmlMetaType: Invalid QML name %s", cname);
return -1;
}
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp
index 8daab6a..8eb58c8 100644
--- a/src/declarative/qml/qmlparser.cpp
+++ b/src/declarative/qml/qmlparser.cpp
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
using namespace QmlParser;
QmlParser::Object::Object()
-: type(-1), metatype(0), extObjectData(0), defaultProperty(0)
+: type(-1), idIndex(-1), metatype(0), defaultProperty(0), parserStatusCast(-1)
{
}
@@ -71,11 +71,19 @@ QmlParser::Object::~Object()
if (defaultProperty) defaultProperty->release();
foreach(Property *prop, properties)
prop->release();
+ foreach(Property *prop, valueProperties)
+ prop->release();
+ foreach(Property *prop, signalProperties)
+ prop->release();
+ foreach(Property *prop, attachedProperties)
+ prop->release();
+ foreach(Property *prop, groupedProperties)
+ prop->release();
}
const QMetaObject *Object::metaObject() const
{
- if (extObjectData && metatype)
+ if (!metadata.isEmpty() && metatype)
return &extObject;
else
return metatype;
@@ -90,6 +98,30 @@ QmlParser::Property *Object::getDefaultProperty()
return defaultProperty;
}
+void QmlParser::Object::addValueProperty(Property *p)
+{
+ p->addref();
+ valueProperties << p;
+}
+
+void QmlParser::Object::addSignalProperty(Property *p)
+{
+ p->addref();
+ signalProperties << p;
+}
+
+void QmlParser::Object::addAttachedProperty(Property *p)
+{
+ p->addref();
+ attachedProperties << p;
+}
+
+void QmlParser::Object::addGroupedProperty(Property *p)
+{
+ p->addref();
+ groupedProperties << p;
+}
+
Property *QmlParser::Object::getProperty(const QByteArray &name, bool create)
{
if (!properties.contains(name)) {
@@ -114,7 +146,7 @@ QmlParser::Object::DynamicProperty::DynamicProperty(const DynamicProperty &o)
type(o.type),
name(o.name),
defaultValue(o.defaultValue),
- range(o.range)
+ location(o.location)
{
}
@@ -160,12 +192,13 @@ void QmlParser::Object::dump(int indent) const
}
QmlParser::Property::Property()
-: parent(0), type(0), index(-1), value(0), isDefault(true)
+: parent(0), type(0), index(-1), value(0), isDefault(true), isDeferred(false)
{
}
QmlParser::Property::Property(const QByteArray &n)
-: parent(0), type(0), index(-1), value(0), name(n), isDefault(false)
+: parent(0), type(0), index(-1), value(0), name(n), isDefault(false),
+ isDeferred(false)
{
}
@@ -187,6 +220,11 @@ void QmlParser::Property::addValue(Value *v)
values << v;
}
+bool QmlParser::Property::isEmpty() const
+{
+ return !value && values.isEmpty();
+}
+
void QmlParser::Property::dump(int indent) const
{
QByteArray ba(indent * 4, ' ');
@@ -232,9 +270,6 @@ void QmlParser::Value::dump(int indent) const
case Value::SignalExpression:
type = "SignalExpression";
break;
- case Value::Component:
- type = "Component";
- break;
case Value::Id:
type = "Id";
break;
diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h
index 7550870..d23b4ea 100644
--- a/src/declarative/qml/qmlparser_p.h
+++ b/src/declarative/qml/qmlparser_p.h
@@ -110,15 +110,17 @@ namespace QmlParser
virtual ~Object();
// Type of the object. The integer is an index into the
- // QmlCompiledData::types array, or -1 if the object is a fetched
- // object.
+ // QmlCompiledData::types array, or -1 if the object is a property
+ // group.
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).
- QByteArray id;
+ // The id assigned to the object (if any). Set by the QmlCompiler
+ QString id;
+ // The id index assigned to the object (if any). Set by the QmlCompiler
+ int idIndex;
// Custom parsed data
QByteArray custom;
// Returns the metaobject for this type, or 0 if not available.
@@ -129,8 +131,9 @@ namespace QmlParser
const QMetaObject *metatype;
// The synthesized metaobject, if QML added signals or properties to
// this type. Otherwise null
- QMetaObject *extObjectData;
QAbstractDynamicMetaObject extObject;
+ QByteArray metadata; // Generated by compiler
+ QByteArray synthdata; // Generated by compiler
Property *getDefaultProperty();
Property *getProperty(const QByteArray &name, bool create=true);
@@ -138,6 +141,22 @@ namespace QmlParser
Property *defaultProperty;
QHash<QByteArray, Property *> properties;
+ // Output of the compilation phase (these properties continue to exist
+ // in either the defaultProperty or properties members too)
+ void addValueProperty(Property *);
+ void addSignalProperty(Property *);
+ void addAttachedProperty(Property *);
+ void addGroupedProperty(Property *);
+ QList<Property *> valueProperties;
+ QList<Property *> signalProperties;
+ QList<Property *> attachedProperties;
+ QList<Property *> groupedProperties;
+
+ // The bytes to cast instances by to get to the QmlParserStatus
+ // interface. -1 indicates the type doesn't support this interface.
+ // Set by the QmlCompiler.
+ int parserStatusCast;
+
LocationSpan location;
struct DynamicProperty {
@@ -150,7 +169,7 @@ namespace QmlParser
Type type;
QByteArray name;
QmlParser::Property *defaultValue;
- LocationRange range;
+ LocationSpan location;
};
struct DynamicSignal {
DynamicSignal();
@@ -242,8 +261,6 @@ namespace QmlParser
SignalObject,
// This is used as a signal expression assignment
SignalExpression,
- // This is used as an implicit component creation
- Component,
// This is used as an id assignment only
Id
};
@@ -281,6 +298,9 @@ namespace QmlParser
// The metaobject index of this property, or -1 if unknown.
int index;
+ // Returns true if this is an empty property - both value and values
+ // are unset.
+ bool isEmpty() const;
// The list of values assigned to this property. Content in values
// and value are mutually exclusive
QList<Value *> values;
@@ -291,6 +311,9 @@ namespace QmlParser
QByteArray name;
// True if this property was accessed as the default property.
bool isDefault;
+ // True if the setting of this property will be deferred. Set by the
+ // QmlCompiler
+ bool isDeferred;
LocationSpan location;
LocationRange listValueRange;
diff --git a/src/declarative/qml/qmlrewrite.cpp b/src/declarative/qml/qmlrewrite.cpp
new file mode 100644
index 0000000..02bf8fa
--- /dev/null
+++ b/src/declarative/qml/qmlrewrite.cpp
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** 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 "qmlrewrite_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QmlRewrite {
+
+QString RewriteBinding::operator()(const QString &code)
+{
+ Engine engine;
+ NodePool pool(QString(), &engine);
+ Lexer lexer(&engine);
+ Parser parser(&engine);
+ lexer.setCode(code, 0);
+ parser.parseStatement();
+ return rewrite(code, 0, parser.statement());
+}
+
+void RewriteBinding::accept(AST::Node *node)
+{
+ AST::Node::acceptChild(node, this);
+}
+
+QString RewriteBinding::rewrite(QString code, unsigned position,
+ AST::Statement *node)
+{
+ TextWriter w;
+ _writer = &w;
+ _position = position;
+
+ accept(node);
+
+ unsigned startOfStatement = node->firstSourceLocation().begin() - _position;
+ unsigned endOfStatement = node->lastSourceLocation().end() - _position;
+
+ _writer->replace(startOfStatement, 0, QLatin1String("function() {\n"));
+ _writer->replace(endOfStatement, 0, QLatin1String("\n}"));
+
+ w.write(&code);
+
+ return code;
+}
+
+bool RewriteBinding::visit(AST::Block *ast)
+{
+ for (AST::StatementList *it = ast->statements; it; it = it->next) {
+ if (! it->next) {
+ // we need to rewrite only the last statement of a block.
+ accept(it->statement);
+ }
+ }
+
+ return false;
+}
+
+bool RewriteBinding::visit(AST::ExpressionStatement *ast)
+{
+ unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position;
+ _writer->replace(startOfExpressionStatement, 0, QLatin1String("return "));
+
+ return false;
+}
+
+bool RewriteBinding::visit(AST::NumericLiteral *node)
+{
+ if (node->suffix != AST::NumericLiteral::noSuffix) {
+ const int suffixLength = AST::NumericLiteral::suffixLength[node->suffix];
+ const char *suffixSpell = AST::NumericLiteral::suffixSpell[node->suffix];
+ QString pre;
+ pre += QLatin1String("qmlNumberFrom");
+ pre += QChar(QLatin1Char(suffixSpell[0])).toUpper();
+ pre += QLatin1String(&suffixSpell[1]);
+ pre += QLatin1Char('(');
+ _writer->replace(node->literalToken.begin() - _position, 0, pre);
+ _writer->replace(node->literalToken.end() - _position - suffixLength,
+ suffixLength,
+ QLatin1String(")"));
+ }
+
+ return false;
+}
+
+QString RewriteNumericLiterals::operator()(QString code, unsigned position, AST::Node *node)
+{
+ TextWriter w;
+ _writer = &w;
+ _position = position;
+
+ AST::Node::acceptChild(node, this);
+
+ w.write(&code);
+
+ return code;
+}
+
+bool RewriteNumericLiterals::visit(AST::NumericLiteral *node)
+{
+ if (node->suffix != AST::NumericLiteral::noSuffix) {
+ const int suffixLength = AST::NumericLiteral::suffixLength[node->suffix];
+ const char *suffixSpell = AST::NumericLiteral::suffixSpell[node->suffix];
+ QString pre;
+ pre += QLatin1String("qmlNumberFrom");
+ pre += QChar(QLatin1Char(suffixSpell[0])).toUpper();
+ pre += QLatin1String(&suffixSpell[1]);
+ pre += QLatin1Char('(');
+ _writer->replace(node->literalToken.begin() - _position, 0, pre);
+ _writer->replace(node->literalToken.end() - _position - suffixLength,
+ suffixLength,
+ QLatin1String(")"));
+ }
+
+ return false;
+}
+
+} // namespace QmlRewrite
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompiledcomponent_p.h b/src/declarative/qml/qmlrewrite_p.h
index 0945892..51a8015 100644
--- a/src/declarative/qml/qmlcompiledcomponent_p.h
+++ b/src/declarative/qml/qmlrewrite_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QMLCOMPILEDCOMPONENT_P_H
-#define QMLCOMPILEDCOMPONENT_P_H
+#ifndef QMLREWRITE_P_H
+#define QMLREWRITE_P_H
//
// W A R N I N G
@@ -53,40 +53,51 @@
// 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
+#include "rewriter/textwriter_p.h"
+#include "parser/qmljslexer_p.h"
+#include "parser/qmljsparser_p.h"
+#include "parser/qmljsnodepool_p.h"
QT_BEGIN_NAMESPACE
-namespace QmlParser {
- class Property;
- class Object;
- class Value;
+namespace QmlRewrite {
+using namespace QmlJS;
+
+class RewriteBinding: protected AST::Visitor
+{
+ unsigned _position;
+ TextWriter *_writer;
+
+public:
+ QString operator()(const QString &code);
+
+protected:
+ using AST::Visitor::visit;
+
+ void accept(AST::Node *node);
+ QString rewrite(QString code, unsigned position, AST::Statement *node);
+ virtual bool visit(AST::Block *ast);
+ virtual bool visit(AST::ExpressionStatement *ast);
+ virtual bool visit(AST::NumericLiteral *node);
};
-class QmlCompiledComponent : public QmlRefCount, public QmlCompiledData
+class RewriteNumericLiterals: protected AST::Visitor
{
+ unsigned _position;
+ TextWriter *_writer;
+
public:
- QmlCompiledComponent();
- ~QmlCompiledComponent();
-
- void dumpPre();
- void dumpPost();
-
-private:
- enum DumpStatus { NoDump = 0x00, DumpPre = 0x01, DumpPost = 0x02 } dumpStatus;
- void dumpInstructions();
- void dump(QmlInstruction *, int idx = -1);
- friend class QmlCompiler;
- friend class QmlDomDocument;
+ QString operator()(QString code, unsigned position, AST::Node *node);
+
+protected:
+ using AST::Visitor::visit;
+
+ virtual bool visit(AST::NumericLiteral *node);
};
+} // namespace QmlRewrite
+
QT_END_NAMESPACE
-QT_END_HEADER
+#endif // QMLREWRITE_P_H
-#endif // QMLCOMPILEDCOMPONENT_P_H
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index f26266b..c1c11c7 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -49,7 +49,7 @@
#include "parser/qmljsastvisitor_p.h"
#include "parser/qmljsast_p.h"
-#include "rewriter/textwriter_p.h"
+#include "qmlrewrite_p.h"
#include <QStack>
#include <QCoreApplication>
@@ -64,48 +64,6 @@ using namespace QmlParser;
namespace {
-class RewriteNumericLiterals: protected AST::Visitor
-{
- unsigned _position;
- TextWriter *_writer;
-
-public:
- QString operator()(QString code, unsigned position, AST::Node *node)
- {
- TextWriter w;
- _writer = &w;
- _position = position;
-
- AST::Node::acceptChild(node, this);
-
- w.write(&code);
-
- return code;
- }
-
-protected:
- using AST::Visitor::visit;
-
- virtual bool visit(AST::NumericLiteral *node)
- {
- if (node->suffix != AST::NumericLiteral::noSuffix) {
- const int suffixLength = AST::NumericLiteral::suffixLength[node->suffix];
- const char *suffixSpell = AST::NumericLiteral::suffixSpell[node->suffix];
- QString pre;
- pre += QLatin1String("qmlNumberFrom");
- pre += QChar(QLatin1Char(suffixSpell[0])).toUpper();
- pre += QLatin1String(&suffixSpell[1]);
- pre += QLatin1Char('(');
- _writer->replace(node->literalToken.begin() - _position, 0, pre);
- _writer->replace(node->literalToken.end() - _position - suffixLength,
- suffixLength,
- QLatin1String(")"));
- }
-
- return false;
- }
-};
-
class ProcessAST: protected AST::Visitor
{
struct State {
@@ -196,7 +154,7 @@ protected:
const AST::SourceLocation &last) const
{ return _contents.mid(first.offset, last.offset + last.length - first.offset); }
- RewriteNumericLiterals rewriteNumericLiterals;
+ QmlRewrite::RewriteNumericLiterals rewriteNumericLiterals;
QString asString(AST::ExpressionNode *expr)
{
@@ -572,8 +530,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;
+ property.location = location(node->firstSourceLocation(),
+ node->lastSourceLocation());
if (node->expression) { // default value
property.defaultValue = new Property;
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 2acf1e2..f468cd0 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qmlvme_p.h"
+#include "qmlcompiler_p.h"
#include <private/qfxperf_p.h>
#include <private/qmlboundsignal_p.h>
#include <private/qmlstringconverters_p.h>
@@ -49,7 +50,6 @@
#include <private/qmlcustomparser_p.h>
#include <QStack>
#include <QWidget>
-#include <private/qmlcompiledcomponent_p.h>
#include <QColor>
#include <QPointF>
#include <QSizeF>
@@ -98,7 +98,7 @@ struct ListInstance
QmlPrivate::ListInterface *qmlListInterface;
};
-QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, int count)
+QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledData *comp, int start, int count)
{
QStack<QObject *> stack;
@@ -116,31 +116,22 @@ void QmlVME::runDeferred(QObject *object)
return;
QmlContext *ctxt = data->context;
- ctxt->activate();
- QmlCompiledComponent *comp = data->deferredComponent;
+ QmlCompiledData *comp = data->deferredComponent;
int start = data->deferredIdx + 1;
int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount;
QStack<QObject *> stack;
stack.push(object);
run(stack, ctxt, comp, start, count);
- ctxt->deactivate();
}
-QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComponent *comp, int start, int count)
+QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledData *comp, int start, int count)
{
- // XXX - All instances of QmlContext::activeContext() here should be
- // replaced with the use of ctxt. However, this cannot be done until
- // behaviours stop modifying the active context and expecting the
- // instantiation to notice. Instead, QmlParserStatus::beginClass() should
- // be able to return a QmlContext that is used for expressions and
- // sub-instances on that type.
Q_ASSERT(comp);
Q_ASSERT(ctxt);
- const QList<QmlCompiledComponent::TypeReference> &types = comp->types;
+ const QList<QmlCompiledData::TypeReference> &types = comp->types;
const QList<QString> &primitives = comp->primitives;
const QList<QByteArray> &datas = comp->datas;
- const QList<QMetaObject *> &synthesizedMetaObjects = comp->synthesizedMetaObjects;;
const QList<QmlCompiledData::CustomTypeData> &customTypeData = comp->customTypeData;
const QList<int> &intData = comp->intData;
const QList<float> &floatData = comp->floatData;
@@ -152,7 +143,6 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
QStack<ListInstance> qliststack;
QStack<QmlMetaProperty> pushedProperties;
- QObject **savedObjects = 0;
vmeErrors.clear();
@@ -162,12 +152,6 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
switch(instr.type) {
case QmlInstruction::Init:
{
- if (instr.init.dataSize) {
- savedObjects = new QObject*[instr.init.dataSize];
- ::memset(savedObjects, 0,
- sizeof(QObject *)*instr.init.dataSize);
- }
-
if (instr.init.bindingsSize)
bindValues = QmlEnginePrivate::SimpleList<QmlBindableValue>(instr.init.bindingsSize);
if (instr.init.parserStatusSize)
@@ -177,7 +161,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
case QmlInstruction::CreateObject:
{
- QObject *o = types.at(instr.create.type).createInstance(QmlContext::activeContext());
+ QObject *o = types.at(instr.create.type).createInstance(ctxt);
if (!o) {
if(types.at(instr.create.type).component)
vmeErrors << types.at(instr.create.type).component->errors();
@@ -211,12 +195,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
case QmlInstruction::SetId:
{
QObject *target = stack.top();
- QmlContext *ctxt =
- QmlContext::activeContext();
ctxt->setContextProperty(primitives.at(instr.setId.value), target);
-
- if (instr.setId.save != -1)
- savedObjects[instr.setId.save] = target;
}
break;
@@ -224,7 +203,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
case QmlInstruction::SetDefault:
{
QObject *target = stack.top();
- QmlContext::activeContext()->addDefaultObject(target);
+ ctxt->addDefaultObject(target);
}
break;
@@ -239,7 +218,14 @@ 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, (const QmlVMEMetaData *)datas.at(instr.storeMeta.aliasData).constData(), comp);
+
+ QMetaObject mo;
+ const QByteArray &metadata = datas.at(instr.storeMeta.data);
+ QMetaObjectBuilder::fromRelocatableData(&mo, 0, metadata);
+
+ const QmlVMEMetaData *data = (const QmlVMEMetaData *)datas.at(instr.storeMeta.aliasData).constData();
+
+ (void)new QmlVMEMetaObject(target, &mo, data, comp);
}
break;
@@ -465,7 +451,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
{
QObject *target = stack.top();
void *a[1];
- QmlCompiledComponent::CustomTypeData data = customTypeData.at(instr.assignCustomType.valueIndex);
+ QmlCompiledData::CustomTypeData data = customTypeData.at(instr.assignCustomType.valueIndex);
const QString &primitive = primitives.at(data.index);
QmlMetaType::StringConverter converter =
QmlMetaType::customStringConverter(data.type);
@@ -519,9 +505,9 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
target->metaObject()->method(instr.storeSignal.signalIndex);
if (signal.parameterTypes().isEmpty()) {
- (void *)new QmlBoundSignal(QmlContext::activeContext(), primitives.at(instr.storeSignal.value), target, instr.storeSignal.signalIndex, target);
+ (void *)new QmlBoundSignal(ctxt, primitives.at(instr.storeSignal.value), target, instr.storeSignal.signalIndex, target);
} else {
- (void *)new QmlBoundSignalProxy(new QmlContext(QmlContext::activeContext(), target, true), primitives.at(instr.storeSignal.value), target, instr.storeSignal.signalIndex, target);
+ (void *)new QmlBoundSignalProxy(new QmlContext(ctxt, target, true), primitives.at(instr.storeSignal.value), target, instr.storeSignal.signalIndex, target);
}
}
break;
@@ -545,15 +531,6 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
}
break;
- case QmlInstruction::PushProperty:
- {
- QObject *target = stack.top();
- QmlMetaProperty mp(target, instr.pushProperty.property,
- QmlMetaProperty::Object);
- pushedProperties.push(mp);
- }
- break;
-
case QmlInstruction::StoreCompiledBinding:
{
QObject *target = stack.top();
@@ -563,7 +540,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, QmlContext::activeContext(), 0);
+ QmlBindableValue *bind = new QmlBindableValue((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, 0);
bindValues.append(bind);
QmlBindableValuePrivate *p =
static_cast<QmlBindableValuePrivate *>(QObjectPrivate::get(bind));
@@ -583,7 +560,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, QmlContext::activeContext());
+ QmlBindableValue *bind = new QmlBindableValue(primitives.at(instr.assignBinding.value), context, ctxt);
bindValues.append(bind);
QmlBindableValuePrivate *p =
static_cast<QmlBindableValuePrivate *>(QObjectPrivate::get(bind));
@@ -745,22 +722,12 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
QObject *target = stack.top();
QObject *obj = 0;
- if (instr.fetch.isObject) {
- // NOTE: This assumes a cast to QObject does not alter the
- // object pointer
- void *a[1];
- a[0] = &obj;
- QMetaObject::metacall(target, QMetaObject::ReadProperty,
- instr.fetch.property, a);
- } else {
- void *a[1];
- QVariant var;
- a[0] = &var;
- QMetaObject::metacall(target, QMetaObject::ReadProperty,
- instr.fetch.property, a);
- obj = QmlMetaType::toQObject(var);
-
- }
+ // NOTE: This assumes a cast to QObject does not alter the
+ // object pointer
+ void *a[1];
+ a[0] = &obj;
+ QMetaObject::metacall(target, QMetaObject::ReadProperty,
+ instr.fetch.property, a);
if (!obj)
VME_EXCEPTION("Cannot set properties on" << target->metaObject()->property(instr.fetch.property).name() << "as it is null");
@@ -795,23 +762,8 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
}
break;
- case QmlInstruction::StoreStackObject:
- {
- const QmlMetaProperty &prop =
- pushedProperties.at(instr.assignStackObject.property);
- QObject *obj = savedObjects[instr.assignStackObject.object];
-
- // NOTE: This assumes a cast to QObject does not alter the
- // object pointer
- void *a[1];
- a[0] = (void *)&obj;
- QMetaObject::metacall(prop.object(), QMetaObject::WriteProperty,
- prop.coreIndex(), a);
- }
- break;
-
default:
- qFatal("QmlCompiledComponent: Internal error - unknown instruction %d", instr.type);
+ qFatal("QmlCompiledData: Internal error - unknown instruction %d", instr.type);
break;
}
}
@@ -832,11 +784,6 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp
if (parserStatus.count)
ep->parserStatus << parserStatus;
- comp->dumpPost();
-
- if (savedObjects)
- delete [] savedObjects;
-
if (stack.isEmpty())
return 0;
else
diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h
index 2da7bb4..30a6e4f 100644
--- a/src/declarative/qml/qmlvme_p.h
+++ b/src/declarative/qml/qmlvme_p.h
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
class QObject;
class QmlInstruction;
-class QmlCompiledComponent;
+class QmlCompiledData;
class QmlCompiledData;
class QmlContext;
@@ -70,14 +70,14 @@ class QmlVME
public:
QmlVME();
- QObject *run(QmlContext *, QmlCompiledComponent *, int start = -1, int count = -1);
+ QObject *run(QmlContext *, QmlCompiledData *, int start = -1, int count = -1);
void runDeferred(QObject *);
bool isError() const;
QList<QmlError> errors() const;
private:
- QObject *run(QStack<QObject *> &, QmlContext *, QmlCompiledComponent *, int start, int count);
+ QObject *run(QStack<QObject *> &, QmlContext *, QmlCompiledData *, int start, int count);
QList<QmlError> vmeErrors;
};
diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp
index 6d14689..33a31a4 100644
--- a/src/declarative/qml/qmlvmemetaobject.cpp
+++ b/src/declarative/qml/qmlvmemetaobject.cpp
@@ -53,12 +53,9 @@ QT_BEGIN_NAMESPACE
QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj,
const QMetaObject *other,
- QList<QString> *strData,
- int slotData,
const QmlVMEMetaData *meta,
QmlRefCount *rc)
-: object(obj), ref(rc), metaData(meta), slotData(strData),
- slotDataIdx(slotData), parent(0)
+: object(obj), ref(rc), metaData(meta), parent(0)
{
if (ref)
ref->addref();
@@ -208,7 +205,11 @@ int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
id -= plainSignals;
if (id < metaData->methodCount) {
- QString code = slotData->at(id + slotDataIdx);
+ QmlVMEMetaData::MethodData *data = metaData->methodData() + id;
+ const QChar *body =
+ (const QChar *)(((const char*)metaData) + data->bodyOffset);
+
+ QString code = QString::fromRawData(body, data->bodyLength);
QmlContext *ctxt = qmlContext(object);
if (0 == (metaData->methodData() + id)->parameterCount) {
diff --git a/src/declarative/qml/qmlvmemetaobject_p.h b/src/declarative/qml/qmlvmemetaobject_p.h
index 6421c3f..931d22c 100644
--- a/src/declarative/qml/qmlvmemetaobject_p.h
+++ b/src/declarative/qml/qmlvmemetaobject_p.h
@@ -78,6 +78,9 @@ struct QmlVMEMetaData
struct MethodData {
int parameterCount;
+ int bodyOffset;
+ int bodyLength;
+ int _dummy;
};
PropertyData *propertyData() const {
@@ -89,7 +92,7 @@ struct QmlVMEMetaData
}
MethodData *methodData() const {
- return (MethodData *)(aliasData() + propertyCount);
+ return (MethodData *)(aliasData() + aliasCount);
}
};
@@ -97,7 +100,8 @@ class QmlRefCount;
class QmlVMEMetaObject : public QAbstractDynamicMetaObject
{
public:
- QmlVMEMetaObject(QObject *, const QMetaObject *, QList<QString> *, int slotData, const QmlVMEMetaData *data, QmlRefCount * = 0);
+ QmlVMEMetaObject(QObject *, const QMetaObject *, const QmlVMEMetaData *data,
+ QmlRefCount * = 0);
~QmlVMEMetaObject();
protected:
@@ -114,8 +118,10 @@ private:
QVariant *data;
QBitArray aConnected;
+#if 0
QList<QString> *slotData;
int slotDataIdx;
+#endif
QAbstractDynamicMetaObject *parent;
diff --git a/src/declarative/test/qfxtestengine.cpp b/src/declarative/test/qfxtestengine.cpp
deleted file mode 100644
index cf746db..0000000
--- a/src/declarative/test/qfxtestengine.cpp
+++ /dev/null
@@ -1,463 +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 <QFile>
-#include <QmlComponent>
-#include <private/qmltimeline_p.h>
-#include "qfxtestengine.h"
-#include "qfxtestobjects.h"
-#include <QCryptographicHash>
-#include <QApplication>
-#include <QKeyEvent>
-#include <QSimpleCanvas>
-#include <QMouseEvent>
-#include <qmlengine.h>
-#include <private/qabstractanimation_p.h>
-#include <QAbstractAnimation>
-
-QT_BEGIN_NAMESPACE
-
-#define MAX_MISMATCHED_FRAMES 5
-#define MAX_MISMATCHED_PIXELS 5
-
-class QFxTestEnginePrivate : public QAbstractAnimation
-{
-public:
- QFxTestEnginePrivate(QFxTestEngine *p)
- : q(p), canvas(0), testMode(QFxTestEngine::NoTest), fullFrame(true),
- status(Working), exitOnFail(true), mismatchedFrames(0),
- lastFrameMismatch(false) {}
-
- QFxTestEngine *q;
-
- QmlEngine engine;
- QSimpleCanvas *canvas;
- QFxTestEngine::TestMode testMode;
- QString testDirectory;
-
- TestLog testData;
- TestLog playbackTestData;
- bool fullFrame;
- QList<QImage> fullFrames;
-
- virtual void updateCurrentTime(int);
-
- void recordFrameEvent(const QImage &img);
- void recordFullFrameEvent(const QImage &img);
- void recordKeyEvent(QKeyEvent *e);
- void recordMouseEvent(QMouseEvent *e);
- void testPass();
- void save(const QString &filename, bool = true);
-
- enum MessageType { Success, Fail };
- void message(MessageType t, const char *);
-
- enum Status { Working, Failed, Passed };
- Status status;
- bool exitOnFail;
-
- QList<TestObject *> toPost;
- QSet<QEvent *> postedEvents;
-
- // OpenGL seems to give inconsistent rendering results. We allow a small
- // tolerance to compensate - a maximum number of mismatched frames and only
- // one mismatch in a row
- int mismatchedFrames;
- bool lastFrameMismatch;
-
- bool compare(const QImage &img1, const QImage &img2);
-
- virtual int duration() const { return -1; }
-
- int elapsed() { return currentTime(); }
-};
-
-bool QFxTestEnginePrivate::compare(const QImage &img1, const QImage &img2)
-{
- if (img1.size() != img2.size()) {
- qWarning() << "Image size mismatch" << img1.size() << img2.size();
- return false;
- }
-
- int errorCount = 0;
- for (int yy = 0; yy < img1.height(); ++yy) {
- for (int xx = 0; xx < img1.width(); ++xx) {
- if (img1.pixel(xx, yy) != img2.pixel(xx, yy)) {
- errorCount++;
- if (errorCount > MAX_MISMATCHED_PIXELS) {
- return false;
- }
- }
- }
- }
-
- return true;
-}
-
-QFxTestEngine::QFxTestEngine(TestMode mode, const QString &dir,
- QSimpleCanvas *canvas, QObject *parent)
-: QObject(parent), d(new QFxTestEnginePrivate(this))
-{
- Q_ASSERT(canvas);
-
- d->canvas = canvas;
- d->start();
-
- d->testDirectory = dir;
- d->testMode = mode;
- if (d->testMode == RecordTest) {
- qWarning("QFxTestEngine: Record ON");
- } else if (d->testMode == PlaybackTest) {
-
- QString fileName(d->testDirectory + QLatin1String("/manifest.qml"));
- QFile f(fileName);
- if (!f.open(QIODevice::ReadOnly)) {
- qWarning() << "QFxTestEngine: Unable to open file" << fileName;
- return;
- }
-
- QByteArray data = f.readAll();
- QmlComponent c(&d->engine, data, QUrl(d->testDirectory + QLatin1String("/manifest.qml")));
- QObject *o = c.create();
- TestLog *log = qobject_cast<TestLog *>(o);
- if (log) {
- log->setParent(this);
- d->playbackTestData.actions() = log->actions();
- qWarning() << "QFxTestEngine: Playback ON," << d->playbackTestData.actions().count() << "actions";
- } else {
- delete o;
- qWarning() << "QFxTestEngine: File" << fileName << "is corrupt.";
- return;
- }
- }
-
- if (d->testMode != NoTest) {
- QUnifiedTimer::instance()->setConsistentTiming(true);
- QObject::connect(canvas, SIGNAL(framePainted()),
- this, SLOT(framePainted()));
-
- canvas->installEventFilter(this);
- for (int ii = 0; ii < d->playbackTestData.actions().count(); ++ii) {
- TestObject *o = d->playbackTestData.actions().at(ii);
- if (TestMouse *m = qobject_cast<TestMouse *>(o))
- d->toPost << m;
- else if (TestKey *k = qobject_cast<TestKey *>(o))
- d->toPost << k;
- }
- }
-}
-
-QFxTestEngine::~QFxTestEngine()
-{
- delete d; d = 0;
-}
-
-void QFxTestEngine::framePainted()
-{
- QImage img = d->canvas->asImage();
-
- if (d->fullFrame) {
- d->fullFrame = false;
- d->recordFullFrameEvent(img);
- } else {
- d->recordFrameEvent(img);
- }
-}
-
-void QFxTestEnginePrivate::recordFullFrameEvent(const QImage &img)
-{
- TestFullFrame *ff = new TestFullFrame(q);
- ff->setTime(elapsed());
- ff->setFrameId(fullFrames.count());
-
- fullFrames << img;
- testData.actions() << ff;
-
- if (testMode == QFxTestEngine::PlaybackTest) {
- TestFullFrame *pf = qobject_cast<TestFullFrame *>(playbackTestData.next());
- QString filename = testDirectory + QLatin1String("/image") + QString::number(pf->frameId()) + QLatin1String(".png");
- QImage recImg(filename);
- if (!pf || !compare(recImg, img) || pf->time() != elapsed()) {
- qDebug() << pf << pf->time() << elapsed();
- message(Fail, "FFrame mismatch");
- } else {
- message(Success, "FFrame OK");
- }
-
- testPass();
- }
-}
-
-static QByteArray toHex(uchar c)
-{
- QByteArray rv;
- uint h = c / 16;
- uint l = c % 16;
- if (h >= 10)
- rv.append(h - 10 + 'A');
- else
- rv.append(h + '0');
- if (l >= 10)
- rv.append(l - 10 + 'A');
- else
- rv.append(l + '0');
- return rv;
-}
-
-void QFxTestEnginePrivate::recordFrameEvent(const QImage &img)
-{
- QCryptographicHash hash(QCryptographicHash::Md5);
-
- hash.addData((const char *)img.bits(), img.bytesPerLine() * img.height());
-
- QByteArray result = hash.result();
- QByteArray hexResult;
- for (int ii = 0; ii < result.count(); ++ii)
- hexResult.append(toHex(result.at(ii)));
-
- TestFrame *f = new TestFrame(q);
- f->setTime(elapsed());
-
- f->setHash(QLatin1String(hexResult));
- testData.actions() << f;
- if (testMode == QFxTestEngine::PlaybackTest) {
- TestObject *o = playbackTestData.next();
- TestFrame *f = qobject_cast<TestFrame *>(o);
- if (!f || f->time() != elapsed() ||
- f->hash() != QLatin1String(hexResult)) {
- mismatchedFrames++;
- if (mismatchedFrames > MAX_MISMATCHED_FRAMES ||
- lastFrameMismatch)
- message(Fail, "Frame mismatch");
- else
- message(Success, "Frame mismatch - within tolerance");
- lastFrameMismatch = true;
- } else {
- message(Success, "Frame OK");
- lastFrameMismatch = false;
- }
-
- testPass();
- }
-}
-
-void QFxTestEnginePrivate::updateCurrentTime(int)
-{
- if (status != Working)
- return;
-
- while(!toPost.isEmpty()) {
- int t = elapsed();
- TestObject *o = toPost.first();
- if (testMode == QFxTestEngine::RecordTest)
- o->setTime(t);
- else if (o->time() != t)
- return;
- toPost.takeFirst();
- if (TestMouse *m = qobject_cast<TestMouse *>(o)) {
- QMouseEvent e((QEvent::Type)m->type(), m->pos(), m->globalPos(), (Qt::MouseButton)m->button(), (Qt::MouseButtons)m->buttons(), (Qt::KeyboardModifiers)0);
- postedEvents.insert(&e);
- QApplication::sendEvent(canvas, &e);
- } else if (TestKey *k = qobject_cast<TestKey *>(o)) {
- QKeyEvent e((QEvent::Type)k->type(), k->key(), (Qt::KeyboardModifiers)k->modifiers(), k->text());
- postedEvents.insert(&e);
- QApplication::sendEvent(canvas, &e);
- }
- }
-}
-
-bool QFxTestEngine::eventFilter(QObject *, QEvent *event)
-{
- if (d->status != QFxTestEnginePrivate::Working)
- return false;
-
- if (event->type() == QEvent::MouseButtonPress ||
- event->type() == QEvent::MouseButtonDblClick ||
- event->type() == QEvent::MouseButtonRelease ||
- event->type() == QEvent::MouseMove) {
- if (d->testMode == RecordTest && d->postedEvents.contains(event)) {
- d->postedEvents.remove(event);
- } else {
- d->recordMouseEvent(static_cast<QMouseEvent *>(event));
- return d->testMode == RecordTest;
- }
- } else if (event->type() == QEvent::KeyPress ||
- event->type() == QEvent::KeyRelease) {
- QKeyEvent *key = static_cast<QKeyEvent *>(event);
- if (key->key() < Qt::Key_F1 || key->key() > Qt::Key_F9) {
-
- if (d->testMode == RecordTest && d->postedEvents.contains(event)) {
- d->postedEvents.remove(event);
- } else {
- d->recordKeyEvent(key);
- return d->testMode == RecordTest;
- }
-
- }
- }
-
- return false;
-}
-
-void QFxTestEnginePrivate::recordMouseEvent(QMouseEvent *e)
-{
- TestMouse *m = new TestMouse(q);
- m->setTime(elapsed());
- m->setType(e->type());
- m->setButton(e->button());
- m->setButtons(e->buttons());
- m->setGlobalPos(e->globalPos());
- m->setPos(e->pos());
- testData.actions() << m;
-
- if (testMode == QFxTestEngine::PlaybackTest) {
- TestMouse *m = qobject_cast<TestMouse *>(playbackTestData.next());
- if (!m || m->time() != elapsed() ||
- m->type() != e->type() ||
- m->button() != e->button() ||
- m->buttons() != e->buttons() ||
-// m->globalPos() != e->globalPos() ||
- m->pos() != e->pos()) {
- if (m)
- qWarning() << m->time() << elapsed();
- message(Fail, "Mouse mismatch");
- } else
- message(Success, "Mouse OK");
-
- testPass();
- } else {
- toPost << m;
- }
-
-}
-
-void QFxTestEnginePrivate::recordKeyEvent(QKeyEvent *e)
-{
- TestKey *k = new TestKey(q);
- k->setTime(elapsed());
- k->setType(e->type());
- k->setModifiers(e->QInputEvent::modifiers());
- k->setText(e->text());
- k->setKey(e->key());
- testData.actions() << k;
- if (testMode == QFxTestEngine::PlaybackTest) {
- TestKey *f = qobject_cast<TestKey *>(playbackTestData.next());
- if (!f || f->time() != elapsed() ||
- f->type() != e->type() ||
- f->modifiers() != e->QInputEvent::modifiers() ||
- f->text() != e->text() ||
- f->key() != e->key())
- message(Fail, "Key mismatch");
- else
- message(Success, "Key OK");
-
- testPass();
- } else {
- toPost << k;
- }
-}
-
-void QFxTestEngine::captureFullFrame()
-{
- d->fullFrame = true;
-}
-
-void QFxTestEnginePrivate::message(MessageType t, const char *message)
-{
- if (exitOnFail)
- qWarning("%s", message);
- if (t == Fail) {
- if (exitOnFail) {
- save(QLatin1String("manifest-fail.qml"), false);
- qFatal("Failed");
- } else {
- status = Failed;
- }
- }
-}
-
-void QFxTestEnginePrivate::save(const QString &filename, bool images)
-{
- qWarning() << "QFxTestEngine: Writing test data";
-
- QFile manifest(testDirectory + QLatin1String("/") + filename);
- manifest.open(QIODevice::WriteOnly);
- testData.save(&manifest);
- manifest.close();
-
- if (images) {
- for (int ii = 0; ii < fullFrames.count(); ++ii)
- fullFrames.at(ii).save(testDirectory + QLatin1String("/image") + QString::number(ii) + QLatin1String(".png"));
- }
-}
-
-void QFxTestEngine::save()
-{
- if (d->testMode != RecordTest)
- return;
-
- d->save(QLatin1String("manifest.qml"));
-}
-
-void QFxTestEnginePrivate::testPass()
-{
- if (playbackTestData.atEnd()) {
- qWarning("Test PASSED");
- if (exitOnFail) {
- save(QLatin1String("manifest-play.qml"));
- exit(0);
- } else {
- status = Passed;
- }
- }
-}
-
-bool QFxTestEngine::runTest()
-{
- d->exitOnFail = false;
- while(d->status == QFxTestEnginePrivate::Working)
- QApplication::processEvents();
- d->exitOnFail = true;
- qWarning() << d->status;
- return d->status == QFxTestEnginePrivate::Passed;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/test/qfxtestengine.h b/src/declarative/test/qfxtestengine.h
deleted file mode 100644
index bce8eec..0000000
--- a/src/declarative/test/qfxtestengine.h
+++ /dev/null
@@ -1,85 +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 _QFXTESTENGINE_H_
-#define _QFXTESTENGINE_H_
-
-#include <QtCore/QObject>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QSimpleCanvas;
-class QFxTestEnginePrivate;
-class Q_DECLARATIVE_EXPORT QFxTestEngine : public QObject
-{
-Q_OBJECT
-public:
- enum TestMode { NoTest, RecordTest, PlaybackTest };
-
- QFxTestEngine(TestMode, const QString &,
- QSimpleCanvas *canvas, QObject * = 0);
- virtual ~QFxTestEngine();
-
- void captureFullFrame();
- void save();
-
- bool runTest();
-
-protected:
- virtual bool eventFilter(QObject *, QEvent *);
-
-private Q_SLOTS:
- void framePainted();
-
-private:
- QFxTestEnginePrivate *d;
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // _QFXTESTENGINE_H_
diff --git a/src/declarative/test/qfxtestobjects.cpp b/src/declarative/test/qfxtestobjects.cpp
deleted file mode 100644
index 5035b28..0000000
--- a/src/declarative/test/qfxtestobjects.cpp
+++ /dev/null
@@ -1,354 +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 "qfxtestobjects.h"
-#include <qml.h>
-#include <QDebug>
-#include <QTextStream>
-
-QML_DECLARE_TYPE(TestObject)
-QML_DECLARE_TYPE(TestFrame)
-QML_DECLARE_TYPE(TestFullFrame)
-QML_DECLARE_TYPE(TestMouse)
-QML_DECLARE_TYPE(TestKey)
-QML_DECLARE_TYPE(TestLog)
-
-QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(TestObject,TestObject)
-QML_DEFINE_TYPE(TestFrame,TestFrame)
-QML_DEFINE_TYPE(TestFullFrame,TestFullFrame)
-QML_DEFINE_TYPE(TestMouse,TestMouse)
-QML_DEFINE_TYPE(TestKey,TestKey)
-QML_DEFINE_TYPE(TestLog,TestLog)
-
-static QString padding(int pad)
-{
- QString p;
- while (pad--)
- p += QLatin1Char(' ');
- return p;
-}
-
-TestObject::TestObject(QObject *parent)
-: QObject(parent), _time(-1)
-{
-}
-
-int TestObject::time() const
-{
- return _time;
-}
-
-void TestObject::setTime(int t)
-{
- if (t == _time)
- return;
- _time = t;
- emit dataChanged();
-}
-
-void TestObject::save(QTextStream &device, int pad)
-{
- device << padding(pad) << QLatin1String("TestObject {") << endl;
- device << padding(pad) << QLatin1String("time: ") << QString::number(time()) << endl;
- device << padding(pad) << QLatin1String("}") << endl;
-}
-
-
-TestFrame::TestFrame(QObject *parent)
-: TestObject(parent)
-{
-}
-
-QString TestFrame::hash() const
-{
- return _hash;
-}
-
-void TestFrame::setHash(const QString &h)
-{
- if (_hash == h)
- return;
- _hash = h;
- emit frameChanged();
-}
-
-void TestFrame::save(QTextStream &device, int pad)
-{
- device << padding(pad) << QLatin1String("TestFrame {") << endl;
- device << padding(pad+4) << QLatin1String("time: ") << QLatin1String(QByteArray::number(time())) << endl;
- device << padding(pad+4)<< QLatin1String("hash: '") << hash() << QLatin1String("'") << endl;
- device << padding(pad) << QLatin1Char('}') << endl;
-}
-
-TestFullFrame::TestFullFrame(QObject *parent)
-: TestObject(parent), _frameId(-1)
-{
-}
-
-int TestFullFrame::frameId() const
-{
- return _frameId;
-}
-
-void TestFullFrame::setFrameId(int id)
-{
- if (id == _frameId)
- return;
- _frameId = id;
- emit frameChanged();
-}
-
-void TestFullFrame::save(QTextStream &device, int pad)
-{
- device << padding(pad) << QLatin1String("TestFullFrame {") << endl;
- device << padding(pad+4) << QLatin1String("time: ") << QLatin1String(QByteArray::number(time())) << endl;
- device << padding(pad+4) << QLatin1String("frameId: ") << QLatin1String(QByteArray::number(frameId())) << endl;
- device << padding(pad) << QLatin1String("}") << endl;
-}
-
-TestMouse::TestMouse(QObject *parent)
-: TestObject(parent), _type(-1), _button(-1), _buttons(-1)
-{
-}
-
-int TestMouse::type() const
-{
- return _type;
-}
-
-void TestMouse::setType(int t)
-{
- if (_type == t)
- return;
- _type = t;
- emit mouseChanged();
-}
-
-int TestMouse::button() const
-{
- return _button;
-}
-
-void TestMouse::setButton(int b)
-{
- if (b == _button)
- return;
- _button = b;
- emit mouseChanged();
-}
-
-int TestMouse::buttons() const
-{
- return _buttons;
-}
-
-void TestMouse::setButtons(int buttons)
-{
- if (_buttons == buttons)
- return;
- _buttons = buttons;
- emit mouseChanged();
-}
-
-QPoint TestMouse::globalPos() const
-{
- return _globalPos;
-}
-
-void TestMouse::setGlobalPos(const QPoint &g)
-{
- if (_globalPos == g)
- return;
- _globalPos = g;
- emit mouseChanged();
-}
-
-QPoint TestMouse::pos() const
-{
- return _pos;
-}
-
-void TestMouse::setPos(const QPoint &p)
-{
- if (p == _pos)
- return;
- _pos = p;
- emit mouseChanged();
-}
-
-void TestMouse::save(QTextStream &device, int pad)
-{
- device << padding(pad) << QLatin1String("TestMouse {") << endl;
- device << padding(pad+4) << QLatin1String("time: ") << QString::number(time()) << endl;
- device << padding(pad+4) << QLatin1String("type: ") << QString::number(type()) << endl;
- device << padding(pad+4) << QLatin1String("button: ") << QString::number(button()) << endl;
- device << padding(pad+4) << QLatin1String("buttons: ") << QString::number(buttons()) << endl;
- device << padding(pad+4) << QLatin1String("globalPos: '") << QString::number(globalPos().x()) + QLatin1String(",") + QString::number(globalPos().y()) << QLatin1String("'") << endl;
- device << padding(pad+4) << QLatin1String("pos: '") << QString::number(pos().x()) + QLatin1String(",") + QString::number(pos().y()) << QLatin1String("'") << endl;
- device << padding(pad) << QLatin1String("}") << endl;
-}
-
-TestKey::TestKey(QObject *parent)
-: TestObject(parent), _type(-1), _modifiers(-1), _key(-1)
-{
-}
-
-int TestKey::type() const
-{
- return _type;
-}
-
-void TestKey::setType(int t)
-{
- if (t == _type)
- return;
- _type = t;
- emit keyChanged();
-}
-
-int TestKey::modifiers() const
-{
- return _modifiers;
-}
-
-void TestKey::setModifiers(int m)
-{
- if (m == _modifiers)
- return;
- _modifiers = m;
- emit keyChanged();
-}
-
-QString TestKey::text() const
-{
- return _text;
-}
-
-void TestKey::setText(const QString &t)
-{
- if (_text == t)
- return;
- _text = t;
- emit keyChanged();
-}
-
-int TestKey::key() const
-{
- return _key;
-}
-
-void TestKey::setKey(int k)
-{
- if (_key == k)
- return;
- _key = k;
- emit keyChanged();
-}
-
-void TestKey::save(QTextStream &device, int pad)
-{
- device << padding(pad) << QLatin1String("TestKey {") << endl;
- device << padding(pad+4) << QLatin1String("time: ") << QString::number(time()) << endl;
- device << padding(pad+4) << QLatin1String("type: ") << QString::number(type()) << endl;
- device << padding(pad+4) << QLatin1String("modifiers: ") << QString::number(modifiers()) << endl;
- device << padding(pad+4) << QLatin1String("key: ") << QString::number(key()) << endl;
- if (key() != Qt::Key_Escape)
- device << padding(pad+4) << QLatin1String("text: '") << text() << QLatin1String("'")<< endl;
- device << padding(pad) << QLatin1String("}") << endl;
-}
-
-TestLog::TestLog(QObject *parent)
-: QObject(parent), _current(0)
-{
-}
-
-QList<TestObject *> *TestLog::qmlActions()
-{
- return &_actions;
-}
-
-QList<TestObject *> &TestLog::actions()
-{
- return _actions;
-}
-
-bool lessThan(TestObject *lhs, TestObject *rhs)
-{
- return lhs->time() < rhs->time();
-}
-
-void TestLog::save(QIODevice *device)
-{
- // Order correctly
- qStableSort(_actions.begin(), _actions.end(), lessThan);
-
- QTextStream writer(device);
- writer << QLatin1String("TestLog {") << endl;
- for (int ii = 0; ii < _actions.count(); ++ii)
- _actions.at(ii)->save(writer, 4);
- writer << QLatin1String("}") << endl;
-}
-
-TestObject *TestLog::next()
-{
- if (atEnd())
- return 0;
- TestObject *rv = _actions.at(_current);
- _current++;
- return rv;
-}
-
-bool TestLog::atEnd() const
-{
- if (_current >= _actions.count())
- return true;
- else
- return false;
-}
-
-int TestLog::current() const
-{
- return _current;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/test/qfxtestobjects.h b/src/declarative/test/qfxtestobjects.h
deleted file mode 100644
index c8686ad..0000000
--- a/src/declarative/test/qfxtestobjects.h
+++ /dev/null
@@ -1,211 +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 _QFXTESTOBJECTS_H_
-#define _QFXTESTOBJECTS_H_
-
-#include <QtCore/QObject>
-#include <QtCore/QPoint>
-#include <QtCore/QList>
-#include <QtCore/QTextStream>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QIODevice;
-class TestObject : public QObject
-{
-Q_OBJECT
-public:
- TestObject(QObject * = 0);
-
- Q_PROPERTY(int time READ time WRITE setTime NOTIFY dataChanged)
- int time() const;
- void setTime(int);
-
- virtual void save(QTextStream &, int pad);
-Q_SIGNALS:
- void dataChanged();
-
-private:
- int _time;
-};
-
-class TestFrame : public TestObject
-{
-Q_OBJECT
-public:
- TestFrame(QObject * = 0);
-
- Q_PROPERTY(QString hash READ hash WRITE setHash NOTIFY frameChanged)
- QString hash() const;
- void setHash(const QString &);
-
- virtual void save(QTextStream &, int pad);
-Q_SIGNALS:
- void frameChanged();
-
-private:
- QString _hash;
-};
-
-class TestFullFrame : public TestObject
-{
-Q_OBJECT
-public:
- TestFullFrame(QObject * = 0);
-
- Q_PROPERTY(int frameId READ frameId WRITE setFrameId NOTIFY frameChanged)
- int frameId() const;
- void setFrameId(int);
-
- virtual void save(QTextStream &, int pad);
-Q_SIGNALS:
- void frameChanged();
-
-private:
- int _frameId;
-};
-
-class TestMouse : public TestObject
-{
-Q_OBJECT
-public:
- TestMouse(QObject * = 0);
-
- Q_PROPERTY(int type READ type WRITE setType NOTIFY mouseChanged)
- int type() const;
- void setType(int);
-
- Q_PROPERTY(int button READ button WRITE setButton NOTIFY mouseChanged)
- int button() const;
- void setButton(int);
-
- Q_PROPERTY(int buttons READ buttons WRITE setButtons NOTIFY mouseChanged)
- int buttons() const;
- void setButtons(int);
-
- Q_PROPERTY(QPoint globalPos READ globalPos WRITE setGlobalPos NOTIFY mouseChanged)
- QPoint globalPos() const;
- void setGlobalPos(const QPoint &);
-
- Q_PROPERTY(QPoint pos READ pos WRITE setPos NOTIFY mouseChanged)
- QPoint pos() const;
- void setPos(const QPoint &);
-
- virtual void save(QTextStream &, int pad);
-
-Q_SIGNALS:
- void mouseChanged();
-
-private:
- int _type;
- int _button;
- int _buttons;
- QPoint _globalPos;
- QPoint _pos;
-};
-
-class TestKey : public TestObject
-{
-Q_OBJECT
-public:
- TestKey(QObject * = 0);
-
- Q_PROPERTY(int type READ type WRITE setType NOTIFY keyChanged)
- int type() const;
- void setType(int);
-
- Q_PROPERTY(int modifiers READ modifiers WRITE setModifiers NOTIFY keyChanged)
- int modifiers() const;
- void setModifiers(int);
-
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY keyChanged)
- QString text() const;
- void setText(const QString &);
-
- Q_PROPERTY(int key READ key WRITE setKey NOTIFY keyChanged)
- int key() const;
- void setKey(int);
-
- virtual void save(QTextStream &, int pad);
-
-Q_SIGNALS:
- void keyChanged();
-
-private:
- int _type;
- int _modifiers;
- int _key;
- QString _text;
-};
-
-class TestLog : public QObject
-{
-Q_OBJECT
-public:
- TestLog(QObject * = 0);
-
- Q_CLASSINFO("DefaultProperty", "actions")
- Q_PROPERTY(QList<TestObject *> *actions READ qmlActions)
- QList<TestObject *> *qmlActions();
-
- QList<TestObject *> &actions();
-
- int current() const;
- void save(QIODevice *);
-
- TestObject *next();
- bool atEnd() const;
-
-private:
- int _current;
- QList<TestObject *> _actions;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // _QFXTESTOBJECTS_H_
diff --git a/src/declarative/test/qfxtestview.cpp b/src/declarative/test/qfxtestview.cpp
deleted file mode 100644
index 0bd5a6b..0000000
--- a/src/declarative/test/qfxtestview.cpp
+++ /dev/null
@@ -1,82 +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 "qfxtestview.h"
-#include <QFile>
-#include <QmlComponent>
-#include <QFileInfo>
-#include <QFxItem>
-#include <QmlContext>
-#include <QFxTestEngine>
-
-
-QT_BEGIN_NAMESPACE
-QFxTestView::QFxTestView(const QString &filename, const QString &testdir)
-: testEngine(0)
-{
- QObject::connect(this, SIGNAL(sceneResized(QSize)),
- this, SLOT(setSceneSize(QSize)));
-
- testEngine = new QFxTestEngine(QFxTestEngine::PlaybackTest, testdir, this, this);
-
- qWarning() << "Testing:" << filename;
- QFile file(filename);
- file.open(QFile::ReadOnly);
- QString qml = QString::fromUtf8(file.readAll());
- setQml(qml, filename);
-
- execute();
-}
-
-void QFxTestView::setSceneSize(QSize s)
-{
- if (s.isNull())
- qWarning() << "Scene size is invalid";
- setFixedSize(s);
-}
-
-bool QFxTestView::runTest()
-{
- show();
- return testEngine->runTest();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/test/qfxtestview.h b/src/declarative/test/qfxtestview.h
deleted file mode 100644
index 353494d..0000000
--- a/src/declarative/test/qfxtestview.h
+++ /dev/null
@@ -1,73 +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 _QFXTESTVIEW_H_
-#define _QFXTESTVIEW_H_
-
-#include <QtDeclarative/QFxView>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QFxTestEngine;
-class Q_DECLARATIVE_EXPORT QFxTestView : public QFxView
-{
-Q_OBJECT
-public:
- QFxTestView(const QString &filename, const QString &testdir);
-
- bool runTest();
-
-private Q_SLOTS:
- void setSceneSize(QSize);
-
-private:
- QFxTestEngine *testEngine;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // _QFXTESTVIEW_H_
diff --git a/src/declarative/test/test.pri b/src/declarative/test/test.pri
deleted file mode 100644
index eacd00f..0000000
--- a/src/declarative/test/test.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-SOURCES += \
- test/qfxtestengine.cpp \
- test/qfxtestobjects.cpp \
- test/qfxtestview.cpp
-
-HEADERS += \
- test/qfxtestengine.h \
- test/qfxtestobjects.h \
- test/qfxtestview.h
diff --git a/src/declarative/util/qfxglobal.h b/src/declarative/util/qfxglobal.h
index 6f2a9fb..9b4aee1 100644
--- a/src/declarative/util/qfxglobal.h
+++ b/src/declarative/util/qfxglobal.h
@@ -51,39 +51,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-#if defined(QT_OPENGL_ES_1)
-#define QFX_CONFIGURATION_OPENGL1
-#elif defined(QT_OPENGL_ES_2)
-#define QFX_CONFIGURATION_OPENGL2
-#else
#define QFX_CONFIGURATION_SOFTWARE
-#endif
-
-/*
- The choices of renderer are:
- QFX_RENDER_QPAINTER
- QFX_RENDER_OPENGL1
- QFX_RENDER_OPENGL2
- To simplify code, if either of the OpenGL renderers are used,
- QFX_RENDER_OPENGL is also defined.
-*/
-
-#if defined(QFX_CONFIGURATION_OPENGL2)
-
-#define QFX_RENDER_OPENGL
-#define QFX_RENDER_OPENGL2
-
-#elif defined(QFX_CONFIGURATION_OPENGL1)
-
-#define QFX_RENDER_OPENGL
-#define QFX_RENDER_OPENGL1
-
-#elif defined(QFX_CONFIGURATION_SOFTWARE)
-
#define QFX_RENDER_QPAINTER
-#endif
-
#define DEFINE_BOOL_CONFIG_OPTION(name, var) \
static bool name() \
{ \
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 41f7db2..d83de28 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -64,8 +64,6 @@
QT_BEGIN_NAMESPACE
-DEFINE_BOOL_CONFIG_OPTION(itemTreeDump, ITEMTREE_DUMP);
-
static QVariant stringToPixmap(const QString &str)
{
//XXX need to use correct paths
@@ -103,6 +101,8 @@ public:
bool resizable;
void init();
+
+ QGraphicsScene scene;
};
/*!
@@ -132,21 +132,7 @@ public:
Constructs a QFxView with the given \a parent.
*/
QFxView::QFxView(QWidget *parent)
-: QSimpleCanvas(parent), d(new QFxViewPrivate(this))
-{
- setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
- d->init();
-}
-
-/*!
- \fn QFxView::QFxView(QSimpleCanvas::CanvasMode mode, QWidget *parent)
- \internal
- Constructs a QFxView with the given \a parent. The canvas
- \a mode can be QSimpleCanvas::GraphicsView or
- QSimpleCanvas::SimpleCanvas.
-*/
-QFxView::QFxView(QSimpleCanvas::CanvasMode mode, QWidget *parent)
-: QSimpleCanvas(mode, parent), d(new QFxViewPrivate(this))
+: QGraphicsView(parent), d(new QFxViewPrivate(this))
{
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
d->init();
@@ -165,6 +151,20 @@ void QFxViewPrivate::init()
QFxPerfTimer<QFxPerf::FontDatabase> perf;
#endif
QFontDatabase database;
+
+ q->setScene(&scene);
+
+ q->setOptimizationFlags(QGraphicsView::DontSavePainterState);
+ q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ q->setFrameStyle(0);
+
+ // These seem to give the best performance
+ q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
+ scene.setItemIndexMethod(QGraphicsScene::NoIndex);
+ q->viewport()->setFocusPolicy(Qt::NoFocus);
+
+ scene.setStickyFocus(true); //### needed for correct focus handling
}
/*!
@@ -246,44 +246,6 @@ void QFxView::execute()
}
}
-/*!
- \internal
-*/
-void QFxView::printErrorLine(const QmlError &error)
-{
- QUrl url = error.url();
- if (error.line() > 0 && error.column() > 0 &&
- url.scheme() == QLatin1String("file")) {
- QString file = url.toLocalFile();
- QFile f(file);
- if (f.open(QIODevice::ReadOnly)) {
- QByteArray data = f.readAll();
- QTextStream stream(data, QIODevice::ReadOnly);
- const QString code = stream.readAll();
- const QStringList lines = code.split(QLatin1Char('\n'));
-
- if (lines.count() >= error.line()) {
- const QString &line = lines.at(error.line() - 1);
- qWarning() << qPrintable(line);
-
- int column = qMax(0, error.column() - 1);
- column = qMin(column, line.length());
-
- QByteArray ind;
- ind.reserve(column);
- for (int i = 0; i < column; ++i) {
- const QChar ch = line.at(i);
- if (ch.isSpace())
- ind.append(ch.unicode());
- else
- ind.append(' ');
- }
- ind.append('^');
- qWarning() << ind.constData();
- }
- }
- }
-}
/*!
\internal
@@ -292,14 +254,15 @@ void QFxView::continueExecute()
{
disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
- if (!d->component){
+ if (!d->component) {
qWarning() << "Error in loading" << d->source;
return;
}
if(d->component->isError()) {
- QList<QmlError> errors = d->component->errors();
- foreach (const QmlError &error, errors) {
+ QList<QmlError> errorList = d->component->errors();
+ emit errors(errorList);
+ foreach (const QmlError &error, errorList) {
qWarning() << error;
}
@@ -309,8 +272,9 @@ void QFxView::continueExecute()
QObject *obj = d->component->create();
if(d->component->isError()) {
- QList<QmlError> errors = d->component->errors();
- foreach (const QmlError &error, errors) {
+ QList<QmlError> errorList = d->component->errors();
+ emit errors(errorList);
+ foreach (const QmlError &error, errorList) {
qWarning() << error;
}
@@ -319,10 +283,8 @@ void QFxView::continueExecute()
if (obj) {
if (QFxItem *item = qobject_cast<QFxItem *>(obj)) {
- item->QSimpleCanvasItem::setParent(QSimpleCanvas::root());
- if (itemTreeDump())
- item->dump();
+ d->scene.addItem(item);
QPerformanceLog::displayData();
QPerformanceLog::clear();
@@ -362,6 +324,10 @@ void QFxView::continueExecute()
This signal is emitted when the view is resized to \a size.
*/
+/*! \fn void QFxView::error(const QList<QmlError> &errors)
+ This signal is emitted when the qml loaded contains errors.
+ */
+
/*!
\internal
*/
@@ -453,8 +419,9 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent)
QmlComponent component(&d->engine, qml.toUtf8(), QUrl());
if(d->component->isError()) {
- QList<QmlError> errors = d->component->errors();
- foreach (const QmlError &error, errors) {
+ QList<QmlError> errorList = d->component->errors();
+ emit errors(errorList);
+ foreach (const QmlError &error, errorList) {
qWarning() << error;
}
@@ -463,8 +430,9 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent)
QObject *obj = component.create();
if(d->component->isError()) {
- QList<QmlError> errors = d->component->errors();
- foreach (const QmlError &error, errors) {
+ QList<QmlError> errorList = d->component->errors();
+ emit errors(errorList);
+ foreach (const QmlError &error, errorList) {
qWarning() << error;
}
@@ -522,7 +490,8 @@ void QFxView::resizeEvent(QResizeEvent *e)
d->root->setWidth(width());
d->root->setHeight(height());
}
- QSimpleCanvas::resizeEvent(e);
+ setSceneRect(rect());
+ QGraphicsView::resizeEvent(e);
}
/*! \fn void QFxView::focusInEvent(QFocusEvent *e)
@@ -544,12 +513,4 @@ void QFxView::focusOutEvent(QFocusEvent *)
// Do nothing (do not call QWidget::update())
}
-/*!
- \internal
- */
-void QFxView::dumpRoot()
-{
- root()->dump();
-}
-
QT_END_NAMESPACE
diff --git a/src/declarative/util/qfxview.h b/src/declarative/util/qfxview.h
index 05bf005..b423749 100644
--- a/src/declarative/util/qfxview.h
+++ b/src/declarative/util/qfxview.h
@@ -44,9 +44,9 @@
#include <QtCore/qdatetime.h>
#include <QtGui/qgraphicssceneevent.h>
+#include <QtGui/qgraphicsview.h>
#include <QtGui/qwidget.h>
#include <QtDeclarative/qfxglobal.h>
-#include <QtDeclarative/qsimplecanvas.h>
QT_BEGIN_HEADER
@@ -60,12 +60,11 @@ class QmlContext;
class QmlError;
class QFxViewPrivate;
-class Q_DECLARATIVE_EXPORT QFxView : public QSimpleCanvas
+class Q_DECLARATIVE_EXPORT QFxView : public QGraphicsView
{
Q_OBJECT
public:
explicit QFxView(QWidget *parent = 0);
- QFxView(QSimpleCanvas::CanvasMode mode, QWidget* parent = 0);
virtual ~QFxView();
@@ -86,11 +85,9 @@ public:
bool contentResizable() const;
QSize sizeHint() const;
- void dumpRoot();
-
- static void printErrorLine(const QmlError &);
Q_SIGNALS:
void sceneResized(QSize size);
+ void errors(const QList<QmlError> &error);
private Q_SLOTS:
void continueExecute();
diff --git a/src/declarative/util/qmlpalette.cpp b/src/declarative/util/qmlpalette.cpp
index 670966d..40cfa71 100644
--- a/src/declarative/util/qmlpalette.cpp
+++ b/src/declarative/util/qmlpalette.cpp
@@ -41,6 +41,7 @@
#include "private/qobject_p.h"
#include "qmlpalette.h"
+#include <QApplication>
QT_BEGIN_NAMESPACE
@@ -63,7 +64,9 @@ QmlPalette::QmlPalette(QObject *parent)
: QObject(*(new QmlPalettePrivate), parent)
{
Q_D(QmlPalette);
+ d->palette = qApp->palette();
d->group = QPalette::Active;
+ qApp->installEventFilter(this);
}
QmlPalette::~QmlPalette()
@@ -148,6 +151,16 @@ QColor QmlPalette::highlightedText() const
return d->palette.color(d->group, QPalette::HighlightedText);
}
+QColor QmlPalette::lighter(const QColor& color) const
+{
+ return color.lighter();
+}
+
+QColor QmlPalette::darker(const QColor& color) const
+{
+ return color.darker();
+}
+
void QmlPalette::setColorGroup(QPalette::ColorGroup colorGroup)
{
Q_D(QmlPalette);
@@ -160,4 +173,26 @@ QPalette QmlPalette::palette() const
return d->palette;
}
+bool QmlPalette::eventFilter(QObject *watched, QEvent *event)
+{
+ if (watched == qApp) {
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
+ return false;
+ }
+ }
+ return QObject::eventFilter(watched, event);
+}
+
+bool QmlPalette::event(QEvent *event)
+{
+ Q_D(QmlPalette);
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ d->palette = qApp->palette();
+ emit paletteChanged();
+ return true;
+ }
+ return QObject::event(event);
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlpalette.h b/src/declarative/util/qmlpalette.h
index f176764..7f26f9a 100644
--- a/src/declarative/util/qmlpalette.h
+++ b/src/declarative/util/qmlpalette.h
@@ -62,19 +62,19 @@ public:
QmlPalette(QObject *parent=0);
~QmlPalette();
- Q_PROPERTY(QColor window READ window CONSTANT)
- Q_PROPERTY(QColor windowText READ windowText CONSTANT)
- Q_PROPERTY(QColor base READ base CONSTANT)
- Q_PROPERTY(QColor alternateBase READ alternateBase CONSTANT)
- Q_PROPERTY(QColor button READ button CONSTANT)
- Q_PROPERTY(QColor buttonText READ buttonText CONSTANT)
- Q_PROPERTY(QColor light READ light CONSTANT)
- Q_PROPERTY(QColor midlight READ midlight CONSTANT)
- Q_PROPERTY(QColor dark READ dark CONSTANT)
- Q_PROPERTY(QColor mid READ mid CONSTANT)
- Q_PROPERTY(QColor shadow READ shadow CONSTANT)
- Q_PROPERTY(QColor highlight READ highlight CONSTANT)
- Q_PROPERTY(QColor highlightedText READ highlightedText CONSTANT)
+ Q_PROPERTY(QColor window READ window NOTIFY paletteChanged)
+ Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged)
+ Q_PROPERTY(QColor base READ base NOTIFY paletteChanged)
+ Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged)
+ Q_PROPERTY(QColor button READ button NOTIFY paletteChanged)
+ Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged)
+ Q_PROPERTY(QColor light READ light NOTIFY paletteChanged)
+ Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged)
+ Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged)
+ Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged)
+ Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged)
+ Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged)
+ Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
QColor window() const;
QColor windowText() const;
@@ -98,8 +98,14 @@ public:
void setColorGroup(QPalette::ColorGroup);
+ bool virtual eventFilter(QObject *watched, QEvent *event);
+ bool virtual event(QEvent *event);
+
+ Q_INVOKABLE QColor lighter(const QColor&) const;
+ Q_INVOKABLE QColor darker(const QColor&) const;
+
Q_SIGNALS:
- void updated();
+ void paletteChanged();
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp
index 5e86b73..ba4e160 100644
--- a/src/declarative/util/qmltransitionmanager.cpp
+++ b/src/declarative/util/qmltransitionmanager.cpp
@@ -109,13 +109,10 @@ void QmlTransitionManager::transition(const QList<Action> &list,
QmlStateOperation::ActionList applyList = list;
// Determine which actions are binding changes.
foreach(const Action &action, applyList) {
- if (action.toBinding) {
+ if (action.toBinding)
d->bindingsList << action;
- if (action.fromBinding)
- action.property.setBinding(0); // Disable current binding
- } else if (action.fromBinding) {
+ if (action.fromBinding)
action.property.setBinding(0); // Disable current binding
- }
}
// Animated transitions need both the start and the end value for
@@ -156,7 +153,7 @@ void QmlTransitionManager::transition(const QList<Action> &list,
continue;
if (action.toBinding)
- action.property.setBinding(0);
+ action.property.setBinding(0); // Make sure this is disabled during the transition
action.property.write(action.fromValue);
}