2021-03-05 02:35:15 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2023-01-02 06:25:33 +03:00
|
|
|
// SPDX-FileCopyrightText: 2023 Nheko Contributors
|
2021-03-05 02:35:15 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-02-15 22:17:17 +03:00
|
|
|
#pragma once
|
|
|
|
|
2022-11-09 06:58:19 +03:00
|
|
|
#include "CacheStructs.h"
|
2021-02-15 22:17:17 +03:00
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QString>
|
|
|
|
|
2022-10-10 15:38:29 +03:00
|
|
|
class RoomsModel final : public QAbstractListModel
|
2021-02-15 22:17:17 +03:00
|
|
|
{
|
|
|
|
public:
|
2021-09-18 01:22:33 +03:00
|
|
|
enum Roles
|
|
|
|
{
|
|
|
|
AvatarUrl = Qt::UserRole,
|
|
|
|
RoomAlias,
|
|
|
|
RoomID,
|
|
|
|
RoomName,
|
|
|
|
};
|
2021-02-15 22:17:17 +03:00
|
|
|
|
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;
|
2023-01-07 19:39:32 +03:00
|
|
|
return (int)rooms.size();
|
2021-09-18 01:22:33 +03:00
|
|
|
}
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
2021-02-15 22:17:17 +03:00
|
|
|
|
|
|
|
private:
|
2023-01-07 19:39:32 +03:00
|
|
|
std::vector<RoomNameAlias> rooms;
|
2021-09-18 01:22:33 +03:00
|
|
|
bool showOnlyRoomWithAliases_;
|
2021-02-15 22:17:17 +03:00
|
|
|
};
|