diff options
-rw-r--r-- | src/declarative/debugger/qmldebug.cpp | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlenginedebug.cpp | 9 | ||||
-rw-r--r-- | src/declarative/qml/qmlenginedebug_p.h | 1 | ||||
-rw-r--r-- | tools/qmldebugger/canvasscene.cpp | 248 | ||||
-rw-r--r-- | tools/qmldebugger/canvasscene.h | 43 | ||||
-rw-r--r-- | tools/qmldebugger/engine.cpp | 77 | ||||
-rw-r--r-- | tools/qmldebugger/engine.h | 9 | ||||
-rw-r--r-- | tools/qmldebugger/engines.qml | 2 | ||||
-rw-r--r-- | tools/qmldebugger/main.cpp | 4 | ||||
-rw-r--r-- | tools/qmldebugger/qmldebugger.pro | 4 | ||||
-rw-r--r-- | tools/tools.pro | 2 |
11 files changed, 93 insertions, 307 deletions
diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index 8309ec6..9397bb9 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -103,6 +103,7 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o, ds >> data; QmlDebugPropertyReference prop; prop.m_name = data.name; + prop.m_binding = data.binding; if (data.type == QmlEngineDebugServer::QmlObjectProperty::Basic) prop.m_value = data.value; else if (data.type == QmlEngineDebugServer::QmlObjectProperty::Object) { diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 2b8aac3..c26f3b7 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -44,6 +44,8 @@ #include <QtCore/qmetaobject.h> #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlmetatype.h> +#include <qmlmetaproperty.h> +#include <qmlbinding.h> #include "qmlcontext_p.h" QT_BEGIN_NAMESPACE @@ -73,7 +75,7 @@ QDataStream &operator>>(QDataStream &ds, QDataStream &operator<<(QDataStream &ds, const QmlEngineDebugServer::QmlObjectProperty &data) { - ds << (int)data.type << data.name << data.value; + ds << (int)data.type << data.name << data.value << data.binding; return ds; } @@ -81,7 +83,7 @@ QDataStream &operator>>(QDataStream &ds, QmlEngineDebugServer::QmlObjectProperty &data) { int type; - ds >> type >> data.name >> data.value; + ds >> type >> data.name >> data.value >> data.binding; data.type = (QmlEngineDebugServer::QmlObjectProperty::Type)type; return ds; } @@ -95,6 +97,9 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx) rv.type = QmlObjectProperty::Unknown; rv.name = prop.name(); + QmlBinding *binding = QmlMetaProperty(obj, rv.name).binding(); + if (binding) + rv.binding = binding->expression(); if (prop.type() < QVariant::UserType) { rv.type = QmlObjectProperty::Basic; diff --git a/src/declarative/qml/qmlenginedebug_p.h b/src/declarative/qml/qmlenginedebug_p.h index e85ab6f..87b2ffd 100644 --- a/src/declarative/qml/qmlenginedebug_p.h +++ b/src/declarative/qml/qmlenginedebug_p.h @@ -81,6 +81,7 @@ public: Type type; QString name; QVariant value; + QString binding; }; static void addEngine(QmlEngine *); diff --git a/tools/qmldebugger/canvasscene.cpp b/tools/qmldebugger/canvasscene.cpp deleted file mode 100644 index 65db9da..0000000 --- a/tools/qmldebugger/canvasscene.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include "canvasscene.h" -#include <QtDeclarative/qmldebugclient.h> -#include <QDataStream> -#include <QVBoxLayout> -#include <QPushButton> -#include <QSpinBox> -#include <QSplitter> -#include <QtDeclarative/qfxrect.h> -#include <QtDeclarative/qfximage.h> - -QT_BEGIN_NAMESPACE - -class CanvasSceneClientPlugin : public QmlDebugClient -{ -public: - CanvasSceneClientPlugin(QmlDebugConnection *, CanvasScene *s); - -protected: - void messageReceived(const QByteArray &); - -private: - void dump(QDataStream &, int indent); - CanvasScene *scene; -}; - -class QmlCanvasDebuggerItem : public QTreeWidgetItem -{ -public: - QmlCanvasDebuggerItem(QTreeWidget *tree) - : QTreeWidgetItem(tree), me(0), img(0) - { - } - - QmlCanvasDebuggerItem(QTreeWidgetItem *item) - : QTreeWidgetItem(item), me(0), img(0) - { - } - - QFxRect *me; - QFxImage *img; -}; - -CanvasSceneClientPlugin::CanvasSceneClientPlugin(QmlDebugConnection *c, - CanvasScene *s) -: QmlDebugClient(QLatin1String("CanvasScene"), c), scene(s) -{ -} - -void CanvasSceneClientPlugin::messageReceived(const QByteArray &data) -{ - QByteArray d = data; - QDataStream ds(&d, QIODevice::ReadOnly); - - scene->message(ds); -} - -void CanvasScene::message(QDataStream &ds) -{ - QList<QSimpleCanvasItem *> children = m_canvasRoot->children(); - qDeleteAll(children); - m_tree->clear(); - m_selected = 0; - - QTreeWidgetItem *root = new QmlCanvasDebuggerItem(m_tree); - root->setText(0, tr("Root")); - root->setExpanded(true); - clone(root, m_canvasRoot, ds); -} - -void CanvasScene::clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, - QDataStream &ds) -{ - int children; - ds >> children; - - for (int ii = 0; ii < children; ++ii) { - QString name; - qreal x, y, z, width, height, scale; - QTransform transform; - bool activeFocus; - int transformOrigin, flip, options; - QPixmap pix; - - ds >> name >> x >> y >> z >> width >> height >> transformOrigin >> scale - >> flip >> transform >> activeFocus >> options >> pix; - - QmlCanvasDebuggerItem *childItem = new QmlCanvasDebuggerItem(item); - childItem->setText(0, name); - childItem->setExpanded(true); - - QFxRect *rect = new QFxRect; - rect->setParent(me); - rect->setX(x); - rect->setY(y); - rect->setZ(z); - rect->setWidth(width); - rect->setHeight(height); - rect->setTransformOrigin((QSimpleCanvasItem::TransformOrigin)transformOrigin); - rect->setScale(scale); - rect->setFlip((QSimpleCanvasItem::Flip)flip); - rect->setTransform(transform); - - if (activeFocus) - rect->setColor(QColor(0, 0, 0, 10)); - else if(options & QSimpleCanvasItem::IsFocusPanel) - rect->setColor(QColor(0, 255, 0, 10)); - else if(options & QSimpleCanvasItem::IsFocusRealm) - rect->setColor(QColor(0, 0, 255, 10)); - else - rect->setColor(QColor(255, 0, 0, 10)); - - if (pix.width() > 0 || pix.height() > 0) { - QFxImage *img = new QFxImage; - img->setParent(rect); - img->setWidth(width); - img->setHeight(height); - img->setPixmap(pix); - img->setOpacity(0); - childItem->img = img; - } - - childItem->me = rect; - - clone(childItem, rect, ds); - } -} - -void CanvasSceneClientPlugin::dump(QDataStream &ds, int indent) -{ - QString name; - qreal x, y, z, width, height, scale; - QTransform transform; - bool activeFocus; - int transformOrigin, flip, options, count; - QPixmap pix; - - ds >> name >> x >> y >> z >> width >> height >> transformOrigin >> scale - >> flip >> transform >> activeFocus >> options >> pix >> count; - - QByteArray ba(indent * 4, ' '); - qWarning() << ba.constData() << name << x << y; - - for(int ii = 0; ii < count; ++ii) - dump(ds, indent + 1); -} - -CanvasScene::CanvasScene(QmlDebugConnection *c, QWidget *parent) -: QWidget(parent) -{ - client = new CanvasSceneClientPlugin(c, this); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0,0,0,0); - layout->setSpacing(0); - setLayout(layout); - QSplitter *splitter = new QSplitter(this); - - m_tree = new QTreeWidget(this); - m_tree->setHeaderHidden(true); - 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); - - 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(tr("Refresh"), this); - QObject::connect(pb, SIGNAL(clicked()), this, SLOT(refresh())); - hlayout->addWidget(pb); -} - -void CanvasScene::refresh() -{ - client->sendMessage(QByteArray()); -} - -void CanvasScene::itemExpanded(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i); - if(item->me) - item->me->setOpacity(1); -} - -void CanvasScene::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 CanvasScene::itemClicked(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i); - - if(m_selected) { - setOpacityRecur(m_selected, 0); - m_selected = 0; - } - - m_selected = item; - setOpacityRecur(m_selected, 1); -} - -void CanvasScene::itemCollapsed(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast<QmlCanvasDebuggerItem *>(i); - if(item->me) - item->me->setOpacity(0); -} - -void CanvasScene::setX(int x) -{ - m_canvasRoot->setX(x); -} - -void CanvasScene::setY(int y) -{ - m_canvasRoot->setY(y); -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/canvasscene.h b/tools/qmldebugger/canvasscene.h deleted file mode 100644 index 8c6b8d5..0000000 --- a/tools/qmldebugger/canvasscene.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef CANVASSCENE_H -#define CANVASSCENE_H - -#include <QWidget> -#include <QTreeWidget> -#include <QtDeclarative/qsimplecanvas.h> -#include <QtDeclarative/qsimplecanvasitem.h> - -QT_BEGIN_NAMESPACE - -class QmlDebugConnection; -class CanvasSceneClient; -class QmlDebugClient; -class CanvasScene : public QWidget -{ -Q_OBJECT -public: - CanvasScene(QmlDebugConnection *, QWidget *parent = 0); - - void message(QDataStream &); -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 *item, QSimpleCanvasItem *me, QDataStream &); - QmlDebugClient *client; - - QTreeWidget *m_tree; - QSimpleCanvas *m_canvas; - QSimpleCanvasItem *m_canvasRoot; - QTreeWidgetItem *m_selected; -}; - -QT_END_NAMESPACE - -#endif // CANVASSCENE_H - diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp index 3b8c8b1..229cd3f 100644 --- a/tools/qmldebugger/engine.cpp +++ b/tools/qmldebugger/engine.cpp @@ -2,7 +2,10 @@ #include <QtDeclarative/qmldebugclient.h> #include <QPushButton> #include <QVBoxLayout> +#include <QHBoxLayout> #include <QLineEdit> +#include <QTreeWidget> +#include <QTableWidget> #include <private/qmlenginedebug_p.h> #include <QtDeclarative/qmlcomponent.h> #include <QtDeclarative/qfxitem.h> @@ -11,9 +14,9 @@ QT_BEGIN_NAMESPACE class DebuggerEngineItem : public QObject { -Q_OBJECT -Q_PROPERTY(QString name READ name CONSTANT); -Q_PROPERTY(QString engineId READ engineId CONSTANT); + Q_OBJECT + Q_PROPERTY(QString name READ name CONSTANT); + Q_PROPERTY(int engineId READ engineId CONSTANT); public: DebuggerEngineItem(const QString &name, int id) @@ -56,7 +59,23 @@ EnginePane::EnginePane(QmlDebugConnection *client, QWidget *parent) QObject::connect(query, SIGNAL(clicked()), this, SLOT(fetchClicked())); layout->addWidget(query); - layout->addStretch(10); + QHBoxLayout *hbox = new QHBoxLayout; + hbox->setContentsMargins(0, 0, 0, 0); + + m_objTree = new QTreeWidget(this); + m_objTree->setHeaderHidden(true); + connect(m_objTree, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(itemClicked(QTreeWidgetItem *))); + hbox->addWidget(m_objTree); + + m_propTable = new QTableWidget(this); + m_propTable->setColumnCount(2); + m_propTable->setColumnWidth(0, 150); + m_propTable->setColumnWidth(1, 400); + m_propTable->setHorizontalHeaderLabels(QStringList() << "name" << "value"); + hbox->addWidget(m_propTable); + hbox->setStretchFactor(m_propTable, 2); + + layout->addLayout(hbox); } void EnginePane::engineSelected(int id) @@ -65,6 +84,40 @@ void EnginePane::engineSelected(int id) queryContext(id); } +void EnginePane::itemClicked(QTreeWidgetItem *item) +{ + m_propTable->clearContents(); + + if (m_object) { + delete m_object; + m_object = 0; + } + + m_object = m_client.queryObjectRecursive(QmlDebugObjectReference(item->data(0, Qt::UserRole).toInt()), this); + if (!m_object->isWaiting()) + showProperties(); + else + QObject::connect(m_object, SIGNAL(stateChanged(State)), + this, SLOT(showProperties())); +} + +void EnginePane::showProperties() +{ + QmlDebugObjectReference obj = m_object->object(); + m_propTable->setRowCount(obj.properties().count()); + for (int ii = 0; ii < obj.properties().count(); ++ii) { + QTableWidgetItem *name = new QTableWidgetItem(obj.properties().at(ii).name()); + m_propTable->setItem(ii, 0, name); + QTableWidgetItem *value; + if (!obj.properties().at(ii).binding().isEmpty()) + value = new QTableWidgetItem(obj.properties().at(ii).binding()); + else + value = new QTableWidgetItem(obj.properties().at(ii).value().toString()); + m_propTable->setItem(ii, 1, value); + } + delete m_object; m_object = 0; +} + void EnginePane::queryContext(int id) { if (m_context) { @@ -110,6 +163,17 @@ void EnginePane::dump(const QmlDebugObjectReference &obj, int ind) dump(obj.children().at(ii), ind + 1); } + +void EnginePane::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *parent) +{ + QTreeWidgetItem *item = parent ? new QTreeWidgetItem(parent) : new QTreeWidgetItem(m_objTree); + item->setText(0, obj.className()); + item->setData(0, Qt::UserRole, obj.debugId()); + + for (int ii = 0; ii < obj.children().count(); ++ii) + buildTree(obj.children().at(ii), item); +} + void EnginePane::queryEngines() { if (m_engines) @@ -131,8 +195,8 @@ void EnginePane::enginesChanged() QList<QmlDebugEngineReference> engines = m_engines->engines(); delete m_engines; m_engines = 0; - for (int ii = 0; ii < engines.count(); ++ii) - m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), + for (int ii = 0; ii < engines.count(); ++ii) + m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), engines.at(ii).debugId()); m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); @@ -162,6 +226,7 @@ void EnginePane::fetchObject(int id) void EnginePane::objectFetched() { dump(m_object->object(), 0); + buildTree(m_object->object(), 0); delete m_object; m_object = 0; } diff --git a/tools/qmldebugger/engine.h b/tools/qmldebugger/engine.h index a713f25..52f0608 100644 --- a/tools/qmldebugger/engine.h +++ b/tools/qmldebugger/engine.h @@ -12,6 +12,9 @@ QT_BEGIN_NAMESPACE class QmlDebugConnection; class EngineClientPlugin; class QLineEdit; +class QTreeWidget; +class QTreeWidgetItem; +class QTableWidget; class EnginePane : public QWidget { Q_OBJECT @@ -31,9 +34,13 @@ private slots: void engineSelected(int); + void itemClicked(QTreeWidgetItem *); + void showProperties(); + private: void dump(const QmlDebugContextReference &, int); void dump(const QmlDebugObjectReference &, int); + void buildTree(const QmlDebugObjectReference &, QTreeWidgetItem *parent); QmlEngineDebug m_client; QmlDebugEnginesQuery *m_engines; @@ -41,6 +48,8 @@ private: QmlDebugObjectQuery *m_object; QLineEdit *m_text; + QTreeWidget *m_objTree; + QTableWidget *m_propTable; QFxView *m_engineView; QList<QObject *> m_engineItems; diff --git a/tools/qmldebugger/engines.qml b/tools/qmldebugger/engines.qml index fc364e2..eedba08 100644 --- a/tools/qmldebugger/engines.qml +++ b/tools/qmldebugger/engines.qml @@ -19,7 +19,7 @@ Item { } Text { anchors.top: Image.bottom; - text: modelData.name + "(" + modelData.engineId + ")" + text: modelData.name + "(" + modelData.engineId + ")" anchors.horizontalCenter: parent.horizontalCenter } MouseRegion { diff --git a/tools/qmldebugger/main.cpp b/tools/qmldebugger/main.cpp index 500836f..a37a437 100644 --- a/tools/qmldebugger/main.cpp +++ b/tools/qmldebugger/main.cpp @@ -8,7 +8,6 @@ #include <QtCore/qstringlist.h> #include <QtCore/qdatastream.h> #include "canvasframerate.h" -#include "canvasscene.h" #include "engine.h" #include <QVBoxLayout> #include <QPushButton> @@ -75,9 +74,6 @@ Shell::Shell(QWidget *parent) CanvasFrameRate *cfr = new CanvasFrameRate(&client, this); tabs->addTab(cfr, tr("Frame Rate")); - CanvasScene *cs = new CanvasScene(&client, this); - tabs->addTab(cs, tr("Scene")); - EnginePane *ep = new EnginePane(&client, this); tabs->addTab(ep, tr("QML Engine")); diff --git a/tools/qmldebugger/qmldebugger.pro b/tools/qmldebugger/qmldebugger.pro index 1068858..532fd2a 100644 --- a/tools/qmldebugger/qmldebugger.pro +++ b/tools/qmldebugger/qmldebugger.pro @@ -3,8 +3,8 @@ QT += network declarative contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl # Input -HEADERS += canvasframerate.h canvasscene.h engine.h -SOURCES += main.cpp canvasframerate.cpp canvasscene.cpp engine.cpp +HEADERS += canvasframerate.h engine.h +SOURCES += main.cpp canvasframerate.cpp engine.cpp target.path=$$[QT_INSTALL_BINS] INSTALLS += target diff --git a/tools/tools.pro b/tools/tools.pro index ecdbcd1..68b4801 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -24,7 +24,7 @@ mac { embedded:SUBDIRS += kmap2qmap -contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer +contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer qmldebugger contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns xmlpatternsvalidator embedded: SUBDIRS += makeqpf |