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
2424
2525 #include "Bookmarks.h"
2626
27−Bookmarks::Bookmarks() {
27+Bookmarks::Bookmarks() :
28+_isMenuSorted(false)
29+{
2830 }
2931
3032 void Bookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
@@ -113,18 +115,38 @@ bool Bookmarks::contains(const QString& name) const { · 82 unmodified lines
113115 }
114116
115117 bool Bookmarks::sortOrder(QAction* a, QAction* b) {
116− return a->text().toLower() < b->text().toLower();
118+ return a->text().toLower().localeAwareCompare(b->text().toLower()) < 0;
117119 }
118120
119−void Bookmarks::sortActions(MenuWrapper* menuWrapper) {
120− QList<QAction*> tmpActions = menuWrapper->actions();
121− qSort(tmpActions.begin(), tmpActions.end(), sortOrder);
121+// TODO: inconsistent naming?
122+void Bookmarks::sortActions(Menu* menubar, MenuWrapper* menuWrapper) {
123+ QList<QAction*> actions = menuWrapper->actions();
124+ qSort(actions.begin(), actions.end(), sortOrder);
122125 for (QAction* action : menuWrapper->actions()) {
123126 menuWrapper->removeAction(action);
127+ //removeBookmarkFromMenu(menubar, action->text());
124128 }
125− for (QAction* action : tmpActions) {
129+ for (QAction* action : actions) {
126130 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+// }
127136 }
137+ _isMenuSorted = true;
138+}
139+
140+int 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;
128150 }
129151
130152 QString Bookmarks::addressForBookmark(const QString& name) const {