From b530723f5a7254d6a2a144aa27789651fe872c6d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 7 May 2009 15:45:08 +1000 Subject: Add a QmlDebuggerStatus interface elements can use to interact with the debugger --- src/declarative/canvas/qsimplecanvas.cpp | 4 +- src/declarative/canvas/qsimplecanvas_software.cpp | 5 ++ src/declarative/canvas/qsimplecanvasitem.cpp | 8 +++ src/declarative/canvas/qsimplecanvasitem.h | 11 ++-- src/declarative/canvas/qsimplecanvasitem_p.h | 25 ++++++++- src/declarative/debugger/debugger.pri | 6 +- src/declarative/debugger/qmldebugger.cpp | 22 ++++++++ src/declarative/debugger/qmldebugger.h | 1 + src/declarative/debugger/qmldebuggerstatus.cpp | 54 ++++++++++++++++++ src/declarative/debugger/qmldebuggerstatus.h | 67 +++++++++++++++++++++++ 10 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 src/declarative/debugger/qmldebuggerstatus.cpp create mode 100644 src/declarative/debugger/qmldebuggerstatus.h diff --git a/src/declarative/canvas/qsimplecanvas.cpp b/src/declarative/canvas/qsimplecanvas.cpp index ce02a4c..c404da6 100644 --- a/src/declarative/canvas/qsimplecanvas.cpp +++ b/src/declarative/canvas/qsimplecanvas.cpp @@ -60,7 +60,7 @@ 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(useGraphicsView, QFX_USE_GRAPHICSVIEW); +DEFINE_BOOL_CONFIG_OPTION(useSimpleCanvas, QFX_USE_SIMPLECANVAS); template class CircularList @@ -556,7 +556,7 @@ QSimpleCanvas::QSimpleCanvas(CanvasMode mode, QWidget *parent) QSimpleCanvas::QSimpleCanvas(QWidget *parent) : QWidget(parent), d(new QSimpleCanvasPrivate(this)) { - d->init(useGraphicsView()?SimpleCanvas:GraphicsView); + d->init(useSimpleCanvas()?SimpleCanvas:GraphicsView); } void QSimpleCanvasPrivate::init(QSimpleCanvas::CanvasMode mode) diff --git a/src/declarative/canvas/qsimplecanvas_software.cpp b/src/declarative/canvas/qsimplecanvas_software.cpp index c130a62..194024d 100644 --- a/src/declarative/canvas/qsimplecanvas_software.cpp +++ b/src/declarative/canvas/qsimplecanvas_software.cpp @@ -172,6 +172,11 @@ void QSimpleCanvasItemPrivate::paint(QPainter &p) 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) diff --git a/src/declarative/canvas/qsimplecanvasitem.cpp b/src/declarative/canvas/qsimplecanvasitem.cpp index 62a44e4..ba33a41 100644 --- a/src/declarative/canvas/qsimplecanvasitem.cpp +++ b/src/declarative/canvas/qsimplecanvasitem.cpp @@ -1380,6 +1380,14 @@ QSimpleCanvasItem::operator QGraphicsItem *() 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); diff --git a/src/declarative/canvas/qsimplecanvasitem.h b/src/declarative/canvas/qsimplecanvasitem.h index 83f19c3..cab8492 100644 --- a/src/declarative/canvas/qsimplecanvasitem.h +++ b/src/declarative/canvas/qsimplecanvasitem.h @@ -42,10 +42,11 @@ #ifndef QSIMPLECANVASITEM_H #define QSIMPLECANVASITEM_H -#include -#include -#include -#include +#include +#include +#include +#include +#include class QPainter; QT_BEGIN_HEADER @@ -70,6 +71,7 @@ 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); @@ -94,6 +96,7 @@ public: QSimpleCanvasItem(QSimpleCanvasItem *parent=0); virtual ~QSimpleCanvasItem(); operator QGraphicsItem *(); + operator QmlDebuggerStatus *(); bool clip() const; void setClip(bool); diff --git a/src/declarative/canvas/qsimplecanvasitem_p.h b/src/declarative/canvas/qsimplecanvasitem_p.h index 27a75bd..cfe0bba 100644 --- a/src/declarative/canvas/qsimplecanvasitem_p.h +++ b/src/declarative/canvas/qsimplecanvasitem_p.h @@ -110,6 +110,22 @@ public: #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 @@ -117,7 +133,8 @@ class QSimpleCanvasItemPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QSimpleCanvasItem); public: QSimpleCanvasItemPrivate() - : parent(0), canvas(0), filter(0), clip(QSimpleCanvasItem::NoClip), + : parent(0), canvas(0), debuggerStatus(0), filter(0), + clip(QSimpleCanvasItem::NoClip), origin(QSimpleCanvasItem::TopLeft), options(QSimpleCanvasItem::NoOption), focusable(false), wantsActiveFocusPanelPendingCanvas(false), hasBeenActiveFocusPanel(false), @@ -127,12 +144,16 @@ public: { } - virtual ~QSimpleCanvasItemPrivate() {} + virtual ~QSimpleCanvasItemPrivate() + { + if(debuggerStatus) delete debuggerStatus; + } QSimpleCanvasItem *parent; QSimpleCanvas *canvas; QList children; + QSimpleCanvasItemDebuggerStatus *debuggerStatus; QSimpleCanvasFilter *filter; QSimpleCanvasItem::ClipType clip:3; diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri index ea5219a..b88b7b3 100644 --- a/src/declarative/debugger/debugger.pri +++ b/src/declarative/debugger/debugger.pri @@ -1,3 +1,5 @@ -SOURCES += debugger/qmldebugger.cpp +SOURCES += debugger/qmldebugger.cpp \ + debugger/qmldebuggerstatus.cpp -HEADERS += debugger/qmldebugger.h +HEADERS += debugger/qmldebugger.h \ + debugger/qmldebuggerstatus.h diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp index a1956f9..f232f02 100644 --- a/src/declarative/debugger/qmldebugger.cpp +++ b/src/declarative/debugger/qmldebugger.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -119,6 +120,7 @@ public: int endLine; QUrl url; + QPointer object; QPointer bindableValue; }; @@ -144,6 +146,24 @@ void QmlDebugger::itemDoubleClicked(QTreeWidgetItem *i) void QmlDebugger::itemClicked(QTreeWidgetItem *i) { QmlDebuggerItem *item = static_cast(i); + + if(m_selectedItem) { + QmlDebuggerStatus *debug = + qobject_cast(m_selectedItem); + Q_ASSERT(debug); + debug->setSelectedState(false); + m_selectedItem = 0; + } + + if(item->object) { + QmlDebuggerStatus *debug = + qobject_cast(item->object); + if(debug) { + debug->setSelectedState(true); + m_selectedItem = item->object; + } + } + if(item->url.scheme() == QLatin1String("file")) { QString f = item->url.toLocalFile(); QFile file(f); @@ -194,6 +214,8 @@ bool QmlDebugger::makeItem(QObject *obj, QmlDebuggerItem *item) QString text; + item->object = obj; + if(QmlBindableValue *bv = qobject_cast(obj)) { QmlExpressionPrivate *p = bv->d; diff --git a/src/declarative/debugger/qmldebugger.h b/src/declarative/debugger/qmldebugger.h index e04eb2e..8d2593d 100644 --- a/src/declarative/debugger/qmldebugger.h +++ b/src/declarative/debugger/qmldebugger.h @@ -82,6 +82,7 @@ private: QPointer m_object; QList > > m_expressions; QSet m_watchedIds; + QPointer m_selectedItem; }; QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmldebuggerstatus.cpp b/src/declarative/debugger/qmldebuggerstatus.cpp new file mode 100644 index 0000000..d46a21d --- /dev/null +++ b/src/declarative/debugger/qmldebuggerstatus.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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 "qmldebuggerstatus.h" + +QT_BEGIN_NAMESPACE + +QmlDebuggerStatus::~QmlDebuggerStatus() +{ +} + +void QmlDebuggerStatus::setSelectedState(bool) +{ +} + +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmldebuggerstatus.h b/src/declarative/debugger/qmldebuggerstatus.h new file mode 100644 index 0000000..8c6355d --- /dev/null +++ b/src/declarative/debugger/qmldebuggerstatus.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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 QMLDEBUGGERSTATUS_P_H +#define QMLDEBUGGERSTATUS_P_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class Q_DECLARATIVE_EXPORT QmlDebuggerStatus +{ +public: + virtual ~QmlDebuggerStatus(); + + virtual void setSelectedState(bool); +}; +Q_DECLARE_INTERFACE(QmlDebuggerStatus, "com.trolltech.qml.QmlDebuggerStatus"); + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QLMDEBUGGERSTATUS_P_H + -- cgit v0.12