browser: make sorting optional

This adds a new option, "noop", to browser_sort_mode. If this mode
is selected, no sorting is done in the browser view, and the elements
are shown in the same order as received from the MPD server.
This commit is contained in:
Trygve Aaberge
2014-08-29 17:10:40 +02:00
committed by Andrzej Rybczak
parent 49f53c07bb
commit 9e8dc741e5
7 changed files with 29 additions and 13 deletions

View File

@@ -437,9 +437,10 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
# else
list = Mpd.GetDirectory(dir);
# endif // !WIN32
if (!isLocal()) // local directory is already sorted
if (Config.browser_sort_mode != SortMode::NoOp && !isLocal()) // local directory is already sorted
std::sort(list.begin(), list.end(),
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode));
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode)
);
for (MPD::ItemList::iterator it = list.begin(); it != list.end(); ++it)
{
@@ -517,8 +518,10 @@ void Browser::GetLocalDirectory(MPD::ItemList &v, const std::string &directory,
}
});
std::sort(v.begin()+start_size, v.end(), LocaleBasedItemSorting(std::locale(),
Config.ignore_leading_the, Config.browser_sort_mode));
if (Config.browser_sort_mode != SortMode::NoOp)
std::sort(v.begin()+start_size, v.end(),
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode)
);
}
void Browser::ClearDirectory(const std::string &path) const