+
+void BufferWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) {
+ ChatView *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)
+ ChatView *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>();
+
+ if(!allowGoingBack) {
+ BufferId bufId = view->scene()->singleBufferId();
+ MsgId oldMsgId = Client::markerLine(bufId);
+ if(oldMsgId.isValid() && msgId <= oldMsgId)
+ return;
+ }
+ view->setMarkerLine(msgId);
+ }
+}
+
+void BufferWidget::jumpToMarkerLine(ChatView *view, bool requestBacklog) {
+ if(!view)
+ view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if(!view)
+ return;
+
+ view->jumpToMarkerLine(requestBacklog);
+}