File indexing completed on 2025-01-05 04:29:53
0001 /** 0002 * SPDX-FileCopyrightText: 2021-2023 Bart De Vries <bart@mogwai.be> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QItemSelection> 0010 #include <QModelIndex> 0011 #include <QObject> 0012 #include <QQmlEngine> 0013 #include <QString> 0014 #include <QVariant> 0015 0016 #include "models/abstractepisodemodel.h" 0017 #include "models/abstractepisodeproxymodel.h" 0018 0019 class QueueModel : public AbstractEpisodeModel 0020 { 0021 Q_OBJECT 0022 QML_ELEMENT 0023 0024 public: 0025 Q_PROPERTY(int timeLeft READ timeLeft NOTIFY timeLeftChanged) 0026 Q_PROPERTY(QString formattedTimeLeft READ formattedTimeLeft NOTIFY timeLeftChanged) 0027 0028 static QueueModel &instance() 0029 { 0030 static QueueModel _instance; 0031 return _instance; 0032 } 0033 explicit QueueModel(QObject *parent = nullptr); 0034 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0035 int rowCount(const QModelIndex &parent) const override; 0036 0037 int timeLeft() const; 0038 QString formattedTimeLeft() const; 0039 0040 Q_INVOKABLE static QString getSortName(AbstractEpisodeProxyModel::SortType type); 0041 Q_INVOKABLE static QString getSortIconName(AbstractEpisodeProxyModel::SortType type); 0042 0043 Q_INVOKABLE QItemSelection createSelection(int rowa, int rowb); 0044 0045 public Q_SLOTS: 0046 void updateInternalState() override; 0047 0048 Q_SIGNALS: 0049 void timeLeftChanged(); 0050 };