History

check-in after menu experiments

https://highfidelity.fogbugz.com/f/cases/3714

Triplelexx committed 9 years ago

Commit 255e7811 parent 07e6b764 files · +58 −13Browse files

Showing the changes to interface/src/Bookmarks.cpp (1 of 4 files). Show all

Unified · Split

interface/src/Bookmarks.cpp+28−6
@@ -24,7 +24,9 @@ · 23 unmodified lines
24 24
25#include "Bookmarks.h"25#include "Bookmarks.h"
26 26
27Bookmarks::Bookmarks() {27Bookmarks::Bookmarks() :
28_isMenuSorted(false)
29{
28}30}
29 31
30void Bookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {32void Bookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
@@ -113,18 +115,38 @@ bool Bookmarks::contains(const QString& name) const { · 82 unmodified lines
113}115}
114 116
115bool Bookmarks::sortOrder(QAction* a, QAction* b) {117bool Bookmarks::sortOrder(QAction* a, QAction* b) {
116 return a->text().toLower() < b->text().toLower();118 return a->text().toLower().localeAwareCompare(b->text().toLower()) < 0;
117}119}
118 120
119void Bookmarks::sortActions(MenuWrapper* menuWrapper) {121// TODO: inconsistent naming?
120 QList<QAction*> tmpActions = menuWrapper->actions();122void Bookmarks::sortActions(Menu* menubar, MenuWrapper* menuWrapper) {
121 qSort(tmpActions.begin(), tmpActions.end(), sortOrder);123 QList<QAction*> actions = menuWrapper->actions();
124 qSort(actions.begin(), actions.end(), sortOrder);
122 for (QAction* action : menuWrapper->actions()) {125 for (QAction* action : menuWrapper->actions()) {
123 menuWrapper->removeAction(action);126 menuWrapper->removeAction(action);
127 //removeBookmarkFromMenu(menubar, action->text());
124 }128 }
125 for (QAction* action : tmpActions) {129 for (QAction* action : actions) {
126 menuWrapper->addAction(action);130 menuWrapper->addAction(action);
131// for (int i = 0; i < _bookmarks.size() ; i++) {
132// if (_bookmarks.keys().at(i) == action->text()) {
133// addBookmarkToMenu(menubar, action->text(), _bookmarks.values().at(i).toString());
134// }
135// }
127 }136 }
137 _isMenuSorted = true;
138}
139
140int Bookmarks::getMenuItemLocation(QList<QAction*> actions, const QString& name) const {
141 int menuItemLocation = 0;
142 for (QAction* action : actions) {
143 if (name.toLower().localeAwareCompare(action->text().toLower()) < 0) {
144 menuItemLocation = actions.indexOf(action);
145 break;
146
147 }
148 }
149 return menuItemLocation;
128}150}
129 151
130QString Bookmarks::addressForBookmark(const QString& name) const {152QString Bookmarks::addressForBookmark(const QString& name) const {