corrections for previous commit

This commit is contained in:
Andrzej Rybczak
2012-07-15 21:58:24 +02:00
parent 6c73c3cecf
commit 27a0dc958f
7 changed files with 74 additions and 42 deletions

View File

@@ -298,30 +298,36 @@ int CaseInsensitiveStringComparison::operator()(const std::string &a, const std:
bool CaseInsensitiveSorting::operator()(const MPD::Item &a, const MPD::Item &b)
{
bool result;
if (a.type == b.type)
{
switch (a.type)
{
case MPD::itDirectory:
return cmp(ExtractTopName(a.name), ExtractTopName(b.name)) < 0;
result = cmp(ExtractTopName(a.name), ExtractTopName(b.name)) < 0;
break;
case MPD::itPlaylist:
return cmp(a.name, b.name) < 0;
case MPD::itSong: {
unsigned mode = Config.sort_mode;
if (myBrowser->isLocal() && mode == 1) mode = 0; // local browser doesn't support sorting by mtime.
switch (mode) {
case 0: return operator()(a.song, b.song);
case 1: return a.song->GetMTime() > b.song->GetMTime();
case 2: return cmp(a.song->toString(Config.sort_format), b.song->toString(Config.sort_format)) < 0;
default: return 0; // no other mode.
result = cmp(a.name, b.name) < 0;
break;
case MPD::itSong:
switch (Config.browser_sort_mode)
{
case smName:
result = operator()(a.song, b.song);
break;
case smMTime:
result = a.song->GetMTime() > b.song->GetMTime();
break;
case smCustomFormat:
result = cmp(a.song->toString(Config.browser_sort_format), b.song->toString(Config.browser_sort_format)) < 0;
break;
}
}
default: // there's no other type, just silence compiler.
return 0;
break;
}
}
else
return a.type < b.type;
result = a.type < b.type;
return result;
}
std::string Timestamp(time_t t)