From f7a9bffd11efce32f0fa318c01de8c8088fe4d95 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 8 May 2009 15:17:39 +1000 Subject: Correct spelling. setConsitentTiming -> setConsistentTiming --- src/corelib/animation/qabstractanimation.cpp | 2 +- src/corelib/animation/qabstractanimation_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 6a824b6..f5b9323 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -205,7 +205,7 @@ void QUnifiedTimer::setTimingInterval(int interval) this allows to have a consistent timer interval at each tick from the timer not taking the real time that passed into account. */ -void QUnifiedTimer::setConsitentTiming(bool b) +void QUnifiedTimer::setConsistentTiming(bool b) { consistentTiming = b; } diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 49c0195..41983a5 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -122,7 +122,7 @@ public: void unregisterAnimation(QAbstractAnimation *animation); void setTimingInterval(int interval); - void setConsitentTiming(bool consistent); + void setConsistentTiming(bool consistent); int elapsedTime() const; -- cgit v0.12 From 7bbd286d474f27c1ff0cd021d27c9e9c577ab0a8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 8 May 2009 16:08:49 +1000 Subject: Add canvas debugger module --- src/declarative/debugger/debugger.pri | 6 +- src/declarative/debugger/qmlcanvasdebugger.cpp | 164 +++++++++++++++++++++++++ src/declarative/debugger/qmlcanvasdebugger_p.h | 84 +++++++++++++ src/declarative/debugger/qmldebugger.cpp | 13 +- src/declarative/debugger/qmldebugger.h | 4 + src/declarative/util/qfxview.cpp | 1 + 6 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 src/declarative/debugger/qmlcanvasdebugger.cpp create mode 100644 src/declarative/debugger/qmlcanvasdebugger_p.h 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..90ec742 --- /dev/null +++ b/src/declarative/debugger/qmlcanvasdebugger.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include + +#include + +QmlCanvasDebugger::QmlCanvasDebugger(QmlWatches *w, QWidget *parent) +: QWidget(parent), m_watches(w), m_tree(0), m_canvas(0), m_debugCanvas(0) +{ + QVBoxLayout *layout = new QVBoxLayout; + setLayout(layout); + QPushButton *pb = new QPushButton("Refresh", this); + QObject::connect(pb, SIGNAL(clicked()), this, SLOT(refresh())); + layout->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); + 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) + { + } + + QmlCanvasDebuggerItem(QTreeWidgetItem *item) + : QTreeWidgetItem(item), me(0) + { + } + + QPointer them; + QFxRect *me; +}; + +void QmlCanvasDebugger::itemExpanded(QTreeWidgetItem *i) +{ + QmlCanvasDebuggerItem *item = static_cast(i); + if(item->me) + item->me->setOpacity(1); +} + +void QmlCanvasDebugger::itemClicked(QTreeWidgetItem *i) +{ + QmlCanvasDebuggerItem *item = static_cast(i); + if(item->them) + emit objectClicked(m_watches->objectId(item->them)); +} + +void QmlCanvasDebugger::itemCollapsed(QTreeWidgetItem *i) +{ + QmlCanvasDebuggerItem *item = static_cast(i); + if(item->me) + item->me->setOpacity(0); +} + +void QmlCanvasDebugger::clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, QSimpleCanvasItem *them) +{ + const QList &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->setWidth(child->width()); + rect->setHeight(child->height()); + + 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)); + + childItem->them = child; + childItem->me = rect; + + clone(childItem, rect, child); + } +} + +void QmlCanvasDebugger::setCanvas(QSimpleCanvas *canvas) +{ + QList children = m_canvas->root()->children(); + qDeleteAll(children); + m_tree->clear(); + + m_debugCanvas = canvas; + if(!m_debugCanvas) + return; + + QTreeWidgetItem *root = new QmlCanvasDebuggerItem(m_tree); + root->setText(0, "Root"); + root->setExpanded(true); + clone(root, m_canvas->root(), 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..24240ee --- /dev/null +++ b/src/declarative/debugger/qmlcanvasdebugger_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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 +#include + +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 *); + +private: + void clone(QTreeWidgetItem *, QSimpleCanvasItem *me, QSimpleCanvasItem *them); + + QmlWatches *m_watches; + QTreeWidget *m_tree; + QSimpleCanvas *m_canvas; + QPointer m_debugCanvas; +}; + +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 #include #include +#include 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 > &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 m_object; 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(); -- cgit v0.12 From 15de11bfcd2907e587dff41013fd39b62f0ca869 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 8 May 2009 16:26:49 +1000 Subject: Make sure qmlviewer uses raster graphcis system, or respects what was input. --- tools/qmlviewer/main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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"); -- cgit v0.12 From 80c80005c74776a930ec4a1a8fb8af5330073a71 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 8 May 2009 19:10:41 +1000 Subject: Add canvas image capture --- src/declarative/debugger/qmlcanvasdebugger.cpp | 94 +++++++++++++++++++++++--- src/declarative/debugger/qmlcanvasdebugger_p.h | 5 ++ 2 files changed, 90 insertions(+), 9 deletions(-) diff --git a/src/declarative/debugger/qmlcanvasdebugger.cpp b/src/declarative/debugger/qmlcanvasdebugger.cpp index 90ec742..fe57bf4 100644 --- a/src/declarative/debugger/qmlcanvasdebugger.cpp +++ b/src/declarative/debugger/qmlcanvasdebugger.cpp @@ -44,27 +44,54 @@ #include #include #include +#include #include #include #include +#include QmlCanvasDebugger::QmlCanvasDebugger(QmlWatches *w, QWidget *parent) -: QWidget(parent), m_watches(w), m_tree(0), m_canvas(0), m_debugCanvas(0) +: 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())); - layout->addWidget(pb); + 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*))); + 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); @@ -80,17 +107,18 @@ class QmlCanvasDebuggerItem : public QTreeWidgetItem { public: QmlCanvasDebuggerItem(QTreeWidget *tree) - : QTreeWidgetItem(tree), me(0) + : QTreeWidgetItem(tree), me(0), img(0) { } QmlCanvasDebuggerItem(QTreeWidgetItem *item) - : QTreeWidgetItem(item), me(0) + : QTreeWidgetItem(item), me(0), img(0) { } QPointer them; QFxRect *me; + QFxImage *img; }; void QmlCanvasDebugger::itemExpanded(QTreeWidgetItem *i) @@ -100,11 +128,29 @@ void QmlCanvasDebugger::itemExpanded(QTreeWidgetItem *i) item->me->setOpacity(1); } +void QmlCanvasDebugger::setOpacityRecur(QTreeWidgetItem *i, qreal op) +{ + QmlCanvasDebuggerItem *item = static_cast(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(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) @@ -127,8 +173,13 @@ void QmlCanvasDebugger::clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, QSim 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)); @@ -139,6 +190,20 @@ void QmlCanvasDebugger::clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, QSim 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; @@ -146,11 +211,22 @@ void QmlCanvasDebugger::clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, QSim } } +void QmlCanvasDebugger::setX(int x) +{ + m_canvasRoot->setX(x); +} + +void QmlCanvasDebugger::setY(int y) +{ + m_canvasRoot->setY(y); +} + void QmlCanvasDebugger::setCanvas(QSimpleCanvas *canvas) { - QList children = m_canvas->root()->children(); + QList children = m_canvasRoot->children(); qDeleteAll(children); m_tree->clear(); + m_selected = 0; m_debugCanvas = canvas; if(!m_debugCanvas) @@ -159,6 +235,6 @@ void QmlCanvasDebugger::setCanvas(QSimpleCanvas *canvas) QTreeWidgetItem *root = new QmlCanvasDebuggerItem(m_tree); root->setText(0, "Root"); root->setExpanded(true); - clone(root, m_canvas->root(), m_debugCanvas->root()); + clone(root, m_canvasRoot, m_debugCanvas->root()); } diff --git a/src/declarative/debugger/qmlcanvasdebugger_p.h b/src/declarative/debugger/qmlcanvasdebugger_p.h index 24240ee..80a2322 100644 --- a/src/declarative/debugger/qmlcanvasdebugger_p.h +++ b/src/declarative/debugger/qmlcanvasdebugger_p.h @@ -68,14 +68,19 @@ private slots: 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 m_debugCanvas; + QTreeWidgetItem *m_selected; }; QT_END_NAMESPACE -- cgit v0.12 From c7b42eb426a27d3f8124f5c37f39a8b91e3e03e8 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 8 May 2009 13:49:35 +0200 Subject: qdoc: Added qlistmodelinterface.cpp to correct some qdoc warnings. --- src/declarative/3rdparty/3rdparty.pri | 3 + src/declarative/3rdparty/qlistmodelinterface.cpp | 115 +++++++++++++++++++++++ src/declarative/3rdparty/qlistmodelinterface.h | 49 ++++------ 3 files changed, 134 insertions(+), 33 deletions(-) create mode 100644 src/declarative/3rdparty/qlistmodelinterface.cpp 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..5e0544e --- /dev/null +++ b/src/declarative/3rdparty/qlistmodelinterface.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** 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. +*/ + +/*! + \typedef QListModelInterface::QList_int + + Synonym for QList. +*/ +QT_END_NAMESPACE diff --git a/src/declarative/3rdparty/qlistmodelinterface.h b/src/declarative/3rdparty/qlistmodelinterface.h index 446b89b..e1eb21e 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 data(int index, const QList &roles = (QList())) 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 &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 QHash_int; + typedef QList 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 values; + QHash_int values; values.insert(role, value); return setData(index, values); } - /*! - Returns which roles the list provides data for. - */ - virtual QList 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 &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) {} }; -- cgit v0.12 From 79900981848fc4ba812243db83a7456d72ddda15 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 8 May 2009 11:18:43 +0200 Subject: Add autotest for crash when compiling "Component {}" --- tests/auto/declarative/qmlparser/tst_qmlparser.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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(component.create()); +} + QTEST_MAIN(tst_qmlparser) #include "tst_qmlparser.moc" -- cgit v0.12 From 7d67d5c24ce3e707c1bb9bc6f181765cccc4090d Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 8 May 2009 14:36:51 +0200 Subject: Expose import statements in QmlDomDocument Reviewed-by: erikv Reviewed-by: Roberto Raggi --- src/declarative/canvas/qsimplecanvas.h | 12 ++++++------ src/declarative/qml/qmldom.cpp | 17 +++++++++++++++-- src/declarative/qml/qmldom.h | 3 ++- src/declarative/qml/qmldom_p.h | 3 +++ src/declarative/qml/qmlscriptparser.cpp | 15 +++++++++++++++ src/declarative/qml/qmlscriptparser_p.h | 18 +++++++++++++----- 6 files changed, 54 insertions(+), 14 deletions(-) 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 #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include QT_BEGIN_HEADER 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 " in the qml. +*/ +QList 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 imports() const; + QList 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 + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -58,6 +60,7 @@ public: ~QmlDomDocumentPrivate(); QList errors; + QList imports; QmlParser::Object *root; }; diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 4385601..8506933 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -362,6 +362,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 +696,11 @@ Object *QmlScriptParser::tree() const return root; } +QList QmlScriptParser::imports() const +{ + return _imports; +} + QList 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 #include #include -#include +#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 imports() const; void clear(); @@ -48,6 +55,7 @@ public: QMap _nameSpacePaths; QmlParser::Object *root; + QList _imports; QStringList _typeNames; QString _scriptFile; }; -- cgit v0.12 From 94d44efa7066961211a4d2824e093ba71483b4ed Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 8 May 2009 15:06:45 +0200 Subject: qdoc: Fixed missing end of comment. --- src/declarative/3rdparty/qlistmodelinterface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/3rdparty/qlistmodelinterface.cpp b/src/declarative/3rdparty/qlistmodelinterface.cpp index 5e0544e..7e50378 100644 --- a/src/declarative/3rdparty/qlistmodelinterface.cpp +++ b/src/declarative/3rdparty/qlistmodelinterface.cpp @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE /*! \fn QListModelInterface::QListModelInterface(QObject *parent) Constructs a QListModelInterface with the specified \a parent. +*/ /*! \fn QListModelInterface::QListModelInterface(QObjectPrivate &dd, QObject *parent) -- cgit v0.12 From 140339c9a8ba51dab7384608a610ba129e0388dd Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 8 May 2009 15:11:32 +0200 Subject: qdoc: Fixed default parameter. --- src/declarative/3rdparty/qlistmodelinterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/3rdparty/qlistmodelinterface.h b/src/declarative/3rdparty/qlistmodelinterface.h index e1eb21e..8a0cf44 100644 --- a/src/declarative/3rdparty/qlistmodelinterface.h +++ b/src/declarative/3rdparty/qlistmodelinterface.h @@ -70,7 +70,7 @@ class Q_DECLARATIVE_EXPORT QListModelInterface : public QObject typedef QHash QHash_int; typedef QList QList_int; - virtual QHash_int data(int index, const QList_int &roles = QList_int) const = 0; + 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; } -- cgit v0.12 From 445c06ef96158befe035a0b45c613e4931d76e82 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 8 May 2009 16:32:12 +0200 Subject: Fixed possible crash when processing Ui object definitions. --- src/declarative/qml/qmlscriptparser.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 8506933..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; -- cgit v0.12