diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2012-08-14 23:55:01 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2012-08-14 23:56:39 +0200 |
commit | e729ab0a38b9052504854950189ca49e352eb63b (patch) | |
tree | c11bc6aa1eca7abecc8785d21bc40e5a53568f35 /src/playlist.h | |
parent | b7999b499f8e7709e33f1cac36335b2aadf0223f (diff) |
playlist: rewrite sorting so it's much less cryptic
Diffstat (limited to 'src/playlist.h')
-rw-r--r-- | src/playlist.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/playlist.h b/src/playlist.h index d08f7b86..9d634f9d 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -105,7 +105,21 @@ class Playlist : public Screen<Window> time_t itsTimer; - static bool Sorting(MPD::Song *a, MPD::Song *b); + // stuff for sorting playlist + static void QuickSort(MPD::SongList::iterator first, MPD::SongList::iterator last, MPD::SongList::iterator begin); + inline static void IterSwap(MPD::SongList::iterator a, MPD::SongList::iterator b, MPD::SongList::iterator begin) + { + iter_swap(a, b); + Mpd.Swap(a-begin, b-begin); + } + inline static bool SongComp(MPD::Song *a, MPD::Song *b) + { + CaseInsensitiveStringComparison cmp; + for (size_t i = 0; i < SortOptions; ++i) + if (int ret = cmp(a->GetTags((*SortDialog)[i].second), b->GetTags((*SortDialog)[i].second))) + return ret < 0; + return a->GetPosition() < b->GetPosition(); + } static Menu< std::pair<std::string, MPD::Song::GetFunction> > *SortDialog; static const size_t SortOptions; |