Add type value of browser_sort_mode (set by default)
This commit is contained in:
@@ -2261,6 +2261,9 @@ void ToggleBrowserSortMode::run()
|
||||
{
|
||||
switch (Config.browser_sort_mode)
|
||||
{
|
||||
case SortMode::Type:
|
||||
Config.browser_sort_mode = SortMode::Name;
|
||||
Statusbar::print("Sort songs by: name");
|
||||
case SortMode::Name:
|
||||
Config.browser_sort_mode = SortMode::ModificationTime;
|
||||
Statusbar::print("Sort songs by: modification time");
|
||||
@@ -2274,15 +2277,16 @@ void ToggleBrowserSortMode::run()
|
||||
Statusbar::print("Do not sort songs");
|
||||
break;
|
||||
case SortMode::None:
|
||||
Config.browser_sort_mode = SortMode::Name;
|
||||
Statusbar::print("Sort songs by: name");
|
||||
Config.browser_sort_mode = SortMode::Type;
|
||||
Statusbar::print("Sort songs by: type");
|
||||
}
|
||||
if (Config.browser_sort_mode != SortMode::None)
|
||||
{
|
||||
size_t sort_offset = myBrowser->inRootDirectory() ? 0 : 1;
|
||||
std::sort(myBrowser->main().begin()+sort_offset, myBrowser->main().end(),
|
||||
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode)
|
||||
);
|
||||
std::stable_sort(
|
||||
myBrowser->main().begin()+sort_offset, myBrowser->main().end(),
|
||||
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the,
|
||||
Config.browser_sort_mode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,9 @@ std::ostream &operator<<(std::ostream &os, SortMode sm)
|
||||
{
|
||||
switch (sm)
|
||||
{
|
||||
case SortMode::Type:
|
||||
os << "type";
|
||||
break;
|
||||
case SortMode::Name:
|
||||
os << "name";
|
||||
break;
|
||||
@@ -98,7 +101,9 @@ std::istream &operator>>(std::istream &is, SortMode &sm)
|
||||
{
|
||||
std::string ssm;
|
||||
is >> ssm;
|
||||
if (ssm == "name")
|
||||
if (ssm == "type")
|
||||
sm = SortMode::Type;
|
||||
else if (ssm == "name")
|
||||
sm = SortMode::Name;
|
||||
else if (ssm == "mtime")
|
||||
sm = SortMode::ModificationTime;
|
||||
|
||||
@@ -32,7 +32,7 @@ enum class SpaceAddMode { AddRemove, AlwaysAdd };
|
||||
std::ostream &operator<<(std::ostream &os, SpaceAddMode sam);
|
||||
std::istream &operator>>(std::istream &is, SpaceAddMode &sam);
|
||||
|
||||
enum class SortMode { Name, ModificationTime, CustomFormat, None };
|
||||
enum class SortMode { Type, Name, ModificationTime, CustomFormat, None };
|
||||
std::ostream &operator<<(std::ostream &os, SortMode sm);
|
||||
std::istream &operator>>(std::istream &is, SortMode &sm);
|
||||
|
||||
|
||||
@@ -500,8 +500,10 @@ void Browser::getDirectory(std::string directory)
|
||||
|
||||
if (Config.browser_sort_mode != SortMode::None)
|
||||
{
|
||||
std::sort(w.begin() + (is_root ? 0 : 1), w.end(),
|
||||
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode));
|
||||
std::stable_sort(
|
||||
w.begin() + (is_root ? 0 : 1), w.end(),
|
||||
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the,
|
||||
Config.browser_sort_mode));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,8 +683,8 @@ void getLocalDirectoryRecursively(std::vector<MPD::Song> &songs, const std::stri
|
||||
|
||||
if (Config.browser_sort_mode != SortMode::None)
|
||||
{
|
||||
std::sort(songs.begin()+sort_offset, songs.end(),
|
||||
LocaleBasedSorting(std::locale(), Config.ignore_leading_the)
|
||||
std::stable_sort(songs.begin()+sort_offset, songs.end(),
|
||||
LocaleBasedSorting(std::locale(), Config.ignore_leading_the)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
|
||||
"{%a - }{%t}|{%f}", [](std::string v) {
|
||||
return Format::parse(v, Format::Flags::Tag);
|
||||
});
|
||||
p.add("browser_sort_mode", &browser_sort_mode, "name", [](std::string v) {
|
||||
p.add("browser_sort_mode", &browser_sort_mode, "type", [](std::string v) {
|
||||
if (v == "noop")
|
||||
{
|
||||
deprecated("browser_sort_mode = 'noop'",
|
||||
|
||||
@@ -58,6 +58,9 @@ bool LocaleBasedItemSorting::operator()(const MPD::Item &a, const MPD::Item &b)
|
||||
{
|
||||
switch (m_sort_mode)
|
||||
{
|
||||
case SortMode::Type:
|
||||
result = a.type() > b.type();
|
||||
break;
|
||||
case SortMode::Name:
|
||||
switch (a.type())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user