+ return false;
+ }
+}
+
+void BufferWidget::currentChanged(const QModelIndex& current, const QModelIndex& previous)
+{
+ auto* prevView = qobject_cast<ChatView*>(ui.stackedWidget->currentWidget());
+
+ AbstractBufferContainer::currentChanged(current, previous); // switch first to avoid a redraw
+
+ // we need to hide the marker line if it's already/still at the bottom of the view (and not scrolled up)
+ auto* curView = qobject_cast<ChatView*>(ui.stackedWidget->currentWidget());
+ if (curView) {
+ BufferId curBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
+ if (curBufferId.isValid()) {
+ MsgId markerMsgId = Client::networkModel()->markerLineMsgId(curBufferId);
+ if (markerMsgId == curView->lastMsgId() && markerMsgId == curView->lastVisibleMsgId())
+ curView->setMarkerLineVisible(false);
+ else
+ curView->setMarkerLineVisible(true);
+ }
+ }
+
+ if (prevView && autoMarkerLine())
+ setMarkerLine(prevView, false);
+}
+
+void BufferWidget::setMarkerLine(ChatView* view, bool allowGoingBack)
+{
+ if (!view)
+ view = qobject_cast<ChatView*>(ui.stackedWidget->currentWidget());
+ if (!view)
+ return;
+
+ ChatLine* lastLine = view->lastVisibleChatLine();
+ if (lastLine) {
+ QModelIndex idx = lastLine->index();
+ MsgId msgId = idx.data(MessageModel::MsgIdRole).value<MsgId>();
+ BufferId bufId = view->scene()->singleBufferId();
+
+ if (!allowGoingBack) {
+ MsgId oldMsgId = Client::markerLine(bufId);
+ if (oldMsgId.isValid() && msgId <= oldMsgId)
+ return;
+ }
+ Client::setMarkerLine(bufId, msgId);
+ }
+}
+
+void BufferWidget::jumpToMarkerLine(ChatView* view, bool requestBacklog)
+{
+ if (!view)
+ view = qobject_cast<ChatView*>(ui.stackedWidget->currentWidget());
+ if (!view)
+ return;
+
+ view->jumpToMarkerLine(requestBacklog);