summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/debugger/qmldebug.cpp15
-rw-r--r--src/declarative/debugger/qmldebug.h2
-rw-r--r--src/declarative/qml/qmlenginedebug.cpp29
-rw-r--r--src/declarative/qml/qmlenginedebug_p.h1
-rw-r--r--tools/qmldebugger/expressionquerywidget.cpp55
-rw-r--r--tools/qmldebugger/expressionquerywidget.h4
-rw-r--r--tools/qmldebugger/objectpropertiesview.cpp19
7 files changed, 89 insertions, 36 deletions
diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp
index 75418e8..2537ec0 100644
--- a/src/declarative/debugger/qmldebug.cpp
+++ b/src/declarative/debugger/qmldebug.cpp
@@ -117,6 +117,7 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o,
prop.m_name = data.name;
prop.m_binding = data.binding;
prop.m_hasNotifySignal = data.hasNotifySignal;
+ prop.m_valueTypeName = data.valueTypeName;
if (data.type == QmlEngineDebugServer::QmlObjectProperty::Basic)
prop.m_value = data.value;
else if (data.type == QmlEngineDebugServer::QmlObjectProperty::Object) {
@@ -124,7 +125,6 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o,
obj.m_debugId = prop.m_value.toInt();
prop.m_value = qVariantFromValue(obj);
}
-
o.m_properties << prop;
}
@@ -812,13 +812,17 @@ QmlDebugPropertyReference::QmlDebugPropertyReference()
}
QmlDebugPropertyReference::QmlDebugPropertyReference(const QmlDebugPropertyReference &o)
-: m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), m_binding(o.m_binding), m_hasNotifySignal(o.m_hasNotifySignal)
+: m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value),
+ m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding),
+ m_hasNotifySignal(o.m_hasNotifySignal)
{
}
QmlDebugPropertyReference &QmlDebugPropertyReference::operator=(const QmlDebugPropertyReference &o)
{
- m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; m_binding = o.m_binding; m_hasNotifySignal = o.m_hasNotifySignal;
+ m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value;
+ m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding;
+ m_hasNotifySignal = o.m_hasNotifySignal;
return *this;
}
@@ -832,6 +836,11 @@ QString QmlDebugPropertyReference::name() const
return m_name;
}
+QString QmlDebugPropertyReference::valueTypeName() const
+{
+ return m_valueTypeName;
+}
+
QVariant QmlDebugPropertyReference::value() const
{
return m_value;
diff --git a/src/declarative/debugger/qmldebug.h b/src/declarative/debugger/qmldebug.h
index 153a10f..bd076ff 100644
--- a/src/declarative/debugger/qmldebug.h
+++ b/src/declarative/debugger/qmldebug.h
@@ -232,6 +232,7 @@ public:
int objectDebugId() const;
QString name() const;
QVariant value() const;
+ QString valueTypeName() const;
QString binding() const;
bool hasNotifySignal() const;
@@ -240,6 +241,7 @@ private:
int m_objectDebugId;
QString m_name;
QVariant m_value;
+ QString m_valueTypeName;
QString m_binding;
bool m_hasNotifySignal;
};
diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp
index bbe6f77..7178e6c 100644
--- a/src/declarative/qml/qmlenginedebug.cpp
+++ b/src/declarative/qml/qmlenginedebug.cpp
@@ -80,7 +80,8 @@ QDataStream &operator>>(QDataStream &ds,
QDataStream &operator<<(QDataStream &ds,
const QmlEngineDebugServer::QmlObjectProperty &data)
{
- ds << (int)data.type << data.name << data.value << data.binding << data.hasNotifySignal;
+ ds << (int)data.type << data.name << data.value << data.valueTypeName
+ << data.binding << data.hasNotifySignal;
return ds;
}
@@ -88,7 +89,8 @@ QDataStream &operator>>(QDataStream &ds,
QmlEngineDebugServer::QmlObjectProperty &data)
{
int type;
- ds >> type >> data.name >> data.value >> data.binding >> data.hasNotifySignal;
+ ds >> type >> data.name >> data.value >> data.valueTypeName
+ >> data.binding >> data.hasNotifySignal;
data.type = (QmlEngineDebugServer::QmlObjectProperty::Type)type;
return ds;
}
@@ -101,6 +103,7 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx)
QMetaProperty prop = obj->metaObject()->property(propIdx);
rv.type = QmlObjectProperty::Unknown;
+ rv.valueTypeName = QString::fromUtf8(prop.typeName());
rv.name = prop.name();
rv.hasNotifySignal = prop.hasNotifySignal();
QmlAbstractBinding *binding = QmlMetaProperty(obj, rv.name).binding();
@@ -116,6 +119,7 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx)
QmlMetaType::isQmlList(prop.userType())) {
rv.type = QmlObjectProperty::List;
}
+
return rv;
}
@@ -149,7 +153,7 @@ void QmlEngineDebugServer::buildObjectList(QDataStream &message,
int ctxtId = QmlDebugService::idForObject(ctxt);
message << ctxtName << ctxtId;
-
+
int count = 0;
for (QSet<QmlContext *>::ConstIterator iter = p->childContexts.begin();
@@ -186,6 +190,12 @@ void QmlEngineDebugServer::buildObjectList(QDataStream &message,
QVariant QmlEngineDebugServer::serializableVariant(const QVariant &value)
{
+ if (value.type() < QVariant::UserType)
+ return value;
+
+ if (!value.toString().isEmpty())
+ return value.toString();
+
QVariant v;
if (value.type() == QVariant::UserType || QmlMetaType::isObject(value.userType())) {
QObject *o = QmlMetaType::toQObject(value);
@@ -195,19 +205,12 @@ QVariant QmlEngineDebugServer::serializableVariant(const QVariant &value)
objectName = QLatin1String("<unnamed>");
v = QString::fromUtf8(o->metaObject()->className()) +
QLatin1String(": ") + objectName;
- } else {
- v = QString::fromUtf8(value.typeName());
- }
- if (v.isNull()) {
- QString s = value.toString();
- if (s.isEmpty())
- s = QLatin1String("<unknown>");
- v = s;
}
- } else {
- v = value;
}
+ if (v.isNull())
+ v = QString::fromUtf8(value.typeName());
+
return v;
}
diff --git a/src/declarative/qml/qmlenginedebug_p.h b/src/declarative/qml/qmlenginedebug_p.h
index 9ad198a..075a711 100644
--- a/src/declarative/qml/qmlenginedebug_p.h
+++ b/src/declarative/qml/qmlenginedebug_p.h
@@ -85,6 +85,7 @@ public:
Type type;
QString name;
QVariant value;
+ QString valueTypeName;
QString binding;
bool hasNotifySignal;
};
diff --git a/tools/qmldebugger/expressionquerywidget.cpp b/tools/qmldebugger/expressionquerywidget.cpp
index 90ab8ee..b29b465 100644
--- a/tools/qmldebugger/expressionquerywidget.cpp
+++ b/tools/qmldebugger/expressionquerywidget.cpp
@@ -16,7 +16,8 @@ ExpressionQueryWidget::ExpressionQueryWidget(QmlEngineDebug *client, QWidget *pa
m_query(0),
m_groupBox(0),
m_textEdit(new QTextEdit),
- m_lineEdit(0)
+ m_lineEdit(0),
+ m_button(0)
{
m_prompt = QLatin1String(">> ");
@@ -31,16 +32,19 @@ ExpressionQueryWidget::ExpressionQueryWidget(QmlEngineDebug *client, QWidget *pa
if (m_style == Compact) {
QHBoxLayout *hbox = new QHBoxLayout;
- QPushButton *button = new QPushButton(tr("Execute"));
- connect(button, SIGNAL(clicked()), SLOT(executeExpression()));
+ m_button = new QPushButton(tr("Execute"));
+ 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)));
hbox->addWidget(new QLabel(tr("Expression:")));
hbox->addWidget(m_lineEdit);
- hbox->addWidget(button);
+ hbox->addWidget(m_button);
vbox->addLayout(hbox);
m_textEdit->setReadOnly(true);
+ m_lineEdit->installEventFilter(this);
} else {
m_textEdit->installEventFilter(this);
}
@@ -55,7 +59,7 @@ void ExpressionQueryWidget::updateTitle()
+ m_currObject.className() + QLatin1String(": ")
+ (m_currObject.name().isEmpty() ? QLatin1String("<unnamed>") : m_currObject.name())
+ QLatin1String(">");
- m_groupBox->setTitle(tr("Expression queries (current context: %1)"
+ m_groupBox->setTitle(tr("Expression queries (using context for %1)"
, "Selected object").arg(desc));
}
}
@@ -101,18 +105,20 @@ void ExpressionQueryWidget::executeExpression()
{
if (m_style == Compact)
m_expr = m_lineEdit->text().trimmed();
+ else
+ m_expr = m_expr.trimmed();
- if (!m_expr.trimmed().isEmpty() && m_currObject.debugId() != -1) {
- checkCurrentContext();
+ if (!m_expr.isEmpty() && m_currObject.debugId() != -1) {
if (m_query)
delete m_query;
- m_query = m_client->queryExpressionResult(m_currObject.debugId(), m_expr.trimmed(), this);
+ m_query = m_client->queryExpressionResult(m_currObject.debugId(), m_expr, this);
if (!m_query->isWaiting())
showResult();
else
QObject::connect(m_query, SIGNAL(stateChanged(State)),
this, SLOT(showResult()));
+ m_lastExpr = m_expr;
if (m_lineEdit)
m_lineEdit->clear();
}
@@ -122,9 +128,11 @@ void ExpressionQueryWidget::showResult()
{
if (m_query) {
m_textEdit->moveCursor(QTextCursor::End);
- QString result = m_query->result().toString();
- if (result.isEmpty())
+ QString result;
+ if (m_query->result().isNull())
result = QLatin1String("<no value>");
+ else
+ result = m_query->result().toString();
if (m_style == Compact) {
m_textEdit->setTextColor(Qt::black);
@@ -140,6 +148,12 @@ 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) {
@@ -176,6 +190,27 @@ bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event)
default:
break;
}
+ } else if (obj == m_lineEdit) {
+ switch (event->type()) {
+ case QEvent::KeyPress:
+ {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ int key = keyEvent->key();
+ if (key == Qt::Key_Up && m_lineEdit->text() != m_lastExpr) {
+ m_expr = m_lineEdit->text();
+ if (!m_lastExpr.isEmpty())
+ m_lineEdit->setText(m_lastExpr);
+ } else if (key == Qt::Key_Down) {
+ m_lineEdit->setText(m_expr);
+ }
+ break;
+ }
+ case QEvent::FocusIn:
+ checkCurrentContext();
+ break;
+ default:
+ break;
+ }
}
return QWidget::eventFilter(obj, event);
}
diff --git a/tools/qmldebugger/expressionquerywidget.h b/tools/qmldebugger/expressionquerywidget.h
index 3ea95ac..8db8f9f 100644
--- a/tools/qmldebugger/expressionquerywidget.h
+++ b/tools/qmldebugger/expressionquerywidget.h
@@ -10,6 +10,7 @@ QT_BEGIN_NAMESPACE
class QGroupBox;
class QTextEdit;
class QLineEdit;
+class QPushButton;
class ExpressionQueryWidget : public QWidget
{
@@ -31,6 +32,7 @@ public slots:
private slots:
void executeExpression();
void showResult();
+ void lineEditTextChanged(const QString &s);
private:
void appendPrompt();
@@ -45,8 +47,10 @@ private:
QGroupBox *m_groupBox;
QTextEdit *m_textEdit;
QLineEdit *m_lineEdit;
+ QPushButton *m_button;
QString m_prompt;
QString m_expr;
+ QString m_lastExpr;
QmlDebugObjectReference m_currObject;
QmlDebugObjectReference m_objectAtLastFocus;
diff --git a/tools/qmldebugger/objectpropertiesview.cpp b/tools/qmldebugger/objectpropertiesview.cpp
index 4a2f97d..61afe3f 100644
--- a/tools/qmldebugger/objectpropertiesview.cpp
+++ b/tools/qmldebugger/objectpropertiesview.cpp
@@ -22,12 +22,12 @@ public:
};
PropertiesViewItem::PropertiesViewItem(QTreeWidget *widget)
-: QTreeWidgetItem(widget)
+ : QTreeWidgetItem(widget)
{
}
PropertiesViewItem::PropertiesViewItem(QTreeWidgetItem *parent)
-: QTreeWidgetItem(parent)
+ : QTreeWidgetItem(parent)
{
}
@@ -108,8 +108,10 @@ void ObjectPropertiesView::setObject(const QmlDebugObjectReference &object)
item->setText(0, p.name());
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
- if (!p.hasNotifySignal())
+ if (!p.hasNotifySignal()) {
item->setForeground(0, Qt::gray);
+ item->setForeground(1, Qt::gray);
+ }
if (!p.binding().isEmpty()) {
PropertiesViewItem *binding = new PropertiesViewItem(item);
@@ -161,14 +163,11 @@ void ObjectPropertiesView::valueChanged(const QByteArray &name, const QVariant &
PropertiesViewItem *item = static_cast<PropertiesViewItem *>(m_tree->topLevelItem(i));
if (item->property.name() == name) {
if (value.isNull()) {
- item->setText(1, QLatin1String("null"));
- item->setForeground(1, Qt::gray);
+ item->setText(1, QLatin1String("<null>")
+ + QLatin1String(" : ")
+ + item->property.valueTypeName());
} else {
- QString s = value.toString();
- if (s.isEmpty())
- s = QString::fromUtf8(value.typeName());
- item->setText(1, s);
- item->setForeground(1, QBrush());
+ item->setText(1, value.toString());
}
}
}