From 8ceb4d9dbcc8468e2bb4d40ee96ce38d86d985a1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Feb 2015 11:45:10 +0100 Subject: Implement debug operator for QStyle::State using the new operator for QFlags. Call the new operator and add ### fixme comments for removal. Change-Id: Ibe4dfe00b6ea1aa5ca5551f10b1f27fdde2114c4 Reviewed-by: Shawn Rutledge Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qstyle.cpp | 47 +++++++++---------------------------------- src/widgets/styles/qstyle.h | 3 +++ 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 5fc2164c97..862a4302f3 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -2355,51 +2355,24 @@ int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1, return result; } +// ### Qt 6: Remove in favor of template QDebug operator<<(QDebug, const QFlags &). +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QT_BEGIN_INCLUDE_NAMESPACE -#include +# include QT_END_INCLUDE_NAMESPACE -#if !defined(QT_NO_DEBUG_STREAM) +# if !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, QStyle::State state) { -#if !defined(QT_NO_DEBUG) - debug << "QStyle::State("; - - QStringList states; - if (state & QStyle::State_Active) states << QLatin1String("Active"); - if (state & QStyle::State_AutoRaise) states << QLatin1String("AutoRaise"); - if (state & QStyle::State_Bottom) states << QLatin1String("Bottom"); - if (state & QStyle::State_Children) states << QLatin1String("Children"); - if (state & QStyle::State_DownArrow) states << QLatin1String("DownArrow"); - if (state & QStyle::State_Editing) states << QLatin1String("Editing"); - if (state & QStyle::State_Enabled) states << QLatin1String("Enabled"); - if (state & QStyle::State_FocusAtBorder) states << QLatin1String("FocusAtBorder"); - if (state & QStyle::State_HasFocus) states << QLatin1String("HasFocus"); - if (state & QStyle::State_Horizontal) states << QLatin1String("Horizontal"); - if (state & QStyle::State_Item) states << QLatin1String("Item"); - if (state & QStyle::State_KeyboardFocusChange) states << QLatin1String("KeyboardFocusChange"); - if (state & QStyle::State_MouseOver) states << QLatin1String("MouseOver"); - if (state & QStyle::State_NoChange) states << QLatin1String("NoChange"); - if (state & QStyle::State_Off) states << QLatin1String("Off"); - if (state & QStyle::State_On) states << QLatin1String("On"); - if (state & QStyle::State_Open) states << QLatin1String("Open"); - if (state & QStyle::State_Raised) states << QLatin1String("Raised"); - if (state & QStyle::State_ReadOnly) states << QLatin1String("ReadOnly"); - if (state & QStyle::State_Selected) states << QLatin1String("Selected"); - if (state & QStyle::State_Sibling) states << QLatin1String("Sibling"); - if (state & QStyle::State_Sunken) states << QLatin1String("Sunken"); - if (state & QStyle::State_Top) states << QLatin1String("Top"); - if (state & QStyle::State_UpArrow) states << QLatin1String("UpArrow"); - - std::sort(states.begin(), states.end()); - debug << states.join(QLatin1String(" | ")); - debug << ')'; -#else +# if !defined(QT_NO_DEBUG) + return operator<< (debug, state); +# else Q_UNUSED(state); -#endif +# endif return debug; } -#endif +# endif // !QT_NO_DEBUG_STREAM +#endif // QT_VERSION < QT_VERSION_CHECK(6,0,0) /*! \since 4.6 diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index f1f063dfcc..b41762795d 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -848,7 +848,10 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State) Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::SubControls) #if !defined(QT_NO_DEBUG_STREAM) +// ### Qt 6: Remove in favor of template QDebug operator<<(QDebug, const QFlags &). +# if QT_VERSION < QT_VERSION_CHECK(6,0,0) Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, QStyle::State state); +# endif #endif QT_END_NAMESPACE -- cgit v1.2.3