diff --git a/fmusim-gui/MainWindow.cpp b/fmusim-gui/MainWindow.cpp index da8e7816..a25c394f 100644 --- a/fmusim-gui/MainWindow.cpp +++ b/fmusim-gui/MainWindow.cpp @@ -75,6 +75,15 @@ MainWindow::MainWindow(QWidget *parent) setColorScheme(QGuiApplication::styleHints()->colorScheme()); + // context menu + contextMenu = new QMenu(this); + + QAction* expandAllAction = contextMenu->addAction("Expand All"); + connect(expandAllAction, &QAction::triggered, ui->modelVariablesTreeView, &QTreeView::expandAll); + + QAction* collapseAllAction = contextMenu->addAction("Collapse All"); + connect(collapseAllAction, &QAction::triggered, ui->modelVariablesTreeView, &QTreeView::collapseAll); + // recent files QVBoxLayout* vbox = new QVBoxLayout(); @@ -177,6 +186,10 @@ MainWindow::MainWindow(QWidget *parent) ui->modelVariablesTreeView->setModel(modelVariablesTreeModel); + connect(ui->modelVariablesTreeView, &QTreeView::customContextMenuRequested, this, [this](const QPoint &pos) { + contextMenu->exec(ui->modelVariablesTreeView->mapToGlobal(pos)); + }); + // variable tool buttons connect(ui->filterLineEdit, &QLineEdit::textChanged, variablesFilterModel, &VariablesFilterModel::setFilterFixedString); connect(ui->filterParameterVariablesToolButton, &QToolButton::clicked, variablesFilterModel, &VariablesFilterModel::setFilterParamterVariables); diff --git a/fmusim-gui/MainWindow.h b/fmusim-gui/MainWindow.h index f6067ee7..0323aafe 100644 --- a/fmusim-gui/MainWindow.h +++ b/fmusim-gui/MainWindow.h @@ -7,6 +7,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Ui { @@ -48,6 +49,7 @@ class MainWindow : public QMainWindow QDoubleValidator *stopTimeValidator; QFileSystemModel filesModel; QComboBox* interfaceTypeComboBox; + QMenu* contextMenu; FMIModelDescription* modelDescription = nullptr; FMIBuildDescription* buildDescription = nullptr; QString unzipdir; @@ -80,5 +82,6 @@ private slots: void simulationFinished(); void buildPlatformBinary(); void showModelVariablesListView(bool show); + }; #endif // MAINWINDOW_H diff --git a/fmusim-gui/MainWindow.ui b/fmusim-gui/MainWindow.ui index c9bd5a85..a5817073 100644 --- a/fmusim-gui/MainWindow.ui +++ b/fmusim-gui/MainWindow.ui @@ -861,7 +861,7 @@ - 1 + 0 @@ -879,6 +879,9 @@ + + Qt::CustomContextMenu + QFrame::NoFrame