Fix locating a song in album only view and make it play nice with dates
This commit is contained in:
@@ -79,11 +79,9 @@ MPD::SongIterator getSongsFromAlbum(const AlbumEntry &album)
|
|||||||
if (!album.isAllTracksEntry())
|
if (!album.isAllTracksEntry())
|
||||||
{
|
{
|
||||||
Mpd.AddSearch(MPD_TAG_ALBUM, album.entry().album());
|
Mpd.AddSearch(MPD_TAG_ALBUM, album.entry().album());
|
||||||
if(!isAlbumOnly) {
|
|
||||||
if (Config.media_library_albums_split_by_date)
|
if (Config.media_library_albums_split_by_date)
|
||||||
Mpd.AddSearch(MPD_TAG_DATE, album.entry().date());
|
Mpd.AddSearch(MPD_TAG_DATE, album.entry().date());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return Mpd.CommitSearchSongs();
|
return Mpd.CommitSearchSongs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,20 +308,8 @@ void MediaLibrary::update()
|
|||||||
unsigned idx = 0;
|
unsigned idx = 0;
|
||||||
while (!(tag = s->get(Config.media_lib_primary_tag, idx++)).empty())
|
while (!(tag = s->get(Config.media_lib_primary_tag, idx++)).empty())
|
||||||
{
|
{
|
||||||
if (isAlbumOnly) {
|
|
||||||
auto key = std::make_tuple(
|
auto key = std::make_tuple(
|
||||||
"",
|
isAlbumOnly ? "" : std::move(tag),
|
||||||
s->getAlbum(),
|
|
||||||
"");
|
|
||||||
auto it = albums.find(key);
|
|
||||||
if (it == albums.end())
|
|
||||||
albums[std::move(key)] = s->getMTime();
|
|
||||||
else
|
|
||||||
it->second = s->getMTime();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
auto key = std::make_tuple(
|
|
||||||
std::move(tag),
|
|
||||||
s->getAlbum(),
|
s->getAlbum(),
|
||||||
Date_(s->getDate()));
|
Date_(s->getDate()));
|
||||||
auto it = albums.find(key);
|
auto it = albums.find(key);
|
||||||
@@ -333,7 +319,6 @@ void MediaLibrary::update()
|
|||||||
it->second = s->getMTime();
|
it->second = s->getMTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
for (const auto &album : albums)
|
for (const auto &album : albums)
|
||||||
{
|
{
|
||||||
@@ -897,7 +882,8 @@ void MediaLibrary::updateTimer()
|
|||||||
|
|
||||||
void MediaLibrary::toggleColumnsMode()
|
void MediaLibrary::toggleColumnsMode()
|
||||||
{
|
{
|
||||||
if (isAlbumOnly) {
|
if (isAlbumOnly)
|
||||||
|
{
|
||||||
hasTwoColumns = 0;
|
hasTwoColumns = 0;
|
||||||
isAlbumOnly = 0;
|
isAlbumOnly = 0;
|
||||||
}
|
}
|
||||||
@@ -918,14 +904,16 @@ void MediaLibrary::toggleColumnsMode()
|
|||||||
{
|
{
|
||||||
std::string item_type = boost::locale::to_lower(
|
std::string item_type = boost::locale::to_lower(
|
||||||
tagTypeToString(Config.media_lib_primary_tag));
|
tagTypeToString(Config.media_lib_primary_tag));
|
||||||
if(!isAlbumOnly) {
|
if (isAlbumOnly)
|
||||||
std::string and_mtime = Config.media_library_sort_by_mtime ? " and mtime" : "";
|
{
|
||||||
Albums.setTitle("Albums (sorted by " + item_type + and_mtime + ")");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
std::string and_mtime = Config.media_library_sort_by_mtime ? " (sorted by mtime)" : "";
|
std::string and_mtime = Config.media_library_sort_by_mtime ? " (sorted by mtime)" : "";
|
||||||
Albums.setTitle("Albums" + and_mtime);
|
Albums.setTitle("Albums" + and_mtime);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string and_mtime = Config.media_library_sort_by_mtime ? " and mtime" : "";
|
||||||
|
Albums.setTitle("Albums (sorted by " + item_type + and_mtime + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -956,14 +944,16 @@ void MediaLibrary::toggleSortMode()
|
|||||||
{
|
{
|
||||||
std::string item_type = boost::locale::to_lower(
|
std::string item_type = boost::locale::to_lower(
|
||||||
tagTypeToString(Config.media_lib_primary_tag));
|
tagTypeToString(Config.media_lib_primary_tag));
|
||||||
if(!isAlbumOnly) {
|
if (isAlbumOnly)
|
||||||
std::string and_mtime = Config.media_library_sort_by_mtime ? (" " "and mtime") : "";
|
{
|
||||||
Albums.setTitle("Albums (sorted by " + item_type + and_mtime + ")");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
std::string and_mtime = Config.media_library_sort_by_mtime ? " (sorted by mtime)" : "";
|
std::string and_mtime = Config.media_library_sort_by_mtime ? " (sorted by mtime)" : "";
|
||||||
Albums.setTitle("Albums" + and_mtime);
|
Albums.setTitle("Albums" + and_mtime);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string and_mtime = Config.media_library_sort_by_mtime ? (" " "and mtime") : "";
|
||||||
|
Albums.setTitle("Albums (sorted by " + item_type + and_mtime + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1106,16 +1096,14 @@ std::string AlbumToString(const AlbumEntry &ae)
|
|||||||
result = "All tracks";
|
result = "All tracks";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (hasTwoColumns)
|
if (!isAlbumOnly && hasTwoColumns)
|
||||||
{
|
{
|
||||||
if(!isAlbumOnly) {
|
|
||||||
if (ae.entry().tag().empty())
|
if (ae.entry().tag().empty())
|
||||||
result += Config.empty_tag;
|
result += Config.empty_tag;
|
||||||
else
|
else
|
||||||
result += ae.entry().tag();
|
result += ae.entry().tag();
|
||||||
result += " - ";
|
result += " - ";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.media_lib_primary_tag != MPD_TAG_DATE && !Config.media_lib_hide_album_dates && !ae.entry().date().empty())
|
if (Config.media_lib_primary_tag != MPD_TAG_DATE && !Config.media_lib_hide_album_dates && !ae.entry().date().empty())
|
||||||
result += "(" + ae.entry().date() + ") ";
|
result += "(" + ae.entry().date() + ") ";
|
||||||
@@ -1180,7 +1168,7 @@ bool MoveToAlbum(NC::Menu<AlbumEntry> &albums, const std::string &primary_tag, c
|
|||||||
std::string date = s.getDate();
|
std::string date = s.getDate();
|
||||||
|
|
||||||
auto equals_fun_argument = [&](AlbumEntry &e) {
|
auto equals_fun_argument = [&](AlbumEntry &e) {
|
||||||
return (!hasTwoColumns || e.entry().tag() == primary_tag)
|
return (isAlbumOnly || !hasTwoColumns || e.entry().tag() == primary_tag)
|
||||||
&& e.entry().album() == album
|
&& e.entry().album() == album
|
||||||
&& (!Config.media_library_albums_split_by_date || e.entry().date() == date);
|
&& (!Config.media_library_albums_split_by_date || e.entry().date() == date);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user