X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fmessagemodel.cpp;h=a4b050d24b3cafc30dfa2c069284a281153772f8;hp=cbcfceb2ce4cfa046c7a6c0bb07bf29c70d4e1da;hb=6eefdfc697067d184a589fc8a231b16316c09106;hpb=695758015a80eb8c158a9ac4c0f1c0b547e70df3 diff --git a/src/client/messagemodel.cpp b/src/client/messagemodel.cpp index cbcfceb2..a4b050d2 100644 --- a/src/client/messagemodel.cpp +++ b/src/client/messagemodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -41,11 +41,12 @@ MessageModel::MessageModel(QObject *parent) QDateTime now = QDateTime::currentDateTime(); now.setTimeSpec(Qt::UTC); _nextDayChange.setTimeSpec(Qt::UTC); - _nextDayChange.setTime_t(((now.toTime_t() / 86400) + 1) * 86400); + _nextDayChange.setMSecsSinceEpoch( + ((now.toMSecsSinceEpoch() / DAY_IN_MSECS) + 1) * DAY_IN_MSECS); _nextDayChange.setTimeSpec(Qt::LocalTime); _dayChangeTimer.setInterval(QDateTime::currentDateTime().secsTo(_nextDayChange) * 1000); _dayChangeTimer.start(); - connect(&_dayChangeTimer, SIGNAL(timeout()), this, SLOT(changeOfDay())); + connect(&_dayChangeTimer, &QTimer::timeout, this, &MessageModel::changeOfDay); } @@ -158,10 +159,10 @@ void MessageModel::insertMessageGroup(const QList &msglist) QDateTime prevTs = msglist.last().timestamp(); nextTs.setTimeSpec(Qt::UTC); prevTs.setTimeSpec(Qt::UTC); - uint nextDay = nextTs.toTime_t() / 86400; - uint prevDay = prevTs.toTime_t() / 86400; + qint64 nextDay = nextTs.toMSecsSinceEpoch() / DAY_IN_MSECS; + qint64 prevDay = prevTs.toMSecsSinceEpoch() / DAY_IN_MSECS; if (nextDay != prevDay) { - nextTs.setTime_t(nextDay * 86400); + nextTs.setMSecsSinceEpoch(nextDay * DAY_IN_MSECS); nextTs.setTimeSpec(Qt::LocalTime); dayChangeMsg = Message::ChangeOfDay(nextTs); dayChangeMsg.setMsgId(msglist.last().msgId()); @@ -206,7 +207,7 @@ int MessageModel::insertMessagesGracefully(const QList &msglist) QList::const_iterator iter; if (inOrder) { iter = msglist.constEnd(); - iter--; // this op is safe as we've allready passed an empty check + --iter; // this op is safe as we've allready passed an empty check } else { iter = msglist.constBegin(); @@ -229,11 +230,11 @@ int MessageModel::insertMessagesGracefully(const QList &msglist) } if (!inOrder) - iter++; + ++iter; if (inOrder) { while (iter != msglist.constBegin()) { - iter--; + --iter; if (!fastForward && (*iter).msgId() <= minId) break; @@ -250,10 +251,10 @@ int MessageModel::insertMessagesGracefully(const QList &msglist) QDateTime prevTs = (*iter).timestamp(); nextTs.setTimeSpec(Qt::UTC); prevTs.setTimeSpec(Qt::UTC); - uint nextDay = nextTs.toTime_t() / 86400; - uint prevDay = prevTs.toTime_t() / 86400; + qint64 nextDay = nextTs.toMSecsSinceEpoch() / DAY_IN_MSECS; + qint64 prevDay = prevTs.toMSecsSinceEpoch() / DAY_IN_MSECS; if (nextDay != prevDay) { - nextTs.setTime_t(nextDay * 86400); + nextTs.setMSecsSinceEpoch(nextDay * DAY_IN_MSECS); nextTs.setTimeSpec(Qt::LocalTime); Message dayChangeMsg = Message::ChangeOfDay(nextTs); dayChangeMsg.setMsgId((*iter).msgId()); @@ -282,10 +283,10 @@ int MessageModel::insertMessagesGracefully(const QList &msglist) QDateTime prevTs = (*iter).timestamp(); nextTs.setTimeSpec(Qt::UTC); prevTs.setTimeSpec(Qt::UTC); - uint nextDay = nextTs.toTime_t() / 86400; - uint prevDay = prevTs.toTime_t() / 86400; + qint64 nextDay = nextTs.toMSecsSinceEpoch() / DAY_IN_MSECS; + qint64 prevDay = prevTs.toMSecsSinceEpoch() / DAY_IN_MSECS; if (nextDay != prevDay) { - nextTs.setTime_t(nextDay * 86400); + nextTs.setMSecsSinceEpoch(nextDay * DAY_IN_MSECS); nextTs.setTimeSpec(Qt::LocalTime); Message dayChangeMsg = Message::ChangeOfDay(nextTs); dayChangeMsg.setMsgId((*iter).msgId()); @@ -295,7 +296,7 @@ int MessageModel::insertMessagesGracefully(const QList &msglist) dupeId = (*iter).msgId(); grouplist.prepend(*iter); } - iter++; + ++iter; } } @@ -348,7 +349,7 @@ int MessageModel::indexForId(MsgId id) // binary search int start = 0; int end = messageCount() - 1; - while (1) { + while (true) { if (end - start == 1) return end; int pivot = (end + start) / 2; @@ -360,7 +361,7 @@ int MessageModel::indexForId(MsgId id) void MessageModel::changeOfDay() { - _dayChangeTimer.setInterval(86400000); + _dayChangeTimer.setInterval(DAY_IN_MSECS); if (!messagesIsEmpty()) { int idx = messageCount(); while (idx > 0 && messageItemAt(idx - 1)->timestamp() > _nextDayChange) { @@ -372,7 +373,7 @@ void MessageModel::changeOfDay() insertMessage__(idx, dayChangeMsg); endInsertRows(); } - _nextDayChange = _nextDayChange.addSecs(86400); + _nextDayChange = _nextDayChange.addMSecs(DAY_IN_MSECS); }