diff --git a/src/database-updater/DatabaseUpdater.cpp b/src/database-updater/DatabaseUpdater.cpp index bd7e424f..dd4d0683 100644 --- a/src/database-updater/DatabaseUpdater.cpp +++ b/src/database-updater/DatabaseUpdater.cpp @@ -230,7 +230,7 @@ Updater::process(boost::system::error_code err) rootDirectories.push_back( std::make_pair( directory->getPath(), directory->getType() )); } - BOOST_FOREACH( RootDirectory rootDirectory, rootDirectories) + for (RootDirectory rootDirectory : rootDirectories) processDirectory(rootDirectory.first, rootDirectory.first, rootDirectory.second, stats); LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Changes = " << stats.nbChanges(); @@ -430,11 +430,16 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats) // ***** Genres std::vector< Genre::pointer > genres; { - genres = getGenres( boost::any_cast< std::list > (items[MetaData::Type::Genres]) ); + std::list genreList; + + if (items.find(MetaData::Type::Genres) != items.end()) + genreList = boost::any_cast< std::list > (items[MetaData::Type::Genres]); + + genres = getGenres( genreList ); } assert( !genres.empty() ); - // Get the associated Artist + // ***** Artist Artist::pointer artist; { std::string artistName; @@ -450,7 +455,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats) } assert(artist); - // Get the associated Release + // ***** Release Release::pointer release; { std::string releaseName; diff --git a/src/database/Artist.cpp b/src/database/Artist.cpp index cabfcfec..ffff62b7 100644 --- a/src/database/Artist.cpp +++ b/src/database/Artist.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Emeric Poupon + * Copyright (C) 2015 Emeric Poupon * * This file is part of LMS. * @@ -17,7 +17,7 @@ * along with LMS. If not, see . */ -#include "Artist.hpp" +#include "Types.hpp" #include "SqlQuery.hpp" #include "logger/Logger.hpp" diff --git a/src/database/Release.cpp b/src/database/Release.cpp index a87ed8d1..d2bd4f72 100644 --- a/src/database/Release.cpp +++ b/src/database/Release.cpp @@ -1,6 +1,23 @@ +/* + * Copyright (C) 2015 Emeric Poupon + * + * This file is part of LMS. + * + * LMS 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. + * + * LMS 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 LMS. If not, see . + */ -#include "Release.hpp" - +#include "Types.hpp" #include "SearchFilter.hpp" #include "SqlQuery.hpp" diff --git a/src/ui/audio/mobile/MobileAudio.cpp b/src/ui/audio/mobile/MobileAudio.cpp index f3394b77..b5c38fd8 100644 --- a/src/ui/audio/mobile/MobileAudio.cpp +++ b/src/ui/audio/mobile/MobileAudio.cpp @@ -97,32 +97,16 @@ Audio::Audio(Wt::WContainerWidget *parent) std::vector keywords; boost::algorithm::split(keywords, text, boost::is_any_of(" "), boost::token_compress_on); - { - SearchFilter filter; - for (std::string keyword : keywords) - { - filter.nameLikeMatch[SearchFilter::Field::Artist].push_back(keyword); - filter.nameLikeMatch[SearchFilter::Field::Release].push_back(keyword); - } + releaseSearch->search(SearchFilter::NameLikeMatch( { + { SearchFilter::Field::Artist, keywords }, + { SearchFilter::Field::Release, keywords }}), + 3); - releaseSearch->search(filter, 3); - } + artistSearch->search(SearchFilter::NameLikeMatch({{SearchFilter::Field::Artist, keywords}}), + 3); - { - SearchFilter filter; - for (std::string keyword : keywords) - filter.nameLikeMatch[SearchFilter::Field::Artist].push_back(keyword); - - artistSearch->search(filter, 3); - } - - { - SearchFilter filter; - BOOST_FOREACH(std::string keyword, keywords) - filter.nameLikeMatch[SearchFilter::Field::Track].push_back(keyword); - - trackSearch->search(filter, 3); - } + trackSearch->search(SearchFilter::NameLikeMatch({{SearchFilter::Field::Track, keywords}}), + 3); artistSearch->show(); releaseSearch->show(); @@ -143,10 +127,8 @@ Audio::Audio(Wt::WContainerWidget *parent) trackSearch->hide(); releaseSearch->show(); - SearchFilter filter; - filter.idMatch[SearchFilter::Field::Artist].push_back(artistId); - - releaseSearch->search(filter, 20); + releaseSearch->search(SearchFilter::IdMatch({{SearchFilter::Field::Artist, {artistId}}}), + 20); }, std::placeholders::_1)); releaseSearch->moreReleasesSelected().connect(std::bind([=] @@ -162,11 +144,8 @@ Audio::Audio(Wt::WContainerWidget *parent) releaseSearch->hide(); trackSearch->show(); - // TODO load track search with selected release - SearchFilter filter; - filter.idMatch[SearchFilter::Field::Release].push_back(releaseId); - - trackSearch->search(filter, 20); + trackSearch->search(SearchFilter::IdMatch({{SearchFilter::Field::Release, {releaseId}}}), + 20); }, std::placeholders::_1)); trackSearch->moreTracksSelected().connect(std::bind([=] @@ -207,10 +186,9 @@ Audio::Audio(Wt::WContainerWidget *parent) // Initially, populate the widgets using an empty search { - SearchFilter filter; // empty filter - artistSearch->search(filter, 3); - releaseSearch->search(filter, 3); - trackSearch->search(filter, 3); + artistSearch->search(SearchFilter(), 3); + releaseSearch->search(SearchFilter(), 3); + trackSearch->search(SearchFilter(), 3); } }