Clean up roomlistmodel.
This commit is contained in:
@@ -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<SpectralRoom*>(room));
|
||||
if (room)
|
||||
refresh(static_cast<SpectralRoom*>(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<int>& 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<int>& roles) {
|
||||
emit dataChanged(idx, idx, roles);
|
||||
}
|
||||
|
||||
void RoomListModel::unreadMessagesChanged(SpectralRoom* room) {
|
||||
int row = m_rooms.indexOf(room);
|
||||
emit dataChanged(index(row), index(row));
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> RoomListModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "name";
|
||||
|
||||
@@ -60,9 +60,6 @@ class RoomListModel : public QAbstractListModel {
|
||||
QHash<int, QByteArray> 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);
|
||||
|
||||
Reference in New Issue
Block a user