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:
parent
93a4d30724
commit
3d9cc86e30
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user