File indexing completed on 2024-05-05 04:53:42

0001 /*
0002     SPDX-FileCopyrightText: 2017 Nicolas Carion
0003     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #pragma once
0007 
0008 #include <QSortFilterProxyModel>
0009 #include <memory>
0010 
0011 class ProfileModel;
0012 /** @brief This class is used as a proxy model to filter the profile tree based on given criterion (fps, interlaced,...)
0013  */
0014 class ProfileFilter : public QSortFilterProxyModel
0015 {
0016     Q_OBJECT
0017 
0018 public:
0019     ProfileFilter(QObject *parent = nullptr);
0020 
0021     /** @brief Manage the interlaced filter
0022        @param enabled whether to enable this filter
0023        @param interlaced whether we keep interlaced profiles or not
0024     */
0025     void setFilterInterlaced(bool enabled, bool interlaced);
0026 
0027     /** @brief Manage the fps filter
0028        @param enabled whether to enable this filter
0029        @param fps value of the fps of the profiles to keep
0030     */
0031     void setFilterFps(bool enabled, double fps);
0032 
0033     /** @brief Returns true if the ModelIndex in the source model is visible after filtering
0034      */
0035     bool isVisible(const QModelIndex &sourceIndex);
0036 
0037 protected:
0038     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
0039 
0040 private:
0041     bool filterInterlaced(std::unique_ptr<ProfileModel> &ptr) const;
0042     bool filterFps(std::unique_ptr<ProfileModel> &ptr) const;
0043 
0044     bool m_interlaced_enabled;
0045     bool m_interlaced_value;
0046 
0047     bool m_fps_enabled;
0048     double m_fps_value;
0049 };