2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: 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>
|
|
|
|
|
2023-06-02 01:24:26 +03:00
|
|
|
#include "timeline/TimelineModel.h"
|
2023-02-26 07:19:15 +03:00
|
|
|
|
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:
|
2023-01-31 19:59:49 +03:00
|
|
|
Invitee(QString mxid,
|
|
|
|
QString displayName = "",
|
|
|
|
QString avatarUrl = "",
|
|
|
|
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)
|
2023-02-27 17:08:26 +03:00
|
|
|
Q_PROPERTY(TimelineModel *room READ room CONSTANT)
|
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
|
|
|
|
2023-02-26 07:19:15 +03:00
|
|
|
InviteesModel(TimelineModel *room, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
TimelineModel *room() const { return room_; }
|
2021-06-11 03:13:12 +03:00
|
|
|
|
2023-01-31 19:59:49 +03:00
|
|
|
Q_INVOKABLE void addUser(QString mxid, QString displayName = "", QString avatarUrl = "");
|
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_;
|
2023-02-26 07:19:15 +03:00
|
|
|
TimelineModel *room_;
|
2021-06-11 03:13:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INVITEESMODEL_H
|