2022-10-05 14:02:46 +08:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2020-04-07 19:09:08 +08:00
|
|
|
|
|
|
|
#ifndef PLAYLISTMODEL_H
|
|
|
|
#define PLAYLISTMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
2022-10-05 14:02:46 +08:00
|
|
|
#include <QScopedPointer>
|
2020-04-07 19:09:08 +08:00
|
|
|
|
2022-10-05 14:02:46 +08:00
|
|
|
QT_BEGIN_NAMESPACE
|
2020-04-07 19:09:08 +08:00
|
|
|
class QMediaPlaylist;
|
2022-10-05 14:02:46 +08:00
|
|
|
QT_END_NAMESPACE
|
2020-04-07 19:09:08 +08:00
|
|
|
|
|
|
|
class PlaylistModel : public QAbstractItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Column
|
|
|
|
{
|
|
|
|
Title = 0,
|
|
|
|
ColumnCount
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit PlaylistModel(QObject *parent = nullptr);
|
2022-10-05 14:02:46 +08:00
|
|
|
~PlaylistModel();
|
2020-04-07 19:09:08 +08:00
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QModelIndex parent(const QModelIndex &child) const override;
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
|
|
|
|
QMediaPlaylist *playlist() const;
|
|
|
|
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void beginInsertItems(int start, int end);
|
|
|
|
void endInsertItems();
|
|
|
|
void beginRemoveItems(int start, int end);
|
|
|
|
void endRemoveItems();
|
|
|
|
void changeItems(int start, int end);
|
|
|
|
|
|
|
|
private:
|
2022-10-05 14:02:46 +08:00
|
|
|
QScopedPointer<QMediaPlaylist> m_playlist;
|
2020-04-07 19:09:08 +08:00
|
|
|
QMap<QModelIndex, QVariant> m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLAYLISTMODEL_H
|