From 39a3be72a419cf64b36774a314ab52222eaff2e0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Oct 2015 12:29:01 +0100 Subject: diaglib: Add more output to DebugProxyStyle. - Add output for QStyleOptionViewItem. - Also wrap styleHint(). Task-number: QTBUG-48916 Change-Id: If28bd89b7d175b7a83ee0c8e2538906796fd8426 Reviewed-by: Shawn Rutledge --- tests/manual/diaglib/debugproxystyle.cpp | 42 ++++++++++++++++++++++++++++---- tests/manual/diaglib/debugproxystyle.h | 1 + 2 files changed, 38 insertions(+), 5 deletions(-) (limited to 'tests/manual/diaglib') diff --git a/tests/manual/diaglib/debugproxystyle.cpp b/tests/manual/diaglib/debugproxystyle.cpp index 667ec403b7..d4e62f5dd6 100644 --- a/tests/manual/diaglib/debugproxystyle.cpp +++ b/tests/manual/diaglib/debugproxystyle.cpp @@ -45,13 +45,36 @@ QDebug operator<<(QDebug debug, const QStyleOption *option) { #if QT_VERSION >= 0x050000 QDebugStateSaver saver(debug); +# if QT_VERSION >= 0x050400 + debug.noquote(); +# endif debug.nospace(); #endif - debug << "QStyleOption("; - if (option) - debug << "rec=" << option->rect; - else - debug << '0'; + if (!option) { + debug << "QStyleOption(0)"; + return debug; + } + if (const QStyleOptionViewItem *ivo = qstyleoption_cast(option)) { + debug << "QStyleOptionViewItem("; +#if QT_VERSION >= 0x050000 + debug << ivo->index; + if (const int textSize = ivo->text.size()) + debug << ", \"" << (textSize < 20 ? ivo->text : ivo->text.left(20) + QLatin1String("...")) << '"'; + debug << ", "; +#else // Qt 5 + Q_UNUSED(ivo) +#endif + } else { + debug << "QStyleOption("; + } + debug << "rect=" << option->rect.width() << 'x' << option->rect.height() + << forcesign << option->rect.x() << option->rect.y() << noforcesign; + if (option->state != QStyle::State_None) + debug << ", state=" << option->state; +#if QT_VERSION >= 0x050000 + if (option->styleObject && !option->styleObject->isWidgetType()) + debug << ", styleObject=" << option->styleObject; +#endif debug << ')'; return debug; } @@ -132,6 +155,15 @@ QRect DebugProxyStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap & return result; } +int DebugProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, + QStyleHintReturn *returnData) const +{ + const int result = QProxyStyle::styleHint(hint, option, widget, returnData); + qDebug() << __FUNCTION__ << hint << option << widget << "returnData=" + << returnData << "returns" << result; + return result; +} + int DebugProxyStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { const int result = QProxyStyle::pixelMetric(metric, option, widget); diff --git a/tests/manual/diaglib/debugproxystyle.h b/tests/manual/diaglib/debugproxystyle.h index 74407e7f3e..01e1e6b6d1 100644 --- a/tests/manual/diaglib/debugproxystyle.h +++ b/tests/manual/diaglib/debugproxystyle.h @@ -48,6 +48,7 @@ public: QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const; QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const; QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const; + int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const; int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const; -- cgit v1.2.3