Deprecate 'noop' value of browser_sort_mode in favor of 'none'.

This commit is contained in:
Andrzej Rybczak
2020-12-19 16:17:45 +01:00
parent 17c950cc57
commit 3c7ce95aaa
9 changed files with 25 additions and 15 deletions

View File

@@ -29,6 +29,7 @@
* Don't run volume changing actions if there is no mixer. * Don't run volume changing actions if there is no mixer.
* Do not loop after sending a database update command to Mopidy. * Do not loop after sending a database update command to Mopidy.
* Deprecate `visualizer_sync_interval` configuration option. * Deprecate `visualizer_sync_interval` configuration option.
* Deprecate `noop` value of `browser_sort_mode` in favor of `none`.
# ncmpcpp-0.8.2 (2018-04-11) # ncmpcpp-0.8.2 (2018-04-11)
* Help screen: fixed display of EoF keycode * Help screen: fixed display of EoF keycode

View File

@@ -268,7 +268,7 @@
## Note: Below variables are used for sorting songs in browser. The sort mode ## 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 ## determines how songs are sorted, and can be used in combination with a sort
## format to specify a custom sorting format. Available values for ## format to specify a custom sorting format. Available values for
## browser_sort_mode are "name", "mtime", "format" and "noop". ## browser_sort_mode are "name", "mtime", "format" and "none".
## ##
# #
#browser_sort_mode = name #browser_sort_mode = name

View File

@@ -173,7 +173,7 @@ Suffix for selected items.
Prefix for modified item (tag editor). Prefix for modified item (tag editor).
.TP .TP
.B browser_sort_mode .B browser_sort_mode
Determines sort mode for browser. Possible values are "name", "mtime", "format" and "noop". Determines sort mode for browser. Possible values are "name", "mtime", "format" and "none".
.TP .TP
.B browser_sort_format .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". Format to use for sorting songs in browser. For this option to be effective, browser_sort_mode must be set to "format".

View File

@@ -2270,14 +2270,14 @@ void ToggleBrowserSortMode::run()
Statusbar::print("Sort songs by: custom format"); Statusbar::print("Sort songs by: custom format");
break; break;
case SortMode::CustomFormat: case SortMode::CustomFormat:
Config.browser_sort_mode = SortMode::NoOp; Config.browser_sort_mode = SortMode::None;
Statusbar::print("Do not sort songs"); Statusbar::print("Do not sort songs");
break; break;
case SortMode::NoOp: case SortMode::None:
Config.browser_sort_mode = SortMode::Name; Config.browser_sort_mode = SortMode::Name;
Statusbar::print("Sort songs by: name"); Statusbar::print("Sort songs by: name");
} }
if (Config.browser_sort_mode != SortMode::NoOp) if (Config.browser_sort_mode != SortMode::None)
{ {
size_t sort_offset = myBrowser->inRootDirectory() ? 0 : 1; size_t sort_offset = myBrowser->inRootDirectory() ? 0 : 1;
std::sort(myBrowser->main().begin()+sort_offset, myBrowser->main().end(), std::sort(myBrowser->main().begin()+sort_offset, myBrowser->main().end(),

View File

@@ -87,8 +87,8 @@ std::ostream &operator<<(std::ostream &os, SortMode sm)
case SortMode::CustomFormat: case SortMode::CustomFormat:
os << "format"; os << "format";
break; break;
case SortMode::NoOp: case SortMode::None:
os << "noop"; os << "none";
break; break;
} }
return os; return os;
@@ -104,8 +104,8 @@ std::istream &operator>>(std::istream &is, SortMode &sm)
sm = SortMode::ModificationTime; sm = SortMode::ModificationTime;
else if (ssm == "format") else if (ssm == "format")
sm = SortMode::CustomFormat; sm = SortMode::CustomFormat;
else if (ssm == "noop") else if (ssm == "none")
sm = SortMode::NoOp; sm = SortMode::None;
else else
is.setstate(std::ios::failbit); is.setstate(std::ios::failbit);
return is; return is;

View File

@@ -32,7 +32,7 @@ enum class SpaceAddMode { AddRemove, AlwaysAdd };
std::ostream &operator<<(std::ostream &os, SpaceAddMode sam); std::ostream &operator<<(std::ostream &os, SpaceAddMode sam);
std::istream &operator>>(std::istream &is, SpaceAddMode &sam); std::istream &operator>>(std::istream &is, SpaceAddMode &sam);
enum class SortMode { Name, ModificationTime, CustomFormat, NoOp }; enum class SortMode { Name, ModificationTime, CustomFormat, None };
std::ostream &operator<<(std::ostream &os, SortMode sm); std::ostream &operator<<(std::ostream &os, SortMode sm);
std::istream &operator>>(std::istream &is, SortMode &sm); std::istream &operator>>(std::istream &is, SortMode &sm);

View File

@@ -498,7 +498,7 @@ void Browser::getDirectory(std::string directory)
w.addItem(std::move(*dir)); w.addItem(std::move(*dir));
} }
if (Config.browser_sort_mode != SortMode::NoOp) if (Config.browser_sort_mode != SortMode::None)
{ {
std::sort(w.begin() + (is_root ? 0 : 1), w.end(), std::sort(w.begin() + (is_root ? 0 : 1), w.end(),
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode)); LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode));
@@ -679,7 +679,7 @@ void getLocalDirectoryRecursively(std::vector<MPD::Song> &songs, const std::stri
songs.push_back(getLocalSong(*entry, false)); songs.push_back(getLocalSong(*entry, false));
}; };
if (Config.browser_sort_mode != SortMode::NoOp) if (Config.browser_sort_mode != SortMode::None)
{ {
std::sort(songs.begin()+sort_offset, songs.end(), std::sort(songs.begin()+sort_offset, songs.end(),
LocaleBasedSorting(std::locale(), Config.ignore_leading_the) LocaleBasedSorting(std::locale(), Config.ignore_leading_the)

View File

@@ -387,7 +387,16 @@ bool Configuration::read(const std::vector<std::string> &config_paths, bool igno
"{%a - }{%t}|{%f}", [](std::string v) { "{%a - }{%t}|{%f}", [](std::string v) {
return Format::parse(v, Format::Flags::Tag); return Format::parse(v, Format::Flags::Tag);
}); });
p.add("browser_sort_mode", &browser_sort_mode, "name"); p.add("browser_sort_mode", &browser_sort_mode, "name", [](std::string v) {
if (v == "noop")
{
deprecated("browser_sort_mode = 'noop'",
"0.10",
"use 'none' instead");
v = "none";
}
return verbose_lexical_cast<SortMode>(v);
});
p.add("browser_sort_format", &browser_sort_format, p.add("browser_sort_format", &browser_sort_format,
"{%a - }{%t}|{%f} {(%l)}", [](std::string v) { "{%a - }{%t}|{%f} {(%l)}", [](std::string v) {
return Format::parse(v, Format::Flags::Tag); return Format::parse(v, Format::Flags::Tag);

View File

@@ -101,8 +101,8 @@ bool LocaleBasedItemSorting::operator()(const MPD::Item &a, const MPD::Item &b)
break; break;
} }
break; break;
case SortMode::NoOp: case SortMode::None:
throw std::logic_error("can't sort with NoOp sorting mode"); throw std::logic_error("can't sort with None sorting mode");
} }
} }
else else