From c0126cea95b056eb3072e6fb7404988da70a2b26 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Mon, 20 May 2019 13:42:18 +0800 Subject: [PATCH] Clean up roomlistmodel. --- src/roomlistmodel.cpp | 21 +++++---------------- src/roomlistmodel.h | 3 --- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/roomlistmodel.cpp b/src/roomlistmodel.cpp index b34f05a91..cee3f607f 100644 --- a/src/roomlistmodel.cpp +++ b/src/roomlistmodel.cpp @@ -48,7 +48,8 @@ void RoomListModel::setConnection(Connection* connection) { Connection::DirectChatsMap removals) { for (QString roomID : additions.values() + removals.values()) { auto room = connection->room(roomID); - if (room) refresh(static_cast(room)); + if (room) + refresh(static_cast(room)); } }); @@ -79,11 +80,9 @@ void RoomListModel::doAddRoom(Room* r) { } void RoomListModel::connectRoomSignals(SpectralRoom* room) { - connect(room, &Room::displaynameChanged, this, [=] { namesChanged(room); }); - connect(room, &Room::unreadMessagesChanged, this, - [=] { unreadMessagesChanged(room); }); - connect(room, &Room::notificationCountChanged, this, - [=] { unreadMessagesChanged(room); }); + connect(room, &Room::displaynameChanged, this, [=] { refresh(room); }); + connect(room, &Room::unreadMessagesChanged, this, [=] { refresh(room); }); + connect(room, &Room::notificationCountChanged, this, [=] { refresh(room); }); connect(room, &Room::avatarChanged, this, [this, room] { refresh(room, {AvatarRole}); }); connect(room, &Room::tagsChanged, this, [=] { refresh(room); }); @@ -207,11 +206,6 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const { return QVariant(); } -void RoomListModel::namesChanged(SpectralRoom* room) { - int row = m_rooms.indexOf(room); - emit dataChanged(index(row), index(row)); -} - void RoomListModel::refresh(SpectralRoom* room, const QVector& roles) { const auto it = std::find(m_rooms.begin(), m_rooms.end(), room); if (it == m_rooms.end()) { @@ -222,11 +216,6 @@ void RoomListModel::refresh(SpectralRoom* room, const QVector& roles) { emit dataChanged(idx, idx, roles); } -void RoomListModel::unreadMessagesChanged(SpectralRoom* room) { - int row = m_rooms.indexOf(room); - emit dataChanged(index(row), index(row)); -} - QHash RoomListModel::roleNames() const { QHash roles; roles[NameRole] = "name"; diff --git a/src/roomlistmodel.h b/src/roomlistmodel.h index 238b372d4..340bfa4fa 100644 --- a/src/roomlistmodel.h +++ b/src/roomlistmodel.h @@ -60,9 +60,6 @@ class RoomListModel : public QAbstractListModel { QHash roleNames() const; private slots: - void namesChanged(SpectralRoom* room); - void unreadMessagesChanged(SpectralRoom* room); - void doAddRoom(Room* room); void updateRoom(Room* room, Room* prev); void deleteRoom(Room* room);