mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-16 17:08:25 +02:00
Have Menu::readLinks() sort using orderLinks()
Previously, it sorted before Link instances were created. Using readLinks() ensures consistency and it might be more efficient if a significant number of link files are rejected. Also modernized the body of orderLinks() and removed unnecessary special case for 1-link sections.
This commit is contained in:
parent
3694deecf6
commit
e39447ee64
13
src/menu.cpp
13
src/menu.cpp
@ -822,13 +822,13 @@ static bool compare_links(Link *a, Link *b)
|
|||||||
|
|
||||||
void Menu::orderLinks()
|
void Menu::orderLinks()
|
||||||
{
|
{
|
||||||
for (std::vector< std::vector<Link *> >::iterator section = links.begin();
|
for (auto& section : links) {
|
||||||
section < links.end(); section++)
|
sort(section.begin(), section.end(), compare_links);
|
||||||
if (section->size() > 1)
|
}
|
||||||
std::sort(section->begin(), section->end(), compare_links);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::readLinks() {
|
void Menu::readLinks()
|
||||||
|
{
|
||||||
vector<string> linkfiles;
|
vector<string> linkfiles;
|
||||||
|
|
||||||
iLink = 0;
|
iLink = 0;
|
||||||
@ -846,7 +846,6 @@ void Menu::readLinks() {
|
|||||||
readLinksOfSection(GMenu2X::getHome() + "/sections/"
|
readLinksOfSection(GMenu2X::getHome() + "/sections/"
|
||||||
+ sections[correct], linkfiles);
|
+ sections[correct], linkfiles);
|
||||||
|
|
||||||
sort(linkfiles.begin(), linkfiles.end(),case_less());
|
|
||||||
for (auto const& linkfile : linkfiles) {
|
for (auto const& linkfile : linkfiles) {
|
||||||
// Check whether the link file could be deleted.
|
// Check whether the link file could be deleted.
|
||||||
bool deletable = access(parentDir(linkfile).c_str(), W_OK) == 0;
|
bool deletable = access(parentDir(linkfile).c_str(), W_OK) == 0;
|
||||||
@ -859,6 +858,8 @@ void Menu::readLinks() {
|
|||||||
delete link;
|
delete link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orderLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::renameSection(int index, const string &name) {
|
void Menu::renameSection(int index, const string &name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user