matrixion/src/UsersModel.h

34 lines
891 B
C
Raw Normal View History

2021-03-05 02:35:15 +03:00
// SPDX-FileCopyrightText: 2021 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
2020-09-07 12:51:28 +03:00
#pragma once
#include <QAbstractListModel>
class UsersModel : public QAbstractListModel
{
public:
enum Roles
{
2020-11-20 04:38:08 +03:00
AvatarUrl = Qt::UserRole,
DisplayName,
2020-11-24 21:06:31 +03:00
UserID,
2020-09-07 12:51:28 +03:00
};
UsersModel(const std::string &roomId, QObject *parent = nullptr);
2020-11-20 04:38:08 +03:00
QHash<int, QByteArray> roleNames() const override;
2020-09-07 12:51:28 +03:00
int rowCount(const QModelIndex &parent = QModelIndex()) const override
{
2020-11-20 04:38:08 +03:00
(void)parent;
2020-12-25 03:08:06 +03:00
return (int)roomMembers_.size();
2020-09-07 12:51:28 +03:00
}
QVariant data(const QModelIndex &index, int role) const override;
private:
2020-11-20 04:38:08 +03:00
std::string room_id;
std::vector<std::string> roomMembers_;
2020-11-20 06:05:31 +03:00
std::vector<QString> displayNames;
std::vector<QString> userids;
2020-09-07 12:51:28 +03:00
};