From e9ef53ed74506d8b630870b906cd5e2cd74141b4 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 3 Jul 2019 10:23:53 +0200 Subject: [PATCH] WIP --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index fa1c8c846e3..04f414ac1f0 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -384,13 +384,13 @@ MainWindow::MainWindow(const QStringList &keywords, bool verbose, QWidget* paren } //Recursive function that do a pass over a menu and its sub-menus(etc.) and hide them when they are empty -void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here) +void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here, QAction* searchAction) { QList buffer; Q_FOREACH(QAction* action, menu->actions()) buffer.append(action); + while(!buffer.isEmpty()){ - Q_FOREACH(QAction* action, buffer) { if(QMenu* submenu = action->menu()) { @@ -410,7 +410,7 @@ void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here) menu->addAction(submenu->menuAction()); } } - filterMenuOperations(submenu, filter, keep); + filterMenuOperations(submenu, filter, keep, searchAction); action->setVisible(!(submenu->isEmpty())); } @@ -420,6 +420,7 @@ void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here) buffer.removeAll(action); } } + QList sorted_actions; for(QAction* action : menu->actions()) { @@ -437,11 +438,9 @@ void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here) ++i; bool res = (atxt[i] < btxt[i]); return res; - }); - menu->clear(); + menu->addActions(sorted_actions); - qDebug()<menuAction()->text()<<" sorted."; } void MainWindow::filterOperations() @@ -470,7 +469,7 @@ void MainWindow::filterOperations() } } // do a pass over all menus in Operations and their sub-menus(etc.) and hide them when they are empty - filterMenuOperations(ui->menuOperations, filter, false); + filterMenuOperations(ui->menuOperations, filter, false, searchAction); operationSearchBar.setFocus(); }