summaryrefslogtreecommitdiffstats
path: root/tests/manual/diaglib
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-10-27 12:29:01 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-03-16 08:13:53 +0000
commit39a3be72a419cf64b36774a314ab52222eaff2e0 (patch)
tree24baf9036415788cdc81c1b178d293a93f6b3474 /tests/manual/diaglib
parent8005fa3524916a56a555f44d4418eb1cd12db645 (diff)
diaglib: Add more output to DebugProxyStyle.
- Add output for QStyleOptionViewItem. - Also wrap styleHint(). Task-number: QTBUG-48916 Change-Id: If28bd89b7d175b7a83ee0c8e2538906796fd8426 Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'tests/manual/diaglib')
-rw-r--r--tests/manual/diaglib/debugproxystyle.cpp42
-rw-r--r--tests/manual/diaglib/debugproxystyle.h1
2 files changed, 38 insertions, 5 deletions
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<const QStyleOptionViewItem *>(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;