summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2015-05-18 14:57:03 +0200
committerShawn Rutledge <shawn.rutledge@theqtcompany.com>2016-01-26 15:27:24 +0000
commite3808072d9b6919d24a0be6e2a4f76afe2b4486d (patch)
treedcfe2b48b71c89ebf757d9ba66610165a1a58521
parentc3b261f3f0df0795053ecf23b401d06c0cb6d075 (diff)
add QDebug operator for QAction
Change-Id: Ie2554323a619ef1c3f9579862eff8fe704079ba5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
-rw-r--r--src/widgets/kernel/qaction.cpp27
-rw-r--r--src/widgets/kernel/qaction.h4
2 files changed, 30 insertions, 1 deletions
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 2c4e4d3125..1ef9e4ef98 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -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"
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
index 8ef26b60bf..0eb2c60c70 100644
--- a/src/widgets/kernel/qaction.h
+++ b/src/widgets/kernel/qaction.h
@@ -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