diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-08-03 17:14:08 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-08-03 17:14:08 +0900 |
commit | de72fb7f9b6e36021c284c011f19714defe80713 (patch) | |
tree | bdc882411f68fb2d29ef5cf3ae20dc7ddf77bc00 /lib/room.h | |
parent | b0551c2164ff519ac8fcd2df5ff5a72655779f2f (diff) | |
download | libquotient-de72fb7f9b6e36021c284c011f19714defe80713.tar.gz libquotient-de72fb7f9b6e36021c284c011f19714defe80713.zip |
Refactor event items
* TimelineItem and a newly introduced PendingEventItem are now
inheriting from the common EventItemBase class
* PendingEventItem has its own status and annotation, serving to track
transition of the item through pending states
Diffstat (limited to 'lib/room.h')
-rw-r--r-- | lib/room.h | 47 |
1 files changed, 3 insertions, 44 deletions
@@ -21,6 +21,7 @@ #include "jobs/syncjob.h" #include "events/roommessageevent.h" #include "events/accountdataevents.h" +#include "eventitem.h" #include "joinstate.h" #include <QtGui/QPixmap> @@ -40,49 +41,6 @@ namespace QMatrixClient class SetRoomStateWithKeyJob; class RedactEventJob; - class TimelineItem - { - public: - // For compatibility with Qt containers, even though we use - // a std:: container now for the room timeline - using index_t = int; - - TimelineItem(RoomEventPtr&& e, index_t number) - : evt(std::move(e)), idx(number) - { - Q_ASSERT(evt); - } - - const RoomEvent* event() const { return rawPtr(evt); } - const RoomEvent* get() const { return event(); } - template <typename EventT> - const EventT* viewAs() const { return eventCast<const EventT>(evt); } - const RoomEventPtr& operator->() const { return evt; } - const RoomEvent& operator*() const { return *evt; } - index_t index() const { return idx; } - - // Used for event redaction - RoomEventPtr replaceEvent(RoomEventPtr&& other); - - private: - RoomEventPtr evt; - index_t idx; - }; - - template<> - inline const StateEventBase* TimelineItem::viewAs<StateEventBase>() const - { - return evt->isStateEvent() ? weakPtrCast<const StateEventBase>(evt) - : nullptr; - } - - inline QDebug& operator<<(QDebug& d, const TimelineItem& ti) - { - QDebugStateSaver dss(d); - d.nospace() << "(" << ti.index() << "|" << ti->id() << ")"; - return d; - } - class FileTransferInfo { Q_GADGET @@ -139,6 +97,7 @@ namespace QMatrixClient public: using Timeline = std::deque<TimelineItem>; + using PendingEvents = std::vector<PendingEventItem>; using rev_iter_t = Timeline::const_reverse_iterator; using timeline_iter_t = Timeline::const_iterator; @@ -216,7 +175,7 @@ namespace QMatrixClient Q_INVOKABLE QString roomMembername(const QString& userId) const; const Timeline& messageEvents() const; - const RoomEvents& pendingEvents() const; + const PendingEvents& pendingEvents() const; /** * A convenience method returning the read marker to the before-oldest * message |