diff options
Diffstat (limited to 'Swift/QtUI/ChatList/ChatListModel.cpp')
-rw-r--r-- | Swift/QtUI/ChatList/ChatListModel.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Swift/QtUI/ChatList/ChatListModel.cpp b/Swift/QtUI/ChatList/ChatListModel.cpp index e5e8963..416b786 100644 --- a/Swift/QtUI/ChatList/ChatListModel.cpp +++ b/Swift/QtUI/ChatList/ChatListModel.cpp @@ -69,87 +69,86 @@ void ChatListModel::removeMUCBookmark(const Swift::MUCBookmark& bookmark) { mucBookmarks_->remove(i); endRemoveRows(); break; } } } void ChatListModel::addWhiteboardSession(const ChatListWindow::Chat& chat) { beginInsertRows(whiteboardsIndex_, 0, whiteboards_->rowCount()); whiteboards_->addItem(new ChatListWhiteboardItem(chat, whiteboards_)); endInsertRows(); } void ChatListModel::removeWhiteboardSession(const JID& jid) { for (int i = 0; i < whiteboards_->rowCount(); i++) { ChatListWhiteboardItem* item = dynamic_cast<ChatListWhiteboardItem*>(whiteboards_->item(i)); if (item->getChat().jid == jid) { beginRemoveRows(whiteboardsIndex_, i, i+1); whiteboards_->remove(i); endRemoveRows(); break; } } } void ChatListModel::setRecents(const std::list<ChatListWindow::Chat>& recents) { beginRemoveRows(recentsIndex_, 0, recents_->rowCount()); recents_->clear(); endRemoveRows(); beginInsertRows(recentsIndex_, 0, recents.size()); - foreach (const ChatListWindow::Chat chat, recents) { + for (const auto& chat : recents) { recents_->addItem(new ChatListRecentItem(chat, recents_)); //whiteboards_->addItem(new ChatListRecentItem(chat, whiteboards_)); } endInsertRows(); } QMimeData* ChatListModel::mimeData(const QModelIndexList& indexes) const { QMimeData* data = QAbstractItemModel::mimeData(indexes); ChatListRecentItem *item = dynamic_cast<ChatListRecentItem*>(getItemForIndex(indexes.first())); if (item == nullptr) { return data; } QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); const ChatListWindow::Chat& chat = item->getChat(); QString mimeType = "application/vnd.swift.contact-jid-list"; if (!chat.impromptuJIDs.size()) { if (chat.isMUC) { mimeType = "application/vnd.swift.contact-jid-muc"; } dataStream << P2QSTRING(chat.jid.toString()); } else { - typedef std::map<std::string, JID> JIDMap; - foreach (const JIDMap::value_type& jid, chat.impromptuJIDs) { + for (const auto& jid : chat.impromptuJIDs) { dataStream << P2QSTRING(jid.second.toString()); } } data->setData(mimeType, itemData); return data; } const ChatListMUCItem* ChatListModel::getChatListMUCItem(const JID& roomJID) const { const ChatListMUCItem* mucItem = nullptr; for (int i = 0; i < mucBookmarks_->rowCount(); i++) { ChatListMUCItem* item = dynamic_cast<ChatListMUCItem*>(mucBookmarks_->item(i)); if (item->getBookmark().getRoom() == roomJID) { mucItem = item; break; } } return mucItem; } int ChatListModel::columnCount(const QModelIndex& /*parent*/) const { return 1; } ChatListItem* ChatListModel::getItemForIndex(const QModelIndex& index) const { return index.isValid() ? static_cast<ChatListItem*>(index.internalPointer()) : nullptr; } QVariant ChatListModel::data(const QModelIndex& index, int role) const { ChatListItem* item = getItemForIndex(index); |