From 82fa8ab292dc6e3a5a891f3b17c53236911374d1 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 29 Apr 2021 19:09:16 +0200 Subject: Highlight navigated to message --- src/timeline/TimelineModel.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/timeline/TimelineModel.cpp') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 30ce176e..5a0f9bad 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -265,6 +265,8 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj connect(&events, &EventStore::updateFlowEventId, this, [this](std::string event_id) { this->updateFlowEventId(event_id); }); + + showEventTimer.callOnTimeout(this, &TimelineModel::scrollTimerEvent); } QHash @@ -1298,6 +1300,42 @@ TimelineModel::cacheMedia(QString eventId) cacheMedia(eventId, NULL); } +void +TimelineModel::showEvent(QString eventId) +{ + using namespace std::chrono_literals; + if (idToIndex(eventId) != -1) { + eventIdToShow = eventId; + emit scrollTargetChanged(); + showEventTimer.start(50ms); + } +} + +void +TimelineModel::eventShown() +{ + eventIdToShow.clear(); + emit scrollTargetChanged(); +} + +QString +TimelineModel::scrollTarget() const +{ + return eventIdToShow; +} + +void +TimelineModel::scrollTimerEvent() +{ + if (eventIdToShow.isEmpty() || showEventTimerCounter > 3) { + showEventTimer.stop(); + showEventTimerCounter = 0; + } else { + emit scrollToIndex(idToIndex(eventIdToShow)); + showEventTimerCounter++; + } +} + QString TimelineModel::formatTypingUsers(const std::vector &users, QColor bg) { -- cgit 1.4.1