matrixion/src/UsersModel.h

36 lines
907 B
C
Raw Normal View History

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