summaryrefslogtreecommitdiffstats
path: root/tools/qmldebugger
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-09-24 06:19:56 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-09-24 06:19:56 (GMT)
commitf1e06cdd804934ff8c0b350b41d3d7187a21560c (patch)
tree8cc7053f90d6155f0336e7ac808e21081f48d9c3 /tools/qmldebugger
parentca244487b4ecc71f14ef6e0d371e848620b15b8d (diff)
downloadQt-f1e06cdd804934ff8c0b350b41d3d7187a21560c.zip
Qt-f1e06cdd804934ff8c0b350b41d3d7187a21560c.tar.gz
Qt-f1e06cdd804934ff8c0b350b41d3d7187a21560c.tar.bz2
Indicate which properties are watchable and use bold text instead of
coloured text for watched properties.
Diffstat (limited to 'tools/qmldebugger')
-rw-r--r--tools/qmldebugger/engine.cpp41
-rw-r--r--tools/qmldebugger/engine.h5
-rw-r--r--tools/qmldebugger/propertyview.cpp24
-rw-r--r--tools/qmldebugger/propertyview.h4
4 files changed, 42 insertions, 32 deletions
diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp
index 3fee46d..f76110c 100644
--- a/tools/qmldebugger/engine.cpp
+++ b/tools/qmldebugger/engine.cpp
@@ -14,6 +14,7 @@
#include <QMenu>
#include <QInputDialog>
#include <QFile>
+#include <QHeaderView>
#include <QPointer>
#include <private/qmlenginedebug_p.h>
#include <QtDeclarative/qmlcomponent.h>
@@ -97,31 +98,38 @@ void QmlObjectTree::mousePressEvent(QMouseEvent *me)
}
-
-class WatchTableView : public QTableView
+class WatchTableHeaderView : public QHeaderView
{
Q_OBJECT
public:
- WatchTableView(QWidget *parent);
+ WatchTableHeaderView(QTableView *parent);
signals:
void stopWatching(int column);
protected:
void mousePressEvent(QMouseEvent *me);
+
+private:
+ QTableView *m_table;
};
-WatchTableView::WatchTableView(QWidget *parent)
- : QTableView(parent)
+WatchTableHeaderView::WatchTableHeaderView(QTableView *parent)
+ : QHeaderView(Qt::Horizontal, parent), m_table(parent)
{
+ QObject::connect(this, SIGNAL(sectionClicked(int)),
+ m_table, SLOT(selectColumn(int)));
+ setClickable(true);
}
-void WatchTableView::mousePressEvent(QMouseEvent *me)
+void WatchTableHeaderView::mousePressEvent(QMouseEvent *me)
{
- QTableView::mousePressEvent(me);
- if (me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) {
- int col = columnAt(me->x());
+ QHeaderView::mousePressEvent(me);
+
+ if (me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) {
+ int col = logicalIndexAt(me->pos());
if (col >= 0) {
+ m_table->selectColumn(col);
QAction action(tr("Stop watching"), 0);
QList<QAction *> actions;
actions << &action;
@@ -193,20 +201,22 @@ EnginePane::EnginePane(QmlDebugConnection *client, QWidget *parent)
hbox->addWidget(m_objTree);
m_propView = new PropertyView(this);
- connect(m_propView, SIGNAL(propertyDoubleClicked(QmlDebugPropertyReference)),
- this, SLOT(propertyDoubleClicked(QmlDebugPropertyReference)));
+ connect(m_propView, SIGNAL(propertyActivated(QmlDebugPropertyReference)),
+ this, SLOT(propertyActivated(QmlDebugPropertyReference)));
m_watchTableModel = new WatchTableModel(this);
- m_watchTable = new WatchTableView(this);
+ m_watchTable = new QTableView(this);
m_watchTable->setModel(m_watchTableModel);
QObject::connect(m_watchTable, SIGNAL(activated(QModelIndex)),
this, SLOT(watchedItemActivated(QModelIndex)));
- QObject::connect(m_watchTable, SIGNAL(stopWatching(int)),
+ WatchTableHeaderView *header = new WatchTableHeaderView(m_watchTable);
+ m_watchTable->setHorizontalHeader(header);
+ QObject::connect(header, SIGNAL(stopWatching(int)),
this, SLOT(stopWatching(int)));
m_tabs = new QTabWidget(this);
m_tabs->addTab(m_propView, tr("Properties"));
- m_tabs->addTab(m_watchTable, tr("Watching"));
+ m_tabs->addTab(m_watchTable, tr("Watched"));
hbox->addWidget(m_tabs);
hbox->setStretchFactor(m_tabs, 2);
@@ -278,7 +288,7 @@ void EnginePane::valueChanged(const QByteArray &propertyName, const QVariant &va
}
}
-void EnginePane::propertyDoubleClicked(const QmlDebugPropertyReference &property)
+void EnginePane::propertyActivated(const QmlDebugPropertyReference &property)
{
PropertyView *view = qobject_cast<PropertyView*>(sender());
if (!view)
@@ -331,6 +341,7 @@ void EnginePane::watchedItemActivated(const QModelIndex &index)
QTreeWidgetItem *item = m_objTree->findItemByObjectId(watch->objectDebugId());
if (item) {
m_objTree->setCurrentItem(item);
+ m_objTree->scrollToItem(item);
item->setExpanded(true);
}
}
diff --git a/tools/qmldebugger/engine.h b/tools/qmldebugger/engine.h
index b3e0129..8e5d384 100644
--- a/tools/qmldebugger/engine.h
+++ b/tools/qmldebugger/engine.h
@@ -17,7 +17,6 @@ class QmlObjectTree;
class EngineClientPlugin;
class PropertyView;
class WatchTableModel;
-class WatchTableView;
class QLineEdit;
class QModelIndex;
class QTreeWidget;
@@ -52,7 +51,7 @@ private slots:
void valueChanged(const QByteArray &property, const QVariant &value);
- void propertyDoubleClicked(const QmlDebugPropertyReference &property);
+ void propertyActivated(const QmlDebugPropertyReference &property);
void propertyWatchStateChanged();
void watchedItemActivated(const QModelIndex &index);
void stopWatching(int column);
@@ -71,7 +70,7 @@ private:
QmlObjectTree *m_objTree;
QTabWidget *m_tabs;
PropertyView *m_propView;
- WatchTableView *m_watchTable;
+ QTableView *m_watchTable;
QmlView *m_engineView;
QList<QObject *> m_engineItems;
diff --git a/tools/qmldebugger/propertyview.cpp b/tools/qmldebugger/propertyview.cpp
index d5bb3df..44e406b 100644
--- a/tools/qmldebugger/propertyview.cpp
+++ b/tools/qmldebugger/propertyview.cpp
@@ -16,8 +16,8 @@ PropertyView::PropertyView(QWidget *parent)
m_tree = new QTreeWidget(this);
m_tree->setExpandsOnDoubleClick(false);
m_tree->setHeaderLabels(QStringList() << tr("Property") << tr("Value"));
- QObject::connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
- this, SLOT(itemDoubleClicked(QTreeWidgetItem *)));
+ QObject::connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
+ this, SLOT(itemActivated(QTreeWidgetItem *)));
m_tree->setColumnCount(2);
@@ -55,11 +55,12 @@ void PropertyView::setObject(const QmlDebugObjectReference &object)
const QmlDebugPropertyReference &p = properties[i];
PropertyViewItem *item = new PropertyViewItem(m_tree);
- item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- item->setCheckState(0, Qt::Unchecked);
item->property = p;
item->setText(0, p.name());
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ if (!p.hasNotifySignal())
+ item->setForeground(0, Qt::lightGray);
if (!p.binding().isEmpty()) {
PropertyViewItem *binding = new PropertyViewItem(item);
@@ -96,20 +97,19 @@ void PropertyView::setPropertyIsWatched(const QString &name, bool watched)
{
for (int i=0; i<m_tree->topLevelItemCount(); i++) {
PropertyViewItem *item = static_cast<PropertyViewItem *>(m_tree->topLevelItem(i));
- if (item->property.name() == name) {
- if (watched)
- item->setCheckState(0, Qt::Checked);
- else
- item->setCheckState(0, Qt::Unchecked);
+ if (item->property.name() == name && item->property.hasNotifySignal()) {
+ QFont font = m_tree->font();
+ font.setBold(watched);
+ item->setFont(0, font);
}
}
}
-void PropertyView::itemDoubleClicked(QTreeWidgetItem *i)
+void PropertyView::itemActivated(QTreeWidgetItem *i)
{
PropertyViewItem *item = static_cast<PropertyViewItem *>(i);
- if (!item->property.name().isEmpty())
- emit propertyDoubleClicked(item->property);
+ if (!item->property.name().isEmpty() && item->property.hasNotifySignal())
+ emit propertyActivated(item->property);
}
QT_END_NAMESPACE
diff --git a/tools/qmldebugger/propertyview.h b/tools/qmldebugger/propertyview.h
index 92200fa..6b69bdf 100644
--- a/tools/qmldebugger/propertyview.h
+++ b/tools/qmldebugger/propertyview.h
@@ -25,10 +25,10 @@ public:
void clear();
signals:
- void propertyDoubleClicked(const QmlDebugPropertyReference &property);
+ void propertyActivated(const QmlDebugPropertyReference &property);
private slots:
- void itemDoubleClicked(QTreeWidgetItem *);
+ void itemActivated(QTreeWidgetItem *);
private:
QmlDebugObjectReference m_object;