aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-11-26 13:44:39 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-11-26 13:44:39 +0100
commitf6155d62740a88b020273ba623c816f7b9805772 (patch)
tree87824e5db591955638655b2e12bd9a5484efcb0a
parent91c1d93d3389ac924f1013dc7b37dfe70a17e57e (diff)
downloadlibquotient-f6155d62740a88b020273ba623c816f7b9805772.tar.gz
libquotient-f6155d62740a88b020273ba623c816f7b9805772.zip
Drop Q_GADGET from most uncopyable classes; other minor cleanup
Q_GADGET is generally used to enable two things outside of QObject: Q_PROPERTY/Q_INVOKABLE and Q_ENUM/Q_FLAG. While the latter can be used in its own right in QML, the former requires Q_GADGET instances to be passed to QML by value, which is not really possible with uncopyable/unassignable classes. Bottom line is that Q_PROPERTY in anything derived from Quotient::Event is not viable, making Q_GADGET macro useless unless there's a Q_ENUM/Q_FLAG (as is the case with RoomMessageEvent, e.g.).
-rw-r--r--lib/eventitem.h5
-rw-r--r--lib/events/encryptedevent.h2
-rw-r--r--lib/events/event.h3
-rw-r--r--lib/events/roomevent.h41
-rw-r--r--lib/events/roommessageevent.h4
-rw-r--r--lib/events/stateevent.h2
-rw-r--r--lib/quotient_common.h1
7 files changed, 14 insertions, 44 deletions
diff --git a/lib/eventitem.h b/lib/eventitem.h
index a70a3c3e..0ab1a01d 100644
--- a/lib/eventitem.h
+++ b/lib/eventitem.h
@@ -9,7 +9,6 @@
#include <utility>
namespace Quotient {
-class StateEventBase;
namespace EventStatus {
Q_NAMESPACE
@@ -31,8 +30,7 @@ namespace EventStatus {
Replaced = 0x10, //< The event has been replaced
Hidden = 0x100, //< The event should not be shown in the timeline
};
- Q_DECLARE_FLAGS(Status, Code)
- Q_FLAG_NS(Status)
+ Q_ENUM_NS(Code)
} // namespace EventStatus
class EventItemBase {
@@ -106,7 +104,6 @@ inline const CallEventBase* EventItemBase::viewAs<CallEventBase>() const
}
class PendingEventItem : public EventItemBase {
- Q_GADGET
public:
using EventItemBase::EventItemBase;
diff --git a/lib/events/encryptedevent.h b/lib/events/encryptedevent.h
index eb7123eb..598829cd 100644
--- a/lib/events/encryptedevent.h
+++ b/lib/events/encryptedevent.h
@@ -7,7 +7,6 @@
#include "roomevent.h"
namespace Quotient {
-class Room;
/*
* While the specification states:
*
@@ -27,7 +26,6 @@ class Room;
* one and doesn't add new restrictions, just provides additional features.
*/
class EncryptedEvent : public RoomEvent {
- Q_GADGET
public:
DEFINE_EVENT_TYPEID("m.room.encrypted", EncryptedEvent)
diff --git a/lib/events/event.h b/lib/events/event.h
index 78853ced..2ed5de5d 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -195,9 +195,6 @@ inline auto registerEventType()
// === Event ===
class Event {
- Q_GADGET
- Q_PROPERTY(Type type READ type CONSTANT)
- Q_PROPERTY(QJsonObject contentJson READ contentJson CONSTANT)
public:
using Type = event_type_t;
using factory_t = EventFactory<Event>;
diff --git a/lib/events/roomevent.h b/lib/events/roomevent.h
index 3174764f..a6cd84ca 100644
--- a/lib/events/roomevent.h
+++ b/lib/events/roomevent.h
@@ -12,16 +12,6 @@ class RedactionEvent;
/** This class corresponds to m.room.* events */
class RoomEvent : public Event {
- Q_GADGET
- Q_PROPERTY(QString id READ id)
- //! \deprecated Use originTimestamp instead
- Q_PROPERTY(QDateTime timestamp READ originTimestamp CONSTANT)
- Q_PROPERTY(QDateTime originTimestamp READ originTimestamp CONSTANT)
- Q_PROPERTY(QString roomId READ roomId CONSTANT)
- Q_PROPERTY(QString senderId READ senderId CONSTANT)
- Q_PROPERTY(QString redactionReason READ redactionReason)
- Q_PROPERTY(bool isRedacted READ isRedacted)
- Q_PROPERTY(QString transactionId READ transactionId WRITE setTransactionId)
public:
using factory_t = EventFactory<RoomEvent>;
@@ -51,28 +41,23 @@ public:
QString transactionId() const;
QString stateKey() const;
+ //! \brief Fill the pending event object with the room id
void setRoomId(const QString& roomId);
+ //! \brief Fill the pending event object with the sender id
void setSender(const QString& senderId);
-
- /**
- * Sets the transaction id for locally created events. This should be
- * done before the event is exposed to any code using the respective
- * Q_PROPERTY.
- *
- * \param txnId - transaction id, normally obtained from
- * Connection::generateTxnId()
- */
+ //! \brief Fill the pending event object with the transaction id
+ //! \param txnId - transaction id, normally obtained from
+ //! Connection::generateTxnId()
void setTransactionId(const QString& txnId);
- /**
- * Sets event id for locally created events
- *
- * When a new event is created locally, it has no server id yet.
- * This function allows to add the id once the confirmation from
- * the server is received. There should be no id set previously
- * in the event. It's the responsibility of the code calling addId()
- * to notify clients that use Q_PROPERTY(id) about its change
- */
+ //! \brief Add an event id to locally created events after they are sent
+ //!
+ //! When a new event is created locally, it has no id; the homeserver
+ //! assigns it once the event is sent. This function allows to add the id
+ //! once the confirmation from the server is received. There should be no id
+ //! set previously in the event. It's the responsibility of the code calling
+ //! addId() to notify clients about the change; there's no signal or
+ //! callback for that in RoomEvent.
void addId(const QString& newId);
protected:
diff --git a/lib/events/roommessageevent.h b/lib/events/roommessageevent.h
index 88d3b74c..56597ddc 100644
--- a/lib/events/roommessageevent.h
+++ b/lib/events/roommessageevent.h
@@ -18,10 +18,6 @@ namespace MessageEventContent = EventContent; // Back-compatibility
*/
class RoomMessageEvent : public RoomEvent {
Q_GADGET
- Q_PROPERTY(QString msgType READ rawMsgtype CONSTANT)
- Q_PROPERTY(QString plainBody READ plainBody CONSTANT)
- Q_PROPERTY(QMimeType mimeType READ mimeType STORED false CONSTANT)
- Q_PROPERTY(const EventContent::TypedBase* content READ content CONSTANT)
public:
DEFINE_EVENT_TYPEID("m.room.message", RoomMessageEvent)
diff --git a/lib/events/stateevent.h b/lib/events/stateevent.h
index bc414a5f..b0aa9907 100644
--- a/lib/events/stateevent.h
+++ b/lib/events/stateevent.h
@@ -18,8 +18,6 @@ inline QJsonObject basicStateEventJson(const QString& matrixTypeId,
}
class StateEventBase : public RoomEvent {
- Q_GADGET
- Q_PROPERTY(QString stateKey READ stateKey CONSTANT)
public:
using factory_t = EventFactory<StateEventBase>;
diff --git a/lib/quotient_common.h b/lib/quotient_common.h
index d91c3d17..0e3e2a40 100644
--- a/lib/quotient_common.h
+++ b/lib/quotient_common.h
@@ -90,7 +90,6 @@ constexpr inline auto JoinStateStrings = make_array(
//! So far only background/foreground flags are available.
//! \sa Connection::callApi, Connection::run
enum RunningPolicy { ForegroundRequest = 0x0, BackgroundRequest = 0x1 };
-
Q_ENUM_NS(RunningPolicy)
//! \brief The result of URI resolution using UriResolver