make sorting items in browser case insensitive

master
unknown 18 years ago
parent 6761de44f8
commit b43e3577f2
  1. 17
      src/helpers.cpp
  2. 1
      src/helpers.h
  3. 2
      src/mpdpp.h

@ -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)

@ -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);

@ -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

Loading…
Cancel
Save