summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-05-07 05:45:08 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-05-07 05:45:08 (GMT)
commitb530723f5a7254d6a2a144aa27789651fe872c6d (patch)
treee94a418f2bdde351248974aea0c1e59445df27a7 /src/declarative
parente82217bf8e4ebaba20eb255bd52a9f261467b9d8 (diff)
downloadQt-b530723f5a7254d6a2a144aa27789651fe872c6d.zip
Qt-b530723f5a7254d6a2a144aa27789651fe872c6d.tar.gz
Qt-b530723f5a7254d6a2a144aa27789651fe872c6d.tar.bz2
Add a QmlDebuggerStatus interface elements can use to interact with the debugger
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/canvas/qsimplecanvas.cpp4
-rw-r--r--src/declarative/canvas/qsimplecanvas_software.cpp5
-rw-r--r--src/declarative/canvas/qsimplecanvasitem.cpp8
-rw-r--r--src/declarative/canvas/qsimplecanvasitem.h11
-rw-r--r--src/declarative/canvas/qsimplecanvasitem_p.h25
-rw-r--r--src/declarative/debugger/debugger.pri6
-rw-r--r--src/declarative/debugger/qmldebugger.cpp22
-rw-r--r--src/declarative/debugger/qmldebugger.h1
-rw-r--r--src/declarative/debugger/qmldebuggerstatus.cpp54
-rw-r--r--src/declarative/debugger/qmldebuggerstatus.h67
10 files changed, 193 insertions, 10 deletions
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 T, int s = 60>
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 <qfxglobal.h>
-#include <qsimplecanvas.h>
-#include <QObject>
-#include <QGraphicsItem>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qmldebuggerstatus.h>
+#include <QtDeclarative/qsimplecanvas.h>
+#include <QtCore/qobject.h>
+#include <QtGui/qgraphicsitem.h>
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<QSimpleCanvasItem *> 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 <QTextBlock>
#include <QtGui/qtabwidget.h>
#include <QtDeclarative/qmlbindablevalue.h>
+#include <QtDeclarative/qmldebuggerstatus.h>
#include <private/qmlboundsignal_p.h>
#include <private/qmlcontext_p.h>
#include <private/qmlengine_p.h>
@@ -119,6 +120,7 @@ public:
int endLine;
QUrl url;
+ QPointer<QObject> object;
QPointer<QmlBindableValue> bindableValue;
};
@@ -144,6 +146,24 @@ void QmlDebugger::itemDoubleClicked(QTreeWidgetItem *i)
void QmlDebugger::itemClicked(QTreeWidgetItem *i)
{
QmlDebuggerItem *item = static_cast<QmlDebuggerItem *>(i);
+
+ if(m_selectedItem) {
+ QmlDebuggerStatus *debug =
+ qobject_cast<QmlDebuggerStatus *>(m_selectedItem);
+ Q_ASSERT(debug);
+ debug->setSelectedState(false);
+ m_selectedItem = 0;
+ }
+
+ if(item->object) {
+ QmlDebuggerStatus *debug =
+ qobject_cast<QmlDebuggerStatus *>(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<QmlBindableValue *>(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<QObject> m_object;
QList<QPair<quint32, QPair<int, QString> > > m_expressions;
QSet<quint32> m_watchedIds;
+ QPointer<QObject> 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 <QtCore/qobject.h>
+
+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
+