File indexing completed on 2024-05-19 05:38:36
0001 0002 0003 /* 0004 SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com> 0005 0006 SPDX-License-Identifier: LGPL-2.1-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include <unordered_set> 0012 0013 #include <QSortFilterProxyModel> 0014 0015 #include "kmpris_export.h" 0016 0017 class Mpris2SourceModel; 0018 0019 /** 0020 * A model that filters out duplicate players from Plasma Browser Integration 0021 */ 0022 class KMPRIS_NO_EXPORT Mpris2FilterProxyModel : public QSortFilterProxyModel 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 static std::shared_ptr<Mpris2FilterProxyModel> self(); 0028 ~Mpris2FilterProxyModel() override; 0029 0030 protected: 0031 bool filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const override; 0032 0033 private Q_SLOTS: 0034 void onRowsInserted(const QModelIndex &parent, int first, int last); 0035 void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last); 0036 void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int> &roles); 0037 0038 private: 0039 explicit Mpris2FilterProxyModel(QObject *parent = nullptr); 0040 0041 std::shared_ptr<Mpris2SourceModel> m_sourceModel; 0042 std::unordered_set<unsigned> m_proxyPidList; 0043 };