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:
parent
247cc8f715
commit
f563b7da40
|
@ -221,6 +221,7 @@ set(SOURCES
|
||||||
networkremote/songsender.cpp
|
networkremote/songsender.cpp
|
||||||
networkremote/zeroconf.cpp
|
networkremote/zeroconf.cpp
|
||||||
|
|
||||||
|
playlist/dbplaylistitem.cpp
|
||||||
playlist/dynamicplaylistcontrols.cpp
|
playlist/dynamicplaylistcontrols.cpp
|
||||||
playlist/playlist.cpp
|
playlist/playlist.cpp
|
||||||
playlist/playlistbackend.cpp
|
playlist/playlistbackend.cpp
|
||||||
|
@ -521,6 +522,7 @@ set(HEADERS
|
||||||
networkremote/remoteclient.h
|
networkremote/remoteclient.h
|
||||||
networkremote/songsender.h
|
networkremote/songsender.h
|
||||||
|
|
||||||
|
playlist/dbplaylistitem.h
|
||||||
playlist/dynamicplaylistcontrols.h
|
playlist/dynamicplaylistcontrols.h
|
||||||
playlist/playlist.h
|
playlist/playlist.h
|
||||||
playlist/playlistbackend.h
|
playlist/playlistbackend.h
|
||||||
|
|
|
@ -21,12 +21,10 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
LibraryPlaylistItem::LibraryPlaylistItem(const QString& type)
|
LibraryPlaylistItem::LibraryPlaylistItem(const QString& type)
|
||||||
: PlaylistItem(type) {}
|
: DbPlaylistItem(type) {}
|
||||||
|
|
||||||
LibraryPlaylistItem::LibraryPlaylistItem(const Song& song)
|
LibraryPlaylistItem::LibraryPlaylistItem(const Song& song)
|
||||||
: PlaylistItem("Library"), song_(song) {}
|
: DbPlaylistItem("Library", song) {}
|
||||||
|
|
||||||
QUrl LibraryPlaylistItem::Url() const { return song_.url(); }
|
|
||||||
|
|
||||||
void LibraryPlaylistItem::Reload() {
|
void LibraryPlaylistItem::Reload() {
|
||||||
TagReaderClient::Instance()->ReadFileBlocking(song_.url().toLocalFile(),
|
TagReaderClient::Instance()->ReadFileBlocking(song_.url().toLocalFile(),
|
||||||
|
@ -39,17 +37,3 @@ bool LibraryPlaylistItem::InitFromQuery(const SqlRow& query) {
|
||||||
|
|
||||||
return song_.is_valid();
|
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_;
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
#define LIBRARYPLAYLISTITEM_H
|
#define LIBRARYPLAYLISTITEM_H
|
||||||
|
|
||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
#include "playlist/playlistitem.h"
|
#include "playlist/dbplaylistitem.h"
|
||||||
|
|
||||||
class LibraryPlaylistItem : public PlaylistItem {
|
class LibraryPlaylistItem : public DbPlaylistItem {
|
||||||
public:
|
public:
|
||||||
LibraryPlaylistItem(const QString& type);
|
LibraryPlaylistItem(const QString& type);
|
||||||
LibraryPlaylistItem(const Song& song);
|
LibraryPlaylistItem(const Song& song);
|
||||||
|
@ -29,18 +29,7 @@ class LibraryPlaylistItem : public PlaylistItem {
|
||||||
bool InitFromQuery(const SqlRow& query);
|
bool InitFromQuery(const SqlRow& query);
|
||||||
void Reload();
|
void Reload();
|
||||||
|
|
||||||
Song Metadata() const;
|
|
||||||
void SetMetadata(const Song& song) { song_ = song; }
|
|
||||||
|
|
||||||
QUrl Url() const;
|
|
||||||
|
|
||||||
bool IsLocalLibraryItem() const { return true; }
|
bool IsLocalLibraryItem() const { return true; }
|
||||||
|
|
||||||
protected:
|
|
||||||
QVariant DatabaseValue(DatabaseColumn column) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Song song_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LIBRARYPLAYLISTITEM_H
|
#endif // LIBRARYPLAYLISTITEM_H
|
||||||
|
|
|
@ -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_;
|
||||||
|
}
|
|
@ -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
|
Loading…
Reference in New Issue