From 6c95d3787325fdb47e45275974a8edfb3555cfdb Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 1 Sep 2016 08:23:35 +0900 Subject: Room: use std::deque for the timeline --- room.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'room.h') diff --git a/room.h b/room.h index afa6f0ef..f42f6947 100644 --- a/room.h +++ b/room.h @@ -26,6 +26,8 @@ #include "jobs/syncjob.h" #include "joinstate.h" +#include + namespace QMatrixClient { class Event; @@ -38,7 +40,7 @@ namespace QMatrixClient Q_OBJECT Q_PROPERTY(QString readMarkerEventId READ readMarkerEventId WRITE markMessagesAsRead NOTIFY readMarkerPromoted) public: - using Timeline = Owning; + using Timeline = Owning< std::deque >; Room(Connection* connection, QString id); virtual ~Room(); -- cgit v1.2.3 From 0e9c56561888cbd786d099bc7d004223e7406e6a Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 7 Nov 2016 19:39:37 +0900 Subject: Room: provide ability to find an event in the timeline by its id A new hashmap, eventsIndex, is provided, that allows you to find the event in the timeline if you have eventId. This hashmap uses the fact that deque iterators don't invalidate upon insertion of elements to either end of the deque. Thanks to that, promoteReadMarker() and doAddNewMessageEvents() have been considerably simplified; also, it should be easier now to calculate event indices without rolling back and forth over the timeline. --- room.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'room.h') diff --git a/room.h b/room.h index f42f6947..f8db6384 100644 --- a/room.h +++ b/room.h @@ -72,7 +72,6 @@ namespace QMatrixClient Q_INVOKABLE void updateData(SyncRoomData& data ); Q_INVOKABLE void setJoinState( JoinState state ); - Q_INVOKABLE QString lastReadEvent(User* user) const; QString readMarkerEventId() const; /** * @brief Mark the event with uptoEventId as read @@ -142,7 +141,7 @@ namespace QMatrixClient void addNewMessageEvents(const Events& events); void addHistoricalMessageEvents(const Events& events); - void setLastReadEvent(User* user, QString eventId); + void setLastReadEvent(User* user, Event* event); }; class MemberSorter -- cgit v1.2.3