1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Show the date for each new day when loading history

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-09 00:08:28 +01:00
parent 93a4d30724
commit 3d9cc86e30
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -715,9 +715,20 @@ void ChatForm::loadHistory(QDateTime since)
std::swap(storedPrevId, previousId);
QList<ChatActionPtr> historyMessages;
QDate lastDate(1,0,0);
for (const auto &it : msgs)
{
ChatActionPtr ca = genMessageActionAction(ToxID::fromString(it.sender), it.message, false, it.timestamp.toLocalTime());
// Show the date every new day
QDateTime msgDateTime = it.timestamp.toLocalTime();
QDate msgDate = msgDateTime.date();
if (msgDate > lastDate)
{
lastDate = msgDate;
historyMessages.append(genSystemInfoAction(msgDate.toString(),"",QDateTime()));
}
// Show each messages
ChatActionPtr ca = genMessageActionAction(ToxID::fromString(it.sender), it.message, false, msgDateTime);
historyMessages.append(ca);
}
std::swap(storedPrevId, previousId);