##// END OF EJS Templates
Parser refactoring (4)...
Parser refactoring (4) Implements results reading and data series creation Implementation takes some of the basic parser, which will be deleted at the end

File last commit:

r468:4682fc2670df
r947:6f8d3c2b5ba3
Show More
SqpSettingsDialog.cpp
66 lines | 1.9 KiB | text/x-c | CppLexer
/ gui / src / Settings / SqpSettingsDialog.cpp
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r463 #include "Settings/SqpSettingsDialog.h"
#include "ui_SqpSettingsDialog.h"
Alexandre Leroux
Settings binding (3)...
r468 namespace {
/**
* Performs a bind operation on widgets that can be binded to SciQlop settings
* @param widgets
* @param bind the bind operation
* @sa ISqpSettingsBindable
*/
template <typename BindMethod>
void processBind(const QStackedWidget &widgets, BindMethod bind)
{
auto count = widgets.count();
for (auto i = 0; i < count; ++i) {
// Performs operation if widget is an ISqpSettingsBindable
if (auto sqpSettingsWidget = dynamic_cast<ISqpSettingsBindable *>(widgets.widget(i))) {
bind(*sqpSettingsWidget);
}
}
}
} // namespace
Alexandre Leroux
Creates settings dialog and adds it to a new menu in MainWindow...
r463 SqpSettingsDialog::SqpSettingsDialog(QWidget *parent)
: QDialog{parent}, ui{new Ui::SqpSettingsDialog}
{
ui->setupUi(this);
// Connection to change the current page to the selection of an entry in the list
connect(ui->listWidget, &QListWidget::currentRowChanged, ui->stackedWidget,
&QStackedWidget::setCurrentIndex);
}
SqpSettingsDialog::~SqpSettingsDialog() noexcept
{
delete ui;
}
Alexandre Leroux
Settings binding (3)...
r468
void SqpSettingsDialog::loadSettings()
{
// Performs load on all widgets that can be binded to SciQlop settings
processBind(*ui->stackedWidget,
[](ISqpSettingsBindable &bindable) { bindable.loadSettings(); });
}
void SqpSettingsDialog::saveSettings() const
{
// Performs save on all widgets that can be binded to SciQlop settings
processBind(*ui->stackedWidget,
[](ISqpSettingsBindable &bindable) { bindable.saveSettings(); });
}
Alexandre Leroux
Implements method to register a widget in the dialog
r464 void SqpSettingsDialog::registerWidget(const QString &name, QWidget *widget) noexcept
{
auto newItem = new QListWidgetItem{ui->listWidget};
newItem->setText(name);
ui->stackedWidget->addWidget(widget);
// Selects widget if it's the first in the dialog
if (ui->listWidget->count() == 1) {
ui->listWidget->setCurrentItem(newItem);
}
}