diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-04-01 11:46:33 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-04-02 06:37:52 +0000 |
commit | e7dae6e672b675a9cdab58bcef4ac22bc494c256 (patch) | |
tree | cdba5bc99fb44e4103dd56ff470e47c21b111e4f /src/quick/items/qquickitem.cpp | |
parent | c1cfbd14438a77e5b4463e15976d9001d4116745 (diff) |
Improve debug operator for QQuickItem.
Use new formatting helpers and output name, z only when necessary.
For example,
QQuickRectangle_QML_4 (this = 0xb380e0 , name= "" , parent = 0xa4a290 , geometry = QRectF(0,0 320x480) , z = 0 )
becomes:
QQuickRectangle_QML_4(0xb380e0, parent=0xa4a290, geometry=0,0 320x480)
Change-Id: I5d4a8cf9f435995754f875a928fa36978418e4bf
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 776da86b7e..7ab2faf052 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -49,7 +49,6 @@ #include <QtGui/qstylehints.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/qinputmethod.h> -#include <QtCore/qdebug.h> #include <QtCore/qcoreevent.h> #include <QtCore/qnumeric.h> #include <QtGui/qpa/qplatformtheme.h> @@ -66,6 +65,7 @@ #include <private/qv4engine_p.h> #include <private/qv4object_p.h> +#include <private/qdebug_p.h> #ifndef QT_NO_CURSOR # include <QtGui/qcursor.h> @@ -7315,18 +7315,27 @@ bool QQuickItem::event(QEvent *ev) } #ifndef QT_NO_DEBUG_STREAM +// FIXME: Qt 6: Make this QDebug operator<<(QDebug debug, const QQuickItem *item) QDebug operator<<(QDebug debug, QQuickItem *item) { + QDebugStateSaver saver(debug); + debug.nospace(); if (!item) { debug << "QQuickItem(0)"; return debug; } - debug << item->metaObject()->className() << "(this =" << ((void*)item) - << ", name=" << item->objectName() - << ", parent =" << ((void*)item->parentItem()) - << ", geometry =" << QRectF(item->position(), QSizeF(item->width(), item->height())) - << ", z =" << item->z() << ')'; + const QRectF rect(item->position(), QSizeF(item->width(), item->height())); + + debug << item->metaObject()->className() << '(' << static_cast<void *>(item); + if (!item->objectName().isEmpty()) + debug << ", name=" << item->objectName(); + debug << ", parent=" << static_cast<void *>(item->parentItem()) + << ", geometry="; + QtDebugUtils::formatQRect(debug, rect); + if (const qreal z = item->z()) + debug << ", z=" << z; + debug << ')'; return debug; } #endif |