Add PlaylistItem::NewFromSong function
This commit is contained in:
@@ -38,8 +38,15 @@
|
|||||||
InternetPlaylistItem::InternetPlaylistItem(const Song::Source source)
|
InternetPlaylistItem::InternetPlaylistItem(const Song::Source source)
|
||||||
: PlaylistItem(source) {}
|
: PlaylistItem(source) {}
|
||||||
|
|
||||||
|
InternetPlaylistItem::InternetPlaylistItem(const Song &metadata)
|
||||||
|
: PlaylistItem(metadata.source()),
|
||||||
|
source_(metadata.source()),
|
||||||
|
metadata_(metadata) {
|
||||||
|
InitMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
InternetPlaylistItem::InternetPlaylistItem(InternetService *service, const Song &metadata)
|
InternetPlaylistItem::InternetPlaylistItem(InternetService *service, const Song &metadata)
|
||||||
: PlaylistItem(Song::Source_Stream),
|
: PlaylistItem(metadata.source()),
|
||||||
source_(service->source()),
|
source_(service->source()),
|
||||||
metadata_(metadata) {
|
metadata_(metadata) {
|
||||||
InitMetadata();
|
InitMetadata();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class InternetPlaylistItem : public PlaylistItem {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InternetPlaylistItem(const Song::Source source);
|
explicit InternetPlaylistItem(const Song::Source source);
|
||||||
|
explicit InternetPlaylistItem(const Song &metadata);
|
||||||
explicit InternetPlaylistItem(InternetService *service, const Song &metadata);
|
explicit InternetPlaylistItem(InternetService *service, const Song &metadata);
|
||||||
|
|
||||||
bool InitFromQuery(const SqlRow &query) override;
|
bool InitFromQuery(const SqlRow &query) override;
|
||||||
|
|||||||
@@ -38,9 +38,7 @@
|
|||||||
|
|
||||||
#include "internet/internetplaylistitem.h"
|
#include "internet/internetplaylistitem.h"
|
||||||
|
|
||||||
PlaylistItem::~PlaylistItem() {}
|
PlaylistItem *PlaylistItem::NewFromSource(const Song::Source source) {
|
||||||
|
|
||||||
PlaylistItem *PlaylistItem::NewFromSource(const Song::Source &source) {
|
|
||||||
|
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case Song::Source_Collection:
|
case Song::Source_Collection:
|
||||||
@@ -61,6 +59,29 @@ PlaylistItem *PlaylistItem::NewFromSource(const Song::Source &source) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlaylistItem *PlaylistItem::NewFromSong(const Song &song) {
|
||||||
|
|
||||||
|
switch (song.source()) {
|
||||||
|
case Song::Source_Collection:
|
||||||
|
return new CollectionPlaylistItem(song);
|
||||||
|
case Song::Source_Subsonic:
|
||||||
|
case Song::Source_Tidal:
|
||||||
|
case Song::Source_Qobuz:
|
||||||
|
case Song::Source_Stream:
|
||||||
|
return new InternetPlaylistItem(song);
|
||||||
|
case Song::Source_LocalFile:
|
||||||
|
case Song::Source_CDDA:
|
||||||
|
case Song::Source_Device:
|
||||||
|
case Song::Source_Unknown:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SongPlaylistItem(song);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistItem::~PlaylistItem() {}
|
||||||
|
|
||||||
void PlaylistItem::BindToQuery(QSqlQuery *query) const {
|
void PlaylistItem::BindToQuery(QSqlQuery *query) const {
|
||||||
|
|
||||||
query->bindValue(":type", source_);
|
query->bindValue(":type", source_);
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
|||||||
explicit PlaylistItem(const Song::Source &source) : should_skip_(false), source_(source) {}
|
explicit PlaylistItem(const Song::Source &source) : should_skip_(false), source_(source) {}
|
||||||
virtual ~PlaylistItem();
|
virtual ~PlaylistItem();
|
||||||
|
|
||||||
static PlaylistItem *NewFromSource(const Song::Source &source);
|
static PlaylistItem *NewFromSource(const Song::Source source);
|
||||||
|
static PlaylistItem *NewFromSong(const Song &song);
|
||||||
|
|
||||||
enum Option {
|
enum Option {
|
||||||
Default = 0x00,
|
Default = 0x00,
|
||||||
|
|||||||
Reference in New Issue
Block a user