Skip to content

Commit

Permalink
Add "Expand All" and "Collapse All" actions (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer authored Aug 14, 2024
1 parent 16f3fa8 commit 14ea739
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions fmusim-gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions fmusim-gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QComboBox>
#include <QFileSystemModel>
#include <QMap>
#include <QMenu>

QT_BEGIN_NAMESPACE
namespace Ui {
Expand Down Expand Up @@ -48,6 +49,7 @@ class MainWindow : public QMainWindow
QDoubleValidator *stopTimeValidator;
QFileSystemModel filesModel;
QComboBox* interfaceTypeComboBox;
QMenu* contextMenu;
FMIModelDescription* modelDescription = nullptr;
FMIBuildDescription* buildDescription = nullptr;
QString unzipdir;
Expand Down Expand Up @@ -80,5 +82,6 @@ private slots:
void simulationFinished();
void buildPlatformBinary();
void showModelVariablesListView(bool show);

};
#endif // MAINWINDOW_H
5 changes: 4 additions & 1 deletion fmusim-gui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@
<item row="1" column="0">
<widget class="QStackedWidget" name="modelVariablesStackedWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="treeViewPage">
<layout class="QGridLayout" name="gridLayout_17">
Expand All @@ -879,6 +879,9 @@
</property>
<item row="0" column="0">
<widget class="QTreeView" name="modelVariablesTreeView">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
Expand Down

0 comments on commit 14ea739

Please sign in to comment.