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