diff --git a/approot/search.xml b/approot/search.xml
index fc357d26..4f248d70 100644
--- a/approot/search.xml
+++ b/approot/search.xml
@@ -16,7 +16,14 @@
${releases}
-
${artists}
+
+
+
+ ${link-type class="form-select"}
+
+
+ ${artists}
+
${tracks}
diff --git a/src/lms/ui/explore/ArtistCollector.cpp b/src/lms/ui/explore/ArtistCollector.cpp
index 0fddcfd7..16bfd9c7 100644
--- a/src/lms/ui/explore/ArtistCollector.cpp
+++ b/src/lms/ui/explore/ArtistCollector.cpp
@@ -78,6 +78,7 @@ namespace UserInterface
Artist::FindParameters params;
params.setClusters(getFilters().getClusterIds());
params.setKeywords(getSearchKeywords());
+ params.setLinkType(_linkType);
params.setSortMethod(ArtistSortMethod::BySortName);
params.setRange(range);
diff --git a/src/lms/ui/explore/ArtistListHelpers.cpp b/src/lms/ui/explore/ArtistListHelpers.cpp
index f8bd2c29..2270307f 100644
--- a/src/lms/ui/explore/ArtistListHelpers.cpp
+++ b/src/lms/ui/explore/ArtistListHelpers.cpp
@@ -21,6 +21,10 @@
#include
#include "services/database/Artist.hpp"
+#include "services/database/Session.hpp"
+#include "services/database/TrackArtistLink.hpp"
+#include "utils/EnumSet.hpp"
+#include "LmsApplication.hpp"
#include "Utils.hpp"
namespace UserInterface::ArtistListHelpers
@@ -33,5 +37,43 @@ namespace UserInterface::ArtistListHelpers
return res;
}
+
+ std::unique_ptr
+ createArtistLinkTypesModel()
+ {
+ using namespace Database;
+
+ std::unique_ptr linkTypesModel {std::make_unique()};
+
+ EnumSet usedLinkTypes;
+ {
+ auto transaction {LmsApp->getDbSession().createSharedTransaction()};
+ usedLinkTypes = TrackArtistLink::findUsedTypes(LmsApp->getDbSession());
+ }
+
+ auto addTypeIfUsed {[&](TrackArtistLinkType linkType, std::string_view stringKey)
+ {
+ if (!usedLinkTypes.contains(linkType))
+ return;
+
+ linkTypesModel->add(Wt::WString::trn(std::string {stringKey}, 2), linkType);
+ }};
+
+ // add default one first (none)
+ linkTypesModel->add(Wt::WString::tr("Lms.Explore.Artists.linktype-all"), std::nullopt);
+
+ // TODO: sort by translated strings
+ addTypeIfUsed(TrackArtistLinkType::Artist, "Lms.Explore.Artists.linktype-artist");
+ addTypeIfUsed(TrackArtistLinkType::ReleaseArtist, "Lms.Explore.Artists.linktype-releaseartist");
+ addTypeIfUsed(TrackArtistLinkType::Composer, "Lms.Explore.Artists.linktype-composer");
+ addTypeIfUsed(TrackArtistLinkType::Conductor, "Lms.Explore.Artists.linktype-conductor");
+ addTypeIfUsed(TrackArtistLinkType::Lyricist, "Lms.Explore.Artists.linktype-lyricist");
+ addTypeIfUsed(TrackArtistLinkType::Mixer, "Lms.Explore.Artists.linktype-mixer");
+ addTypeIfUsed(TrackArtistLinkType::Performer, "Lms.Explore.Artists.linktype-performer");
+ addTypeIfUsed(TrackArtistLinkType::Producer, "Lms.Explore.Artists.linktype-producer");
+ addTypeIfUsed(TrackArtistLinkType::Remixer, "Lms.Explore.Artists.linktype-remixer");
+
+ return linkTypesModel;
+ }
}
diff --git a/src/lms/ui/explore/ArtistListHelpers.hpp b/src/lms/ui/explore/ArtistListHelpers.hpp
index 79bbf700..40d3bf6b 100644
--- a/src/lms/ui/explore/ArtistListHelpers.hpp
+++ b/src/lms/ui/explore/ArtistListHelpers.hpp
@@ -23,15 +23,23 @@
#include
+#include "common/ValueStringModel.hpp"
#include "services/database/Object.hpp"
+#include "services/database/Types.hpp"
namespace Database
{
class Artist;
}
-namespace UserInterface::ArtistListHelpers
+namespace UserInterface
{
- std::unique_ptr createEntry(const Database::ObjectPtr& artist);
+ using ArtistLinkTypesModel = ValueStringModel>;
+
+ namespace ArtistListHelpers
+ {
+ std::unique_ptr createEntry(const Database::ObjectPtr& artist);
+ std::unique_ptr createArtistLinkTypesModel();
+ }
}
diff --git a/src/lms/ui/explore/ArtistsView.cpp b/src/lms/ui/explore/ArtistsView.cpp
index 990d4dd5..1db66e42 100644
--- a/src/lms/ui/explore/ArtistsView.cpp
+++ b/src/lms/ui/explore/ArtistsView.cpp
@@ -24,10 +24,8 @@
#include "services/database/Artist.hpp"
#include "services/database/Session.hpp"
#include "services/database/TrackArtistLink.hpp"
-#include "utils/EnumSet.hpp"
#include "utils/Logger.hpp"
-#include "common/ValueStringModel.hpp"
#include "common/InfiniteScrollingContainer.hpp"
#include "ArtistListHelpers.hpp"
#include "Filters.hpp"
@@ -37,8 +35,6 @@ using namespace Database;
namespace UserInterface {
-using ArtistLinkModel = ValueStringModel>;
-
Artists::Artists(Filters& filters)
: Wt::WTemplate {Wt::WString::tr("Lms.Explore.Artists.template")}
, _artistCollector {filters, _defaultMode, _maxCount}
@@ -71,18 +67,17 @@ Artists::Artists(Filters& filters)
bindMenuItem("all", Wt::WString::tr("Lms.Explore.all"), ArtistCollector::Mode::All);
_linkType = bindNew("link-type");
- _linkType->setModel(std::make_shared());
+ _linkType->setModel(ArtistListHelpers::createArtistLinkTypesModel());
_linkType->changed().connect([this]
{
- const std::optional linkType {static_cast(_linkType->model().get())->getValue(_linkType->currentIndex())};
+ const std::optional linkType {static_cast(_linkType->model().get())->getValue(_linkType->currentIndex())};
refreshView(linkType);
});
- refreshArtistLinkTypes();
LmsApp->getScannerEvents().scanComplete.connect(this, [this](const Scanner::ScanStats& stats)
{
if (stats.nbChanges())
- refreshArtistLinkTypes();
+ _linkType->setModel(ArtistListHelpers::createArtistLinkTypesModel());
});
_container = bindNew("artists", Wt::WString::tr("Lms.Explore.Artists.template.container"));
@@ -120,42 +115,6 @@ Artists::refreshView(std::optional linkType)
refreshView();
}
-void
-Artists::refreshArtistLinkTypes()
-{
- std::shared_ptr linkTypeModel {std::static_pointer_cast(_linkType->model())};
-
- EnumSet usedLinkTypes;
- {
- auto transaction {LmsApp->getDbSession().createSharedTransaction()};
- usedLinkTypes = TrackArtistLink::findUsedTypes(LmsApp->getDbSession());
- }
-
- auto addTypeIfUsed {[&](TrackArtistLinkType linkType, std::string_view stringKey)
- {
- if (!usedLinkTypes.contains(linkType))
- return;
-
- linkTypeModel->add(Wt::WString::trn(std::string {stringKey}, 2), linkType);
- }};
-
- linkTypeModel->clear();
-
- // add default one first (none)
- linkTypeModel->add(Wt::WString::tr("Lms.Explore.Artists.linktype-all"), std::nullopt);
-
- // TODO: sort by translated strings
- addTypeIfUsed(TrackArtistLinkType::Artist, "Lms.Explore.Artists.linktype-artist");
- addTypeIfUsed(TrackArtistLinkType::ReleaseArtist, "Lms.Explore.Artists.linktype-releaseartist");
- addTypeIfUsed(TrackArtistLinkType::Composer, "Lms.Explore.Artists.linktype-composer");
- addTypeIfUsed(TrackArtistLinkType::Conductor, "Lms.Explore.Artists.linktype-conductor");
- addTypeIfUsed(TrackArtistLinkType::Lyricist, "Lms.Explore.Artists.linktype-lyricist");
- addTypeIfUsed(TrackArtistLinkType::Mixer, "Lms.Explore.Artists.linktype-mixer");
- addTypeIfUsed(TrackArtistLinkType::Performer, "Lms.Explore.Artists.linktype-performer");
- addTypeIfUsed(TrackArtistLinkType::Producer, "Lms.Explore.Artists.linktype-producer");
- addTypeIfUsed(TrackArtistLinkType::Remixer, "Lms.Explore.Artists.linktype-remixer");
-}
-
void
Artists::addSome()
{
diff --git a/src/lms/ui/explore/ArtistsView.hpp b/src/lms/ui/explore/ArtistsView.hpp
index 53a200e2..26e34e16 100644
--- a/src/lms/ui/explore/ArtistsView.hpp
+++ b/src/lms/ui/explore/ArtistsView.hpp
@@ -42,7 +42,6 @@ namespace UserInterface
void refreshView();
void refreshView(ArtistCollector::Mode mode);
void refreshView(std::optional linkType);
- void refreshArtistLinkTypes();
void addSome();
static constexpr std::size_t _batchSize {30};
diff --git a/src/lms/ui/explore/SearchView.cpp b/src/lms/ui/explore/SearchView.cpp
index c8fca22b..ccfb2dd5 100644
--- a/src/lms/ui/explore/SearchView.cpp
+++ b/src/lms/ui/explore/SearchView.cpp
@@ -48,6 +48,14 @@ namespace UserInterface
_artists = bindNew("artists", Wt::WString::tr("Lms.Explore.Artists.template.container"));
_artists->onRequestElements.connect([this] { addSomeArtists(); });
+ _artistLinkType = bindNew("link-type");
+ _artistLinkType->setModel(ArtistListHelpers::createArtistLinkTypesModel());
+ _artistLinkType->changed().connect([this]
+ {
+ const std::optional linkType {static_cast(_artistLinkType->model().get())->getValue(_artistLinkType->currentIndex())};
+ refreshView(linkType);
+ });
+
_releases = bindNew("releases", Wt::WString::tr("Lms.Explore.Releases.template.container"));
_releases->onRequestElements.connect([this] { addSomeReleases(); });
@@ -76,6 +84,13 @@ namespace UserInterface
return it->second;
}
+ void
+ SearchView::refreshView(std::optional linkType)
+ {
+ _artistCollector.setArtistLinkType(linkType);
+ refreshView();
+ }
+
void
SearchView::refreshView(const Wt::WString& searchText)
{
diff --git a/src/lms/ui/explore/SearchView.hpp b/src/lms/ui/explore/SearchView.hpp
index 337a3a0c..bc5c33df 100644
--- a/src/lms/ui/explore/SearchView.hpp
+++ b/src/lms/ui/explore/SearchView.hpp
@@ -19,11 +19,14 @@
#pragma once
+#include
#include
+#include
#include
#include
+#include "services/database/Types.hpp"
#include "ArtistCollector.hpp"
#include "ReleaseCollector.hpp"
#include "TrackCollector.hpp"
@@ -67,6 +70,7 @@ namespace UserInterface
std::size_t getMaxCount(Mode mode) const;
void refreshView();
+ void refreshView(std::optional linkType);
void addSomeArtists();
void addSomeReleases();
void addSomeTracks();
@@ -77,9 +81,11 @@ namespace UserInterface
ReleaseCollector _releaseCollector;
TrackCollector _trackCollector;
- InfiniteScrollingContainer* _artists;
- InfiniteScrollingContainer* _releases;
- InfiniteScrollingContainer* _tracks;
+ InfiniteScrollingContainer* _artists {};
+ InfiniteScrollingContainer* _releases {};
+ InfiniteScrollingContainer* _tracks {};
+
+ Wt::WComboBox* _artistLinkType {};
std::vector _results;
};