Document collapsestateproxymodel

Document collapsestateproxymodel and make som public functions private.
This commit is contained in:
James Graham
2023-04-13 16:41:41 +00:00
parent 9a0d82eb31
commit 333bd3cdb9

View File

@@ -6,26 +6,58 @@
#include "messageeventmodel.h" #include "messageeventmodel.h"
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
/**
* @class CollapseStateProxyModel
*
* This model aggregates multiple sequential state events into a single entry.
*
* Events are only aggregated if they happened on the same day.
*
* @sa MessageEventModel
*/
class CollapseStateProxyModel : public QSortFilterProxyModel class CollapseStateProxyModel : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
public: public:
/**
* @brief Defines the model roles.
*/
enum Roles { enum Roles {
AggregateDisplayRole = MessageEventModel::LastRole + 1, AggregateDisplayRole = MessageEventModel::LastRole + 1, /**< Single line aggregation of all the state events. */
StateEventsRole, StateEventsRole, /**< List of state events in the aggregated state. */
AuthorListRole, AuthorListRole, /**< List of unique authors of the aggregated state event. */
}; };
/**
* @brief Whether a row should be shown out or not.
*
* @sa QSortFilterProxyModel::filterAcceptsRow
*/
[[nodiscard]] bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; [[nodiscard]] bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
/**
* @brief Get the given role value at the given index.
*
* @sa QSortFilterProxyModel::data
*/
[[nodiscard]] QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override; [[nodiscard]] QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
/** /**
* @brief QString aggregating the text of consecutive state events starting at row. * @brief Returns a mapping from Role enum values to role names.
*
* @sa Roles, QAbstractProxyModel::roleNames()
*/
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
private:
/**
* @brief Aggregation of the text of consecutive state events starting at row.
* *
* If state events happen on different days they will be split into two aggregate * If state events happen on different days they will be split into two aggregate
* events. * events.
*/ */
[[nodiscard]] QString aggregateEventToString(int row) const; [[nodiscard]] QString aggregateEventToString(int row) const;
/** /**
* @brief Return a list of consecutive state events starting at row. * @brief Return a list of consecutive state events starting at row.
* *
@@ -33,6 +65,7 @@ public:
* events. * events.
*/ */
[[nodiscard]] QVariantList stateEventsList(int row) const; [[nodiscard]] QVariantList stateEventsList(int row) const;
/** /**
* @brief List of unique authors for the aggregate state events starting at row. * @brief List of unique authors for the aggregate state events starting at row.
*/ */