Document sortfilterroomlistmodel
This commit is contained in:
committed by
Carl Schwan
parent
3f572c79fa
commit
88dfacbbb3
@@ -5,12 +5,44 @@
|
|||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class SortFilterRoomListModel
|
||||||
|
*
|
||||||
|
* This model sorts and filters the room list.
|
||||||
|
*
|
||||||
|
* There are numerous room sort orders available:
|
||||||
|
* - Categories - sort rooms by their NeoChatRoomType and then by last activty within
|
||||||
|
* each category.
|
||||||
|
* - LastActivity - sort rooms by the last active time in the room.
|
||||||
|
* - Alphabetical - sort the rooms alphabetically by room name.
|
||||||
|
*
|
||||||
|
* The model can be given a filter string that will only show rooms who's name includes
|
||||||
|
* the text.
|
||||||
|
*
|
||||||
|
* The model can also be given an active space ID and will only show rooms within
|
||||||
|
* that space.
|
||||||
|
*
|
||||||
|
* All space rooms and upgraded rooms will also be filtered out.
|
||||||
|
*/
|
||||||
class SortFilterRoomListModel : public QSortFilterProxyModel
|
class SortFilterRoomListModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The order by which the rooms will be sorted.
|
||||||
|
*
|
||||||
|
* @sa RoomSortOrder
|
||||||
|
*/
|
||||||
Q_PROPERTY(RoomSortOrder roomSortOrder READ roomSortOrder WRITE setRoomSortOrder NOTIFY roomSortOrderChanged)
|
Q_PROPERTY(RoomSortOrder roomSortOrder READ roomSortOrder WRITE setRoomSortOrder NOTIFY roomSortOrderChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The text to use to filter room names.
|
||||||
|
*/
|
||||||
Q_PROPERTY(QString filterText READ filterText READ filterText WRITE setFilterText NOTIFY filterTextChanged)
|
Q_PROPERTY(QString filterText READ filterText READ filterText WRITE setFilterText NOTIFY filterTextChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ID of the space to show rooms for.
|
||||||
|
*/
|
||||||
Q_PROPERTY(QString activeSpaceId READ activeSpaceId WRITE setActiveSpaceId NOTIFY activeSpaceIdChanged)
|
Q_PROPERTY(QString activeSpaceId READ activeSpaceId WRITE setActiveSpaceId NOTIFY activeSpaceIdChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -29,12 +61,22 @@ public:
|
|||||||
void setFilterText(const QString &text);
|
void setFilterText(const QString &text);
|
||||||
[[nodiscard]] QString filterText() const;
|
[[nodiscard]] QString filterText() const;
|
||||||
|
|
||||||
[[nodiscard]] bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
|
||||||
|
|
||||||
QString activeSpaceId() const;
|
QString activeSpaceId() const;
|
||||||
void setActiveSpaceId(const QString &spaceId);
|
void setActiveSpaceId(const QString &spaceId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* @brief Returns true if the value of source_left is less than source_right.
|
||||||
|
*
|
||||||
|
* @sa QSortFilterProxyModel::lessThan
|
||||||
|
*/
|
||||||
|
[[nodiscard]] bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|||||||
Reference in New Issue
Block a user