File indexing completed on 2025-01-19 13:24:20
0001 /* 0002 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "libruqolacore_export.h" 0010 #include "ownuser/ownuserpreferences.h" 0011 #include <QSortFilterProxyModel> 0012 0013 /** 0014 * This proxy model sits on top of RoomModel and implements 0015 * - filtering (on the RoomOpen role) 0016 * - sorting (by RoomOrder and by RoomName) 0017 */ 0018 class LIBRUQOLACORE_EXPORT RoomFilterProxyModel : public QSortFilterProxyModel 0019 { 0020 Q_OBJECT 0021 public: 0022 explicit RoomFilterProxyModel(QObject *parent = nullptr); 0023 ~RoomFilterProxyModel() override; 0024 0025 void setFilterString(const QString &string); 0026 0027 void setSortOrder(OwnUserPreferences::RoomListSortOrder sortOrder); 0028 0029 protected: 0030 [[nodiscard]] bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; 0031 [[nodiscard]] bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0032 0033 private: 0034 QString mFilterString; 0035 OwnUserPreferences::RoomListSortOrder mSortOrder = OwnUserPreferences::RoomListSortOrder::Unknown; 0036 };