Permission model

Add a model for managing permissions (power levels) in rooms. This gets rid of a whole bunch of boiler plate in NeoChat and as a bonus makes it easy to add a feature to allow setting the permission level for any event.
This commit is contained in:
James Graham
2024-05-25 16:25:39 +00:00
parent 8199653ddd
commit a48151920d
10 changed files with 736 additions and 678 deletions

View File

@@ -7,6 +7,7 @@
#include <Quotient/events/roompowerlevelsevent.h>
#include "enums/powerlevel.h"
#include "neochatroom.h"
using namespace Quotient;
@@ -94,16 +95,10 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const
auto userPl = pl->powerLevelForUser(user->id());
switch (userPl) {
case 0:
return QStringLiteral("Member");
case 50:
return QStringLiteral("Moderator");
case 100:
return QStringLiteral("Admin");
default:
return QStringLiteral("Custom");
}
return i18nc("%1 is the name of the power level, e.g. admin and %2 is the value that represents.",
"%1 (%2)",
PowerLevel::nameForLevel(PowerLevel::levelForValue(userPl)),
userPl);
}
return {};