matrixion/src/RoomsModel.h

40 lines
984 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
#pragma once
#include "CacheStructs.h"
#include <QAbstractListModel>
#include <QString>
2022-10-10 15:38:29 +03:00
class RoomsModel final : public QAbstractListModel
{
public:
2021-09-18 01:22:33 +03:00
enum Roles
{
AvatarUrl = Qt::UserRole,
RoomAlias,
RoomID,
RoomName,
};
2021-09-18 01:22:33 +03:00
RoomsModel(bool showOnlyRoomWithAliases = false, QObject *parent = nullptr);
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override
{
(void)parent;
return (int)roomids.size();
}
QVariant data(const QModelIndex &index, int role) const override;
private:
2021-09-18 01:22:33 +03:00
std::vector<QString> roomids;
std::vector<QString> roomAliases;
std::map<QString, RoomInfo> roomInfos;
bool showOnlyRoomWithAliases_;
};