From 0355027fc68e7ceafe0ee1d439772b0b00656e09 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 29 Oct 2009 15:48:41 +1000 Subject: Minor improvements --- tools/qmldebugger/standalone/expressionquerywidget.cpp | 13 +++++-------- tools/qmldebugger/standalone/objectpropertiesview.cpp | 2 +- tools/qmldebugger/standalone/qmldebugger.cpp | 3 ++- tools/qmldebugger/standalone/watchtable.cpp | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tools/qmldebugger/standalone/expressionquerywidget.cpp b/tools/qmldebugger/standalone/expressionquerywidget.cpp index e064189..a0d3df6 100644 --- a/tools/qmldebugger/standalone/expressionquerywidget.cpp +++ b/tools/qmldebugger/standalone/expressionquerywidget.cpp @@ -112,7 +112,7 @@ void ExpressionQueryWidget::showCurrentContext() m_textEdit->setTextColor(Qt::darkGreen); m_textEdit->append(m_currObject.className() + QLatin1String(": ") - + (m_currObject.name().isEmpty() ? QLatin1String("") : m_currObject.name())); + + (m_currObject.name().isEmpty() ? QLatin1String("") : m_currObject.name())); appendPrompt(); } @@ -149,15 +149,12 @@ void ExpressionQueryWidget::showResult() QVariant value = m_query->result(); QString result; - if (value.isNull()) { + if (value.type() == QVariant::List || value.type() == QVariant::StringList) { + result = tr("<%1 items>", "%1 = number of items").arg(value.toList().count()); + } else if (value.isNull()) { result = QLatin1String(""); } else { - if (value.canConvert(QVariant::String)) { - result = value.toString(); - } else { - QDebug debug(&result); - debug << value; - } + result = value.toString(); } if (m_mode == SeparateEntryMode) { diff --git a/tools/qmldebugger/standalone/objectpropertiesview.cpp b/tools/qmldebugger/standalone/objectpropertiesview.cpp index d6fefa0..b8e10a3 100644 --- a/tools/qmldebugger/standalone/objectpropertiesview.cpp +++ b/tools/qmldebugger/standalone/objectpropertiesview.cpp @@ -141,7 +141,7 @@ void ObjectPropertiesView::setPropertyValue(PropertiesViewItem *item, const QVar item->setExpanded(false); } else { - item->setText(1, (value.isNull() ? QLatin1String("") : value.toString())); + item->setText(1, (value.isNull() ? QLatin1String("") : value.toString())); item->setExpanded(true); } diff --git a/tools/qmldebugger/standalone/qmldebugger.cpp b/tools/qmldebugger/standalone/qmldebugger.cpp index 5882cb2..b91763d 100644 --- a/tools/qmldebugger/standalone/qmldebugger.cpp +++ b/tools/qmldebugger/standalone/qmldebugger.cpp @@ -17,7 +17,6 @@ QmlDebugger::QmlDebugger(QWidget *parent) QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); - QHBoxLayout *connectLayout = new QHBoxLayout; layout->addLayout(connectLayout); connectLayout->addStretch(2); @@ -61,6 +60,8 @@ QmlDebugger::QmlDebugger(QWidget *parent) this, SLOT(connectionError(QAbstractSocket::SocketError))); m_tabs->setCurrentIndex(1); + + connectToHost(); } void QmlDebugger::setHost(const QString &host) diff --git a/tools/qmldebugger/standalone/watchtable.cpp b/tools/qmldebugger/standalone/watchtable.cpp index 19f034e..7483d28 100644 --- a/tools/qmldebugger/standalone/watchtable.cpp +++ b/tools/qmldebugger/standalone/watchtable.cpp @@ -217,7 +217,7 @@ void WatchTableModel::togglePropertyWatch(const QmlDebugObjectReference &object, + QLatin1String(" on\n") + object.className() + QLatin1String(":\n") - + (object.name().isEmpty() ? QLatin1String("") : object.name()); + + (object.name().isEmpty() ? QLatin1String("") : object.name()); addWatch(watch, desc); emit watchCreated(watch); } -- cgit v0.12 From 37b5b477a044929bf69fe5f7251f2b5cbd892d93 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 29 Oct 2009 15:51:36 +1000 Subject: Minor changes --- src/declarative/qml/qmlenginedebug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 63be6b0..8629f3a 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -143,7 +143,7 @@ QVariant QmlEngineDebugServer::valueContents(const QVariant &value) const if (o) { QString name = o->objectName(); if (name.isEmpty()) - name = QLatin1String(""); + name = QLatin1String(""); return name; } } -- cgit v0.12 From 55e2858f2146d72bc43bde850dbec0cf7aa055e6 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 2 Nov 2009 11:16:02 +1000 Subject: Make QmlBoundSignal children look like properties (instead of children) in the debugger to reflect how signal properties are written in QML. This also changes the FETCH_OBJECT reply stream to send children data before property data. --- src/declarative/debugger/qmldebug.cpp | 42 +++++++++++++++---------- src/declarative/qml/qmlenginedebug.cpp | 56 +++++++++++++++++++++++++++++----- src/declarative/qml/qmlenginedebug_p.h | 2 +- 3 files changed, 75 insertions(+), 25 deletions(-) diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index 5a8cda0..08d3d75 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -110,6 +110,15 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o, if (simple) return; + int childCount; + bool recur; + ds >> childCount >> recur; + + for (int ii = 0; ii < childCount; ++ii) { + o.m_children.append(QmlDebugObjectReference()); + decode(ds, o.m_children.last(), !recur); + } + int propCount; ds >> propCount; @@ -122,25 +131,26 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o, prop.m_binding = data.binding; prop.m_hasNotifySignal = data.hasNotifySignal; prop.m_valueTypeName = data.valueTypeName; - if (data.type == QmlEngineDebugServer::QmlObjectProperty::Basic - || data.type == QmlEngineDebugServer::QmlObjectProperty::List) { - prop.m_value = data.value; - } else if (data.type == QmlEngineDebugServer::QmlObjectProperty::Object) { - QmlDebugObjectReference obj; - obj.m_debugId = prop.m_value.toInt(); - prop.m_value = qVariantFromValue(obj); + switch (data.type) { + case QmlEngineDebugServer::QmlObjectProperty::Basic: + case QmlEngineDebugServer::QmlObjectProperty::List: + case QmlEngineDebugServer::QmlObjectProperty::SignalProperty: + { + prop.m_value = data.value; + break; + } + case QmlEngineDebugServer::QmlObjectProperty::Object: + { + QmlDebugObjectReference obj; + obj.m_debugId = prop.m_value.toInt(); + prop.m_value = qVariantFromValue(obj); + break; + } + case QmlEngineDebugServer::QmlObjectProperty::Unknown: + break; } o.m_properties << prop; } - - int childCount; - bool recur; - ds >> childCount >> recur; - - for (int ii = 0; ii < childCount; ++ii) { - o.m_children.append(QmlDebugObjectReference()); - decode(ds, o.m_children.last(), !recur); - } } void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugContextReference &c) diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 8629f3a..7fb8d36 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -155,21 +155,61 @@ void QmlEngineDebugServer::buildObjectDump(QDataStream &message, QObject *object, bool recur) { message << objectData(object); - message << object->metaObject()->propertyCount(); - for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) - message << propertyData(object, ii); + // Some children aren't added to an object until particular properties are read + // - e.g. child state objects aren't added until the 'states' property is read - + // but this should only affect internal objects that aren't shown by the + // debugger anyway. QObjectList children = object->children(); - message << children.count() << recur; + + int childrenCount = children.count(); + for (int ii = 0; ii < children.count(); ++ii) { + if (QmlBoundSignal::cast(children[ii])) + --childrenCount; + } + + message << childrenCount << recur; + + QList fakeProperties; for (int ii = 0; ii < children.count(); ++ii) { QObject *child = children.at(ii); - if (recur) - buildObjectDump(message, child, recur); - else - message << objectData(child); + QmlBoundSignal *signal = QmlBoundSignal::cast(child); + if (signal) { + QmlObjectProperty prop; + prop.type = QmlObjectProperty::SignalProperty; + prop.hasNotifySignal = false; + QmlExpression *expr = signal->expression(); + if (expr) { + prop.value = expr->expression(); + QObject *scope = expr->scopeObject(); + if (scope) { + QString sig = scope->metaObject()->method(signal->index()).signature(); + int lparen = sig.indexOf(QLatin1Char('(')); + if (lparen >= 0) { + QString methodName = sig.mid(0, lparen); + prop.name = QLatin1String("on") + methodName[0].toUpper() + + methodName.mid(1); + } + } + } + fakeProperties << prop; + } else { + if (recur) + buildObjectDump(message, child, recur); + else + message << objectData(child); + } } + + message << (object->metaObject()->propertyCount() + fakeProperties.count()); + + for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) + message << propertyData(object, ii); + + for (int ii = 0; ii < fakeProperties.count(); ++ii) + message << fakeProperties[ii]; } void QmlEngineDebugServer::buildObjectList(QDataStream &message, diff --git a/src/declarative/qml/qmlenginedebug_p.h b/src/declarative/qml/qmlenginedebug_p.h index a8572eb..7dbbbda 100644 --- a/src/declarative/qml/qmlenginedebug_p.h +++ b/src/declarative/qml/qmlenginedebug_p.h @@ -81,7 +81,7 @@ public: }; struct QmlObjectProperty { - enum Type { Unknown, Basic, Object, List }; + enum Type { Unknown, Basic, Object, List, SignalProperty }; Type type; QString name; QVariant value; -- cgit v0.12 From 837f5d2385e413b89e78cd487f5a3f818c179292 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 2 Nov 2009 11:23:59 +1000 Subject: Fix to send correct data for property value changes. --- src/declarative/qml/qmlenginedebug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 7fb8d36..5b54fbb 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -418,7 +418,7 @@ void QmlEngineDebugServer::propertyChanged(int id, int objectId, const QMetaProp QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("UPDATE_WATCH") << id << objectId << QString::fromUtf8(property.name()) << valueContents(value); + rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value); sendMessage(reply); } -- cgit v0.12