From be838b2f4f294a7e1b3f8a771f91d9d1eac14431 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 22 May 2017 10:22:28 +0900 Subject: Refactored Events The biggest change is we have no pimpls in Event objects anymore - because it's two new's instead of one per Event, and we have thousands and even more of Events created during initial sync. The other big change is introduction of RoomEvent, so that now the structure of events almost precisely reflects the CS API spec. The refactoring made UnknownEvent unnecessary as a separate class; a respective base class (either RoomEvent or Event) is used for this purpose now. All the other changes are consequences of these (mostly of RoomEvent introduction). --- room.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'room.h') diff --git a/room.h b/room.h index 60be33b9..4f7a3c97 100644 --- a/room.h +++ b/room.h @@ -43,14 +43,14 @@ namespace QMatrixClient // a std:: container now using index_t = int; - TimelineItem(Event* e, index_t number) : evt(e), idx(number) { } + TimelineItem(RoomEvent* e, index_t number) : evt(e), idx(number) { } - Event* event() const { return evt.get(); } - Event* operator->() const { return event(); } //< Synonym for event() + RoomEvent* event() const { return evt.get(); } + RoomEvent* operator->() const { return event(); } //< Synonym for event() index_t index() const { return idx; } private: - std::unique_ptr evt; + std::unique_ptr evt; index_t idx; }; inline QDebug& operator<<(QDebug& d, const TimelineItem& ti) @@ -152,8 +152,8 @@ namespace QMatrixClient void userRenamed(User* user, QString oldName); signals: - void aboutToAddHistoricalMessages(const Events& events); - void aboutToAddNewMessages(const Events& events); + void aboutToAddHistoricalMessages(const RoomEvents& events); + void aboutToAddNewMessages(const RoomEvents& events); void addedMessages(); /** @@ -177,17 +177,17 @@ namespace QMatrixClient void unreadMessagesChanged(Room* room); protected: - virtual void doAddNewMessageEvents(const Events& events); - virtual void doAddHistoricalMessageEvents(const Events& events); - virtual void processStateEvents(const Events& events); + virtual void doAddNewMessageEvents(const RoomEvents& events); + virtual void doAddHistoricalMessageEvents(const RoomEvents& events); + virtual void processStateEvents(const RoomEvents& events); virtual void processEphemeralEvent(Event* event); private: class Private; Private* d; - void addNewMessageEvents(Events events); - void addHistoricalMessageEvents(Events events); + void addNewMessageEvents(RoomEvents events); + void addHistoricalMessageEvents(RoomEvents events); void markMessagesAsRead(rev_iter_t upToMarker); }; @@ -209,4 +209,4 @@ namespace QMatrixClient private: const Room* room; }; -} +} // namespace QMatrixClient -- cgit v1.2.3