X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcorebacklogmanager.cpp;h=9df40cbe1ba31d24dda0f8d8ecbe3881a268954f;hp=9ef4b8990e2279fbe46b8c29c38e7e62dda710ef;hb=694f9bfbf7f1af19108461c7e00d133e55082bce;hpb=61c8d84d1c849373e0f115dc748ed45cff95287d diff --git a/src/core/corebacklogmanager.cpp b/src/core/corebacklogmanager.cpp index 9ef4b899..9df40cbe 100644 --- a/src/core/corebacklogmanager.cpp +++ b/src/core/corebacklogmanager.cpp @@ -26,86 +26,92 @@ INIT_SYNCABLE_OBJECT(CoreBacklogManager) CoreBacklogManager::CoreBacklogManager(CoreSession *coreSession) - : BacklogManager(coreSession), + : BacklogManager(coreSession), _coreSession(coreSession) { } -QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional) { - QVariantList backlog; - QList msgList; - msgList = Core::requestMsgs(coreSession()->user(), bufferId, first, last, limit); - QList::const_iterator msgIter = msgList.constBegin(); - QList::const_iterator msgListEnd = msgList.constEnd(); - while(msgIter != msgListEnd) { - backlog << qVariantFromValue(*msgIter); - msgIter++; - } +QVariantList CoreBacklogManager::requestBacklog(BufferId bufferId, MsgId first, MsgId last, int limit, int additional) +{ + QVariantList backlog; + QList msgList; + msgList = Core::requestMsgs(coreSession()->user(), bufferId, first, last, limit); - if(additional && limit != 0) { - MsgId oldestMessage = first; - if(!msgList.isEmpty()) { - if(msgList.first().msgId() < msgList.last().msgId()) - oldestMessage = msgList.first().msgId(); - else - oldestMessage = msgList.last().msgId(); + QList::const_iterator msgIter = msgList.constBegin(); + QList::const_iterator msgListEnd = msgList.constEnd(); + while (msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; } - if(first != -1) { - last = first; - } else { - last = oldestMessage; - } + if (additional && limit != 0) { + MsgId oldestMessage = first; + if (!msgList.isEmpty()) { + if (msgList.first().msgId() < msgList.last().msgId()) + oldestMessage = msgList.first().msgId(); + else + oldestMessage = msgList.last().msgId(); + } - // only fetch additional messages if they continue seemlessly - // that is, if the list of messages is not truncated by the limit - if(last == oldestMessage) { - msgList = Core::requestMsgs(coreSession()->user(), bufferId, -1, last, additional); - msgIter = msgList.constBegin(); - msgListEnd = msgList.constEnd(); - while(msgIter != msgListEnd) { - backlog << qVariantFromValue(*msgIter); - msgIter++; - } + if (first != -1) { + last = first; + } + else { + last = oldestMessage; + } + + // only fetch additional messages if they continue seemlessly + // that is, if the list of messages is not truncated by the limit + if (last == oldestMessage) { + msgList = Core::requestMsgs(coreSession()->user(), bufferId, -1, last, additional); + msgIter = msgList.constBegin(); + msgListEnd = msgList.constEnd(); + while (msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; + } + } } - } - return backlog; + return backlog; } -QVariantList CoreBacklogManager::requestBacklogAll(MsgId first, MsgId last, int limit, int additional) { - QVariantList backlog; - QList msgList; - msgList = Core::requestAllMsgs(coreSession()->user(), first, last, limit); - QList::const_iterator msgIter = msgList.constBegin(); - QList::const_iterator msgListEnd = msgList.constEnd(); - while(msgIter != msgListEnd) { - backlog << qVariantFromValue(*msgIter); - msgIter++; - } +QVariantList CoreBacklogManager::requestBacklogAll(MsgId first, MsgId last, int limit, int additional) +{ + QVariantList backlog; + QList msgList; + msgList = Core::requestAllMsgs(coreSession()->user(), first, last, limit); - if(additional) { - if(first != -1) { - last = first; - } else { - last = -1; - if(!msgList.isEmpty()) { - if(msgList.first().msgId() < msgList.last().msgId()) - last = msgList.first().msgId(); - else - last = msgList.last().msgId(); - } + QList::const_iterator msgIter = msgList.constBegin(); + QList::const_iterator msgListEnd = msgList.constEnd(); + while (msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; } - msgList = Core::requestAllMsgs(coreSession()->user(), -1, last, additional); - msgIter = msgList.constBegin(); - msgListEnd = msgList.constEnd(); - while(msgIter != msgListEnd) { - backlog << qVariantFromValue(*msgIter); - msgIter++; + + if (additional) { + if (first != -1) { + last = first; + } + else { + last = -1; + if (!msgList.isEmpty()) { + if (msgList.first().msgId() < msgList.last().msgId()) + last = msgList.first().msgId(); + else + last = msgList.last().msgId(); + } + } + msgList = Core::requestAllMsgs(coreSession()->user(), -1, last, additional); + msgIter = msgList.constBegin(); + msgListEnd = msgList.constEnd(); + while (msgIter != msgListEnd) { + backlog << qVariantFromValue(*msgIter); + msgIter++; + } } - } - return backlog; + return backlog; }