Commit 641a9d5d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

IPlaylist: Provide a remove( const IMedia& ) overload

parent 917668a6
......@@ -83,6 +83,7 @@ public:
/// \return true on success, false on failure
///
virtual bool remove( int64_t mediaId ) = 0;
virtual bool remove( const IMedia& media ) = 0;
};
}
......@@ -247,8 +247,17 @@ bool Playlist::move( int64_t mediaId, unsigned int position )
bool Playlist::remove( int64_t mediaId )
{
static const std::string req = "DELETE FROM PlaylistMediaRelation WHERE playlist_id = ? AND media_id = ?";
return sqlite::Tools::executeDelete( m_ml->getConn(), req, m_id, mediaId );
const auto media = m_ml->media( mediaId );
if ( media == nullptr )
return false;
return remove( *media );
}
bool Playlist::remove( const IMedia& media )
{
static const std::string req = "DELETE FROM PlaylistMediaRelation WHERE "
"playlist_id = ? AND media_id = ?";
return sqlite::Tools::executeDelete( m_ml->getConn(), req, m_id, media.id() );
}
void Playlist::createTable( sqlite::Connection* dbConn, uint32_t dbModel )
......
......@@ -66,6 +66,7 @@ public:
virtual bool add( const int64_t mediaId, unsigned int position ) override;
virtual bool move( int64_t mediaId, unsigned int position ) override;
virtual bool remove( int64_t mediaId ) override;
virtual bool remove( const IMedia& media ) override;
std::shared_ptr<File> addFile( const fs::IFile& fileFs, int64_t parentFolderId,
bool isFolderFsRemovable );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment