more work on smart pointer transition of musrStep.

This commit is contained in:
suter_a 2023-10-22 11:00:24 +02:00
parent 7743eaee09
commit 3d7d86d657
2 changed files with 60 additions and 57 deletions

View File

@ -55,27 +55,27 @@ PModSelect::PModSelect(QWidget *parent) :
{
setWindowTitle("Modify Selected");
fScaleByFactor = new QPushButton("Scale by &Factor");
fScaleByFactor = std::make_unique<QPushButton>("Scale by &Factor");
fScaleByFactor->setWhatsThis("if pressed it will use the Factor value, and the absolut value selection to change the selected parameter steps.");
fFactorLabel = new QLabel("Factor");
fFactorLineEdit = new QLineEdit("0.01");
fFactorLabel = std::make_unique<QLabel>("Factor");
fFactorLineEdit = std::make_unique<QLineEdit>("0.01");
fFactorLineEdit->setValidator(new QDoubleValidator);
fAbsVal = new QCheckBox("Absolute Value");
fAbsVal = std::make_unique<QCheckBox>("Absolute Value");
fAbsVal->setWhatsThis("if checked, the factor is used as an absolut value rather than a multiplication factor for the selected steps.");
QHBoxLayout *top = new QHBoxLayout;
top->addWidget(fScaleByFactor);
top->addWidget(fFactorLabel);
top->addWidget(fFactorLineEdit);
top->addWidget(fAbsVal);
top->addWidget(fScaleByFactor.get());
top->addWidget(fFactorLabel.get());
top->addWidget(fFactorLineEdit.get());
top->addWidget(fAbsVal.get());
fScaleAutomatic = new QPushButton("Scale &Automatically");
fScaleAutomatic = std::make_unique<QPushButton>("Scale &Automatically");
fScaleAutomatic->setWhatsThis("Will try to reset the step size of the selected items based on some crude rules");
fCancel = new QPushButton("&Cancel");
fCancel = std::make_unique<QPushButton>("&Cancel");
QHBoxLayout *bottom = new QHBoxLayout;
bottom->addWidget(fScaleAutomatic);
bottom->addWidget(fCancel);
bottom->addWidget(fScaleAutomatic.get());
bottom->addWidget(fCancel.get());
QVBoxLayout *main = new QVBoxLayout;
main->addLayout(top);
@ -83,10 +83,10 @@ PModSelect::PModSelect(QWidget *parent) :
setLayout(main);
connect(fAbsVal, SIGNAL(stateChanged(int)), this, SLOT(absoluteValueStateChanged(int)));
connect(fScaleAutomatic, SIGNAL(pressed()), this, SLOT(scaleAuto()));
connect(fScaleByFactor, SIGNAL(pressed()), this, SLOT(getFactor()));
connect(fCancel, SIGNAL(pressed()), this, SLOT(reject()));
connect(fAbsVal.get(), SIGNAL(stateChanged(int)), this, SLOT(absoluteValueStateChanged(int)));
connect(fScaleAutomatic.get(), SIGNAL(pressed()), this, SLOT(scaleAuto()));
connect(fScaleByFactor.get(), SIGNAL(pressed()), this, SLOT(getFactor()));
connect(fCancel.get(), SIGNAL(pressed()), this, SLOT(reject()));
}
//-------------------------------------------------------------------------
@ -151,7 +151,7 @@ PMusrStep::PMusrStep(const char *fln, QWidget *parent) :
fValid = false;
QString title = QString("<b><font size=""14"">%1</font></b>").arg(fMsrFileName);
fTitleLabel = new QLabel(title);
fTitleLabel = std::make_unique<QLabel>(title);
QLabel *icon = new QLabel();
if (isDarkTheme)
str = QString(":/icons/musrStep-32x32-dark.svg");
@ -160,7 +160,7 @@ PMusrStep::PMusrStep(const char *fln, QWidget *parent) :
icon->setPixmap(QPixmap(str));
QHBoxLayout *titleLayout = new QHBoxLayout;
titleLayout->addWidget(fTitleLabel);
titleLayout->addWidget(fTitleLabel.get());
titleLayout->addWidget(icon);
titleLayout->insertStretch(1);
@ -185,7 +185,7 @@ PMusrStep::PMusrStep(const char *fln, QWidget *parent) :
setMinimumSize(400, height);
// populate dialog
fParamTable = new QTableWidget(fParamVec.size(), 3);
fParamTable = std::make_unique<QTableWidget>(fParamVec.size(), 3);
QStringList strL;
strL << "name" << "value" << "step";
fParamTable->setHorizontalHeaderLabels(strL);
@ -202,54 +202,54 @@ PMusrStep::PMusrStep(const char *fln, QWidget *parent) :
item = new QTableWidgetItem(fParamVec[i].step);
fParamTable->setItem(i, 2, item);
}
fCheckSpecific = new QPushButton("Check S&pecific");
fCheckSpecific = std::make_unique<QPushButton>("Check S&pecific");
fCheckSpecific->setWhatsThis("Allows to specify a template name which is used\nto select parameter names fitting to it.");
fCheckAll = new QPushButton("Check A&ll");
fCheckAll = std::make_unique<QPushButton>("Check A&ll");
fCheckAll->setWhatsThis("Select all parameter names,\nexcept the ones with step == 0");
fUnCheckAll = new QPushButton("&Uncheck All");
fUnCheckAll = std::make_unique<QPushButton>("&Uncheck All");
fUnCheckAll->setWhatsThis("Unselect all parameter names");
QHBoxLayout *checkLayout = new QHBoxLayout;
checkLayout->addWidget(fCheckSpecific);
checkLayout->addWidget(fCheckAll);
checkLayout->addWidget(fUnCheckAll);
checkLayout->addWidget(fCheckSpecific.get());
checkLayout->addWidget(fCheckAll.get());
checkLayout->addWidget(fUnCheckAll.get());
fModifyAuto = new QPushButton("Modify &Automatic");
fModifyAuto = std::make_unique<QPushButton>("Modify &Automatic");
fModifyAuto->setWhatsThis("Will try to reset the step size,\nbased on some crude rules");
fModifyAuto->setDefault(true);
fModifySelected = new QPushButton("&Modify Selected");
fModifySelected = std::make_unique<QPushButton>("&Modify Selected");
fModifySelected->setWhatsThis("Will call a dialog which all to specify how\nto proceed with the selected parameter steps.");
QHBoxLayout *modifyLayout = new QHBoxLayout;
modifyLayout->addWidget(fModifyAuto);
modifyLayout->addWidget(fModifySelected);
modifyLayout->addWidget(fModifyAuto.get());
modifyLayout->addWidget(fModifySelected.get());
fSave = new QPushButton("&Save&&Quit");
fCancel = new QPushButton("&Cancel");
fSave = std::make_unique<QPushButton>("&Save&&Quit");
fCancel = std::make_unique<QPushButton>("&Cancel");
QHBoxLayout *buttomLayout = new QHBoxLayout;
buttomLayout->addWidget(fSave);
buttomLayout->addWidget(fCancel);
buttomLayout->addWidget(fSave.get());
buttomLayout->addWidget(fCancel.get());
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(titleLayout);
mainLayout->addWidget(fParamTable);
mainLayout->addWidget(fParamTable.get());
mainLayout->addLayout(checkLayout);
mainLayout->addLayout(modifyLayout);
mainLayout->addLayout(buttomLayout);
setLayout(mainLayout);
connect(fParamTable, SIGNAL(cellChanged(int, int)), this, SLOT(handleCellChanged(int, int)));
connect(fParamTable.get(), SIGNAL(cellChanged(int, int)), this, SLOT(handleCellChanged(int, int)));
connect(fCheckSpecific, SIGNAL(pressed()), this, SLOT(checkSpecific()));
connect(fCheckAll, SIGNAL(pressed()), this, SLOT(checkAll()));
connect(fUnCheckAll, SIGNAL(pressed()), this, SLOT(unCheckAll()));
connect(fCheckSpecific.get(), SIGNAL(pressed()), this, SLOT(checkSpecific()));
connect(fCheckAll.get(), SIGNAL(pressed()), this, SLOT(checkAll()));
connect(fUnCheckAll.get(), SIGNAL(pressed()), this, SLOT(unCheckAll()));
connect(fModifyAuto, SIGNAL(pressed()), this, SLOT(modifyAuto()));
connect(fModifySelected, SIGNAL(pressed()), this, SLOT(modifyChecked()));
connect(fSave, SIGNAL(pressed()), this, SLOT(saveAndQuit()));
connect(fCancel, SIGNAL(pressed()), this, SLOT(reject()));
connect(fModifyAuto.get(), SIGNAL(pressed()), this, SLOT(modifyAuto()));
connect(fModifySelected.get(), SIGNAL(pressed()), this, SLOT(modifyChecked()));
connect(fSave.get(), SIGNAL(pressed()), this, SLOT(saveAndQuit()));
connect(fCancel.get(), SIGNAL(pressed()), this, SLOT(reject()));
fModSelect = new PModSelect(this);
connect(fModSelect, SIGNAL(scale(bool,double,bool)), this, SLOT(handleModSelect(bool,double,bool)));

View File

@ -30,6 +30,8 @@
#ifndef _PMUSRSTEP_H_
#define _PMUSRSTEP_H_
#include <memory>
#include <QDialog>
#include <QWidget>
#include <QVector>
@ -37,6 +39,7 @@
#include <QTableWidget>
#include <QLabel>
#include <QCheckBox>
#include <QLineEdit>
struct PParam {
QString number;
@ -65,12 +68,12 @@ class PModSelect : public QDialog
void getFactor();
private:
QCheckBox *fAbsVal;
QLabel *fFactorLabel;
QLineEdit *fFactorLineEdit;
QPushButton *fScaleByFactor;
QPushButton *fScaleAutomatic;
QPushButton *fCancel;
std::unique_ptr<QCheckBox> fAbsVal;
std::unique_ptr<QLabel> fFactorLabel;
std::unique_ptr<QLineEdit> fFactorLineEdit;
std::unique_ptr<QPushButton> fScaleByFactor;
std::unique_ptr<QPushButton> fScaleAutomatic;
std::unique_ptr<QPushButton> fCancel;
};
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -98,15 +101,15 @@ class PMusrStep : public QDialog
QVector<PParam> fParamVec;
QLabel *fTitleLabel;
QTableWidget *fParamTable;
QPushButton *fCheckSpecific;
QPushButton *fCheckAll;
QPushButton *fUnCheckAll;
QPushButton *fModifyAuto;
QPushButton *fModifySelected;
QPushButton *fSave;
QPushButton *fCancel;
std::unique_ptr<QLabel> fTitleLabel;
std::unique_ptr<QTableWidget> fParamTable;
std::unique_ptr<QPushButton> fCheckSpecific;
std::unique_ptr<QPushButton> fCheckAll;
std::unique_ptr<QPushButton> fUnCheckAll;
std::unique_ptr<QPushButton> fModifyAuto;
std::unique_ptr<QPushButton> fModifySelected;
std::unique_ptr<QPushButton> fSave;
std::unique_ptr<QPushButton> fCancel;
PModSelect *fModSelect;