[libraries/qxmpp] src/base: SpamReport: Add Q_GADGET to expose Reason to the meta-object system
Linus Jahn <[email protected]> Wed, 5 Aug 2026 09:22:58 +0000 (UTC)
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit b4072af6d1c76379175184956cdede7848e0cc7d by Linus Jahn. Committed on 05/08/2026 at 09:16. Pushed by lnj into branch 'master'. SpamReport: Add Q_GADGET to expose Reason to the meta-object system Without Q_GADGET/Q_ENUM, QXmppSpamReport::Reason has no QMetaEnum, so clients can neither access it from QML nor use it in Q_INVOKABLE signatures. Applications have to duplicate the enum and cast between both versions (e.g. Kaidan's BlockingController::ReportReason). qobjectdefs.h is included instead of QObject because it is all Q_GADGET needs: it adds about 1% to the preprocessed size of the header, while QObject adds about 34%. Qt uses the same include for its own gadget-only value classes (e.g. qcborcommon.h, qcryptographichash.h). Co-Authored-By: Claude Opus 5 <[email protected]> M +4 -0 src/base/QXmppSpamReport.h https://invent.kde.org/libraries/qxmpp/-/commit/b4072af6d1c76379175184956cdede7848e0cc7d diff --git a/src/base/QXmppSpamReport.h b/src/base/QXmppSpamReport.h index 484107c5..ddf37d09 100644 --- a/src/base/QXmppSpamReport.h +++ b/src/base/QXmppSpamReport.h @@ -14,17 +14,21 @@ #include <QList> #include <QString> +// for Q_GADGET +#include <QtCore/qobjectdefs.h> class QDomElement; class QXmlStreamWriter; class QXMPP_EXPORT QXmppSpamReport { + Q_GADGET public: enum class Reason { Spam, Abuse, }; + Q_ENUM(Reason) QXmppSpamReport() = default; explicit QXmppSpamReport(Reason reason) : m_reason(reason) { }