make sorting items in browser case insensitive

This commit is contained in:
unknown
2008-08-18 20:40:09 +02:00
parent 6761de44f8
commit b43e3577f2
3 changed files with 19 additions and 1 deletions

View File

@@ -554,6 +554,20 @@ bool GetSongInfo(Song &s)
return true;
}
bool SortDirectory(const Item &a, const Item &b)
{
if (a.type == b.type)
{
string sa = a.type == itSong ? a.song->GetShortFilename() : a.name;
string sb = b.type == itSong ? b.song->GetShortFilename() : b.name;
transform(sa.begin(), sa.end(), sa.begin(), tolower);
transform(sb.begin(), sb.end(), sb.begin(), tolower);
return sa < sb;
}
else
return a.type < b.type;
}
void GetDirectory(string dir)
{
int highlightme = -1;
@@ -571,6 +585,9 @@ void GetDirectory(string dir)
vBrowser.push_back(parent);
}
Mpd->GetDirectory(dir, vBrowser);
sort(vBrowser.begin(), vBrowser.end(), SortDirectory);
for (ItemList::iterator it = vBrowser.begin()+(dir != "/" ? 1 : 0); it != vBrowser.end(); it++)
{
switch (it->type)

View File

@@ -36,6 +36,7 @@ void WindowTitle(const string &);
string TotalPlaylistLength();
string DisplaySong(const Song &, const string & = Config.song_list_format);
void ShowMessage(const string &, int = Config.message_delay_time);
bool SortDirectory(const Item &a, const Item &b);
void GetDirectory(string);
bool GetSongInfo(Song &);
void PrepareSearchEngine(Song &s);

View File

@@ -25,7 +25,7 @@
#include "song.h"
enum QueueCommandType { qctAdd, qctDelete, qctDeleteID };
enum ItemType { itSong, itDirectory, itPlaylist };
enum ItemType { itDirectory, itSong, itPlaylist };
enum PlayerState { psUnknown, psStop, psPlay, psPause };
struct MPDStatusChanges