matrixion/src/ImagePackListModel.h

43 lines
1.1 KiB
C
Raw Normal View History

// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QAbstractListModel>
#include <QQmlEngine>
#include <QSharedPointer>
class SingleImagePackModel;
2022-10-10 15:38:29 +03:00
class ImagePackListModel final : public QAbstractListModel
{
2021-09-18 01:22:33 +03:00
Q_OBJECT
Q_PROPERTY(bool containsAccountPack READ containsAccountPack CONSTANT)
public:
2021-09-18 01:22:33 +03:00
enum Roles
{
DisplayName = Qt::UserRole,
AvatarUrl,
FromAccountData,
FromCurrentRoom,
2022-09-01 14:25:11 +03:00
FromSpace,
2021-09-18 01:22:33 +03:00
StateKey,
RoomId,
};
ImagePackListModel(const std::string &roomId, QObject *parent = nullptr);
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
Q_INVOKABLE SingleImagePackModel *packAt(int row);
Q_INVOKABLE SingleImagePackModel *newPack(bool inRoom);
bool containsAccountPack() const;
private:
2021-09-18 01:22:33 +03:00
std::string room_id;
2021-09-18 01:22:33 +03:00
std::vector<QSharedPointer<SingleImagePackModel>> packs;
};