Commit 86fe8b41 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Media: Rename setTitle

parent 65be97cf
...@@ -459,7 +459,7 @@ const std::string &Media::title() const ...@@ -459,7 +459,7 @@ const std::string &Media::title() const
return m_title; return m_title;
} }
void Media::setTitle( const std::string &title ) void Media::setTitleBuffered( const std::string &title )
{ {
if ( m_title == title ) if ( m_title == title )
return; return;
......
...@@ -91,7 +91,12 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable> ...@@ -91,7 +91,12 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
virtual SubType subType() const override; virtual SubType subType() const override;
void setType( Type type ); void setType( Type type );
virtual const std::string& title() const override; virtual const std::string& title() const override;
void setTitle( const std::string& title ); ///
/// \brief setTitleBuffered Mark the media as changed but doesn't save the change in DB
/// Querying the title after this method will return the new title, but it won't appear in DB
/// until save() is called
///
void setTitleBuffered( const std::string& title );
virtual AlbumTrackPtr albumTrack() const override; virtual AlbumTrackPtr albumTrack() const override;
void setAlbumTrack( AlbumTrackPtr albumTrack ); void setAlbumTrack( AlbumTrackPtr albumTrack );
virtual int64_t duration() const override; virtual int64_t duration() const override;
......
...@@ -396,7 +396,7 @@ std::shared_ptr<AlbumTrack> MetadataParser::handleTrack( std::shared_ptr<Album> ...@@ -396,7 +396,7 @@ std::shared_ptr<AlbumTrack> MetadataParser::handleTrack( std::shared_ptr<Album>
} }
} }
if ( title.empty() == false ) if ( title.empty() == false )
task.media->setTitle( title ); task.media->setTitleBuffered( title );
auto track = std::static_pointer_cast<AlbumTrack>( album->addTrack( task.media, trackNumber, auto track = std::static_pointer_cast<AlbumTrack>( album->addTrack( task.media, trackNumber,
discNumber, artist->id(), discNumber, artist->id(),
......
...@@ -178,7 +178,7 @@ TEST_F( Medias, SearchAfterEdit ) ...@@ -178,7 +178,7 @@ TEST_F( Medias, SearchAfterEdit )
auto media = ml->searchMedia( "media" ).others; auto media = ml->searchMedia( "media" ).others;
ASSERT_EQ( 1u, media.size() ); ASSERT_EQ( 1u, media.size() );
m->setTitle( "otters are awesome" ); m->setTitleBuffered( "otters are awesome" );
m->save(); m->save();
media = ml->searchMedia( "media" ).others; media = ml->searchMedia( "media" ).others;
...@@ -347,17 +347,17 @@ TEST_F( Medias, SetReleaseDate ) ...@@ -347,17 +347,17 @@ TEST_F( Medias, SetReleaseDate )
TEST_F( Medias, SortByAlpha ) TEST_F( Medias, SortByAlpha )
{ {
auto m1 = std::static_pointer_cast<Media>( ml->addMedia( "media1.mp3" ) ); auto m1 = std::static_pointer_cast<Media>( ml->addMedia( "media1.mp3" ) );
m1->setTitle( "Abcd" ); m1->setTitleBuffered( "Abcd" );
m1->setType( Media::Type::Audio ); m1->setType( Media::Type::Audio );
m1->save(); m1->save();
auto m2 = std::static_pointer_cast<Media>( ml->addMedia( "media2.mp3" ) ); auto m2 = std::static_pointer_cast<Media>( ml->addMedia( "media2.mp3" ) );
m2->setTitle( "Zyxw" ); m2->setTitleBuffered( "Zyxw" );
m2->setType( Media::Type::Audio ); m2->setType( Media::Type::Audio );
m2->save(); m2->save();
auto m3 = std::static_pointer_cast<Media>( ml->addMedia( "media3.mp3" ) ); auto m3 = std::static_pointer_cast<Media>( ml->addMedia( "media3.mp3" ) );
m3->setTitle( "afterA-beforeZ" ); m3->setTitleBuffered( "afterA-beforeZ" );
m3->setType( Media::Type::Audio ); m3->setType( Media::Type::Audio );
m3->save(); m3->save();
......
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