summaryrefslogtreecommitdiffstats
path: root/tools/qmldebugger
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-09-30 00:35:17 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-09-30 00:35:17 (GMT)
commit19aef645df1e24fa4d9513136c1fee8093173eb1 (patch)
tree0d86fabdac55034b91ecd1bc631c6d89699f9489 /tools/qmldebugger
parent34cc88253b2ddd8b2216ce2a86d67e2cec3d7f55 (diff)
downloadQt-19aef645df1e24fa4d9513136c1fee8093173eb1.zip
Qt-19aef645df1e24fa4d9513136c1fee8093173eb1.tar.gz
Qt-19aef645df1e24fa4d9513136c1fee8093173eb1.tar.bz2
If there's only one engine, auto-connect to it and hide engines view.
Also auto-load available engines on connect.
Diffstat (limited to 'tools/qmldebugger')
-rw-r--r--tools/qmldebugger/engine.cpp17
-rw-r--r--tools/qmldebugger/engine.h4
-rw-r--r--tools/qmldebugger/main.cpp9
-rw-r--r--tools/qmldebugger/watchtablemodel.cpp8
-rw-r--r--tools/qmldebugger/watchtablemodel.h2
5 files changed, 35 insertions, 5 deletions
diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp
index fedae6b..321f5e0 100644
--- a/tools/qmldebugger/engine.cpp
+++ b/tools/qmldebugger/engine.cpp
@@ -180,8 +180,9 @@ EnginePane::EnginePane(QmlDebugConnection *client, QWidget *parent)
QObject::connect(m_engineView->root(), SIGNAL(engineClicked(int)),
this, SLOT(engineSelected(int)));
QObject::connect(m_engineView->root(), SIGNAL(refreshEngines()),
- this, SLOT(queryEngines()));
+ this, SLOT(refreshEngines()));
+ m_engineView->setVisible(false);
layout->addWidget(m_engineView);
QSplitter *splitter = new QSplitter;
@@ -421,11 +422,16 @@ void EnginePane::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *
buildTree(obj.children().at(ii), item);
}
-void EnginePane::queryEngines()
+void EnginePane::refreshEngines()
{
if (m_engines)
return;
+ QList<QmlDebugWatch *> watches = m_watchTableModel->watches();
+ for (int i=0; i<watches.count(); i++)
+ m_client.removeWatch(watches[i]);
+ qDeleteAll(watches);
+
m_engines = m_client.queryAvailableEngines(this);
if (!m_engines->isWaiting())
enginesChanged();
@@ -442,11 +448,18 @@ void EnginePane::enginesChanged()
QList<QmlDebugEngineReference> engines = m_engines->engines();
delete m_engines; m_engines = 0;
+ if (engines.isEmpty())
+ qWarning("qmldebugger: no engines found!");
+
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));
+
+ m_engineView->setVisible(m_engineItems.count() > 1);
+ if (m_engineItems.count() == 1)
+ engineSelected(qobject_cast<DebuggerEngineItem*>(m_engineItems.at(0))->engineId());
}
void EnginePane::fetchObject(int id)
diff --git a/tools/qmldebugger/engine.h b/tools/qmldebugger/engine.h
index 62fc6fb..c7707ed 100644
--- a/tools/qmldebugger/engine.h
+++ b/tools/qmldebugger/engine.h
@@ -32,8 +32,10 @@ Q_OBJECT
public:
EnginePane(QmlDebugConnection *, QWidget *parent = 0);
+public slots:
+ void refreshEngines();
+
private slots:
- void queryEngines();
void enginesChanged();
void queryContext(int);
diff --git a/tools/qmldebugger/main.cpp b/tools/qmldebugger/main.cpp
index a37a437..7fabfb7 100644
--- a/tools/qmldebugger/main.cpp
+++ b/tools/qmldebugger/main.cpp
@@ -7,6 +7,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qdatastream.h>
+#include <QtCore/qtimer.h>
#include "canvasframerate.h"
#include "engine.h"
#include <QVBoxLayout>
@@ -35,6 +36,8 @@ private:
QSpinBox *m_port;
QPushButton *m_connectButton;
QPushButton *m_disconnectButton;
+
+ EnginePane *m_enginePane;
};
Shell::Shell(QWidget *parent)
@@ -74,8 +77,8 @@ Shell::Shell(QWidget *parent)
CanvasFrameRate *cfr = new CanvasFrameRate(&client, this);
tabs->addTab(cfr, tr("Frame Rate"));
- EnginePane *ep = new EnginePane(&client, this);
- tabs->addTab(ep, tr("QML Engine"));
+ m_enginePane = new EnginePane(&client, this);
+ tabs->addTab(m_enginePane, tr("QML Engine"));
QObject::connect(&client, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(connectionStateChanged()));
connectionStateChanged();
@@ -104,6 +107,8 @@ void Shell::connectionStateChanged()
m_connectionState->setText(tr("Connected"));
m_connectButton->setEnabled(false);
m_disconnectButton->setEnabled(true);
+
+ QTimer::singleShot(0, m_enginePane, SLOT(refreshEngines()));
break;
case QAbstractSocket::ClosingState:
m_connectionState->setText(tr("Closing"));
diff --git a/tools/qmldebugger/watchtablemodel.cpp b/tools/qmldebugger/watchtablemodel.cpp
index 2fed199..9d3ca1e 100644
--- a/tools/qmldebugger/watchtablemodel.cpp
+++ b/tools/qmldebugger/watchtablemodel.cpp
@@ -87,6 +87,14 @@ QmlDebugWatch *WatchTableModel::findWatch(int objectDebugId, const QString &prop
return 0;
}
+QList<QmlDebugWatch *> WatchTableModel::watches() const
+{
+ QList<QmlDebugWatch *> watches;
+ for (int i=0; i<m_columns.count(); i++)
+ watches << m_columns[i].watch;
+ return watches;
+}
+
int WatchTableModel::rowCount(const QModelIndex &) const
{
return m_values.count();
diff --git a/tools/qmldebugger/watchtablemodel.h b/tools/qmldebugger/watchtablemodel.h
index ee99920..306b9d8 100644
--- a/tools/qmldebugger/watchtablemodel.h
+++ b/tools/qmldebugger/watchtablemodel.h
@@ -22,6 +22,8 @@ public:
QmlDebugWatch *findWatch(int column) const;
QmlDebugWatch *findWatch(int objectDebugId, const QString &property) const;
+ QList<QmlDebugWatch *> watches() const;
+
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;