bool BufferSyncer::setLastSeenMsg(BufferId buffer, const MsgId &msgId) { if(!msgId.isValid()) return false; const MsgId oldLastSeenMsg = lastSeenMsg(buffer); if(!oldLastSeenMsg.isValid() || oldLastSeenMsg < msgId) { _lastSeenMsg[buffer] = msgId; SYNC(ARG(buffer), ARG(msgId)) emit lastSeenMsgSet(buffer, msgId); return true; } return false; }
void CoreBufferSyncer::storeDirtyIds() { UserId userId = _coreSession->user(); MsgId msgId; foreach(BufferId bufferId, dirtyLastSeenBuffers) { msgId = lastSeenMsg(bufferId); if (msgId.isValid()) Core::setBufferLastSeenMsg(userId, bufferId, msgId); }
bool BufferSyncer::setMarkerLine(BufferId buffer, const MsgId &msgId) { if (!msgId.isValid()) return false; if (_markerLines.value(buffer) == msgId) return false; _markerLines[buffer] = msgId; SYNC(ARG(buffer), ARG(msgId)) emit markerLineSet(buffer, msgId); return true; }
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); } }