File indexing completed on 2024-05-05 16:58:40
0001 // SPDX-FileCopyrightText: 2022 Snehit Sah <hi@snehit.dev> 0002 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 0004 #pragma once 0005 0006 #include <QSortFilterProxyModel> 0007 0008 /** 0009 * @class SortFilterSpaceListModel 0010 * 0011 * This model sorts and filters the space list. 0012 * 0013 * The spaces are sorted by their matrix ID. The filter only shows space rooms, 0014 * but filters out upgraded spaces. 0015 */ 0016 class SortFilterSpaceListModel : public QSortFilterProxyModel 0017 { 0018 Q_OBJECT 0019 /** 0020 * @brief The number of spaces in the model. 0021 */ 0022 Q_PROPERTY(int count READ rowCount NOTIFY countChanged) 0023 0024 public: 0025 explicit SortFilterSpaceListModel(QObject *parent = nullptr); 0026 0027 Q_SIGNALS: 0028 void countChanged(); 0029 0030 protected: 0031 /** 0032 * @brief Returns true if the value of source_left is less than source_right. 0033 * 0034 * @sa QSortFilterProxyModel::lessThan 0035 */ 0036 [[nodiscard]] bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override; 0037 0038 /** 0039 * @brief Whether a row should be shown out or not. 0040 * 0041 * @sa QSortFilterProxyModel::filterAcceptsRow 0042 */ 0043 [[nodiscard]] bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0044 };