Support more collections

This commit is contained in:
Jonas Kvinge
2025-03-08 22:24:28 +01:00
parent 5ae0320911
commit bdbe66b116
28 changed files with 327 additions and 341 deletions

View File

@@ -1,84 +0,0 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-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 "streamplaylistitem.h"
#include "streamingservice.h"
#include "core/sqlrow.h"
StreamPlaylistItem::StreamPlaylistItem(const Song::Source source)
: PlaylistItem(source),
source_(source) {}
StreamPlaylistItem::StreamPlaylistItem(const Song &metadata)
: PlaylistItem(metadata.source()),
source_(metadata.source()),
metadata_(metadata) {
InitMetadata();
}
StreamPlaylistItem::StreamPlaylistItem(StreamingServicePtr service, const Song &metadata)
: PlaylistItem(metadata.source()),
source_(service->source()),
metadata_(metadata) {
InitMetadata();
}
bool StreamPlaylistItem::InitFromQuery(const SqlRow &query) {
metadata_.InitFromQuery(query, false, static_cast<int>(Song::kRowIdColumns.count()));
InitMetadata();
return true;
}
QVariant StreamPlaylistItem::DatabaseValue(DatabaseColumn column) const {
return PlaylistItem::DatabaseValue(column);
}
void StreamPlaylistItem::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 StreamPlaylistItem::Metadata() const {
if (HasTemporaryMetadata()) return temp_metadata_;
return metadata_;
}
QUrl StreamPlaylistItem::Url() const { return metadata_.url(); }
void StreamPlaylistItem::SetArtManual(const QUrl &cover_url) {
metadata_.set_art_manual(cover_url);
temp_metadata_.set_art_manual(cover_url);
}

View File

@@ -1,66 +0,0 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-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 STREAMPLAYLISTITEM_H
#define STREAMPLAYLISTITEM_H
#include "config.h"
#include <QVariant>
#include <QUrl>
#include "includes/shared_ptr.h"
#include "core/song.h"
#include "core/sqlrow.h"
#include "playlist/playlistitem.h"
class StreamingService;
class StreamPlaylistItem : public PlaylistItem {
public:
explicit StreamPlaylistItem(const Song::Source source);
explicit StreamPlaylistItem(const Song &metadata);
explicit StreamPlaylistItem(SharedPtr<StreamingService> service, 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(StreamPlaylistItem)
};
#endif // STREAMPLAYLISTITEM_H

View File

@@ -0,0 +1,27 @@
/*
* Strawberry Music Player
* Copyright 2018-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 "streamserviceplaylistitem.h"
#include "streamingservice.h"
StreamServicePlaylistItem::StreamServicePlaylistItem(const Song &song)
: StreamPlaylistItem(song) {}
StreamServicePlaylistItem::StreamServicePlaylistItem(const StreamingServicePtr service, const Song &song)
: StreamPlaylistItem(song), service_(service) {}

View File

@@ -0,0 +1,38 @@
/*
* Strawberry Music Player
* Copyright 2018-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 STREAMSERVICEPLAYLISTITEM_H
#define STREAMSERVICEPLAYLISTITEM_H
#include "includes/shared_ptr.h"
#include "core/song.h"
#include "playlist/streamplaylistitem.h"
class StreamingService;
class StreamServicePlaylistItem : public StreamPlaylistItem {
public:
explicit StreamServicePlaylistItem(const Song &song);
explicit StreamServicePlaylistItem(const SharedPtr<StreamingService> service, const Song &song);
Q_DISABLE_COPY(StreamServicePlaylistItem)
private:
SharedPtr<StreamingService> service_;
};
#endif // STREAMPLAYLISTITEM_H

View File

@@ -2,7 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2011, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
* Copyright 2018-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
@@ -22,6 +22,6 @@
#include "includes/shared_ptr.h"
#include "streamsongmimedata.h"
StreamSongMimeData::StreamSongMimeData(SharedPtr<StreamingService> _service, QObject *parent) : service(_service) {
StreamSongMimeData::StreamSongMimeData(const SharedPtr<StreamingService> _service, QObject *parent) : service(_service) {
Q_UNUSED(parent);
}

View File

@@ -2,7 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2011, David Sansome <me@davidsansome.com>
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
* Copyright 2018-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
@@ -32,9 +32,9 @@ class StreamSongMimeData : public MimeData {
Q_OBJECT
public:
explicit StreamSongMimeData(SharedPtr<StreamingService> _service, QObject *parent = nullptr);
explicit StreamSongMimeData(const SharedPtr<StreamingService> _service, QObject *parent = nullptr);
SharedPtr<StreamingService> service;
const SharedPtr<StreamingService> service;
SongList songs;
};