matrixion/src/ImagePackListModel.h

47 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>
2023-06-19 20:54:58 +03:00
#include "SingleImagePackModel.h"
class ImagePackListModel : public QAbstractListModel
{
2021-09-18 01:22:33 +03:00
Q_OBJECT
2023-06-19 20:54:58 +03:00
QML_ELEMENT
QML_UNCREATABLE("")
2021-09-18 01:22:33 +03:00
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;
};