Browse Source

Speedup loading history

By not marking everything as not sent then doing a second pass that marks sent things as sent, redoing the layout for every item...
pull/2834/head
tux3 10 years ago
parent
commit
217716184b
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 9
      src/widget/form/chatform.cpp

9
src/widget/form/chatform.cpp

@ -719,12 +719,13 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
ToxId authorId = ToxId(it.sender); ToxId authorId = ToxId(it.sender);
QString authorStr = !it.dispName.isEmpty() ? it.dispName : (authorId.isSelf() ? Core::getInstance()->getUsername() : resolveToxId(authorId)); QString authorStr = !it.dispName.isEmpty() ? it.dispName : (authorId.isSelf() ? Core::getInstance()->getUsername() : resolveToxId(authorId));
bool isAction = it.message.startsWith("/me ", Qt::CaseInsensitive); bool isAction = it.message.startsWith("/me ", Qt::CaseInsensitive);
bool needSending = !it.isSent && authorId.isSelf();
ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr,
isAction ? it.message.mid(4) : it.message, isAction ? it.message.mid(4) : it.message,
isAction ? ChatMessage::ACTION : ChatMessage::NORMAL, isAction ? ChatMessage::ACTION : ChatMessage::NORMAL,
authorId.isSelf(), authorId.isSelf(),
QDateTime()); needSending ? QDateTime() : msgDateTime);
if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) ) if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
msg->hideSender(); msg->hideSender();
@ -732,11 +733,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
prevId = authorId; prevId = authorId;
prevMsgDateTime = msgDateTime; prevMsgDateTime = msgDateTime;
if (it.isSent || !authorId.isSelf()) if (needSending)
{
msg->markAsSent(msgDateTime);
}
else
{ {
if (processUndelivered) if (processUndelivered)
{ {

Loading…
Cancel
Save