Add type value of browser_sort_mode (set by default)
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
* Do not loop after sending a database update command to Mopidy.
|
||||
* Deprecate `visualizer_sync_interval` configuration option.
|
||||
* Deprecate `noop` value of `browser_sort_mode` in favor of `none`.
|
||||
* Add `type` value of `browser_sort_mode` (set by default).
|
||||
|
||||
# ncmpcpp-0.8.2 (2018-04-11)
|
||||
* Help screen: fixed display of EoF keycode
|
||||
|
||||
@@ -268,10 +268,10 @@
|
||||
## Note: Below variables are used for sorting songs in browser. The sort mode
|
||||
## determines how songs are sorted, and can be used in combination with a sort
|
||||
## format to specify a custom sorting format. Available values for
|
||||
## browser_sort_mode are "name", "mtime", "format" and "none".
|
||||
## browser_sort_mode are "type", "name", "mtime", "format" and "none".
|
||||
##
|
||||
#
|
||||
#browser_sort_mode = name
|
||||
#browser_sort_mode = type
|
||||
#
|
||||
#browser_sort_format = {%a - }{%t}|{%f} {(%l)}
|
||||
#
|
||||
|
||||
@@ -173,7 +173,7 @@ Suffix for selected items.
|
||||
Prefix for modified item (tag editor).
|
||||
.TP
|
||||
.B browser_sort_mode
|
||||
Determines sort mode for browser. Possible values are "name", "mtime", "format" and "none".
|
||||
Determines sort mode for browser. Possible values are "type", "name", "mtime", "format" and "none".
|
||||
.TP
|
||||
.B browser_sort_format
|
||||
Format to use for sorting songs in browser. For this option to be effective, browser_sort_mode must be set to "format".
|
||||
|
||||
@@ -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