2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-04-27 00:06:58 +02:00
|
|
|
#include "playlistbackend.h"
|
2009-12-24 20:16:07 +01:00
|
|
|
#include "songplaylistitem.h"
|
|
|
|
|
2010-08-03 20:57:17 +02:00
|
|
|
#include "library/sqlrow.h"
|
|
|
|
|
2009-12-24 20:16:07 +01:00
|
|
|
#include <QtDebug>
|
2010-03-10 22:39:25 +01:00
|
|
|
#include <QFile>
|
2009-12-24 20:16:07 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
2010-04-14 23:03:00 +02:00
|
|
|
SongPlaylistItem::SongPlaylistItem(const QString& type)
|
|
|
|
: PlaylistItem(type)
|
2009-12-24 20:16:07 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SongPlaylistItem::SongPlaylistItem(const Song& song)
|
2011-03-20 13:43:10 +01:00
|
|
|
: PlaylistItem(song.is_stream() ? "Stream" : "File"),
|
2010-04-14 23:03:00 +02:00
|
|
|
song_(song)
|
2009-12-24 20:16:07 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-03 20:57:17 +02:00
|
|
|
bool SongPlaylistItem::InitFromQuery(const SqlRow& query) {
|
2011-06-17 22:00:10 +02:00
|
|
|
song_.InitFromQuery(query, false, (Song::kColumns.count() + 1) * 3);
|
2010-03-10 22:39:25 +01:00
|
|
|
|
2010-04-14 23:03:00 +02:00
|
|
|
if (type() == "Stream") {
|
|
|
|
song_.set_filetype(Song::Type_Stream);
|
2010-03-10 22:39:25 +01:00
|
|
|
} else {
|
2011-04-27 00:06:58 +02:00
|
|
|
song_.set_directory_id(-1);
|
2010-03-10 22:39:25 +01:00
|
|
|
}
|
2011-01-19 16:36:40 +01:00
|
|
|
|
2010-04-27 19:37:26 +02:00
|
|
|
return true;
|
2010-03-10 22:39:25 +01:00
|
|
|
}
|
|
|
|
|
2010-03-24 21:58:17 +01:00
|
|
|
QUrl SongPlaylistItem::Url() const {
|
2011-03-10 19:01:35 +01:00
|
|
|
return song_.url();
|
2009-12-24 20:16:07 +01:00
|
|
|
}
|
2010-01-16 17:12:47 +01:00
|
|
|
|
|
|
|
void SongPlaylistItem::Reload() {
|
2011-06-10 01:08:43 +02:00
|
|
|
if (song_.url().scheme() != "file")
|
|
|
|
return;
|
2011-04-28 14:27:53 +02:00
|
|
|
QString old_filename = song_.url().toLocalFile();
|
2011-03-10 19:01:35 +01:00
|
|
|
int old_directory_id = song_.directory_id();
|
|
|
|
|
|
|
|
song_ = Song();
|
|
|
|
song_.InitFromFile(old_filename, old_directory_id);
|
2010-01-16 17:12:47 +01:00
|
|
|
}
|
2010-07-10 21:40:16 +02:00
|
|
|
|
|
|
|
Song SongPlaylistItem::Metadata() const {
|
2010-07-10 21:45:29 +02:00
|
|
|
if (HasTemporaryMetadata())
|
2010-07-10 21:40:16 +02:00
|
|
|
return temp_metadata_;
|
|
|
|
return song_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|