diff --git a/src/Makefile.am b/src/Makefile.am index 7c5889d0..663e56cc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,7 +11,6 @@ lms_SOURCES = \ $(srcdir)/database/Playlist.cpp \ $(srcdir)/database/Release.cpp \ $(srcdir)/database/ScanSettings.cpp \ - $(srcdir)/database/Setting.cpp \ $(srcdir)/database/SqlQuery.cpp \ $(srcdir)/database/Track.cpp \ $(srcdir)/database/User.cpp \ @@ -33,7 +32,6 @@ lms_SOURCES = \ $(srcdir)/ui/explore/ArtistView.cpp \ $(srcdir)/ui/explore/ArtistsView.cpp \ $(srcdir)/ui/explore/Explore.cpp \ - $(srcdir)/ui/explore/ExploreUtils.cpp \ $(srcdir)/ui/explore/Filters.cpp \ $(srcdir)/ui/explore/ReleasesView.cpp \ $(srcdir)/ui/explore/ReleaseView.cpp \ diff --git a/src/database/ScanSettings.hpp b/src/database/ScanSettings.hpp index c478fa3f..cdc1ef0e 100644 --- a/src/database/ScanSettings.hpp +++ b/src/database/ScanSettings.hpp @@ -27,7 +27,6 @@ namespace Database { class ClusterType; -// class meant to store general settings class ScanSettings : public Wt::Dbo::Dbo { public: diff --git a/src/ui/explore/ArtistView.cpp b/src/ui/explore/ArtistView.cpp index e308d009..665b98a6 100644 --- a/src/ui/explore/ArtistView.cpp +++ b/src/ui/explore/ArtistView.cpp @@ -34,31 +34,14 @@ #include "LmsApplication.hpp" #include "Filters.hpp" -#include "ExploreUtils.hpp" using namespace Database; -namespace { - -const std::string artistClusterTypesSetting = "artist_cluster_types"; -const std::set defaultArtistClusterTypes = -{ - "GENRE", - "ALBUMGROUPING", - "ALBUMMOOD", - "COMMENT:SONGS-DB_OCCASION", -}; - -} // namespace - namespace UserInterface { Artist::Artist(Filters* filters) : _filters(filters) { - if (!Setting::exists(LmsApp->getDboSession(), artistClusterTypesSetting)) - setClusterTypesToSetting(artistClusterTypesSetting, defaultArtistClusterTypes); - wApp->internalPathChanged().connect(std::bind([=] { refresh(); @@ -98,7 +81,7 @@ Artist::refresh() Wt::WContainerWidget* clusterContainers = t->bindNew("clusters"); { - auto clusterTypes = getClusterTypesFromSetting(artistClusterTypesSetting); + auto clusterTypes = ScanSettings::get(LmsApp->getDboSession())->getClusterTypes(); auto clusterGroups = artist->getClusterGroups(clusterTypes, 3); for (auto clusters : clusterGroups) diff --git a/src/ui/explore/ArtistsView.cpp b/src/ui/explore/ArtistsView.cpp index 4ca9a617..201cbc65 100644 --- a/src/ui/explore/ArtistsView.cpp +++ b/src/ui/explore/ArtistsView.cpp @@ -31,31 +31,15 @@ #include "LmsApplication.hpp" #include "Filters.hpp" -#include "ExploreUtils.hpp" using namespace Database; -namespace { - -const std::string artistsClusterTypesSetting = "artists_cluster_types"; -const std::set defaultArtistsClusterTypes = -{ - "ALBUMGROUPING", - "GENRE", - "ALBUMMOOD", -}; - -} - namespace UserInterface { Artists::Artists(Filters* filters) : Wt::WTemplate(Wt::WString::tr("Lms.Explore.Artists.template")), _filters(filters) { - if (!Setting::exists(LmsApp->getDboSession(), artistsClusterTypesSetting)) - setClusterTypesToSetting(artistsClusterTypesSetting, defaultArtistsClusterTypes); - addFunction("tr", &Wt::WTemplate::Functions::tr); _search = bindNew("search"); @@ -109,7 +93,7 @@ Artists::addSome() Wt::WContainerWidget* clusterContainers = entry->bindNew("clusters"); { - auto clusterTypes = getClusterTypesFromSetting(artistsClusterTypesSetting); + auto clusterTypes = ScanSettings::get(LmsApp->getDboSession())->getClusterTypes(); auto clusterGroups = artist->getClusterGroups(clusterTypes, 1); for (auto clusters : clusterGroups) diff --git a/src/ui/explore/ExploreUtils.cpp b/src/ui/explore/ExploreUtils.cpp deleted file mode 100644 index 6ecaeccc..00000000 --- a/src/ui/explore/ExploreUtils.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -/* - * Copyright (C) 2018 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 "ExploreUtils.hpp" - -#include "utils/Utils.hpp" - -#include "database/Setting.hpp" - -#include "LmsApplication.hpp" - -namespace UserInterface { - -std::vector getClusterTypesFromSetting(std::string setting) -{ - std::vector res; - for (auto clusterTypeName : splitString(Database::Setting::getString(LmsApp->getDboSession(), setting), " ")) - { - auto clusterType = Database::ClusterType::getByName(LmsApp->getDboSession(), clusterTypeName); - if (clusterType) - res.push_back(clusterType); - } - - return res; -} - -void setClusterTypesToSetting(std::string setting, const std::set& clusterTypes) -{ - std::vector vec(clusterTypes.begin(), clusterTypes.end()); - Database::Setting::setString(LmsApp->getDboSession(), setting, joinStrings(vec, " ")); -} - -} // namespace UserInterface - diff --git a/src/ui/explore/ExploreUtils.hpp b/src/ui/explore/ExploreUtils.hpp deleted file mode 100644 index f805a480..00000000 --- a/src/ui/explore/ExploreUtils.hpp +++ /dev/null @@ -1,29 +0,0 @@ - -/* - * Copyright (C) 2018 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 "database/Cluster.hpp" - -namespace UserInterface { - -std::vector getClusterTypesFromSetting(std::string setting); - -void setClusterTypesToSetting(std::string setting, const std::set& clusterTypes); - -} // namespace UserInterface diff --git a/src/ui/explore/ReleaseView.cpp b/src/ui/explore/ReleaseView.cpp index 8efc7560..04e41297 100644 --- a/src/ui/explore/ReleaseView.cpp +++ b/src/ui/explore/ReleaseView.cpp @@ -26,7 +26,6 @@ #include #include "database/Release.hpp" -#include "database/Setting.hpp" #include "database/Track.hpp" #include "utils/Logger.hpp" @@ -36,31 +35,14 @@ #include "LmsApplication.hpp" #include "Filters.hpp" -#include "ExploreUtils.hpp" using namespace Database; -namespace { - -const std::string releaseClusterTypesSetting = "release_cluster_types"; -const std::set defaultReleaseClusterTypes = -{ - "GENRE", - "ALBUMGROUPING", - "ALBUMMOOD", - "COMMENT:SONGS-DB_OCCASION", -}; - -} // namespace - namespace UserInterface { Release::Release(Filters* filters) : _filters(filters) { - if (!Setting::exists(LmsApp->getDboSession(), releaseClusterTypesSetting)) - setClusterTypesToSetting(releaseClusterTypesSetting, defaultReleaseClusterTypes); - wApp->internalPathChanged().connect(std::bind([=] { refresh(); @@ -131,7 +113,7 @@ Release::refresh() Wt::WContainerWidget* clusterContainers = t->bindNew("clusters"); { - auto clusterTypes = getClusterTypesFromSetting(releaseClusterTypesSetting); + auto clusterTypes = ScanSettings::get(LmsApp->getDboSession())->getClusterTypes(); auto clusterGroups = release->getClusterGroups(clusterTypes, 3); for (auto clusters : clusterGroups) diff --git a/src/ui/explore/ReleasesView.cpp b/src/ui/explore/ReleasesView.cpp index 81bddc25..c823a79f 100644 --- a/src/ui/explore/ReleasesView.cpp +++ b/src/ui/explore/ReleasesView.cpp @@ -26,7 +26,6 @@ #include #include "database/Release.hpp" -#include "database/Setting.hpp" #include "utils/Logger.hpp" #include "utils/Utils.hpp" @@ -35,30 +34,15 @@ #include "LmsApplication.hpp" #include "Filters.hpp" -#include "ExploreUtils.hpp" using namespace Database; -namespace { - -const std::string releasesClusterTypesSetting = "releases_cluster_types"; -const std::set defaultReleasesClusterTypes = -{ - "GENRE", - "ALBUMGROUPING", -}; - -} // namespace - namespace UserInterface { Releases::Releases(Filters* filters) : Wt::WTemplate(Wt::WString::tr("Lms.Explore.Releases.template")), _filters(filters) { - if (!Setting::exists(LmsApp->getDboSession(), releasesClusterTypesSetting)) - setClusterTypesToSetting(releasesClusterTypesSetting, defaultReleasesClusterTypes); - addFunction("tr", &Wt::WTemplate::Functions::tr); _search = bindNew("search"); @@ -126,7 +110,7 @@ Releases::addSome() Wt::WContainerWidget* clusterContainers = entry->bindNew("clusters"); { - auto clusterTypes = getClusterTypesFromSetting(releasesClusterTypesSetting); + auto clusterTypes = ScanSettings::get(LmsApp->getDboSession())->getClusterTypes(); auto clusterGroups = release->getClusterGroups(clusterTypes, 1); for (auto clusters : clusterGroups) diff --git a/src/ui/explore/TracksView.cpp b/src/ui/explore/TracksView.cpp index 7889499b..00dbef25 100644 --- a/src/ui/explore/TracksView.cpp +++ b/src/ui/explore/TracksView.cpp @@ -26,7 +26,6 @@ #include "database/Artist.hpp" #include "database/Release.hpp" -#include "database/Setting.hpp" #include "database/Track.hpp" #include "utils/Logger.hpp" @@ -36,32 +35,15 @@ #include "LmsApplication.hpp" #include "Filters.hpp" -#include "ExploreUtils.hpp" using namespace Database; -namespace { - -const std::string trackClusterTypesSetting = "track_cluster_types"; -const std::set defaultTrackClusterTypes = -{ - "GENRE", - "ALBUMGROUPING", - "ALBUMMOOD", - "COMMENT:SONGS-DB_OCCASION", -}; - -} // namespace - namespace UserInterface { Tracks::Tracks(Filters* filters) : Wt::WTemplate(Wt::WString::tr("Lms.Explore.Tracks.template")), _filters(filters) { - if (!Setting::exists(LmsApp->getDboSession(), trackClusterTypesSetting)) - setClusterTypesToSetting(trackClusterTypesSetting, defaultTrackClusterTypes); - addFunction("tr", &Wt::WTemplate::Functions::tr); _search = bindNew("search"); @@ -154,7 +136,7 @@ Tracks::addSome() Wt::WContainerWidget* clusterContainers = entry->bindNew("clusters"); { - auto clusterTypes = getClusterTypesFromSetting(trackClusterTypesSetting); + auto clusterTypes = ScanSettings::get(LmsApp->getDboSession())->getClusterTypes(); auto clusterGroups = track->getClusterGroups(clusterTypes, 1); for (auto clusters : clusterGroups)