From bcb3e98ddc308016137ba14dec08d386810125b9 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Thu, 18 Jul 2013 17:38:09 -0400 Subject: [PATCH] Order the links in alphabetical order --- src/menu.cpp | 15 +++++++++++++++ src/menu.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/menu.cpp b/src/menu.cpp index a9519a2..46ff483 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -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 &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 >::iterator section = links.begin(); + section < links.end(); section++) + std::sort(section->begin(), section->end(), compare_links); +} + void Menu::readLinks() { vector linkfiles; diff --git a/src/menu.h b/src/menu.h index 25db0a7..908f257 100644 --- a/src/menu.h +++ b/src/menu.h @@ -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);