diff options
-rw-r--r-- | doc/config | 3 | ||||
-rw-r--r-- | doc/ncmpcpp.1 | 2 | ||||
-rw-r--r-- | src/actions.cpp | 17 | ||||
-rw-r--r-- | src/browser.cpp | 11 | ||||
-rw-r--r-- | src/enums.cpp | 5 | ||||
-rw-r--r-- | src/enums.h | 2 | ||||
-rw-r--r-- | src/utility/comparators.cpp | 2 |
7 files changed, 29 insertions, 13 deletions
@@ -183,7 +183,8 @@ ## 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" and "format". +## Available values for browser_sort_mode are "name", "mtime", "format" +## and "noop". ## # #browser_sort_mode = name diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 65f5b5b7..5bc2ddd5 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -109,7 +109,7 @@ Format for albums' list in Tag editor. Song format for window title. .TP .B browser_sort_mode -Determines sort mode for browser. Possible values are "name", "mtime" and "format". +Determines sort mode for browser. Possible values are "name", "mtime", "format" and "noop". .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". diff --git a/src/actions.cpp b/src/actions.cpp index df807209..3a96af2f 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -2060,19 +2060,24 @@ void ToggleBrowserSortMode::run() { case SortMode::Name: Config.browser_sort_mode = SortMode::ModificationTime; - Statusbar::print("Sort songs by: Modification time"); + Statusbar::print("Sort songs by: modification time"); break; case SortMode::ModificationTime: Config.browser_sort_mode = SortMode::CustomFormat; - Statusbar::print("Sort songs by: Custom format"); + Statusbar::print("Sort songs by: custom format"); break; case SortMode::CustomFormat: - Config.browser_sort_mode = SortMode::Name; - Statusbar::print("Sort songs by: Name"); + Config.browser_sort_mode = SortMode::NoOp; + Statusbar::print("Do not sort songs"); break; + case SortMode::NoOp: + Config.browser_sort_mode = SortMode::Name; + Statusbar::print("Sort songs by: name"); } - std::sort(myBrowser->main().begin()+(myBrowser->CurrentDir() != "/"), myBrowser->main().end(), - LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode)); + if (Config.browser_sort_mode != SortMode::NoOp) + std::sort(myBrowser->main().begin()+(myBrowser->CurrentDir() != "/"), myBrowser->main().end(), + LocaleBasedItemSorting(std::locale(), Config.ignore_leading_the, Config.browser_sort_mode) + ); } bool ToggleLibraryTagType::canBeRun() const diff --git a/src/browser.cpp b/src/browser.cpp index 0841761f..366644b0 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -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 diff --git a/src/enums.cpp b/src/enums.cpp index b18fb36e..4e37a074 100644 --- a/src/enums.cpp +++ b/src/enums.cpp @@ -60,6 +60,9 @@ std::ostream &operator<<(std::ostream &os, SortMode sm) case SortMode::CustomFormat: os << "format"; break; + case SortMode::NoOp: + os << "noop"; + break; } return os; } @@ -74,6 +77,8 @@ std::istream &operator>>(std::istream &is, SortMode &sm) sm = SortMode::ModificationTime; else if (ssm == "format") sm = SortMode::CustomFormat; + else if (ssm == "noop") + sm = SortMode::NoOp; else is.setstate(std::ios::failbit); return is; diff --git a/src/enums.h b/src/enums.h index 4fcdcb4e..11dd13c9 100644 --- a/src/enums.h +++ b/src/enums.h @@ -27,7 +27,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 }; +enum class SortMode { Name, ModificationTime, CustomFormat, NoOp }; std::ostream &operator<<(std::ostream &os, SortMode sm); std::istream &operator>>(std::istream &is, SortMode &sm); diff --git a/src/utility/comparators.cpp b/src/utility/comparators.cpp index 35c5673d..9dd90fa3 100644 --- a/src/utility/comparators.cpp +++ b/src/utility/comparators.cpp @@ -78,6 +78,8 @@ bool LocaleBasedItemSorting::operator()(const MPD::Item &a, const MPD::Item &b) result = m_cmp(a.song->toString(Config.browser_sort_format, Config.tags_separator), b.song->toString(Config.browser_sort_format, Config.tags_separator)); break; + case SortMode::NoOp: + throw std::logic_error("can't sort with NoOp sorting mode"); } break; } |