Add DbPlaylistItem base class to LibraryPlaylistItem

This will be used to move items from non-library databases away from the
LibraryPlaylistItem class.
This commit is contained in:
Jim Broadus 2020-06-16 15:23:30 -07:00 committed by John Maguire
parent 247cc8f715
commit f563b7da40
5 changed files with 90 additions and 31 deletions

View File

@ -221,6 +221,7 @@ set(SOURCES
networkremote/songsender.cpp
networkremote/zeroconf.cpp
playlist/dbplaylistitem.cpp
playlist/dynamicplaylistcontrols.cpp
playlist/playlist.cpp
playlist/playlistbackend.cpp
@ -521,6 +522,7 @@ set(HEADERS
networkremote/remoteclient.h
networkremote/songsender.h
playlist/dbplaylistitem.h
playlist/dynamicplaylistcontrols.h
playlist/playlist.h
playlist/playlistbackend.h

View File

@ -21,12 +21,10 @@
#include <QSettings>
LibraryPlaylistItem::LibraryPlaylistItem(const QString& type)
: PlaylistItem(type) {}
: DbPlaylistItem(type) {}
LibraryPlaylistItem::LibraryPlaylistItem(const Song& song)
: PlaylistItem("Library"), song_(song) {}
QUrl LibraryPlaylistItem::Url() const { return song_.url(); }
: DbPlaylistItem("Library", song) {}
void LibraryPlaylistItem::Reload() {
TagReaderClient::Instance()->ReadFileBlocking(song_.url().toLocalFile(),
@ -39,17 +37,3 @@ bool LibraryPlaylistItem::InitFromQuery(const SqlRow& query) {
return song_.is_valid();
}
QVariant LibraryPlaylistItem::DatabaseValue(DatabaseColumn column) const {
switch (column) {
case Column_LibraryId:
return song_.id();
default:
return PlaylistItem::DatabaseValue(column);
}
}
Song LibraryPlaylistItem::Metadata() const {
if (HasTemporaryMetadata()) return temp_metadata_;
return song_;
}

View File

@ -19,9 +19,9 @@
#define LIBRARYPLAYLISTITEM_H
#include "core/song.h"
#include "playlist/playlistitem.h"
#include "playlist/dbplaylistitem.h"
class LibraryPlaylistItem : public PlaylistItem {
class LibraryPlaylistItem : public DbPlaylistItem {
public:
LibraryPlaylistItem(const QString& type);
LibraryPlaylistItem(const Song& song);
@ -29,18 +29,7 @@ class LibraryPlaylistItem : public PlaylistItem {
bool InitFromQuery(const SqlRow& query);
void Reload();
Song Metadata() const;
void SetMetadata(const Song& song) { song_ = song; }
QUrl Url() const;
bool IsLocalLibraryItem() const { return true; }
protected:
QVariant DatabaseValue(DatabaseColumn column) const;
protected:
Song song_;
};
#endif // LIBRARYPLAYLISTITEM_H

View File

@ -0,0 +1,42 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Copyright 2020, Jim Broadus <jbroadus@gmail.com>
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/>.
*/
#include "dbplaylistitem.h"
#include "core/tagreaderclient.h"
DbPlaylistItem::DbPlaylistItem(const QString& type)
: PlaylistItem(type) {}
DbPlaylistItem::DbPlaylistItem(const QString& type, const Song& song)
: PlaylistItem(type), song_(song) {}
QUrl DbPlaylistItem::Url() const { return song_.url(); }
QVariant DbPlaylistItem::DatabaseValue(DatabaseColumn column) const {
switch (column) {
case Column_LibraryId:
return song_.id();
default:
return PlaylistItem::DatabaseValue(column);
}
}
Song DbPlaylistItem::Metadata() const {
if (HasTemporaryMetadata()) return temp_metadata_;
return song_;
}

View File

@ -0,0 +1,42 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Copyright 2020, Jim Broadus <jbroadus@gmail.com>
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/>.
*/
#ifndef DBPLAYLISTITEM_H
#define DBPLAYLISTITEM_H
#include "core/song.h"
#include "playlist/playlistitem.h"
class DbPlaylistItem : public PlaylistItem {
public:
DbPlaylistItem(const QString& type);
DbPlaylistItem(const QString& type, const Song& song);
Song Metadata() const;
void SetMetadata(const Song& song) { song_ = song; }
QUrl Url() const;
protected:
QVariant DatabaseValue(DatabaseColumn column) const;
protected:
Song song_;
};
#endif // DBPLAYLISTITEM_H