matrixion/src/RoomsModel.h

36 lines
798 B
C
Raw Normal View History

// SPDX-FileCopyrightText: 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;
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;
private:
2023-01-07 19:39:32 +03:00
std::vector<RoomNameAlias> rooms;
2021-09-18 01:22:33 +03:00
bool showOnlyRoomWithAliases_;
};