##// END OF EJS Templates
Connects variable widget to visualization widget...
Connects variable widget to visualization widget The connection is used to populate variable menu with the plot menu

File last commit:

r247:96c4c8973e0c
r249:3d1d1572319d
Show More
VariableInspectorWidget.cpp
50 lines | 1.6 KiB | text/x-c | CppLexer
/ gui / src / Variable / VariableInspectorWidget.cpp
Alexandre Leroux
Affects model to the Variable Widget
r152 #include <Variable/VariableController.h>
Alexandre Leroux
Initializes the variable inspector and adds it to the MainWindow
r110 #include <Variable/VariableInspectorWidget.h>
Alexandre Leroux
Affects model to the Variable Widget
r152 #include <Variable/VariableModel.h>
Alexandre Leroux
Initializes the variable inspector and adds it to the MainWindow
r110
#include <ui_VariableInspectorWidget.h>
Alexandre Leroux
Affects model to the Variable Widget
r152 #include <QSortFilterProxyModel>
#include <SqpApplication.h>
Alexandre Leroux
Initializes the variable inspector and adds it to the MainWindow
r110 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
: QWidget{parent}, ui{new Ui::VariableInspectorWidget}
{
ui->setupUi(this);
Alexandre Leroux
Affects model to the Variable Widget
r152
// Sets model for table
auto sortFilterModel = new QSortFilterProxyModel{this};
sortFilterModel->setSourceModel(sqpApp->variableController().variableModel());
ui->tableView->setModel(sortFilterModel);
Alexandre Leroux
Activates menu on variable widget
r245
// Connection to show a menu when right clicking on the tree
ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->tableView, &QTableView::customContextMenuRequested, this,
&VariableInspectorWidget::onTableMenuRequested);
Alexandre Leroux
Initializes the variable inspector and adds it to the MainWindow
r110 }
VariableInspectorWidget::~VariableInspectorWidget()
{
delete ui;
}
Alexandre Leroux
Activates menu on variable widget
r245
void VariableInspectorWidget::onTableMenuRequested(const QPoint &pos) noexcept
{
Alexandre Leroux
Retrieves the current selected variable when clicking on the variable widget
r246 auto selectedIndex = ui->tableView->indexAt(pos);
if (selectedIndex.isValid()) {
// Gets the model to retrieve the underlying selected variable
auto model = sqpApp->variableController().variableModel();
if (auto selectedVariable = model->variable(selectedIndex.row())) {
QMenu tableMenu{};
Alexandre Leroux
Creates signal to make dynmaic menu for a variable
r247 // Emit a signal so that potential receivers can populate the menu before displaying it
emit tableMenuAboutToBeDisplayed(&tableMenu, selectedVariable);
Alexandre Leroux
Retrieves the current selected variable when clicking on the variable widget
r246
if (!tableMenu.isEmpty()) {
tableMenu.exec(mapToGlobal(pos));
}
}
}
Alexandre Leroux
Activates menu on variable widget
r245 }