Allow removing users from the invite dialog

This commit is contained in:
Loren Burkholder 2021-11-13 15:05:26 -05:00
parent e09af0b101
commit b1c1274d96
3 changed files with 29 additions and 3 deletions

View File

@ -116,6 +116,7 @@ ApplicationWindow {
spacing: Nheko.paddingMedium
anchors.verticalCenter: parent.verticalCenter
x: parent.x + Nheko.paddingSmall
width: del.width - Nheko.paddingSmall * 2
Avatar {
width: Nheko.avatarSize
@ -148,11 +149,21 @@ ApplicationWindow {
}
CursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
ImageButton {
image: ":/icons/icons/ui/remove-symbol.png"
onClicked: invitees.removeUser(model.mxid)
}
}
CursorShape {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
}
}

View File

@ -30,6 +30,20 @@ InviteesModel::addUser(QString mxid)
emit countChanged();
}
void
InviteesModel::removeUser(QString mxid)
{
for (int i = 0; i < invitees_.length(); ++i) {
if (invitees_[i]->mxid_ == mxid) {
beginRemoveRows(QModelIndex(), i, i);
invitees_.removeAt(i);
endRemoveRows();
emit countChanged();
break;
}
}
}
QHash<int, QByteArray>
InviteesModel::roleNames() const
{

View File

@ -43,6 +43,7 @@ public:
InviteesModel(QObject *parent = nullptr);
Q_INVOKABLE void addUser(QString mxid);
Q_INVOKABLE void removeUser(QString mxid);
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex & = QModelIndex()) const override