Highlight navigated to message
1 files changed, 38 insertions, 0 deletions
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<int, QByteArray>
@@ -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<QString> &users, QColor bg)
{
|