File indexing completed on 2024-05-05 16:58:40
0001 // SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 #pragma once 0005 0006 #include <QSortFilterProxyModel> 0007 0008 /** 0009 * @class UserFilterModel 0010 * 0011 * This class creates a custom QSortFilterProxyModel for filtering a users by either 0012 * display name or matrix ID. The filter can accept a full matrix id i.e. example:kde.org 0013 * to separate between accounts on different servers with similar names. 0014 */ 0015 class UserFilterModel : public QSortFilterProxyModel 0016 { 0017 Q_OBJECT 0018 0019 /** 0020 * @brief This property hold the text of the filter. 0021 * 0022 * The text is either a desired display name or matrix id. 0023 */ 0024 Q_PROPERTY(QString filterText READ filterText WRITE setFilterText NOTIFY filterTextChanged) 0025 0026 public: 0027 /** 0028 * @brief Custom filter function checking boith the display name and matrix ID. 0029 * 0030 * @note The filter cannot be modified and will always use the same filter properties. 0031 */ 0032 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; 0033 0034 QString filterText() const; 0035 void setFilterText(const QString &filterText); 0036 0037 Q_SIGNALS: 0038 void filterTextChanged(); 0039 0040 private: 0041 QString m_filterText; 0042 };