2021-07-17 20:31:38 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2023-01-02 06:25:33 +03:00
|
|
|
// SPDX-FileCopyrightText: 2023 Nheko Contributors
|
2021-07-17 20:31:38 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-06-11 03:13:12 +03:00
|
|
|
#ifndef INVITEESMODEL_H
|
|
|
|
#define INVITEESMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QVector>
|
|
|
|
|
2022-10-10 15:38:29 +03:00
|
|
|
class Invitee final : public QObject
|
2021-06-11 03:13:12 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_OBJECT
|
2021-06-11 03:13:12 +03:00
|
|
|
|
|
|
|
public:
|
2021-12-29 08:01:38 +03:00
|
|
|
Invitee(QString mxid, QObject *parent = nullptr);
|
2021-06-11 03:13:12 +03:00
|
|
|
|
|
|
|
signals:
|
2021-09-18 01:22:33 +03:00
|
|
|
void userInfoLoaded();
|
2021-06-11 03:13:12 +03:00
|
|
|
|
|
|
|
private:
|
2021-09-18 01:22:33 +03:00
|
|
|
const QString mxid_;
|
|
|
|
QString displayName_;
|
|
|
|
QString avatarUrl_;
|
2021-06-11 03:13:12 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
friend class InviteesModel;
|
2021-06-11 03:13:12 +03:00
|
|
|
};
|
|
|
|
|
2022-10-10 15:38:29 +03:00
|
|
|
class InviteesModel final : public QAbstractListModel
|
2021-06-11 03:13:12 +03:00
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_OBJECT
|
2021-06-11 03:13:12 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
|
2021-07-19 19:31:20 +03:00
|
|
|
|
2021-06-11 03:13:12 +03:00
|
|
|
public:
|
2021-09-18 01:22:33 +03:00
|
|
|
enum Roles
|
|
|
|
{
|
|
|
|
Mxid,
|
|
|
|
DisplayName,
|
|
|
|
AvatarUrl,
|
|
|
|
};
|
2021-06-11 03:13:12 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
InviteesModel(QObject *parent = nullptr);
|
2021-06-11 03:13:12 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_INVOKABLE void addUser(QString mxid);
|
2021-11-13 23:05:26 +03:00
|
|
|
Q_INVOKABLE void removeUser(QString mxid);
|
2021-06-11 03:13:12 +03:00
|
|
|
|
2021-12-29 08:01:38 +03:00
|
|
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
|
|
|
[[nodiscard]] int rowCount(const QModelIndex & = QModelIndex()) const override
|
2021-09-18 01:22:33 +03:00
|
|
|
{
|
|
|
|
return (int)invitees_.size();
|
|
|
|
}
|
2021-12-29 08:01:38 +03:00
|
|
|
[[nodiscard]] QVariant
|
|
|
|
data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
2021-09-18 01:22:33 +03:00
|
|
|
QStringList mxids();
|
2021-06-11 03:13:12 +03:00
|
|
|
|
|
|
|
signals:
|
2021-09-18 01:22:33 +03:00
|
|
|
void accept();
|
|
|
|
void countChanged();
|
2021-06-11 03:13:12 +03:00
|
|
|
|
|
|
|
private:
|
2021-09-18 01:22:33 +03:00
|
|
|
QVector<Invitee *> invitees_;
|
2021-06-11 03:13:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INVITEESMODEL_H
|