X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fmessagemodel.cpp;h=3cddb8ae67f409dc83782bb7650632ad5a2f2cdd;hp=549856621eab6fe6ccf5767d3cf35bd9b616db57;hb=a65f42197839da536975b3e2858eedcef420035f;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/client/messagemodel.cpp b/src/client/messagemodel.cpp index 54985662..3cddb8ae 100644 --- a/src/client/messagemodel.cpp +++ b/src/client/messagemodel.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-09 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "messagemodel.h" @@ -41,7 +41,8 @@ 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(); @@ -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; } } @@ -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); }