summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-10-27 04:04:03 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-10-27 04:04:03 (GMT)
commit578a9db47635e8a5dad55022c10f0222e7b1f29c (patch)
tree9feaa6f8b150070bf74676d994ba7e08ef4ea8c2 /tools
parent2559961affdbf66d1cfad3b71b439b6aea0bc66f (diff)
downloadQt-578a9db47635e8a5dad55022c10f0222e7b1f29c.zip
Qt-578a9db47635e8a5dad55022c10f0222e7b1f29c.tar.gz
Qt-578a9db47635e8a5dad55022c10f0222e7b1f29c.tar.bz2
Allow debugger components to be reset/cleared.
Diffstat (limited to 'tools')
-rw-r--r--tools/qmldebugger/canvasframerate.cpp63
-rw-r--r--tools/qmldebugger/canvasframerate.h22
-rw-r--r--tools/qmldebugger/expressionquerywidget.cpp25
-rw-r--r--tools/qmldebugger/expressionquerywidget.h2
-rw-r--r--tools/qmldebugger/objectpropertiesview.cpp7
-rw-r--r--tools/qmldebugger/objectpropertiesview.h1
-rw-r--r--tools/qmldebugger/objecttree.cpp3
-rw-r--r--tools/qmldebugger/qmldebugger.cpp3
-rw-r--r--tools/qmldebugger/watchtable.cpp18
-rw-r--r--tools/qmldebugger/watchtable.h3
10 files changed, 109 insertions, 38 deletions
diff --git a/tools/qmldebugger/canvasframerate.cpp b/tools/qmldebugger/canvasframerate.cpp
index 7c5d089..ae0131f 100644
--- a/tools/qmldebugger/canvasframerate.cpp
+++ b/tools/qmldebugger/canvasframerate.cpp
@@ -178,7 +178,6 @@ void QLineGraph::paintEvent(QPaintEvent *)
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
-
QRect r(50, 10, width() - 60, height() - 60);
p.setBrush(QColor("lightsteelblue"));
drawSample(&p, 0, r);
@@ -247,11 +246,10 @@ void CanvasFrameRatePlugin::messageReceived(const QByteArray &data)
ld = d;
}
-CanvasFrameRate::CanvasFrameRate(QmlDebugConnection *client, QWidget *parent)
-: QWidget(parent)
+CanvasFrameRate::CanvasFrameRate(QWidget *parent)
+: QWidget(parent),
+ m_plugin(0)
{
- m_plugin = new CanvasFrameRatePlugin(client);
-
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
@@ -261,7 +259,8 @@ CanvasFrameRate::CanvasFrameRate(QmlDebugConnection *client, QWidget *parent)
layout->addWidget(m_tabs);
QHBoxLayout *bottom = new QHBoxLayout;
- bottom->setSpacing(5);
+ bottom->setContentsMargins(5, 0, 5, 0);
+ bottom->setSpacing(10);
layout->addLayout(bottom);
QLabel *label = new QLabel("Resolution", this);
@@ -275,15 +274,51 @@ CanvasFrameRate::CanvasFrameRate(QmlDebugConnection *client, QWidget *parent)
bottom->addStretch(2);
- QCheckBox *check = new QCheckBox("Enable", this);
- bottom->addWidget(check);
- QObject::connect(check, SIGNAL(stateChanged(int)),
- this, SLOT(stateChanged(int)));
+ m_enabledCheckBox = new QCheckBox("Enable", this);
+ bottom->addWidget(m_enabledCheckBox);
+ QObject::connect(m_enabledCheckBox, SIGNAL(stateChanged(int)),
+ this, SLOT(enabledStateChanged(int)));
QPushButton *pb = new QPushButton(tr("New Tab"), this);
QObject::connect(pb, SIGNAL(clicked()), this, SLOT(newTab()));
bottom->addWidget(pb);
+}
+
+void CanvasFrameRate::reset(QmlDebugConnection *conn)
+{
+ delete m_plugin;
+ m_plugin = 0;
+
+ QWidget *w;
+ for (int i=0; i<m_tabs->count(); i++) {
+ w = m_tabs->widget(i);
+ m_tabs->removeTab(i);
+ delete w;
+ }
+ if (conn) {
+ connect(conn, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
+ SLOT(connectionStateChanged(QAbstractSocket::SocketState)));
+ if (conn->state() == QAbstractSocket::ConnectedState)
+ handleConnected(conn);
+ }
+}
+
+void CanvasFrameRate::connectionStateChanged(QAbstractSocket::SocketState state)
+{
+ if (state == QAbstractSocket::UnconnectedState) {
+ delete m_plugin;
+ m_plugin = 0;
+ } else if (state == QAbstractSocket::ConnectedState) {
+ handleConnected(qobject_cast<QmlDebugConnection*>(sender()));
+ }
+}
+
+void CanvasFrameRate::handleConnected(QmlDebugConnection *conn)
+{
+ delete m_plugin;
+ m_plugin = new CanvasFrameRatePlugin(conn);
+ enabledStateChanged(m_enabledCheckBox->checkState());
newTab();
}
@@ -299,6 +334,9 @@ QSize CanvasFrameRate::sizeHint() const
void CanvasFrameRate::newTab()
{
+ if (!m_plugin)
+ return;
+
if (m_tabs->count()) {
QWidget *w = m_tabs->widget(m_tabs->count() - 1);
QObject::disconnect(m_plugin, SIGNAL(sample(int,int,int,bool)),
@@ -317,11 +355,12 @@ void CanvasFrameRate::newTab()
m_tabs->setCurrentIndex(id);
}
-void CanvasFrameRate::stateChanged(int s)
+void CanvasFrameRate::enabledStateChanged(int s)
{
bool checked = s != 0;
- static_cast<QmlDebugClient *>(m_plugin)->setEnabled(checked);
+ if (m_plugin)
+ static_cast<QmlDebugClient *>(m_plugin)->setEnabled(checked);
}
QT_END_NAMESPACE
diff --git a/tools/qmldebugger/canvasframerate.h b/tools/qmldebugger/canvasframerate.h
index aa275aa..6c1ff9f 100644
--- a/tools/qmldebugger/canvasframerate.h
+++ b/tools/qmldebugger/canvasframerate.h
@@ -1,31 +1,43 @@
#ifndef CANVASFRAMERATE_H
#define CANVASFRAMERATE_H
-#include <QWidget>
+#include <QtCore/qpointer.h>
+#include <QtGui/qwidget.h>
+
+#include <QtDeclarative/qmldebugclient.h>
QT_BEGIN_NAMESPACE
-class QmlDebugConnection;
class QTabWidget;
class QSpinBox;
+class QCheckBox;
+
+class CanvasFrameRatePlugin;
+
class CanvasFrameRate : public QWidget
{
Q_OBJECT
public:
- CanvasFrameRate(QmlDebugConnection *, QWidget *parent = 0);
+ CanvasFrameRate(QWidget *parent = 0);
+
+ void reset(QmlDebugConnection *conn);
void setSizeHint(const QSize &);
virtual QSize sizeHint() const;
private slots:
void newTab();
- void stateChanged(int);
+ void enabledStateChanged(int);
+ void connectionStateChanged(QAbstractSocket::SocketState state);
private:
+ void handleConnected(QmlDebugConnection *conn);
+
QTabWidget *m_tabs;
QSpinBox *m_spin;
- QObject *m_plugin;
+ CanvasFrameRatePlugin *m_plugin;
QSize m_sizeHint;
+ QCheckBox *m_enabledCheckBox;
};
QT_END_NAMESPACE
diff --git a/tools/qmldebugger/expressionquerywidget.cpp b/tools/qmldebugger/expressionquerywidget.cpp
index 53ede3a..f8f5aef 100644
--- a/tools/qmldebugger/expressionquerywidget.cpp
+++ b/tools/qmldebugger/expressionquerywidget.cpp
@@ -17,28 +17,25 @@ ExpressionQueryWidget::ExpressionQueryWidget(QmlEngineDebug *client, QWidget *pa
m_client(client),
m_query(0),
m_textEdit(new QTextEdit),
- m_lineEdit(0),
- m_button(0)
+ m_lineEdit(0)
{
m_prompt = QLatin1String(">> ");
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
+ layout->setSpacing(0);
layout->addWidget(m_textEdit);
updateTitle();
if (m_style == Compact) {
- QHBoxLayout *hbox = new QHBoxLayout;
- m_button = new QPushButton(tr("Query"));
- m_button->setEnabled(false);
- connect(m_button, SIGNAL(clicked()), SLOT(executeExpression()));
m_lineEdit = new QLineEdit;
connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(executeExpression()));
- connect(m_lineEdit, SIGNAL(textChanged(QString)), SLOT(lineEditTextChanged(QString)));
+ QHBoxLayout *hbox = new QHBoxLayout;
+ hbox->setMargin(5);
+ hbox->setSpacing(5);
hbox->addWidget(new QLabel(tr("Expression:")));
hbox->addWidget(m_lineEdit);
- hbox->addWidget(m_button);
layout->addLayout(hbox);
m_textEdit->setReadOnly(true);
@@ -53,6 +50,12 @@ void ExpressionQueryWidget::setEngineDebug(QmlEngineDebug *client)
m_client = client;
}
+void ExpressionQueryWidget::clear()
+{
+ m_textEdit->clear();
+ m_lineEdit->clear();
+}
+
void ExpressionQueryWidget::updateTitle()
{
if (m_currObject.debugId() < 0) {
@@ -153,12 +156,6 @@ void ExpressionQueryWidget::showResult()
}
}
-void ExpressionQueryWidget::lineEditTextChanged(const QString &s)
-{
- if (m_button)
- m_button->setEnabled(!s.isEmpty());
-}
-
bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event)
{
if (obj == m_textEdit) {
diff --git a/tools/qmldebugger/expressionquerywidget.h b/tools/qmldebugger/expressionquerywidget.h
index 3d9b580..6fab059 100644
--- a/tools/qmldebugger/expressionquerywidget.h
+++ b/tools/qmldebugger/expressionquerywidget.h
@@ -24,6 +24,7 @@ public:
ExpressionQueryWidget(QmlEngineDebug *client = 0, QWidget *parent = 0);
void setEngineDebug(QmlEngineDebug *client);
+ void clear();
protected:
bool eventFilter(QObject *obj, QEvent *event);
@@ -34,7 +35,6 @@ public slots:
private slots:
void executeExpression();
void showResult();
- void lineEditTextChanged(const QString &s);
private:
void appendPrompt();
diff --git a/tools/qmldebugger/objectpropertiesview.cpp b/tools/qmldebugger/objectpropertiesview.cpp
index 274552a..ae9e8be 100644
--- a/tools/qmldebugger/objectpropertiesview.cpp
+++ b/tools/qmldebugger/objectpropertiesview.cpp
@@ -43,6 +43,7 @@ ObjectPropertiesView::ObjectPropertiesView(QmlEngineDebug *client, QWidget *pare
setLayout(layout);
m_tree = new QTreeWidget(this);
+ m_tree->setAlternatingRowColors(true);
m_tree->setExpandsOnDoubleClick(false);
m_tree->setHeaderLabels(QStringList() << tr("Property") << tr("Value"));
QObject::connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
@@ -58,6 +59,11 @@ void ObjectPropertiesView::setEngineDebug(QmlEngineDebug *client)
m_client = client;
}
+void ObjectPropertiesView::clear()
+{
+ setObject(QmlDebugObjectReference());
+}
+
void ObjectPropertiesView::reload(const QmlDebugObjectReference &obj)
{
if (!m_client)
@@ -105,7 +111,6 @@ void ObjectPropertiesView::setObject(const QmlDebugObjectReference &object)
m_object = object;
m_tree->clear();
-
QList<QmlDebugPropertyReference> properties = object.properties();
for (int i=0; i<properties.count(); i++) {
const QmlDebugPropertyReference &p = properties[i];
diff --git a/tools/qmldebugger/objectpropertiesview.h b/tools/qmldebugger/objectpropertiesview.h
index d555940..6a1fc03 100644
--- a/tools/qmldebugger/objectpropertiesview.h
+++ b/tools/qmldebugger/objectpropertiesview.h
@@ -18,6 +18,7 @@ public:
ObjectPropertiesView(QmlEngineDebug *client = 0, QWidget *parent = 0);
void setEngineDebug(QmlEngineDebug *client);
+ void clear();
signals:
void activated(const QmlDebugObjectReference &, const QmlDebugPropertyReference &);
diff --git a/tools/qmldebugger/objecttree.cpp b/tools/qmldebugger/objecttree.cpp
index 981a80b..4059e77 100644
--- a/tools/qmldebugger/objecttree.cpp
+++ b/tools/qmldebugger/objecttree.cpp
@@ -68,6 +68,9 @@ void ObjectTree::objectFetched()
void ObjectTree::currentItemChanged(QTreeWidgetItem *item)
{
+ if (!item)
+ return;
+
QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value<QmlDebugObjectReference>();
if (obj.debugId() < 0) {
qWarning("QML Object Tree: bad object id");
diff --git a/tools/qmldebugger/qmldebugger.cpp b/tools/qmldebugger/qmldebugger.cpp
index 2828026..5455878 100644
--- a/tools/qmldebugger/qmldebugger.cpp
+++ b/tools/qmldebugger/qmldebugger.cpp
@@ -45,7 +45,8 @@ QmlDebugger::QmlDebugger(QWidget *parent)
m_tabs = new QTabWidget(this);
layout->addWidget(m_tabs);
- CanvasFrameRate *cfr = new CanvasFrameRate(&client, this);
+ CanvasFrameRate *cfr = new CanvasFrameRate(this);
+ cfr->reset(&client);
cfr->setSizeHint(QSize(800, 600));
m_tabs->addTab(cfr, tr("Frame Rate"));
diff --git a/tools/qmldebugger/watchtable.cpp b/tools/qmldebugger/watchtable.cpp
index 774727b..ee74cfb 100644
--- a/tools/qmldebugger/watchtable.cpp
+++ b/tools/qmldebugger/watchtable.cpp
@@ -18,7 +18,7 @@ WatchTableModel::WatchTableModel(QmlEngineDebug *client, QObject *parent)
}
WatchTableModel::~WatchTableModel()
-{
+{
for (int i=0; i<m_columns.count(); i++)
delete m_columns[i].watch;
}
@@ -247,7 +247,7 @@ void WatchTableModel::expressionWatchRequested(const QmlDebugObjectReference &ob
}
}
-void WatchTableModel::stopWatching(int column)
+void WatchTableModel::removeWatchAt(int column)
{
if (!m_client)
return;
@@ -260,6 +260,17 @@ void WatchTableModel::stopWatching(int column)
}
}
+void WatchTableModel::removeAllWatches()
+{
+ for (int i=0; i<m_columns.count(); i++) {
+ if (m_client)
+ m_client->removeWatch(m_columns[i].watch);
+ delete m_columns[i].watch;
+ }
+ m_columns.clear();
+ m_values.clear();
+ reset();
+}
//----------------------------------------------
@@ -281,7 +292,7 @@ void WatchTableHeaderView::mousePressEvent(QMouseEvent *me)
QList<QAction *> actions;
actions << &action;
if (QMenu::exec(actions, me->globalPos()))
- m_model->stopWatching(col);
+ m_model->removeWatchAt(col);
}
}
}
@@ -293,6 +304,7 @@ WatchTableView::WatchTableView(WatchTableModel *model, QWidget *parent)
: QTableView(parent),
m_model(model)
{
+ setAlternatingRowColors(true);
connect(model, SIGNAL(watchCreated(QmlDebugWatch*)), SLOT(watchCreated(QmlDebugWatch*)));
connect(this, SIGNAL(activated(QModelIndex)), SLOT(indexActivated(QModelIndex)));
}
diff --git a/tools/qmldebugger/watchtable.h b/tools/qmldebugger/watchtable.h
index 772142c..67c2565 100644
--- a/tools/qmldebugger/watchtable.h
+++ b/tools/qmldebugger/watchtable.h
@@ -29,7 +29,8 @@ public:
QmlDebugWatch *findWatch(int column) const;
int columnForWatch(QmlDebugWatch *watch) const;
- void stopWatching(int column);
+ void removeWatchAt(int column);
+ void removeAllWatches();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;