From fb5d5ce1cd1e2714343c3e26338601aa5dd79a54 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Oct 2009 10:13:55 +1000 Subject: Give more information about the value of a property when the variant toString() is empty. --- src/declarative/qml/qmlenginedebug.cpp | 12 +++++++++--- tools/qmldebugger/objectpropertiesview.cpp | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index e20616a..1c7450a 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -318,7 +318,7 @@ void QmlEngineDebugServer::propertyChanged(int id, int objectId, const QByteArra QByteArray reply; QVariant v; QDataStream rs(&reply, QIODevice::WriteOnly); - + if (value.type() == QVariant::UserType || QmlMetaType::isObject(value.userType())) { QObject *o = QmlMetaType::toQObject(value); if (o) { @@ -327,9 +327,15 @@ void QmlEngineDebugServer::propertyChanged(int id, int objectId, const QByteArra objectName = QLatin1String(""); 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(""); + v = s; } - if (v.isNull()) - v = value.toString(); } else { v = value; } diff --git a/tools/qmldebugger/objectpropertiesview.cpp b/tools/qmldebugger/objectpropertiesview.cpp index f725194..864468c 100644 --- a/tools/qmldebugger/objectpropertiesview.cpp +++ b/tools/qmldebugger/objectpropertiesview.cpp @@ -109,7 +109,7 @@ void ObjectPropertiesView::setObject(const QmlDebugObjectReference &object) item->setText(0, p.name()); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); if (!p.hasNotifySignal()) - item->setForeground(0, Qt::lightGray); + item->setForeground(0, Qt::gray); if (!p.binding().isEmpty()) { PropertiesViewItem *binding = new PropertiesViewItem(item); @@ -159,8 +159,18 @@ void ObjectPropertiesView::valueChanged(const QByteArray &name, const QVariant & { for (int i=0; itopLevelItemCount(); i++) { PropertiesViewItem *item = static_cast(m_tree->topLevelItem(i)); - if (item->property.name() == name) - item->setText(1, value.toString()); + if (item->property.name() == name) { + if (value.isNull()) { + item->setText(1, QLatin1String("null")); + item->setForeground(1, Qt::gray); + } else { + QString s = value.toString(); + if (s.isEmpty()) + s = QString::fromUtf8(value.typeName()); + item->setText(1, s); + item->setForeground(1, QBrush()); + } + } } } -- cgit v0.12