aboutsummaryrefslogtreecommitdiff
path: root/lib/room.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-08-03 17:14:08 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-08-03 17:14:08 +0900
commitde72fb7f9b6e36021c284c011f19714defe80713 (patch)
treebdc882411f68fb2d29ef5cf3ae20dc7ddf77bc00 /lib/room.h
parentb0551c2164ff519ac8fcd2df5ff5a72655779f2f (diff)
downloadlibquotient-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.h47
1 files changed, 3 insertions, 44 deletions
diff --git a/lib/room.h b/lib/room.h
index 599b7fbf..15e2146e 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -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