Implement debug operator for QStyle::State using the new operator for QFlags<T>.

Call the new operator and add ### fixme comments for removal.

Change-Id: Ibe4dfe00b6ea1aa5ca5551f10b1f27fdde2114c4
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Friedemann Kleint 2015-02-27 11:45:10 +01:00 committed by Shawn Rutledge
parent 918e976d39
commit 8ceb4d9dbc
2 changed files with 13 additions and 37 deletions

View File

@ -2355,51 +2355,24 @@ int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
return result;
}
// ### Qt 6: Remove in favor of template<class T> QDebug operator<<(QDebug, const QFlags<T> &).
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
QT_BEGIN_INCLUDE_NAMESPACE
#include <QDebug>
# include <QDebug>
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<< <QStyle::StateFlag>(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

View File

@ -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<class T> QDebug operator<<(QDebug, const QFlags<T> &).
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, QStyle::State state);
# endif
#endif
QT_END_NAMESPACE