File indexing completed on 2024-05-19 05:38:37
0001 0002 /* 0003 SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <QSortFilterProxyModel> 0011 0012 #include <qqmlregistration.h> 0013 0014 #include "kmpris_export.h" 0015 0016 class Multiplexer; 0017 class PlayerContainer; 0018 0019 /** 0020 * A model to list the only player from the multiplexer 0021 * 0022 * @note Can't use QSortFilterProxyModel since QConcatenateTablesProxyModel gets confused when two items are from the same source index, 0023 * and the frontend can switch to a different player seamlessly by using dataChanged. 0024 */ 0025 class KMPRIS_EXPORT MultiplexerModel : public QAbstractListModel 0026 { 0027 Q_OBJECT 0028 QML_ELEMENT 0029 0030 public: 0031 static std::shared_ptr<MultiplexerModel> self(); 0032 explicit MultiplexerModel(QObject *parent = nullptr); 0033 ~MultiplexerModel() override; 0034 0035 /** 0036 * To override the desktop icon 0037 */ 0038 QVariant data(const QModelIndex &index, int role) const override; 0039 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0040 QHash<int, QByteArray> roleNames() const override; 0041 0042 private Q_SLOTS: 0043 void updateActivePlayer(); 0044 0045 private: 0046 std::shared_ptr<Multiplexer> m_multiplexer; 0047 PlayerContainer *m_activePlayer = nullptr; 0048 };