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

MediaLibrary: Provide an aggregate search method

parent f2ddf15b
......@@ -33,6 +33,14 @@ namespace medialibrary
{
static constexpr auto UnknownArtistID = 1u;
static constexpr auto VariousArtistID = 2u;
struct SearchAggregate
{
std::vector<AlbumPtr> albums;
std::vector<ArtistPtr> artists;
std::vector<MediaPtr> media;
std::vector<PlaylistPtr> playlists;
};
}
class IMediaLibraryCb
......@@ -120,6 +128,7 @@ class IMediaLibrary
virtual std::vector<AlbumPtr> searchAlbums( const std::string& pattern ) const = 0;
virtual std::vector<GenrePtr> searchGenre( const std::string& genre ) const = 0;
virtual std::vector<ArtistPtr> searchArtists( const std::string& name ) const = 0;
virtual medialibrary::SearchAggregate search( const std::string& pattern ) const = 0;
/**
* @brief discover Launch a discovery on the provided entry point.
......
......@@ -440,6 +440,16 @@ std::vector<ArtistPtr> MediaLibrary::searchArtists(const std::string& name ) con
return Artist::search( m_dbConnection.get(), name );
}
medialibrary::SearchAggregate MediaLibrary::search( const std::string& pattern ) const
{
medialibrary::SearchAggregate res;
res.albums = searchAlbums( pattern );
res.artists = searchArtists( pattern );
res.media = searchMedia( pattern );
res.playlists = searchPlaylists( pattern );
return res;
}
void MediaLibrary::startParser()
{
m_parser.reset( new Parser( m_dbConnection.get(), this, m_callback ) );
......
......@@ -94,6 +94,7 @@ class MediaLibrary : public IMediaLibrary
virtual std::vector<AlbumPtr> searchAlbums( const std::string& pattern ) const override;
virtual std::vector<GenrePtr> searchGenre( const std::string& genre ) const override;
virtual std::vector<ArtistPtr> searchArtists( const std::string& name ) const override;
virtual medialibrary::SearchAggregate search( const std::string& pattern ) const override;
virtual void discover( const std::string& entryPoint ) override;
bool banFolder( const std::string& path ) override;
......
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