Fix showing permissions settings for v12 rooms

This commit is contained in:
Tobias Fella
2025-09-08 08:14:17 +00:00
parent d67cb89505
commit 0fd924be7b
4 changed files with 17 additions and 5 deletions

View File

@@ -93,6 +93,9 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const
return QVariant::fromValue(memberId);
}
if (role == PowerLevelRole) {
if (m_currentRoom->isCreator(memberId)) {
return std::numeric_limits<int>::max();
}
auto plEvent = m_currentRoom->currentState().get<RoomPowerLevelsEvent>();
if (!plEvent) {
return 0;
@@ -118,6 +121,9 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const
PowerLevel::nameForLevel(PowerLevel::levelForValue(userPl)),
userPl);
}
if (role == IsCreatorRole) {
return m_currentRoom->isCreator(memberId);
}
return {};
}
@@ -219,6 +225,7 @@ QHash<int, QByteArray> UserListModel::roleNames() const
roles[ObjectRole] = "user";
roles[PowerLevelRole] = "powerLevel";
roles[PowerLevelStringRole] = "powerLevelString";
roles[IsCreatorRole] = "isCreator";
return roles;
}

View File

@@ -48,6 +48,7 @@ public:
ObjectRole, /**< The QObject for the user. */
PowerLevelRole, /**< The user's power level in the current room. */
PowerLevelStringRole, /**< The name of the user's power level in the current room. */
IsCreatorRole, /**< Whether this user is considered a creator of the current room. */
};
Q_ENUM(EventRoles)

View File

@@ -605,7 +605,7 @@ public:
*
* For unusual room versions, this information might be wrong.
*/
bool roomCreatorHasUltimatePowerLevel() const;
Q_INVOKABLE bool roomCreatorHasUltimatePowerLevel() const;
/**
* @brief Whether this user is considered a creator of this room. Only applies to post-v12 rooms.