+ start--;
+ end--;
+ }
+ }
+
+ if(!dayChangeItem && start < _messageList.count()) {
+ // check if we need to insert a daychange message at the end of the this group
+
+ // if this assert triggers then indexForId() would have found a spot right before a DayChangeMsg
+ // this should never happen as daychange messages share the msgId with the preceeding message
+ Q_ASSERT(_messageList[start]->msgType() != Message::DayChange);
+ QDateTime nextTs = _messageList[start]->timeStamp();
+ 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;
+ if(nextDay != prevDay) {
+ nextTs.setTime_t(nextDay * 86400);
+ nextTs.setTimeSpec(Qt::LocalTime);
+ Message dayChangeMsg = Message::ChangeOfDay(nextTs);
+ dayChangeMsg.setMsgId(msglist.last().msgId());
+ dayChangeItem = createMessageModelItem(dayChangeMsg);