Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Expand All" and "Collapse All" actions #558

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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