Support more collections
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QVariant>
|
||||
#include <QUrl>
|
||||
|
||||
#include "radioplaylistitem.h"
|
||||
#include "core/sqlrow.h"
|
||||
|
||||
RadioPlaylistItem::RadioPlaylistItem(const Song::Source source)
|
||||
: PlaylistItem(source), source_(source) {}
|
||||
|
||||
RadioPlaylistItem::RadioPlaylistItem(const Song &metadata)
|
||||
: PlaylistItem(metadata.source()),
|
||||
source_(metadata.source()),
|
||||
metadata_(metadata) {
|
||||
InitMetadata();
|
||||
}
|
||||
|
||||
bool RadioPlaylistItem::InitFromQuery(const SqlRow &query) {
|
||||
|
||||
metadata_.InitFromQuery(query, false, static_cast<int>(Song::kRowIdColumns.count()));
|
||||
InitMetadata();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
QVariant RadioPlaylistItem::DatabaseValue(DatabaseColumn column) const {
|
||||
return PlaylistItem::DatabaseValue(column);
|
||||
}
|
||||
|
||||
void RadioPlaylistItem::InitMetadata() {
|
||||
|
||||
if (metadata_.title().isEmpty()) metadata_.set_title(metadata_.url().toString());
|
||||
if (metadata_.source() == Song::Source::Unknown) metadata_.set_source(Song::Source::Stream);
|
||||
if (metadata_.filetype() == Song::FileType::Unknown) metadata_.set_filetype(Song::FileType::Stream);
|
||||
metadata_.set_valid(true);
|
||||
|
||||
}
|
||||
|
||||
Song RadioPlaylistItem::Metadata() const {
|
||||
|
||||
if (HasTemporaryMetadata()) return temp_metadata_;
|
||||
return metadata_;
|
||||
|
||||
}
|
||||
|
||||
QUrl RadioPlaylistItem::Url() const { return metadata_.url(); }
|
||||
|
||||
void RadioPlaylistItem::SetArtManual(const QUrl &cover_url) {
|
||||
|
||||
metadata_.set_art_manual(cover_url);
|
||||
temp_metadata_.set_art_manual(cover_url);
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2021, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef RADIOPLAYLISTITEM_H
|
||||
#define RADIOPLAYLISTITEM_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QVariant>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/song.h"
|
||||
#include "core/sqlrow.h"
|
||||
#include "playlist/playlistitem.h"
|
||||
|
||||
class RadioService;
|
||||
|
||||
class RadioPlaylistItem : public PlaylistItem {
|
||||
|
||||
public:
|
||||
explicit RadioPlaylistItem(const Song::Source source);
|
||||
explicit RadioPlaylistItem(const Song &metadata);
|
||||
|
||||
bool InitFromQuery(const SqlRow &query) override;
|
||||
Song Metadata() const override;
|
||||
Song OriginalMetadata() const override { return metadata_; }
|
||||
QUrl Url() const override;
|
||||
|
||||
void SetMetadata(const Song &metadata) override { metadata_ = metadata; }
|
||||
void SetArtManual(const QUrl &cover_url) override;
|
||||
|
||||
protected:
|
||||
QVariant DatabaseValue(DatabaseColumn) const override;
|
||||
Song DatabaseSongMetadata() const override { return metadata_; }
|
||||
|
||||
private:
|
||||
void InitMetadata();
|
||||
|
||||
private:
|
||||
Song::Source source_;
|
||||
Song metadata_;
|
||||
|
||||
Q_DISABLE_COPY(RadioPlaylistItem)
|
||||
};
|
||||
|
||||
#endif // RADIOPLAYLISTITEM_H
|
||||
26
src/radios/radiostreamplaylistitem.cpp
Normal file
26
src/radios/radiostreamplaylistitem.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2021-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "radiostreamplaylistitem.h"
|
||||
|
||||
RadioStreamPlaylistItem::RadioStreamPlaylistItem(const Song &song)
|
||||
: StreamPlaylistItem(song) {}
|
||||
|
||||
RadioStreamPlaylistItem::RadioStreamPlaylistItem(const SharedPtr<RadioService> service, const Song &song)
|
||||
: StreamPlaylistItem(song), service_(service) {}
|
||||
39
src/radios/radiostreamplaylistitem.h
Normal file
39
src/radios/radiostreamplaylistitem.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2021-2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef RADIOSTREAMPLAYLISTITEM_H
|
||||
#define RADIOSTREAMPLAYLISTITEM_H
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "playlist/streamplaylistitem.h"
|
||||
|
||||
class RadioService;
|
||||
|
||||
class RadioStreamPlaylistItem : public StreamPlaylistItem {
|
||||
public:
|
||||
explicit RadioStreamPlaylistItem(const Song &song);
|
||||
explicit RadioStreamPlaylistItem(const SharedPtr<RadioService> service, const Song &song);
|
||||
Q_DISABLE_COPY(RadioStreamPlaylistItem)
|
||||
|
||||
private:
|
||||
const SharedPtr<RadioService> service_;
|
||||
};
|
||||
|
||||
#endif // RADIOSTREAMPLAYLISTITEM_H
|
||||
Reference in New Issue
Block a user