diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-13 05:21:42 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-07-13 05:21:42 (GMT) |
commit | 29dd542d079d1b2bac37357d8ea18e5622cc12dc (patch) | |
tree | d4525cd54f5faf900374904d37d6e5fc1cbacd08 /tools/qmldebugger | |
parent | d5e372425698c6a87e86743114e4b8d28d5d86eb (diff) | |
download | Qt-29dd542d079d1b2bac37357d8ea18e5622cc12dc.zip Qt-29dd542d079d1b2bac37357d8ea18e5622cc12dc.tar.gz Qt-29dd542d079d1b2bac37357d8ea18e5622cc12dc.tar.bz2 |
Start moving debugger out of process
Diffstat (limited to 'tools/qmldebugger')
-rw-r--r-- | tools/qmldebugger/engine.cpp | 172 | ||||
-rw-r--r-- | tools/qmldebugger/engine.h | 52 | ||||
-rw-r--r-- | tools/qmldebugger/main.cpp | 4 | ||||
-rw-r--r-- | tools/qmldebugger/qmldebugger.pro | 4 |
4 files changed, 230 insertions, 2 deletions
diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp new file mode 100644 index 0000000..46d30c4 --- /dev/null +++ b/tools/qmldebugger/engine.cpp @@ -0,0 +1,172 @@ +#include "engine.h" +#include <QtDeclarative/qmldebugclient.h> +#include <QPushButton> +#include <QVBoxLayout> +#include <QLineEdit> +#include <private/qmlenginedebug_p.h> +#include <QtDeclarative/qmlcomponent.h> +#include <QtDeclarative/qfxitem.h> + +QT_BEGIN_NAMESPACE + +class DebuggerEngineItem : public QObject +{ +Q_OBJECT +Q_PROPERTY(QString name READ name CONSTANT); +Q_PROPERTY(QString engineId READ engineId CONSTANT); + +public: + DebuggerEngineItem(const QString &name, int id) + : m_name(name), m_engineId(id) {} + + QString name() const { return m_name; } + int engineId() const { return m_engineId; } + +private: + QString m_name; + int m_engineId; +}; + +EnginePane::EnginePane(QmlDebugClient *client, QWidget *parent) +: QWidget(parent), m_client(client), m_engines(0), m_context(0), m_object(0) +{ + QVBoxLayout *layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + + setLayout(layout); + + m_engineView = new QFxView(this); + m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); + m_engineView->setContentResizable(true); + m_engineView->setUrl(QUrl::fromLocalFile("engines.qml")); + m_engineView->execute(); + m_engineView->setFixedHeight(100); + QObject::connect(m_engineView->root(), SIGNAL(engineClicked(int)), + this, SLOT(engineSelected(int))); + QObject::connect(m_engineView->root(), SIGNAL(refreshEngines()), + this, SLOT(queryEngines())); + + layout->addWidget(m_engineView); + + + m_text = new QLineEdit(this); + layout->addWidget(m_text); + + QPushButton *query = new QPushButton("Fetch object", this); + QObject::connect(query, SIGNAL(clicked()), this, SLOT(fetchClicked())); + layout->addWidget(query); + + layout->addStretch(10); +} + +void EnginePane::engineSelected(int id) +{ + qWarning() << "Engine selected" << id; + queryContext(id); +} + +void EnginePane::queryContext(int id) +{ + if (m_context) { + delete m_context; + m_context = 0; + } + + m_context = m_client.queryRootContexts(QmlDebugEngineReference(id), this); + if (!m_context->isWaiting()) + contextChanged(); + else + QObject::connect(m_context, SIGNAL(stateChanged(State)), + this, SLOT(contextChanged())); +} + +void EnginePane::contextChanged() +{ + dump(m_context->rootContext(), 0); + delete m_context; m_context = 0; +} + +void EnginePane::dump(const QmlDebugContextReference &ctxt, int ind) +{ + QByteArray indent(ind * 4, ' '); + qWarning().nospace() << indent.constData() << ctxt.debugId() << " " + << qPrintable(ctxt.name()); + + for (int ii = 0; ii < ctxt.contexts().count(); ++ii) + dump(ctxt.contexts().at(ii), ind + 1); + + for (int ii = 0; ii < ctxt.objects().count(); ++ii) + dump(ctxt.objects().at(ii), ind); +} + +void EnginePane::dump(const QmlDebugObjectReference &obj, int ind) +{ + QByteArray indent(ind * 4, ' '); + qWarning().nospace() << indent.constData() << qPrintable(obj.className()) + << " " << qPrintable(obj.name()) << " " + << obj.debugId(); + + for (int ii = 0; ii < obj.children().count(); ++ii) + dump(obj.children().at(ii), ind + 1); +} + +void EnginePane::queryEngines() +{ + if (m_engines) + return; + + m_engines = m_client.queryAvailableEngines(this); + if (!m_engines->isWaiting()) + enginesChanged(); + else + QObject::connect(m_engines, SIGNAL(stateChanged(State)), + this, SLOT(enginesChanged())); +} + +void EnginePane::enginesChanged() +{ + qDeleteAll(m_engineItems); + m_engineItems.clear(); + + 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(), + engines.at(ii).debugId()); + + m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); +} + +void EnginePane::fetchClicked() +{ + int id = m_text->text().toInt(); + fetchObject(id); +} + +void EnginePane::fetchObject(int id) +{ + if (m_object) { + delete m_object; + m_object = 0; + } + + m_object = m_client.queryObjectRecursive(QmlDebugObjectReference(id), this); + if (!m_object->isWaiting()) + objectFetched(); + else + QObject::connect(m_object, SIGNAL(stateChanged(State)), + this, SLOT(objectFetched())); +} + +void EnginePane::objectFetched() +{ + dump(m_object->object(), 0); + delete m_object; m_object = 0; +} + + +#include "engine.moc" + +QT_END_NAMESPACE + diff --git a/tools/qmldebugger/engine.h b/tools/qmldebugger/engine.h new file mode 100644 index 0000000..191cd1d --- /dev/null +++ b/tools/qmldebugger/engine.h @@ -0,0 +1,52 @@ +#ifndef ENGINE_H +#define ENGINE_H + +#include <QWidget> +#include <QtDeclarative/qmlengine.h> +#include <QtDeclarative/qmlcontext.h> +#include <QtDeclarative/qfxview.h> +#include <QtDeclarative/qmldebug.h> + +QT_BEGIN_NAMESPACE + +class QmlDebugClient; +class EngineClientPlugin; +class QLineEdit; +class EnginePane : public QWidget +{ +Q_OBJECT +public: + EnginePane(QmlDebugClient *, QWidget *parent = 0); + +private slots: + void queryEngines(); + void enginesChanged(); + + void queryContext(int); + void contextChanged(); + + void fetchClicked(); + void fetchObject(int); + void objectFetched(); + + void engineSelected(int); + +private: + void dump(const QmlDebugContextReference &, int); + void dump(const QmlDebugObjectReference &, int); + + QmlEngineDebug m_client; + QmlDebugEnginesQuery *m_engines; + QmlDebugRootContextQuery *m_context; + QmlDebugObjectQuery *m_object; + + QLineEdit *m_text; + + QFxView *m_engineView; + QList<QObject *> m_engineItems; +}; + +QT_END_NAMESPACE + +#endif // ENGINE_H + diff --git a/tools/qmldebugger/main.cpp b/tools/qmldebugger/main.cpp index 5b94cbb..4bed41d 100644 --- a/tools/qmldebugger/main.cpp +++ b/tools/qmldebugger/main.cpp @@ -9,6 +9,7 @@ #include <QtCore/qdatastream.h> #include "canvasframerate.h" #include "canvasscene.h" +#include "engine.h" #include <QVBoxLayout> #include <QPushButton> #include <QLineEdit> @@ -77,6 +78,9 @@ Shell::Shell(QWidget *parent) CanvasScene *cs = new CanvasScene(&client, this); tabs->addTab(cs, tr("Scene")); + EnginePane *ep = new EnginePane(&client, this); + tabs->addTab(ep, tr("QML Engine")); + QObject::connect(&client, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(connectionStateChanged())); connectionStateChanged(); } diff --git a/tools/qmldebugger/qmldebugger.pro b/tools/qmldebugger/qmldebugger.pro index 358dbae..1068858 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 -SOURCES += main.cpp canvasframerate.cpp canvasscene.cpp +HEADERS += canvasframerate.h canvasscene.h engine.h +SOURCES += main.cpp canvasframerate.cpp canvasscene.cpp engine.cpp target.path=$$[QT_INSTALL_BINS] INSTALLS += target |