summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/3rdparty/3rdparty.pri3
-rw-r--r--src/declarative/3rdparty/qlistmodelinterface.cpp116
-rw-r--r--src/declarative/3rdparty/qlistmodelinterface.h49
-rw-r--r--src/declarative/canvas/qsimplecanvas.h12
-rw-r--r--src/declarative/debugger/debugger.pri6
-rw-r--r--src/declarative/debugger/qmlcanvasdebugger.cpp240
-rw-r--r--src/declarative/debugger/qmlcanvasdebugger_p.h89
-rw-r--r--src/declarative/debugger/qmldebugger.cpp13
-rw-r--r--src/declarative/debugger/qmldebugger.h4
-rw-r--r--src/declarative/qml/qmldom.cpp17
-rw-r--r--src/declarative/qml/qmldom.h3
-rw-r--r--src/declarative/qml/qmldom_p.h3
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp24
-rw-r--r--src/declarative/qml/qmlscriptparser_p.h18
-rw-r--r--src/declarative/util/qfxview.cpp1
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp9
-rw-r--r--tools/qmlviewer/main.cpp18
17 files changed, 566 insertions, 59 deletions
diff --git a/src/declarative/3rdparty/3rdparty.pri b/src/declarative/3rdparty/3rdparty.pri
index 5350fcf..fc78cb2 100644
--- a/src/declarative/3rdparty/3rdparty.pri
+++ b/src/declarative/3rdparty/3rdparty.pri
@@ -1,2 +1,5 @@
HEADERS += \
3rdparty/qlistmodelinterface.h\
+
+SOURCES += \
+ 3rdparty/qlistmodelinterface.cpp \
diff --git a/src/declarative/3rdparty/qlistmodelinterface.cpp b/src/declarative/3rdparty/qlistmodelinterface.cpp
new file mode 100644
index 0000000..7e50378
--- /dev/null
+++ b/src/declarative/3rdparty/qlistmodelinterface.cpp
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** 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 "qlistmodelinterface.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QListModelInterface
+ \brief The QListModelInterface class can be subclassed to provide C++ models to QFx Views
+
+ This class is comprised primarily of pure virtual functions which
+ you must implement in a subclass. You can then use the subclass
+ as a model for a QFx view, such as a QFxListView.
+*/
+
+/*! \fn QListModelInterface::QListModelInterface(QObject *parent)
+ Constructs a QListModelInterface with the specified \a parent.
+*/
+
+ /*! \fn QListModelInterface::QListModelInterface(QObjectPrivate &dd, QObject *parent)
+
+ \internal
+ */
+
+/*! \fn QListModelInterface::~QListModelInterface()
+ The destructor is virtual.
+ */
+
+/*! \fn int QListModelInterface::count() const
+ Returns the number of data entries in the model.
+*/
+
+/*! \fn QHash_int QListModelInterface::data(int index, const QList_int &roles) const
+ Returns the data at the given \a index for the specifed \a roles.
+*/
+
+/*! \fn bool QListModelInterface::setData(int index, const QHash_int &values)
+ Sets the data at the given \a index. \a values is a mapping of
+ QVariant values to roles.
+*/
+
+/*! \fn bool QListModelInterface::setData(int index, const QVariant &value, int role)
+ This convenience function builds a QHash_int from
+ the specified \a role and \a value and calls the other setData()
+ with the QHash and the \a index.
+*/
+
+/*! \fn QList_int QListModelInterface::roles() const
+ Returns the list of roles for which the list model interface
+ provides data.
+*/
+
+/*! \fn QString QListModelInterface::toString(int role) const
+ Returns a string description of the specified \a role.
+*/
+
+/*! \enum QListModelInterface::Roles
+
+ Values for representing roles.
+
+ \value TextRole
+
+ \value IconRole
+*/
+
+/*!
+ \typedef QListModelInterface::QHash_int
+
+ Synonym for QHash<int, QVariant>.
+*/
+
+/*!
+ \typedef QListModelInterface::QList_int
+
+ Synonym for QList<int>.
+*/
+QT_END_NAMESPACE
diff --git a/src/declarative/3rdparty/qlistmodelinterface.h b/src/declarative/3rdparty/qlistmodelinterface.h
index 446b89b..8a0cf44 100644
--- a/src/declarative/3rdparty/qlistmodelinterface.h
+++ b/src/declarative/3rdparty/qlistmodelinterface.h
@@ -53,16 +53,10 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-/*!
- \class QListModelInterface
- \brief The QListModelInterface class can be subclassed to provide C++ models to QFx Views
-
- This class is comprised primarily of pure virtual functions which you need to implement in a subclass. You can then use the subclass as a model for a QFx view, such as a QFxListView.
-*/
class Q_DECLARATIVE_EXPORT QListModelInterface : public QObject
{
Q_OBJECT
-public:
+ public:
QListModelInterface(QObject *parent = 0) : QObject(parent) {}
virtual ~QListModelInterface() {}
@@ -72,47 +66,36 @@ public:
IconRole = Qt::DecorationRole
};
- /*!
- Returns the number of data entries in the model.
- */
virtual int count() const = 0;
- /*!
- Returns the data at the given \a index for the specifed \a roles.
- */
- virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const = 0;
- /*!
- Sets the data at the given \a index.\a values is a mapping of QVariant values to roles.
- */
- virtual bool setData(int index, const QHash<int,QVariant> &values) { Q_UNUSED(index); Q_UNUSED(values); return false; }
- /*!
- This convinience function can be used to set the data for one specific role. It internally uses the other setData and does not need to be reimplemented.
- */
+
+ typedef QHash<int, QVariant> QHash_int;
+ typedef QList<int> QList_int;
+ virtual QHash_int data(int index, const QList_int &roles = QList_int()) const = 0;
+
+ virtual bool setData(int index, const QHash_int &values)
+ { Q_UNUSED(index); Q_UNUSED(values); return false; }
+
inline bool setData(int index, const QVariant &value, int role)
{
- QHash<int,QVariant> values;
+ QHash_int values;
values.insert(role, value);
return setData(index, values);
}
- /*!
- Returns which roles the list provides data for.
- */
- virtual QList<int> roles() const = 0;
- /*!
- Returns a string description of the specified \a role.
- */
+ virtual QList_int roles() const = 0;
virtual QString toString(int role) const = 0;
//void bind(int index, int role, QObject *object, const char *propertyName, bool readOnly = true);
-Q_SIGNALS:
+ Q_SIGNALS:
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
void itemsMoved(int from, int to, int count);
- void itemsChanged(int index, int count, const QList<int> &roles);
+ void itemsChanged(int index, int count, const QList_int &roles);
-protected:
- QListModelInterface(QObjectPrivate &dd, QObject *parent) : QObject(dd, parent) {}
+ protected:
+ QListModelInterface(QObjectPrivate &dd, QObject *parent)
+ : QObject(dd, parent) {}
};
diff --git a/src/declarative/canvas/qsimplecanvas.h b/src/declarative/canvas/qsimplecanvas.h
index 20dab28..d57ada4 100644
--- a/src/declarative/canvas/qsimplecanvas.h
+++ b/src/declarative/canvas/qsimplecanvas.h
@@ -48,12 +48,12 @@
#include <QtGui/qmatrix4x4.h>
#endif
-#include <QTransform>
-#include <QPainter>
-#include <QDebug>
-#include <QWidget>
-#include <QImage>
-#include <QKeyEvent>
+#include <QtGui/QTransform>
+#include <QtGui/QPainter>
+#include <QtCore/QDebug>
+#include <QtGui/QWidget>
+#include <QtGui/QImage>
+#include <QtGui/QKeyEvent>
QT_BEGIN_HEADER
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri
index 4df7e51..c386d74 100644
--- a/src/declarative/debugger/debugger.pri
+++ b/src/declarative/debugger/debugger.pri
@@ -2,10 +2,12 @@ SOURCES += debugger/qmldebugger.cpp \
debugger/qmldebuggerstatus.cpp \
debugger/qmlpropertyview.cpp \
debugger/qmlwatches.cpp \
- debugger/qmlobjecttree.cpp
+ debugger/qmlobjecttree.cpp \
+ debugger/qmlcanvasdebugger.cpp
HEADERS += debugger/qmldebugger.h \
debugger/qmldebuggerstatus.h \
debugger/qmlpropertyview_p.h \
debugger/qmlwatches_p.h \
- debugger/qmlobjecttree_p.h
+ debugger/qmlobjecttree_p.h \
+ debugger/qmlcanvasdebugger_p.h
diff --git a/src/declarative/debugger/qmlcanvasdebugger.cpp b/src/declarative/debugger/qmlcanvasdebugger.cpp
new file mode 100644
index 0000000..fe57bf4
--- /dev/null
+++ b/src/declarative/debugger/qmlcanvasdebugger.cpp
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qmlcanvasdebugger_p.h>
+#include <private/qmlwatches_p.h>
+#include <QtDeclarative/qsimplecanvas.h>
+#include <QtGui/qboxlayout.h>
+#include <QtGui/qpushbutton.h>
+#include <QtGui/qspinbox.h>
+#include <QtGui/qsplitter.h>
+#include <QtGui/qtreewidget.h>
+
+#include <QtDeclarative/qfxrect.h>
+#include <QtDeclarative/qfximage.h>
+
+QmlCanvasDebugger::QmlCanvasDebugger(QmlWatches *w, QWidget *parent)
+: QWidget(parent), m_watches(w), m_tree(0), m_canvas(0), m_canvasRoot(0), m_debugCanvas(0),
+ m_selected(0)
+{
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setContentsMargins(0,0,0,0);
+ layout->setSpacing(0);
+ setLayout(layout);
+ QHBoxLayout *hlayout = new QHBoxLayout;
+ hlayout->setContentsMargins(0,0,0,0);
+ hlayout->addStretch(2);
+ hlayout->setSpacing(0);
+ layout->addLayout(hlayout);
+ QSpinBox *x = new QSpinBox(this);
+ x->setSingleStep(50);
+ x->setMaximum(10000);
+ x->setMinimum(-10000);
+ QObject::connect(x, SIGNAL(valueChanged(int)), this, SLOT(setX(int)));
+ QSpinBox *y = new QSpinBox(this);
+ y->setSingleStep(50);
+ y->setMaximum(10000);
+ y->setMinimum(-10000);
+ QObject::connect(y, SIGNAL(valueChanged(int)), this, SLOT(setY(int)));
+ hlayout->addWidget(x);
+ hlayout->addWidget(y);
+ QPushButton *pb = new QPushButton("Refresh", this);
+ QObject::connect(pb, SIGNAL(clicked()), this, SLOT(refresh()));
+ hlayout->addWidget(pb);
+
+ QSplitter *splitter = new QSplitter(this);
+
+ m_tree = new QTreeWidget(this);
+ QObject::connect(m_tree, SIGNAL(itemExpanded(QTreeWidgetItem*)),
+ this, SLOT(itemExpanded(QTreeWidgetItem*)));
+ QObject::connect(m_tree, SIGNAL(itemCollapsed(QTreeWidgetItem*)),
+ this, SLOT(itemCollapsed(QTreeWidgetItem*)));
+ QObject::connect(m_tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
+ this, SLOT(itemClicked(QTreeWidgetItem*)));
+ m_canvas = new QSimpleCanvas(QSimpleCanvas::SimpleCanvas, this);
+ m_canvasRoot = new QSimpleCanvasItem;
+ m_canvasRoot->setParent(m_canvas->root());
+ splitter->addWidget(m_tree);
+ splitter->addWidget(m_canvas);
+ splitter->setStretchFactor(1, 2);
+ layout->addWidget(splitter);
+}
+
+void QmlCanvasDebugger::refresh()
+{
+ setCanvas(m_debugCanvas);
+}
+
+class QmlCanvasDebuggerItem : public QTreeWidgetItem
+{
+public:
+ QmlCanvasDebuggerItem(QTreeWidget *tree)
+ : QTreeWidgetItem(tree), me(0), img(0)
+ {
+ }
+
+ QmlCanvasDebuggerItem(QTreeWidgetItem *item)
+ : QTreeWidgetItem(item), me(0), img(0)
+ {
+ }
+
+ QPointer<QObject> them;
+ QFxRect *me;
+ QFxImage *img;
+};
+
+void QmlCanvasDebugger::itemExpanded(QTreeWidgetItem *i)
+{
+ QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i);
+ if(item->me)
+ item->me->setOpacity(1);
+}
+
+void QmlCanvasDebugger::setOpacityRecur(QTreeWidgetItem *i, qreal op)
+{
+ QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i);
+ if(item->img)
+ item->img->setOpacity(op);
+
+ for(int ii = 0; ii < item->childCount(); ++ii)
+ setOpacityRecur(item->child(ii), op);
+}
+
+void QmlCanvasDebugger::itemClicked(QTreeWidgetItem *i)
+{
+ QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i);
+ if(item->them)
+ emit objectClicked(m_watches->objectId(item->them));
+
+ if(m_selected) {
+ setOpacityRecur(m_selected, 0);
+ m_selected = 0;
+ }
+
+ m_selected = item;
+ setOpacityRecur(m_selected, 1);
+}
+
+void QmlCanvasDebugger::itemCollapsed(QTreeWidgetItem *i)
+{
+ QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i);
+ if(item->me)
+ item->me->setOpacity(0);
+}
+
+void QmlCanvasDebugger::clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, QSimpleCanvasItem *them)
+{
+ const QList<QSimpleCanvasItem *> &children = them->children();
+
+ foreach(QSimpleCanvasItem *child, children) {
+ QmlCanvasDebuggerItem *childItem = new QmlCanvasDebuggerItem(item);
+ childItem->setText(0, QmlWatches::objectToString(child));
+ childItem->setExpanded(true);
+
+ QFxRect *rect = new QFxRect;
+ rect->setParent(me);
+ rect->setX(child->x());
+ rect->setY(child->y());
+ rect->setZ(child->z());
+ rect->setWidth(child->width());
+ rect->setHeight(child->height());
+ rect->setTransformOrigin(child->transformOrigin());
+ rect->setScale(child->scale());
+ rect->setFlip(child->flip());
+ rect->setTransform(child->transform());
+
+ if(child->hasActiveFocus())
+ rect->setColor(QColor(0, 0, 0, 10));
+ else if(child->options() & QSimpleCanvasItem::IsFocusPanel)
+ rect->setColor(QColor(0, 255, 0, 10));
+ else if(child->options() & QSimpleCanvasItem::IsFocusRealm)
+ rect->setColor(QColor(0, 0, 255, 10));
+ else
+ rect->setColor(QColor(255, 0, 0, 10));
+
+ if(child->width() > 0 && child->height() > 0) {
+ QPixmap pix(child->width(), child->height());
+ pix.fill(QColor(0,0,0,0));
+ QPainter p(&pix);
+ child->paintContents(p);
+ QFxImage *img = new QFxImage;
+ img->setParent(rect);
+ img->setWidth(child->width());
+ img->setHeight(child->height());
+ img->setPixmap(pix);
+ img->setOpacity(0);
+ childItem->img = img;
+ }
+
+ childItem->them = child;
+ childItem->me = rect;
+
+ clone(childItem, rect, child);
+ }
+}
+
+void QmlCanvasDebugger::setX(int x)
+{
+ m_canvasRoot->setX(x);
+}
+
+void QmlCanvasDebugger::setY(int y)
+{
+ m_canvasRoot->setY(y);
+}
+
+void QmlCanvasDebugger::setCanvas(QSimpleCanvas *canvas)
+{
+ QList<QSimpleCanvasItem *> children = m_canvasRoot->children();
+ qDeleteAll(children);
+ m_tree->clear();
+ m_selected = 0;
+
+ m_debugCanvas = canvas;
+ if(!m_debugCanvas)
+ return;
+
+ QTreeWidgetItem *root = new QmlCanvasDebuggerItem(m_tree);
+ root->setText(0, "Root");
+ root->setExpanded(true);
+ clone(root, m_canvasRoot, m_debugCanvas->root());
+}
+
diff --git a/src/declarative/debugger/qmlcanvasdebugger_p.h b/src/declarative/debugger/qmlcanvasdebugger_p.h
new file mode 100644
index 0000000..80a2322
--- /dev/null
+++ b/src/declarative/debugger/qmlcanvasdebugger_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** 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 QMLCANVASDEBUGGER_P_H
+#define QMLCANVASDEBUGGER_P_H
+
+#include <QtGui/qwidget.h>
+#include <QtCore/qpointer.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSimpleCanvas;
+class QSimpleCanvasItem;
+class QTreeWidget;
+class QTreeWidgetItem;
+class QmlWatches;
+class QmlCanvasDebugger : public QWidget
+{
+ Q_OBJECT
+public:
+ QmlCanvasDebugger(QmlWatches *, QWidget *parent = 0);
+
+ void setCanvas(QSimpleCanvas *);
+
+signals:
+ void objectClicked(quint32);
+
+private slots:
+ void refresh();
+ void itemClicked(QTreeWidgetItem *);
+ void itemExpanded(QTreeWidgetItem *);
+ void itemCollapsed(QTreeWidgetItem *);
+ void setX(int);
+ void setY(int);
+
+private:
+ void setOpacityRecur(QTreeWidgetItem *, qreal);
+ void clone(QTreeWidgetItem *, QSimpleCanvasItem *me, QSimpleCanvasItem *them);
+
+ QmlWatches *m_watches;
+ QTreeWidget *m_tree;
+ QSimpleCanvas *m_canvas;
+ QSimpleCanvasItem *m_canvasRoot;
+ QPointer<QSimpleCanvas> m_debugCanvas;
+ QTreeWidgetItem *m_selected;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMLCANVASDEBUGGER_P_H
+
diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp
index 76d6b10..49ad8d9 100644
--- a/src/declarative/debugger/qmldebugger.cpp
+++ b/src/declarative/debugger/qmldebugger.cpp
@@ -61,10 +61,11 @@
#include <QtDeclarative/qmlexpression.h>
#include <private/qmlpropertyview_p.h>
#include <private/qmlwatches_p.h>
+#include <private/qmlcanvasdebugger_p.h>
QmlDebugger::QmlDebugger(QWidget *parent)
: QWidget(parent), m_tree(0), m_warnings(0), m_watchTable(0), m_watches(0),
- m_properties(0), m_text(0), m_highlightedItem(0)
+ m_canvas(0), m_properties(0), m_text(0), m_highlightedItem(0)
{
QHBoxLayout *layout = new QHBoxLayout;
setLayout(layout);
@@ -110,6 +111,11 @@ QmlDebugger::QmlDebugger(QWidget *parent)
tabs->addTab(m_properties, "Properties");
tabs->setCurrentWidget(m_properties);
+ m_canvas = new QmlCanvasDebugger(m_watches, this);
+ QObject::connect(m_canvas, SIGNAL(objectClicked(quint32)),
+ this, SLOT(highlightObject(quint32)));
+ tabs->addTab(m_canvas, "Canvas");
+
splitter->addWidget(tabs);
splitter->setStretchFactor(1, 2);
@@ -331,6 +337,11 @@ bool operator<(const QPair<quint32, QPair<int, QString> > &lhs,
return lhs.first < rhs.first;
}
+void QmlDebugger::setCanvas(QSimpleCanvas *c)
+{
+ m_canvas->setCanvas(c);
+}
+
void QmlDebugger::setDebugObject(QObject *obj)
{
m_tree->clear();
diff --git a/src/declarative/debugger/qmldebugger.h b/src/declarative/debugger/qmldebugger.h
index ddb846b..4641bce 100644
--- a/src/declarative/debugger/qmldebugger.h
+++ b/src/declarative/debugger/qmldebugger.h
@@ -61,6 +61,8 @@ class QmlPropertyView;
class QmlWatches;
class QmlObjectTree;
class QmlContext;
+class QmlCanvasDebugger;
+class QSimpleCanvas;
class QmlDebugger : public QWidget
{
Q_OBJECT
@@ -68,6 +70,7 @@ public:
QmlDebugger(QWidget *parent = 0);
void setDebugObject(QObject *);
+ void setCanvas(QSimpleCanvas *);
public slots:
void refresh();
@@ -85,6 +88,7 @@ private:
QTreeWidget *m_warnings;
QTableView *m_watchTable;
QmlWatches *m_watches;
+ QmlCanvasDebugger *m_canvas;
QmlPropertyView *m_properties;
QPlainTextEdit *m_text;
QPointer<QObject> m_object;
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index a31be81..4e754a3 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -143,7 +143,15 @@ int QmlDomDocument::version() const
}
/*!
- Loads a QmlDomDocument from \a data. \a data should be valid QML XML
+ Return the URIs listed by "import <dir>" in the qml.
+*/
+QList<QUrl> QmlDomDocument::imports() const
+{
+ return d->imports;
+}
+
+/*!
+ Loads a QmlDomDocument from \a data. \a data should be valid QML
data. On success, true is returned. If the \a data is malformed, false
is returned and QmlDomDocument::loadError() contains an error description.
@@ -153,11 +161,12 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
{
Q_UNUSED(engine);
d->errors.clear();
+ d->imports.clear();
QmlCompiledComponent component;
QmlCompiler compiler;
- QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, url);;
+ QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, url);
if(td->status == QmlCompositeTypeData::Error) {
d->errors = td->errors;
@@ -179,6 +188,10 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl
return false;
}
+ for (int i = 0; i < td->data.imports().size(); ++i) {
+ d->imports += QUrl(td->data.imports().at(i).uri);
+ }
+
if (td->data.tree()) {
td->data.tree()->dump();
d->root = td->data.tree();
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
index f90fb08..8b503fa 100644
--- a/src/declarative/qml/qmldom.h
+++ b/src/declarative/qml/qmldom.h
@@ -71,7 +71,8 @@ public:
QmlDomDocument &operator=(const QmlDomDocument &);
int version() const;
-
+ QList<QUrl> imports() const;
+
QList<QmlError> errors() const;
bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl());
QByteArray save() const;
diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h
index 4c3ca44..74edd47 100644
--- a/src/declarative/qml/qmldom_p.h
+++ b/src/declarative/qml/qmldom_p.h
@@ -42,6 +42,8 @@
#ifndef QMLDOM_P_H
#define QMLDOM_P_H
+#include <QtCore/QtGlobal>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -58,6 +60,7 @@ public:
~QmlDomDocumentPrivate();
QList<QmlError> errors;
+ QList<QUrl> imports;
QmlParser::Object *root;
};
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index 4385601..0092ec2 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -226,9 +226,12 @@ ProcessAST::defineObjectBinding_helper(int line,
return 0;
}
- _stateStack.pushProperty(objectType,
- this->location(propertyName));
- accept(initializer);
+ SourceLocation loc = typeLocation;
+ if (propertyName)
+ loc = location(propertyName);
+
+ _stateStack.pushProperty(objectType, loc);
+ accept(initializer);
_stateStack.pop();
return 0;
@@ -362,6 +365,16 @@ bool ProcessAST::visit(AST::UiImport *node)
{
QString fileName = node->fileName->asString();
_parser->addNamespacePath(fileName);
+
+ AST::SourceLocation startLoc = node->importToken;
+ AST::SourceLocation endLoc = node->semicolonToken;
+
+ QmlScriptParser::Import import;
+ import.location = location(startLoc, endLoc);
+ import.uri = fileName;
+
+ _parser->_imports << import;
+
return false;
}
@@ -686,6 +699,11 @@ Object *QmlScriptParser::tree() const
return root;
}
+QList<QmlScriptParser::Import> QmlScriptParser::imports() const
+{
+ return _imports;
+}
+
QList<QmlError> QmlScriptParser::errors() const
{
return _errors;
diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h
index 4155bba..8a5466f 100644
--- a/src/declarative/qml/qmlscriptparser_p.h
+++ b/src/declarative/qml/qmlscriptparser_p.h
@@ -4,22 +4,28 @@
#include <QtCore/QList>
#include <QtCore/QUrl>
#include <QtDeclarative/qmlerror.h>
-#include <qml.h>
+#include "qmlparser_p.h"
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-namespace QmlParser {
- class Object;
-}
-
class QByteArray;
class QmlScriptParser
{
public:
+ class Import
+ {
+ public:
+ Import() {}
+
+ QString uri;
+ QmlParser::LocationSpan location;
+ };
+
QmlScriptParser();
~QmlScriptParser();
@@ -29,6 +35,7 @@ public:
QStringList types() const;
QmlParser::Object *tree() const;
+ QList<Import> imports() const;
void clear();
@@ -48,6 +55,7 @@ public:
QMap<QString,QString> _nameSpacePaths;
QmlParser::Object *root;
+ QList<Import> _imports;
QStringList _typeNames;
QString _scriptFile;
};
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index ea2719d..078916b 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -329,6 +329,7 @@ void QFxView::continueExecute()
if(qmlDebugger()) {
QmlDebugger *debugger = new QmlDebugger;
debugger->setDebugObject(item);
+ debugger->setCanvas(this);
debugger->show();
raise();
debugger->raise();
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index 96f6f4f..efd45d3 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -156,6 +156,9 @@ private slots:
//void cannotAssignBindingToSignal();
void assignObjectToSignal();
+ // regression tests for crashes
+ void crash1();
+
private:
QmlEngine engine;
};
@@ -439,6 +442,12 @@ void tst_qmlparser::assignObjectToSignal()
emit object->basicSignal();
}
+void tst_qmlparser::crash1()
+{
+ QmlComponent component(&engine, "Component {}");
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+}
+
QTEST_MAIN(tst_qmlparser)
#include "tst_qmlparser.moc"
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp
index 379fda9..9a008d2 100644
--- a/tools/qmlviewer/main.cpp
+++ b/tools/qmlviewer/main.cpp
@@ -47,18 +47,24 @@ int main(int argc, char ** argv)
//### default to using raster graphics backend for now
int newargc = argc + 2;
char **newargv;
- newargv = new char * [newargc];
+ bool gsSpecified = false;
for (int i = 0; i < argc; ++i) {
- newargv[i] = argv[i];
if (!qstrcmp(argv[i], "-graphicssystem")) {
+ gsSpecified = true;
newargc -= 2;
break;
}
}
- char system[] = "-graphicssystem";
- newargv[argc] = system;
- char raster[] = "raster";
- newargv[argc+1] = raster;
+ newargv = new char * [newargc];
+ for (int i = 0; i < argc; ++i) {
+ newargv[i] = argv[i];
+ }
+ if (!gsSpecified) {
+ char system[] = "-graphicssystem";
+ newargv[argc] = system;
+ char raster[] = "raster";
+ newargv[argc+1] = raster;
+ }
QApplication app(newargc, newargv);
app.setApplicationName("viewer");