libQuotient
A Qt library for building matrix clients
quotient_common.h File Reference
#include "quotient_export.h"
#include <qobjectdefs.h>
#include "util.h"
#include <array>
Include dependency graph for quotient_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 Quotient
 

Macros

#define QUO_DECLARE_FLAGS(Flags, Enum)
 Quotient replacement for the Q_FLAG/Q_DECLARE_FLAGS combination. More...
 
#define QUO_DECLARE_FLAGS_NS(Flags, Enum)
 Quotient replacement for the Q_FLAG_NS/Q_DECLARE_FLAGS combination. More...
 

Enumerations

enum class  Quotient::Membership : uint16_t {
  Quotient::Invalid = 0x0 , Quotient::Join = 0x1 , Quotient::Leave = 0x2 , Quotient::Invite = 0x4 ,
  Quotient::Knock = 0x8 , Quotient::Ban = 0x10 , Quotient::Undefined = Invalid
}
 Membership states. More...
 
enum class  Quotient::JoinState : std::underlying_type_t< Membership > {
  Quotient::Invalid = std::underlying_type_t<Membership>(Membership::Invalid) , Quotient::Join = std::underlying_type_t<Membership>(Membership::Join) , Quotient::Leave = std::underlying_type_t<Membership>(Membership::Leave) , Quotient::Invite = std::underlying_type_t<Membership>(Membership::Invite) ,
  Quotient::Knock = std::underlying_type_t<Membership>(Membership::Knock)
}
 Local user join-state names. More...
 
enum  Quotient::RunningPolicy { Quotient::ForegroundRequest = 0x0 , Quotient::BackgroundRequest = 0x1 }
 Network job running policy flags. More...
 
enum  Quotient::UriResolveResult : int8_t {
  Quotient::StillResolving = -1 , Quotient::UriResolved = 0 , Quotient::CouldNotResolve , Quotient::IncorrectAction ,
  Quotient::InvalidUri , Quotient::NoAccount
}
 The result of URI resolution using UriResolver. More...
 
enum class  Quotient::RoomType : uint8_t { Quotient::Space = 0 , Quotient::Undefined = 0xFF }
 
enum class  Quotient::EncryptionType : uint8_t { Quotient::MegolmV1AesSha2 = 0 , Quotient::Undefined = 0xFF }
 

Variables

constexpr std::array Quotient::MembershipStrings
 
constexpr std::array Quotient::JoinStateStrings
 
constexpr std::array Quotient::RoomTypeStrings { "m.space"_L1 }
 

Macro Definition Documentation

◆ QUO_DECLARE_FLAGS

#define QUO_DECLARE_FLAGS (   Flags,
  Enum 
)
Value:
Q_DECLARE_FLAGS(Flags, Enum) \
Q_ENUM_IMPL(Enum) \
Q_FLAG(Flags)

Quotient replacement for the Q_FLAG/Q_DECLARE_FLAGS combination.

Although the comment in QTBUG-82295 says that Q_FLAG[NS] "should" be applied to the enum type only, Qt then doesn't allow to wrap the corresponding flag type (defined with Q_DECLARE_FLAGS) into a QVariant. This macro defines Q_FLAG and on top of that adds Q_ENUM_IMPL which is a part of Q_ENUM() macro that enables the metatype data but goes under the moc radar to avoid double registration of the same data in the map defined in moc*.cpp.

Simply put, instead of using Q_FLAG/Q_DECLARE_FLAGS combo (and struggling to figure out what you should pass to Q_FLAG if you want to make it wrappable in a QVariant) use the macro below, and things will just work.

See also
https://bugreports.qt.io/browse/QTBUG-82295

Definition at line 29 of file quotient_common.h.

◆ QUO_DECLARE_FLAGS_NS

#define QUO_DECLARE_FLAGS_NS (   Flags,
  Enum 
)
Value:
Q_DECLARE_FLAGS(Flags, Enum) \
Q_ENUM_NS_IMPL(Enum) \
Q_FLAG_NS(Flags)

Quotient replacement for the Q_FLAG_NS/Q_DECLARE_FLAGS combination.

This is the equivalent of QUO_DECLARE_FLAGS for enums declared at the namespace level (be sure to provide Q_NAMESPACE in the same file as the enum definition and this macro).

See also
QUO_DECLARE_FLAGS

Definition at line 40 of file quotient_common.h.