matrixion/src/InviteesModel.h

64 lines
1.2 KiB
C
Raw Normal View History

2021-07-17 20:31:38 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// 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>
class Invitee : public QObject
{
2021-09-18 01:22:33 +03:00
Q_OBJECT
2021-06-11 03:13:12 +03:00
public:
2021-09-18 01:22:33 +03:00
Invitee(const 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
};
class InviteesModel : public QAbstractListModel
{
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-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-06-11 03:13:12 +03:00
2021-09-18 01:22:33 +03:00
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex & = QModelIndex()) const override
{
return (int)invitees_.size();
}
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
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