use vector<string_pair> instead of map<string, string>
This commit is contained in:
@@ -180,6 +180,15 @@ bool CaseInsensitiveSorting::operator()(string a, string b)
|
||||
return a < b;
|
||||
}
|
||||
|
||||
bool CaseInsensitiveSorting::operator()(const string_pair &a, const string_pair &b)
|
||||
{
|
||||
string aa = a.first;
|
||||
string bb = b.first;
|
||||
ToLower(aa);
|
||||
ToLower(bb);
|
||||
return aa < bb;
|
||||
}
|
||||
|
||||
bool CaseInsensitiveSorting::operator()(Song *sa, Song *sb)
|
||||
{
|
||||
string a = sa->GetName();
|
||||
|
||||
@@ -32,6 +32,7 @@ class CaseInsensitiveSorting
|
||||
{
|
||||
public:
|
||||
bool operator()(std::string, std::string);
|
||||
bool operator()(const string_pair &, const string_pair &);
|
||||
bool operator()(MPD::Song *, MPD::Song *);
|
||||
bool operator()(const MPD::Item &, const MPD::Item &);
|
||||
};
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
#include "charset.h"
|
||||
#include "display.h"
|
||||
@@ -148,7 +147,7 @@ void MediaLibrary::Update()
|
||||
{
|
||||
Albums->Reset();
|
||||
TagList list;
|
||||
std::map<string, string, CaseInsensitiveSorting> maplist;
|
||||
std::vector<string_pair> maplist;
|
||||
locale_to_utf(Artists->Current());
|
||||
if (Config.media_lib_primary_tag == MPD_TAG_ITEM_ARTIST)
|
||||
Mpd->GetAlbums(Artists->Current(), list);
|
||||
@@ -184,13 +183,14 @@ void MediaLibrary::Update()
|
||||
{
|
||||
utf_to_locale(*it);
|
||||
l[0]->Localize();
|
||||
maplist[l[0]->toString(Config.media_lib_album_format)] = *it;
|
||||
maplist.push_back(make_pair(l[0]->toString(Config.media_lib_album_format), *it));
|
||||
}
|
||||
FreeSongList(l);
|
||||
}
|
||||
utf_to_locale(Artists->Current());
|
||||
for (std::map<string, string>::const_iterator it = maplist.begin(); it != maplist.end(); it++)
|
||||
Albums->AddOption(make_pair(it->first, it->second));
|
||||
sort(maplist.begin(), maplist.end(), CaseInsensitiveSorting());
|
||||
for (std::vector<string_pair>::const_iterator it = maplist.begin(); it != maplist.end(); it++)
|
||||
Albums->AddOption(*it);
|
||||
Albums->Window::Clear();
|
||||
Albums->Refresh();
|
||||
}
|
||||
|
||||
@@ -408,7 +408,7 @@ void TagEditor::Update()
|
||||
TagList list;
|
||||
if (Config.albums_in_tag_editor)
|
||||
{
|
||||
std::map<string, string, CaseInsensitiveSorting> maplist;
|
||||
std::vector<string_pair> maplist;
|
||||
*Albums << XY(0, 0) << "Fetching albums' list..." << wrefresh;
|
||||
Mpd->GetAlbums("", list);
|
||||
for (TagList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
@@ -420,12 +420,13 @@ void TagEditor::Update()
|
||||
if (!l.empty())
|
||||
{
|
||||
l[0]->Localize();
|
||||
maplist[l[0]->toString(Config.tag_editor_album_format)] = *it;
|
||||
maplist.push_back(make_pair(l[0]->toString(Config.tag_editor_album_format), *it));
|
||||
}
|
||||
FreeSongList(l);
|
||||
}
|
||||
for (std::map<string, string>::const_iterator it = maplist.begin(); it != maplist.end(); it++)
|
||||
Albums->AddOption(make_pair(it->first, it->second));
|
||||
sort(maplist.begin(), maplist.end(), CaseInsensitiveSorting());
|
||||
for (std::vector<string_pair>::const_iterator it = maplist.begin(); it != maplist.end(); it++)
|
||||
Albums->AddOption(*it);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user