From 3bfb1d9736e05fe216c016ae2dbb8eac4ac78048 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 20 Jan 2018 14:52:58 +0900 Subject: Room: store the first displayed event as well; Room::*DisplayedMarker() methods --- room.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'room.cpp') diff --git a/room.cpp b/room.cpp index 68762a8a..8c6465e2 100644 --- a/room.cpp +++ b/room.cpp @@ -91,6 +91,7 @@ class Room::Private QList membersLeft; bool unreadMessages = false; bool displayed = false; + QString firstDisplayedEventId; QString lastDisplayedEventId; QHash lastReadEventIds; QString prevBatch; @@ -436,18 +437,48 @@ void Room::setDisplayed(bool displayed) } } +QString Room::firstDisplayedEventId() const +{ + return d->firstDisplayedEventId; +} + +Room::rev_iter_t Room::firstDisplayedMarker() const +{ + return findInTimeline(firstDisplayedEventId()); +} + +void Room::setFirstDisplayedEventId(const QString& eventId) +{ + if (d->firstDisplayedEventId == eventId) + return; + + d->firstDisplayedEventId = eventId; + emit firstDisplayedEventChanged(); +} + +void Room::setFirstDisplayedEvent(TimelineItem::index_t index) +{ + Q_ASSERT(isValidIndex(index)); + setFirstDisplayedEventId(findInTimeline(index)->event()->id()); +} + QString Room::lastDisplayedEventId() const { return d->lastDisplayedEventId; } +Room::rev_iter_t Room::lastDisplayedMarker() const +{ + return findInTimeline(lastDisplayedEventId()); +} + void Room::setLastDisplayedEventId(const QString& eventId) { if (d->lastDisplayedEventId == eventId) return; d->lastDisplayedEventId = eventId; - emit lastDisplayedEventIdChanged(); + emit lastDisplayedEventChanged(); } void Room::setLastDisplayedEvent(TimelineItem::index_t index) -- cgit v1.2.3