add QDebug operator for QAction

Change-Id: Ie2554323a619ef1c3f9579862eff8fe704079ba5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
bb10
Shawn Rutledge 2015-05-18 14:57:03 +02:00 committed by Shawn Rutledge
parent c3b261f3f0
commit e3808072d9
2 changed files with 30 additions and 1 deletions

View File

@ -39,10 +39,10 @@
#include "qapplication.h"
#include "qevent.h"
#include "qlist.h"
#include "qdebug.h"
#include <private/qshortcutmap_p.h>
#include <private/qapplication_p.h>
#include <private/qmenu_p.h>
#include <private/qdebug_p.h>
#define QAPP_CHECK(functionName) \
if (!qApp) { \
@ -1296,6 +1296,31 @@ bool QAction::isIconVisibleInMenu() const
return d->iconVisibleInMenu;
}
#ifndef QT_NO_DEBUG_STREAM
Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action)
{
QDebugStateSaver saver(d);
d.nospace();
d << "QAction(" << static_cast<const void *>(action);
if (action) {
d << " text=" << action->text();
if (!action->toolTip().isEmpty())
d << " toolTip=" << action->toolTip();
if (action->isCheckable())
d << " checked=" << action->isChecked();
if (!action->shortcut().isEmpty())
d << " shortcut=" << action->shortcut();
d << " menuRole=";
QtDebugUtils::formatQEnum(d, action->menuRole());
d << " visible=" << action->isVisible();
} else {
d << '0';
}
d << ')';
return d;
}
#endif // QT_NO_DEBUG_STREAM
QT_END_NAMESPACE
#include "moc_qaction.cpp"

View File

@ -203,6 +203,10 @@ private:
#endif
};
#ifndef QT_NO_DEBUG_STREAM
Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QAction *);
#endif
QT_BEGIN_INCLUDE_NAMESPACE
#include <QtWidgets/qactiongroup.h>
QT_END_INCLUDE_NAMESPACE