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.
|
* 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`.
|
* 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)
|
# ncmpcpp-0.8.2 (2018-04-11)
|
||||||
* Help screen: fixed display of EoF keycode
|
* Help screen: fixed display of EoF keycode
|
||||||
|
|||||||
@@ -268,10 +268,10 @@
|
|||||||
## 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 "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)}
|
#browser_sort_format = {%a - }{%t}|{%f} {(%l)}
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -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 "none".
|
Determines sort mode for browser. Possible values are "type", "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".
|
||||||
|
|||||||
@@ -2261,6 +2261,9 @@ void ToggleBrowserSortMode::run()
|
|||||||
{
|
{
|
||||||
switch (Config.browser_sort_mode)
|
switch (Config.browser_sort_mode)
|
||||||
{
|
{
|
||||||
|
case SortMode::Type:
|
||||||
|
Config.browser_sort_mode = SortMode::Name;
|
||||||
|
Statusbar::print("Sort songs by: name");
|
||||||
case SortMode::Name:
|
case SortMode::Name:
|
||||||
Config.browser_sort_mode = SortMode::ModificationTime;
|
Config.browser_sort_mode = SortMode::ModificationTime;
|
||||||
Statusbar::print("Sort songs by: modification time");
|
Statusbar::print("Sort songs by: modification time");
|
||||||
@@ -2274,15 +2277,16 @@ void ToggleBrowserSortMode::run()
|
|||||||
Statusbar::print("Do not sort songs");
|
Statusbar::print("Do not sort songs");
|
||||||
break;
|
break;
|
||||||
case SortMode::None:
|
case SortMode::None:
|
||||||
Config.browser_sort_mode = SortMode::Name;
|
Config.browser_sort_mode = SortMode::Type;
|
||||||
Statusbar::print("Sort songs by: name");
|
Statusbar::print("Sort songs by: type");
|
||||||
}
|
}
|
||||||
if (Config.browser_sort_mode != SortMode::None)
|
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::stable_sort(
|
||||||
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode)
|
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)
|
switch (sm)
|
||||||
{
|
{
|
||||||
|
case SortMode::Type:
|
||||||
|
os << "type";
|
||||||
|
break;
|
||||||
case SortMode::Name:
|
case SortMode::Name:
|
||||||
os << "name";
|
os << "name";
|
||||||
break;
|
break;
|
||||||
@@ -98,7 +101,9 @@ std::istream &operator>>(std::istream &is, SortMode &sm)
|
|||||||
{
|
{
|
||||||
std::string ssm;
|
std::string ssm;
|
||||||
is >> ssm;
|
is >> ssm;
|
||||||
if (ssm == "name")
|
if (ssm == "type")
|
||||||
|
sm = SortMode::Type;
|
||||||
|
else if (ssm == "name")
|
||||||
sm = SortMode::Name;
|
sm = SortMode::Name;
|
||||||
else if (ssm == "mtime")
|
else if (ssm == "mtime")
|
||||||
sm = SortMode::ModificationTime;
|
sm = SortMode::ModificationTime;
|
||||||
|
|||||||
@@ -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, None };
|
enum class SortMode { Type, 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);
|
||||||
|
|
||||||
|
|||||||
@@ -500,8 +500,10 @@ void Browser::getDirectory(std::string directory)
|
|||||||
|
|
||||||
if (Config.browser_sort_mode != SortMode::None)
|
if (Config.browser_sort_mode != SortMode::None)
|
||||||
{
|
{
|
||||||
std::sort(w.begin() + (is_root ? 0 : 1), w.end(),
|
std::stable_sort(
|
||||||
LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode));
|
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)
|
if (Config.browser_sort_mode != SortMode::None)
|
||||||
{
|
{
|
||||||
std::sort(songs.begin()+sort_offset, songs.end(),
|
std::stable_sort(songs.begin()+sort_offset, songs.end(),
|
||||||
LocaleBasedSorting(std::locale(), Config.ignore_leading_the)
|
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) {
|
"{%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", [](std::string v) {
|
p.add("browser_sort_mode", &browser_sort_mode, "type", [](std::string v) {
|
||||||
if (v == "noop")
|
if (v == "noop")
|
||||||
{
|
{
|
||||||
deprecated("browser_sort_mode = '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)
|
switch (m_sort_mode)
|
||||||
{
|
{
|
||||||
|
case SortMode::Type:
|
||||||
|
result = a.type() > b.type();
|
||||||
|
break;
|
||||||
case SortMode::Name:
|
case SortMode::Name:
|
||||||
switch (a.type())
|
switch (a.type())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user