1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 18:32:20 +03:00

Order the links in alphabetical order

This commit is contained in:
Paul Cercueil 2013-07-18 17:38:09 -04:00
parent 9029deceeb
commit bcb3e98ddc
2 changed files with 16 additions and 0 deletions

View File

@ -76,6 +76,8 @@ Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
}
}
#endif
orderLinks();
}
Menu::~Menu() {
@ -501,6 +503,7 @@ void Menu::openPackage(std::string path)
}
opk_close(opk);
orderLinks();
}
void Menu::readPackages(std::string parentDir)
@ -586,6 +589,18 @@ void Menu::readLinksOfSection(std::string path, std::vector<std::string> &linkfi
closedir(dirp);
}
static bool compare_links(Link *a, Link *b)
{
return a->getTitle().compare(b->getTitle()) <= 0;
}
void Menu::orderLinks()
{
for (std::vector< std::vector<Link *> >::iterator section = links.begin();
section < links.end(); section++)
std::sort(section->begin(), section->end(), compare_links);
}
void Menu::readLinks() {
vector<string> linkfiles;

View File

@ -46,6 +46,7 @@ private:
void readLinks();
void freeLinks();
void orderLinks();
// Load all the sections of the given "sections" directory.
void readSections(std::string parentDir);