diff --git a/README.md b/README.md index acdace6..093f11e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -_**This is a not ready for use, toy project**_ +_**This is a not ready to use, toy project**_ ## Note diff --git a/playlistmodel.cpp b/playlistmodel.cpp index a7b7c27..8540813 100644 --- a/playlistmodel.cpp +++ b/playlistmodel.cpp @@ -48,7 +48,6 @@ ** ****************************************************************************/ - #include "playlistmodel.h" #include @@ -110,28 +109,28 @@ QVariant PlaylistModel::data(const QModelIndex &index, int role) const QMediaPlaylist *PlaylistModel::playlist() const { - return m_playlist.data(); + return m_playlist; } void PlaylistModel::setPlaylist(QMediaPlaylist *playlist) { if (m_playlist) { - disconnect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems); - disconnect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems); - disconnect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems); - disconnect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems); - disconnect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems); + disconnect(m_playlist, &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems); + disconnect(m_playlist, &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems); + disconnect(m_playlist, &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems); + disconnect(m_playlist, &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems); + disconnect(m_playlist, &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems); } beginResetModel(); - m_playlist.reset(playlist); + m_playlist = playlist; if (m_playlist) { - connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems); - connect(m_playlist.data(), &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems); - connect(m_playlist.data(), &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems); - connect(m_playlist.data(), &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems); - connect(m_playlist.data(), &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems); + connect(m_playlist, &QMediaPlaylist::mediaAboutToBeInserted, this, &PlaylistModel::beginInsertItems); + connect(m_playlist, &QMediaPlaylist::mediaInserted, this, &PlaylistModel::endInsertItems); + connect(m_playlist, &QMediaPlaylist::mediaAboutToBeRemoved, this, &PlaylistModel::beginRemoveItems); + connect(m_playlist, &QMediaPlaylist::mediaRemoved, this, &PlaylistModel::endRemoveItems); + connect(m_playlist, &QMediaPlaylist::mediaChanged, this, &PlaylistModel::changeItems); } endResetModel(); diff --git a/playlistmodel.h b/playlistmodel.h index 1ce4df3..7957a95 100644 --- a/playlistmodel.h +++ b/playlistmodel.h @@ -48,12 +48,10 @@ ** ****************************************************************************/ - #ifndef PLAYLISTMODEL_H #define PLAYLISTMODEL_H #include -#include class QMediaPlaylist; @@ -69,7 +67,7 @@ public: }; explicit PlaylistModel(QObject *parent = nullptr); - ~PlaylistModel(); + ~PlaylistModel() override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; @@ -92,7 +90,7 @@ private slots: void changeItems(int start, int end); private: - QScopedPointer m_playlist; + QMediaPlaylist * m_playlist = nullptr; QMap m_data; };