Improve spaces support

This commit is contained in:
Tobias Fella
2023-05-09 08:11:47 +00:00
parent 30c7d86045
commit 11343e6bdf
10 changed files with 490 additions and 134 deletions

View File

@@ -7,6 +7,7 @@
#include "neochatconfig.h"
#include "neochatroom.h"
#include "roommanager.h"
#include "spacehierarchycache.h"
#include "user.h"
#include <QDebug>
@@ -65,6 +66,9 @@ RoomListModel::RoomListModel(QObject *parent)
qGuiApp->setBadgeNumber(m_notificationCount);
#endif // QT_VERSION_CHECK(6, 6, 0)
});
connect(&SpaceHierarchyCache::instance(), &SpaceHierarchyCache::spaceHierarchyChanged, this, [this]() {
Q_EMIT dataChanged(index(0, 0), index(rowCount(), 0), {IsChildSpaceRole});
});
}
RoomListModel::~RoomListModel() = default;
@@ -412,6 +416,9 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
if (role == IsSpaceRole) {
return room->isSpace();
}
if (role == IsChildSpaceRole) {
return SpaceHierarchyCache::instance().isChildSpace(room->id());
}
return QVariant();
}
@@ -447,6 +454,7 @@ QHash<int, QByteArray> RoomListModel::roleNames() const
roles[SubtitleTextRole] = "subtitleText";
roles[IsSpaceRole] = "isSpace";
roles[IdRole] = "id";
roles[IsChildSpaceRole] = "isChildSpace";
return roles;
}