strawberry-audio-player-win.../src/internet/internetplaylistitem.cpp

84 lines
2.4 KiB
C++
Raw Normal View History

2018-08-09 18:10:03 +02:00
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
2018-09-08 12:38:02 +02:00
* Copyright 2018, Jonas Kvinge <jonas@jkvinge.net>
2018-08-09 18:10:03 +02:00
*
* 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 <QSettings>
#include <QVariant>
#include <QString>
2020-02-09 02:29:35 +01:00
#include <QStringList>
2018-08-09 18:10:03 +02:00
#include <QtDebug>
#include "internetplaylistitem.h"
#include "internetservices.h"
2018-08-09 18:10:03 +02:00
#include "internetservice.h"
#include "core/settingsprovider.h"
#include "collection/sqlrow.h"
#include "playlist/playlistbackend.h"
2020-06-14 18:58:24 +02:00
InternetPlaylistItem::InternetPlaylistItem(const Song::Source source)
2018-09-08 12:38:02 +02:00
: PlaylistItem(source) {}
2018-08-09 18:10:03 +02:00
InternetPlaylistItem::InternetPlaylistItem(InternetService *service, const Song &metadata)
2018-09-08 12:38:02 +02:00
: PlaylistItem(Song::Source_Stream),
source_(service->source()),
2018-08-09 18:10:03 +02:00
metadata_(metadata) {
InitMetadata();
}
bool InternetPlaylistItem::InitFromQuery(const SqlRow &query) {
2018-08-09 18:10:03 +02:00
metadata_.InitFromQuery(query, false, (Song::kColumns.count() + 1) * 1);
InitMetadata();
return true;
2018-08-09 18:10:03 +02:00
}
QVariant InternetPlaylistItem::DatabaseValue(DatabaseColumn column) const {
2018-09-08 12:38:02 +02:00
return PlaylistItem::DatabaseValue(column);
2018-08-09 18:10:03 +02:00
}
void InternetPlaylistItem::InitMetadata() {
2018-09-08 12:38:02 +02:00
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);
2018-08-09 18:10:03 +02:00
metadata_.set_valid(true);
2018-08-09 18:10:03 +02:00
}
Song InternetPlaylistItem::Metadata() const {
2018-08-09 18:10:03 +02:00
if (HasTemporaryMetadata()) return temp_metadata_;
return metadata_;
2018-08-09 18:10:03 +02:00
}
QUrl InternetPlaylistItem::Url() const { return metadata_.url(); }
void InternetPlaylistItem::SetArtManual(const QUrl &cover_url) {
metadata_.set_art_manual(cover_url);
temp_metadata_.set_art_manual(cover_url);
}