summary refs log tree commit diff
path: root/src/timeline/TimelineModel.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-04-29 19:09:16 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-04-29 19:09:16 +0200
commit82fa8ab292dc6e3a5a891f3b17c53236911374d1 (patch)
tree5fa4bdff6818190d93dc3cc33a2998e91c798122 /src/timeline/TimelineModel.cpp
parentFix some encoding issues when translating matrix.to to matrix: (diff)
downloadnheko-82fa8ab292dc6e3a5a891f3b17c53236911374d1.tar.xz
Highlight navigated to message
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r--src/timeline/TimelineModel.cpp38
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)
 {