diff --git a/chatlistmodel.h b/chatlistmodel.h index 0c7b85c4..20c6eeba 100644 --- a/chatlistmodel.h +++ b/chatlistmodel.h @@ -99,7 +99,9 @@ public: Q_ASSERT(nextChat); setCurrentChat(nextChat); } - beginRemoveRows(QModelIndex(), index, index); + + const int newIndex = m_chats.indexOf(chat); + beginRemoveRows(QModelIndex(), newIndex, newIndex); m_chats.removeAll(chat); endRemoveRows(); delete chat; @@ -167,6 +169,15 @@ private Q_SLOTS: emit dataChanged(index, index, {NameRole}); } + void printChats() + { + for (auto c : m_chats) { + qDebug() << c->name() + << (c == m_currentChat ? "currentChat: true" : "currentChat: false") + << (c == m_newChat ? "newChat: true" : "newChat: false"); + } + } + private: Chat* m_newChat; Chat* m_currentChat;