summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/debugger/debugger.pri6
-rw-r--r--src/declarative/debugger/qmlcanvasdebugger.cpp164
-rw-r--r--src/declarative/debugger/qmlcanvasdebugger_p.h84
-rw-r--r--src/declarative/debugger/qmldebugger.cpp13
-rw-r--r--src/declarative/debugger/qmldebugger.h4
-rw-r--r--src/declarative/util/qfxview.cpp1
6 files changed, 269 insertions, 3 deletions
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 <private/qmlcanvasdebugger_p.h>
+#include <private/qmlwatches_p.h>
+#include <QtDeclarative/qsimplecanvas.h>
+#include <QtGui/qboxlayout.h>
+#include <QtGui/qpushbutton.h>
+#include <QtGui/qsplitter.h>
+#include <QtGui/qtreewidget.h>
+
+#include <QtDeclarative/qfxrect.h>
+
+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<QObject> them;
+ QFxRect *me;
+};
+
+void QmlCanvasDebugger::itemExpanded(QTreeWidgetItem *i)
+{
+ QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i);
+ if(item->me)
+ item->me->setOpacity(1);
+}
+
+void QmlCanvasDebugger::itemClicked(QTreeWidgetItem *i)
+{
+ QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i);
+ if(item->them)
+ emit objectClicked(m_watches->objectId(item->them));
+}
+
+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->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<QSimpleCanvasItem *> 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 <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 *);
+
+private:
+ void clone(QTreeWidgetItem *, QSimpleCanvasItem *me, QSimpleCanvasItem *them);
+
+ QmlWatches *m_watches;
+ QTreeWidget *m_tree;
+ QSimpleCanvas *m_canvas;
+ QPointer<QSimpleCanvas> 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 <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/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();