2021-02-15 22:17:17 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Cache.h"
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
class RoomsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Roles
|
|
|
|
{
|
|
|
|
AvatarUrl = Qt::UserRole,
|
|
|
|
RoomAlias,
|
|
|
|
RoomID,
|
|
|
|
RoomName,
|
|
|
|
};
|
|
|
|
|
2021-02-17 17:21:35 +03:00
|
|
|
RoomsModel(bool showOnlyRoomWithAliases = false, QObject *parent = nullptr);
|
2021-02-15 22:17:17 +03:00
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
|
|
|
{
|
|
|
|
(void)parent;
|
2021-02-17 17:21:35 +03:00
|
|
|
return (int)roomids.size();
|
2021-02-15 22:17:17 +03:00
|
|
|
}
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<QString> roomids;
|
|
|
|
std::vector<QString> roomAliases;
|
|
|
|
std::map<QString, RoomInfo> roomInfos;
|
2021-02-17 17:21:35 +03:00
|
|
|
bool showOnlyRoomWithAliases_;
|
2021-02-15 22:17:17 +03:00
|
|
|
};
|