Document statemodel
This commit is contained in:
committed by
Carl Schwan
parent
a7ee1fac3c
commit
3f572c79fa
@@ -7,28 +7,57 @@
|
|||||||
|
|
||||||
#include "neochatroom.h"
|
#include "neochatroom.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class StateModel
|
||||||
|
*
|
||||||
|
* This class defines the model for visualising the state events in a room.
|
||||||
|
*/
|
||||||
class StateModel : public QAbstractListModel
|
class StateModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The current room that the model is getting its state events from.
|
||||||
|
*/
|
||||||
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged)
|
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Defines the model roles.
|
||||||
|
*/
|
||||||
enum Roles {
|
enum Roles {
|
||||||
TypeRole,
|
TypeRole, /**< The type of the state event. */
|
||||||
StateKeyRole,
|
StateKeyRole, /**< The state key of the state event. */
|
||||||
SourceRole,
|
SourceRole, /**< The full event source JSON. */
|
||||||
};
|
};
|
||||||
Q_ENUM(Roles);
|
Q_ENUM(Roles);
|
||||||
|
|
||||||
StateModel(QObject *parent = nullptr);
|
StateModel(QObject *parent = nullptr);
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
|
||||||
int rowCount(const QModelIndex &parent) const override;
|
|
||||||
|
|
||||||
NeoChatRoom *room() const;
|
NeoChatRoom *room() const;
|
||||||
void setRoom(NeoChatRoom *room);
|
void setRoom(NeoChatRoom *room);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the given role value at the given index.
|
||||||
|
*
|
||||||
|
* @sa QAbstractItemModel::data
|
||||||
|
*/
|
||||||
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of rows in the model.
|
||||||
|
*
|
||||||
|
* @sa QAbstractItemModel::rowCount
|
||||||
|
*/
|
||||||
|
int rowCount(const QModelIndex &parent) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a mapping from Role enum values to role names.
|
||||||
|
*
|
||||||
|
* @sa Roles, QAbstractItemModel::roleNames()
|
||||||
|
*/
|
||||||
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void roomChanged();
|
void roomChanged();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user