Filters private messages exchanged between two specific users. More...
Header: | #include <PrivateMessageProxyModel> |
Inherits: | QSortFilterProxyModel |
PrivateMessageProxyModel(QObject *parent = nullptr) | |
QVariantMap | get(int row) const |
QString | myUserId() const |
void | setMyUserId(const QString &id) |
void | setTargetUserId(const QString &id) |
QString | targetUserId() const |
void | myUserIdChanged() |
void | targetUserIdChanged() |
virtual bool | filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override |
PrivateMessageProxyModel sits on top of PrivateMessageModel and filters its contents to only expose messages where either:
This allows QML views to display private chat threads without managing filtering logic.
See also PrivateMessageModel.
[explicit]
PrivateMessageProxyModel::PrivateMessageProxyModel(QObject *parent = nullptr)Constructs a new proxy model for filtering private messages.
[override virtual protected]
bool PrivateMessageProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) constReimplements: QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const.
Returns true
if the message at sourceRow is between the current user and the target user.
Both sent and received messages are accepted.
sourceParent is the parent index for the row. For flat list models, this is typically an invalid index.
[invokable]
QVariantMap PrivateMessageProxyModel::get(int row) constReturns a single row as a QVariantMap, useful for QML delegate access.
row is the index in the proxy model. Returns an empty map if the index is invalid.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
Returns the ID of the current user.
Note: Getter function for property myUserId.
See also setMyUserId().
Sets the ID of the current user.
id is the client user id.
Calling this triggers a re-evaluation of the filter.
Note: Setter function for property myUserId.
See also myUserId().
Sets the ID of the user being chatted with.
id is the user id of private chat partner.
Calling this triggers a re-evaluation of the filter.
Note: Setter function for property targetUserId.
See also targetUserId().
Returns the ID of the chat partner (target user).
Note: Getter function for property targetUserId.
See also setTargetUserId().