summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlinfo.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-12-18 01:42:51 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-12-18 01:49:55 (GMT)
commit7cb8f90c27f29cee09bd81d747142842d809d775 (patch)
treea484487de1bb3cc6f7f57b434250670d116d1dc0 /src/declarative/qml/qmlinfo.cpp
parent1900bfc37d38806894db2eb1deace8aff200ed88 (diff)
downloadQt-7cb8f90c27f29cee09bd81d747142842d809d775.zip
Qt-7cb8f90c27f29cee09bd81d747142842d809d775.tar.gz
Qt-7cb8f90c27f29cee09bd81d747142842d809d775.tar.bz2
Have qmlInfo report the QML element name rather than C++ class name.
Task-number: QTBUG-5476
Diffstat (limited to 'src/declarative/qml/qmlinfo.cpp')
-rw-r--r--src/declarative/qml/qmlinfo.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp
index 27f5426..dabf944 100644
--- a/src/declarative/qml/qmlinfo.cpp
+++ b/src/declarative/qml/qmlinfo.cpp
@@ -43,6 +43,7 @@
#include "qmldeclarativedata_p.h"
#include "qmlcontext.h"
+#include "qmlmetatype.h"
#include <QCoreApplication>
@@ -53,7 +54,7 @@ QT_BEGIN_NAMESPACE
\brief Prints warnings messages that include the file and line number for QML types.
- When QML types display warning messages, it improves tracibility
+ When QML types display warning messages, it improves traceability
if they include the QML file and line number on which the
particular instance was instantiated.
@@ -71,7 +72,7 @@ QT_BEGIN_NAMESPACE
prints
\code
- QML ComponentInstance (unknown location): component property is a write-once property
+ QML MyCustomType (unknown location): component property is a write-once property
\endcode
*/
@@ -81,7 +82,22 @@ QmlInfo::QmlInfo(const QObject *object)
QString pos = QLatin1String("QML");
if (object) {
pos += QLatin1Char(' ');
- pos += QLatin1String(object->metaObject()->className());
+
+ QString typeName;
+ QmlType *type = QmlMetaType::qmlType(object->metaObject());
+ if (type) {
+ typeName = QLatin1String(type->qmlTypeName());
+ int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
+ if (lastSlash != -1)
+ typeName = typeName.mid(lastSlash+1);
+ } else {
+ typeName = QString::fromUtf8(object->metaObject()->className());
+ int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
+ if (marker != -1)
+ typeName = typeName.left(marker);
+ }
+
+ pos += typeName;
}
QmlDeclarativeData *ddata = object?QmlDeclarativeData::get(object):0;
pos += QLatin1String(" (");