Document imagepacksmodel
This commit is contained in:
committed by
Tobias Fella
parent
8802753de1
commit
d424aba0bc
@@ -10,27 +10,66 @@
|
|||||||
|
|
||||||
class NeoChatRoom;
|
class NeoChatRoom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class ImagePacksModel
|
||||||
|
*
|
||||||
|
* Defines the model for visualising image packs.
|
||||||
|
*
|
||||||
|
* See Matrix MSC2545 for more details on image packs.
|
||||||
|
* https://github.com/Sorunome/matrix-doc/blob/soru/emotes/proposals/2545-emotes.md
|
||||||
|
*/
|
||||||
class ImagePacksModel : public QAbstractListModel
|
class ImagePacksModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The current room that the model is being used in.
|
||||||
|
*/
|
||||||
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged)
|
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether sticker image packs should be shown.
|
||||||
|
*/
|
||||||
Q_PROPERTY(bool showStickers READ showStickers WRITE setShowStickers NOTIFY showStickersChanged)
|
Q_PROPERTY(bool showStickers READ showStickers WRITE setShowStickers NOTIFY showStickersChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether emoticon image packs should be shown.
|
||||||
|
*/
|
||||||
Q_PROPERTY(bool showEmoticons READ showEmoticons WRITE setShowEmoticons NOTIFY showEmoticonsChanged)
|
Q_PROPERTY(bool showEmoticons READ showEmoticons WRITE setShowEmoticons NOTIFY showEmoticonsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Defines the model roles.
|
||||||
|
*/
|
||||||
enum Roles {
|
enum Roles {
|
||||||
DisplayNameRole = Qt::DisplayRole,
|
DisplayNameRole = Qt::DisplayRole, /**< The display name of the image pack. */
|
||||||
AvatarUrlRole,
|
AvatarUrlRole, /**< The source mxc URL for the pack avatar. */
|
||||||
AttributionRole,
|
AttributionRole, /**< The attribution for the pack author(s). */
|
||||||
IdRole,
|
IdRole, /**< The ID of the image pack. */
|
||||||
};
|
};
|
||||||
Q_ENUM(Roles);
|
Q_ENUM(Roles);
|
||||||
|
|
||||||
explicit ImagePacksModel(QObject *parent = nullptr);
|
explicit ImagePacksModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] int rowCount(const QModelIndex &index) const override;
|
/**
|
||||||
|
* @brief Get the given role value at the given index.
|
||||||
|
*
|
||||||
|
* @sa QAbstractItemModel::data
|
||||||
|
*/
|
||||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of rows in the model.
|
||||||
|
*
|
||||||
|
* @sa QAbstractItemModel::rowCount
|
||||||
|
*/
|
||||||
|
[[nodiscard]] int rowCount(const QModelIndex &index) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a mapping from Role enum values to role names.
|
||||||
|
*
|
||||||
|
* @sa Roles, QAbstractItemModel::roleNames()
|
||||||
|
*/
|
||||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
[[nodiscard]] NeoChatRoom *room() const;
|
[[nodiscard]] NeoChatRoom *room() const;
|
||||||
@@ -42,6 +81,9 @@ public:
|
|||||||
[[nodiscard]] bool showEmoticons() const;
|
[[nodiscard]] bool showEmoticons() const;
|
||||||
void setShowEmoticons(bool showEmoticons);
|
void setShowEmoticons(bool showEmoticons);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return a vector of the images in the pack at the given index.
|
||||||
|
*/
|
||||||
[[nodiscard]] QVector<Quotient::ImagePackEventContent::ImagePackImage> images(int index);
|
[[nodiscard]] QVector<Quotient::ImagePackEventContent::ImagePackImage> images(int index);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|||||||
Reference in New Issue
Block a user