File indexing completed on 2024-04-28 04:49:03

0001 /*
0002    SPDX-FileCopyrightText: 2020 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
0003 
0004    SPDX-License-Identifier: LGPL-3.0-or-later
0005  */
0006 
0007 #ifndef VIEWSPROXYMODEL_H
0008 #define VIEWSPROXYMODEL_H
0009 
0010 #include "elisaLib_export.h"
0011 
0012 #include "elisautils.h"
0013 
0014 #include <QSortFilterProxyModel>
0015 
0016 #include <memory>
0017 
0018 class ViewsProxyModelPrivate;
0019 
0020 class ELISALIB_EXPORT ViewsProxyModel : public QSortFilterProxyModel
0021 {
0022     Q_OBJECT
0023 
0024     Q_PROPERTY(ElisaUtils::PlayListEntryType embeddedCategory
0025                READ embeddedCategory
0026                WRITE setEmbeddedCategory
0027                NOTIFY embeddedCategoryChanged)
0028 
0029 public:
0030     explicit ViewsProxyModel(QObject *parent = nullptr);
0031 
0032     ~ViewsProxyModel() override;
0033 
0034     [[nodiscard]] ElisaUtils::PlayListEntryType embeddedCategory() const;
0035 
0036     Q_INVOKABLE int mapRowToSource(int row) const;
0037 
0038     Q_INVOKABLE int mapRowFromSource(int row) const;
0039 
0040 Q_SIGNALS:
0041     void embeddedCategoryChanged();
0042 
0043 public Q_SLOTS:
0044     void setEmbeddedCategory(const ElisaUtils::PlayListEntryType category);
0045 
0046 protected:
0047 
0048     [[nodiscard]] bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
0049 
0050     [[nodiscard]] bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
0051 
0052 private:
0053     std::unique_ptr<ViewsProxyModelPrivate> d;
0054 };
0055 
0056 #endif // VIEWSPROXYMODEL_H