Raw -> Smart Pointers for mupp, qt5/qt6.

This commit is contained in:
suter_a 2023-10-24 12:55:26 +02:00
parent 3d149dc6ab
commit 51520868f1
9 changed files with 140 additions and 158 deletions

View File

@ -290,10 +290,10 @@ bool PParamDataHandler::ReadParamFile(const QStringList fln, QString &errorMsg)
// make sure that the system environment variables are properly set // make sure that the system environment variables are properly set
QString cmd(""); QString cmd("");
fProc = new QProcess(this); fProc = std::make_unique<QProcess>(this);
connect( fProc, SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) ); connect( fProc.get(), SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
connect( fProc, SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) ); connect( fProc.get(), SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
connect( fProc, SIGNAL( finished(int, QProcess::ExitStatus) ), this, SLOT( processDone(int, QProcess::ExitStatus) ) ); connect( fProc.get(), SIGNAL( finished(int, QProcess::ExitStatus) ), this, SLOT( processDone(int, QProcess::ExitStatus) ) );
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
#if defined(Q_OS_DARWIN) #if defined(Q_OS_DARWIN)

View File

@ -30,6 +30,8 @@
#ifndef _PMUPP_H_ #ifndef _PMUPP_H_
#define _PMUPP_H_ #define _PMUPP_H_
#include <memory>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@ -156,7 +158,7 @@ class PParamDataHandler : public QObject {
void newData(); void newData();
private: private:
QProcess *fProc; ///< this will be needed if msr2data needs to be called std::unique_ptr<QProcess> fProc; ///< this will be needed if msr2data needs to be called
QVector<PmuppCollection> fCollection; ///< all the collections handeled QVector<PmuppCollection> fCollection; ///< all the collections handeled
bool analyzeFileList(const QStringList &fln, QString &collectionName, bool analyzeFileList(const QStringList &fln, QString &collectionName,

View File

@ -242,13 +242,8 @@ PmuppGui::PmuppGui(QStringList fln)
fDatime = dt.toTime_t(); fDatime = dt.toTime_t();
fMuppInstance = -1; fMuppInstance = -1;
fMuppPlot = nullptr;
fNormalizeAction = nullptr;
fNormalize = false; fNormalize = false;
fVarDlg = nullptr;
fMacroPath = QString("./"); fMacroPath = QString("./");
fMacroName = QString(""); fMacroName = QString("");
@ -287,135 +282,135 @@ PmuppGui::PmuppGui(QStringList fln)
setupHelpActions(); setupHelpActions();
// create central widget // create central widget
fCentralWidget = new QWidget(this); fCentralWidget = std::make_unique<QWidget>(this);
// setup widgets // setup widgets
fBoxLayout_Main = new QBoxLayout(QBoxLayout::TopToBottom); fBoxLayout_Main = std::make_unique<QBoxLayout>(QBoxLayout::TopToBottom);
fBoxLayout_Main->setGeometry(QRect(10, 40, 600, 500)); fBoxLayout_Main->setGeometry(QRect(10, 40, 600, 500));
fBoxLayout_Top = new QBoxLayout(QBoxLayout::LeftToRight); fBoxLayout_Top = std::make_unique<QBoxLayout>(QBoxLayout::LeftToRight);
fGridLayout_Left = new QGridLayout(); fGridLayout_Left = std::make_unique<QGridLayout>();
fGridLayout_Right = new QGridLayout(); fGridLayout_Right = std::make_unique<QGridLayout>();
fBoxLayout_Cmd = new QBoxLayout(QBoxLayout::LeftToRight); fBoxLayout_Cmd = std::make_unique<QBoxLayout>(QBoxLayout::LeftToRight);
// label for the collection/parameter list widgets // label for the collection/parameter list widgets
fColLabel = new QLabel(this); fColLabel = std::make_unique<QLabel>(this);
fColLabel->setText("Collection -> Parameter"); fColLabel->setText("Collection -> Parameter");
fColLabel->setMaximumHeight(15); fColLabel->setMaximumHeight(15);
// central widget for the collection/parameter list widgets // central widget for the collection/parameter list widgets
fColParamSplitter = new QSplitter(Qt::Horizontal, this); fColParamSplitter = std::make_unique<QSplitter>(Qt::Horizontal, this);
fColParamSplitter->setMinimumSize(550,330); fColParamSplitter->setMinimumSize(550,330);
fColList = new QListWidget(this); fColList = std::make_unique<QListWidget>(this);
fColList->setSelectionMode(QAbstractItemView::ExtendedSelection); fColList->setSelectionMode(QAbstractItemView::ExtendedSelection);
fParamList = new QListWidget(this); fParamList = std::make_unique<QListWidget>(this);
// the next two lines enable drag and drop facility (drag) // the next two lines enable drag and drop facility (drag)
fParamList->setSelectionMode(QAbstractItemView::SingleSelection); fParamList->setSelectionMode(QAbstractItemView::SingleSelection);
fParamList->setDragEnabled(true); fParamList->setDragEnabled(true);
fColParamSplitter->addWidget(fColList); fColParamSplitter->addWidget(fColList.get());
fColParamSplitter->addWidget(fParamList); fColParamSplitter->addWidget(fParamList.get());
fRemoveCollection = new QPushButton("Remove Collection", this); fRemoveCollection = std::make_unique<QPushButton>("Remove Collection", this);
fRefreshCollection = new QPushButton("Refresh Collection", this); fRefreshCollection = std::make_unique<QPushButton>("Refresh Collection", this);
fGridLayout_Left->addWidget(fColLabel, 1, 1, 1, 2); fGridLayout_Left->addWidget(fColLabel.get(), 1, 1, 1, 2);
fGridLayout_Left->addWidget(fColParamSplitter, 2, 1, 1, 2); fGridLayout_Left->addWidget(fColParamSplitter.get(), 2, 1, 1, 2);
fGridLayout_Left->addWidget(fRemoveCollection, 3, 1); fGridLayout_Left->addWidget(fRemoveCollection.get(), 3, 1);
fGridLayout_Left->addWidget(fRefreshCollection, 3, 2); fGridLayout_Left->addWidget(fRefreshCollection.get(), 3, 2);
// X-axis // X-axis
fXaxisLabel = new QLabel("x-axis"); fXaxisLabel = std::make_unique<QLabel>("x-axis");
fViewX = new QListWidget(this); fViewX = std::make_unique<QListWidget>(this);
// the next two lines enable drag and drop facility (copy drop) // the next two lines enable drag and drop facility (copy drop)
fViewX->viewport()->setAcceptDrops(true); fViewX->viewport()->setAcceptDrops(true);
fViewX->setDropIndicatorShown(true); fViewX->setDropIndicatorShown(true);
fAddX = new QPushButton("add X", this); fAddX = std::make_unique<QPushButton>("add X", this);
fRemoveX = new QPushButton("remove X", this); fRemoveX = std::make_unique<QPushButton>("remove X", this);
// Y-axis // Y-axis
fYaxisLabel = new QLabel("y-axis"); fYaxisLabel = std::make_unique<QLabel>("y-axis");
fViewY = new QListWidget(this); fViewY = std::make_unique<QListWidget>(this);
// the next two lines enable drag and drop facility (copy drop) // the next two lines enable drag and drop facility (copy drop)
fViewY->viewport()->setAcceptDrops(true); fViewY->viewport()->setAcceptDrops(true);
fViewY->setDropIndicatorShown(true); fViewY->setDropIndicatorShown(true);
fAddY = new QPushButton("add Y", this); fAddY = std::make_unique<QPushButton>("add Y", this);
fRemoveY = new QPushButton("remove Y", this); fRemoveY = std::make_unique<QPushButton>("remove Y", this);
// 2 column button's for the right grid // 2 column button's for the right grid
fAddDitto = new QPushButton("Add Ditto", this); fAddDitto = std::make_unique<QPushButton>("Add Ditto", this);
fPlot = new QPushButton("Plot", this); fPlot = std::make_unique<QPushButton>("Plot", this);
fGridLayout_Right->addWidget(fXaxisLabel, 1, 1); fGridLayout_Right->addWidget(fXaxisLabel.get(), 1, 1);
fGridLayout_Right->addWidget(fYaxisLabel, 1, 2); fGridLayout_Right->addWidget(fYaxisLabel.get(), 1, 2);
fGridLayout_Right->addWidget(fViewX, 2, 1); fGridLayout_Right->addWidget(fViewX.get(), 2, 1);
fGridLayout_Right->addWidget(fViewY, 2, 2); fGridLayout_Right->addWidget(fViewY.get(), 2, 2);
fGridLayout_Right->addWidget(fAddX, 3, 1); fGridLayout_Right->addWidget(fAddX.get(), 3, 1);
fGridLayout_Right->addWidget(fAddY, 3, 2); fGridLayout_Right->addWidget(fAddY.get(), 3, 2);
fGridLayout_Right->addWidget(fRemoveX, 4, 1); fGridLayout_Right->addWidget(fRemoveX.get(), 4, 1);
fGridLayout_Right->addWidget(fRemoveY, 4, 2); fGridLayout_Right->addWidget(fRemoveY.get(), 4, 2);
fGridLayout_Right->addWidget(fAddDitto, 5, 1, 1, 2); fGridLayout_Right->addWidget(fAddDitto.get(), 5, 1, 1, 2);
fGridLayout_Right->addWidget(fPlot, 6, 1, 1, 2); fGridLayout_Right->addWidget(fPlot.get(), 6, 1, 1, 2);
fBoxLayout_Top->addLayout(fGridLayout_Left); fBoxLayout_Top->addLayout(fGridLayout_Left.get());
fBoxLayout_Top->addLayout(fGridLayout_Right); fBoxLayout_Top->addLayout(fGridLayout_Right.get());
fCmdLineHistory = new QPlainTextEdit(this); fCmdLineHistory = std::make_unique<QPlainTextEdit>(this);
fCmdLineHistory->setReadOnly(true); fCmdLineHistory->setReadOnly(true);
fCmdLineHistory->setMaximumBlockCount(50); fCmdLineHistory->setMaximumBlockCount(50);
// fill cmd history // fill cmd history
for (int i=0; i<fCmdHistory.size(); i++) for (int i=0; i<fCmdHistory.size(); i++)
fCmdLineHistory->insertPlainText(QString("%1\n").arg(fCmdHistory[i])); fCmdLineHistory->insertPlainText(QString("%1\n").arg(fCmdHistory[i]));
fCmdLine = new QLineEdit(this); fCmdLine = std::make_unique<QLineEdit>(this);
fCmdLine->installEventFilter(this); fCmdLine->installEventFilter(this);
fCmdLine->setText("$ "); fCmdLine->setText("$ ");
fCmdLine->setFocus(); // sets the keyboard focus fCmdLine->setFocus(); // sets the keyboard focus
fExitButton = new QPushButton("E&xit", this); fExitButton = std::make_unique<QPushButton>("E&xit", this);
QVBoxLayout *cmdLayout = new QVBoxLayout; QVBoxLayout *cmdLayout = new QVBoxLayout;
QLabel *cmdLabel = new QLabel("History:"); QLabel *cmdLabel = new QLabel("History:");
cmdLayout->addWidget(cmdLabel); cmdLayout->addWidget(cmdLabel);
cmdLayout->addWidget(fCmdLineHistory); cmdLayout->addWidget(fCmdLineHistory.get());
cmdLayout->addWidget(fCmdLine); cmdLayout->addWidget(fCmdLine.get());
fBoxLayout_Cmd = new QBoxLayout(QBoxLayout::LeftToRight); fBoxLayout_Cmd = std::make_unique<QBoxLayout>(QBoxLayout::LeftToRight);
fBoxLayout_Cmd->addLayout(cmdLayout); fBoxLayout_Cmd->addLayout(cmdLayout);
fBoxLayout_Cmd->addWidget(fExitButton); fBoxLayout_Cmd->addWidget(fExitButton.get());
fBoxLayout_Cmd->setAlignment(fCmdLine, Qt::AlignBottom); fBoxLayout_Cmd->setAlignment(fCmdLine.get(), Qt::AlignBottom);
fBoxLayout_Cmd->setAlignment(fExitButton, Qt::AlignBottom); fBoxLayout_Cmd->setAlignment(fExitButton.get(), Qt::AlignBottom);
fCmdSplitter = new QSplitter(Qt::Vertical, this); fCmdSplitter = std::make_unique<QSplitter>(Qt::Vertical, this);
QWidget *topWidget = new QWidget(this); // only needed since splitter needs a QWidget QWidget *topWidget = new QWidget(this); // only needed since splitter needs a QWidget
topWidget->setLayout(fBoxLayout_Top); topWidget->setLayout(fBoxLayout_Top.get());
QWidget *cmdWidget = new QWidget(this); // only needed since splitter needs a QWidget QWidget *cmdWidget = new QWidget(this); // only needed since splitter needs a QWidget
cmdWidget->setLayout(fBoxLayout_Cmd); cmdWidget->setLayout(fBoxLayout_Cmd.get());
fCmdSplitter->addWidget(topWidget); fCmdSplitter->addWidget(topWidget);
fCmdSplitter->addWidget(cmdWidget); fCmdSplitter->addWidget(cmdWidget);
fBoxLayout_Main->addWidget(fCmdSplitter); fBoxLayout_Main->addWidget(fCmdSplitter.get());
// establish all the necessary signal/slots // establish all the necessary signal/slots
connect(fRefreshCollection, SIGNAL( pressed() ), this, SLOT( refresh() )); connect(fRefreshCollection.get(), SIGNAL( pressed() ), this, SLOT( refresh() ));
connect(fRemoveCollection, SIGNAL( pressed() ), this, SLOT( remove() )); connect(fRemoveCollection.get(), SIGNAL( pressed() ), this, SLOT( remove() ));
connect(fAddX, SIGNAL( pressed() ), this, SLOT( addX() )); connect(fAddX.get(), SIGNAL( pressed() ), this, SLOT( addX() ));
connect(fAddY, SIGNAL( pressed() ), this, SLOT( addY() )); connect(fAddY.get(), SIGNAL( pressed() ), this, SLOT( addY() ));
connect(fRemoveX, SIGNAL( pressed() ), this, SLOT( removeX() )); connect(fRemoveX.get(), SIGNAL( pressed() ), this, SLOT( removeX() ));
connect(fRemoveY, SIGNAL( pressed() ), this, SLOT( removeY() )); connect(fRemoveY.get(), SIGNAL( pressed() ), this, SLOT( removeY() ));
connect(fAddDitto, SIGNAL( pressed() ), this, SLOT( addDitto() )); connect(fAddDitto.get(), SIGNAL( pressed() ), this, SLOT( addDitto() ));
connect(fPlot, SIGNAL( pressed()), this, SLOT( plot()) ); connect(fPlot.get(), SIGNAL( pressed()), this, SLOT( plot()) );
connect(fCmdLine, SIGNAL ( returnPressed() ), this, SLOT( handleCmds() )); connect(fCmdLine.get(), SIGNAL ( returnPressed() ), this, SLOT( handleCmds() ));
connect(fExitButton, SIGNAL( pressed() ), this, SLOT( aboutToQuit() )); connect(fExitButton.get(), SIGNAL( pressed() ), this, SLOT( aboutToQuit() ));
connect(fColList, SIGNAL( currentRowChanged(int) ), this, SLOT( updateParamList(int) )); connect(fColList.get(), SIGNAL( currentRowChanged(int) ), this, SLOT( updateParamList(int) ));
connect(fColList, SIGNAL( itemDoubleClicked(QListWidgetItem*) ), this, SLOT( editCollName(QListWidgetItem*) )); connect(fColList.get(), SIGNAL( itemDoubleClicked(QListWidgetItem*) ), this, SLOT( editCollName(QListWidgetItem*) ));
connect(fViewX, SIGNAL( currentRowChanged(int) ), this, SLOT( refreshY() )); connect(fViewX.get(), SIGNAL( currentRowChanged(int) ), this, SLOT( refreshY() ));
connect(fViewX, SIGNAL( itemChanged(QListWidgetItem*) ), this, SLOT( dropOnViewX(QListWidgetItem*) )); connect(fViewX.get(), SIGNAL( itemChanged(QListWidgetItem*) ), this, SLOT( dropOnViewX(QListWidgetItem*) ));
connect(fViewY, SIGNAL( itemChanged(QListWidgetItem*) ), this, SLOT( dropOnViewY(QListWidgetItem*) )); connect(fViewY.get(), SIGNAL( itemChanged(QListWidgetItem*) ), this, SLOT( dropOnViewY(QListWidgetItem*) ));
// deal with parameter data specifics // deal with parameter data specifics
if (dataAtStartup) if (dataAtStartup)
@ -423,8 +418,8 @@ PmuppGui::PmuppGui(QStringList fln)
connect(fParamDataHandler, SIGNAL( newData() ), this, SLOT( handleNewData() )); connect(fParamDataHandler, SIGNAL( newData() ), this, SLOT( handleNewData() ));
fCentralWidget->setLayout(fBoxLayout_Main); fCentralWidget->setLayout(fBoxLayout_Main.get());
setCentralWidget(fCentralWidget); setCentralWidget(fCentralWidget.get());
// in case there is no db/dat file list given open the db/dat file open menu automatically. // in case there is no db/dat file list given open the db/dat file open menu automatically.
if (fln.size() == 0) { if (fln.size() == 0) {
@ -593,11 +588,11 @@ void PmuppGui::setupToolActions()
menu->addSeparator(); menu->addSeparator();
fNormalizeAction = new QAction(tr( "Normalize" ), this); fNormalizeAction = std::make_unique<QAction>(tr( "Normalize" ), this);
fNormalizeAction->setStatusTip( tr("Plot Data Normalized (y-axis)") ); fNormalizeAction->setStatusTip( tr("Plot Data Normalized (y-axis)") );
fNormalizeAction->setCheckable(true); fNormalizeAction->setCheckable(true);
connect( fNormalizeAction, SIGNAL( changed() ), this, SLOT( normalize() ) ); connect( fNormalizeAction.get(), SIGNAL( changed() ), this, SLOT( normalize() ) );
menu->addAction(fNormalizeAction); menu->addAction(fNormalizeAction.get());
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1319,13 +1314,10 @@ void PmuppGui::addVar()
} }
// call variable dialog // call variable dialog
if (fVarDlg != nullptr) { fVarDlg.reset();
delete fVarDlg; fVarDlg = std::make_unique<PVarDialog>(collection_list, fDarkTheme);
fVarDlg = nullptr; connect(fVarDlg.get(), SIGNAL(check_request(QString,QVector<int>)), this, SLOT(check(QString,QVector<int>)));
} connect(fVarDlg.get(), SIGNAL(add_request(QString,QVector<int>)), this, SLOT(add(QString,QVector<int>)));
fVarDlg = new PVarDialog(collection_list, fDarkTheme);
connect(fVarDlg, SIGNAL(check_request(QString,QVector<int>)), this, SLOT(check(QString,QVector<int>)));
connect(fVarDlg, SIGNAL(add_request(QString,QVector<int>)), this, SLOT(add(QString,QVector<int>)));
fVarDlg->show(); fVarDlg->show();
} }
@ -2398,7 +2390,7 @@ void PmuppGui::plot()
} }
// start native ROOT parameter plot application if not already running // start native ROOT parameter plot application if not already running
if (fMuppPlot == 0) { // not running yet if (fMuppPlot == nullptr) { // not running yet
startMuppPlot(); startMuppPlot();
} else { } else {
// check if mupp_plot is still running // check if mupp_plot is still running
@ -2425,9 +2417,9 @@ void PmuppGui::startMuppPlot()
// feed the mupp instance // feed the mupp instance
arg << QString("%1").arg(fMuppInstance); arg << QString("%1").arg(fMuppInstance);
fMuppPlot = new QProcess(this); fMuppPlot = std::make_unique<QProcess>(this);
if (fMuppPlot == nullptr) { if (fMuppPlot == nullptr) {
QMessageBox::critical(0, "**ERROR**", "Couldn't invoke QProcess for mupp_plot!"); QMessageBox::critical(this, "**ERROR**", "Couldn't invoke QProcess for mupp_plot!");
return; return;
} }
@ -2443,7 +2435,7 @@ void PmuppGui::startMuppPlot()
if (!fMuppPlot->waitForStarted()) { if (!fMuppPlot->waitForStarted()) {
// error handling // error handling
QString msg(tr("Could not execute the output command: ")+cmd); QString msg(tr("Could not execute the output command: ")+cmd);
QMessageBox::critical( 0, QMessageBox::critical(this,
tr("Fatal error"), tr("Fatal error"),
msg, msg,
tr("Quit") ); tr("Quit") );
@ -2490,7 +2482,7 @@ void PmuppGui::handleCmds()
fMacroName = tok[1]; fMacroName = tok[1];
createMacro(); createMacro();
} else if (cmd.startsWith("path")) { // cmd: path <macro_path> } else if (cmd.startsWith("path")) { // cmd: path <macro_path>
QMessageBox::information(0, "INFO", "set's eventually the path for the macros to be saved."); QMessageBox::information(this, "INFO", "set's eventually the path for the macros to be saved.");
// will set the path to where to save the macro // will set the path to where to save the macro
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QStringList tok = cmd.split(" ", QString::SkipEmptyParts); QStringList tok = cmd.split(" ", QString::SkipEmptyParts);
@ -2514,7 +2506,7 @@ void PmuppGui::handleCmds()
QString fullPath = env.value(envVar); // get environment variable value if present, otherwise "" is returned QString fullPath = env.value(envVar); // get environment variable value if present, otherwise "" is returned
if (fullPath.isEmpty()) { if (fullPath.isEmpty()) {
fMacroPath = ""; fMacroPath = "";
QMessageBox::critical(0, "ERROR", QString("Environment variable '%1' not present. Typo?!").arg(envVar.prepend("$"))); QMessageBox::critical(this, "ERROR", QString("Environment variable '%1' not present. Typo?!").arg(envVar.prepend("$")));
return; return;
} }
fMacroPath.replace(envVar.prepend("$"), fullPath); fMacroPath.replace(envVar.prepend("$"), fullPath);
@ -2530,7 +2522,7 @@ void PmuppGui::handleCmds()
if (tok.size() > 1) if (tok.size() > 1)
addX(tok[1]); addX(tok[1]);
else else
QMessageBox::critical(0, "ERROR", QString("Found command 'x' without variable.")); QMessageBox::critical(this, "ERROR", QString("Found command 'x' without variable."));
} else if (cmd.startsWith("y")) { } else if (cmd.startsWith("y")) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QStringList tok = cmd.split(" ", QString::SkipEmptyParts); QStringList tok = cmd.split(" ", QString::SkipEmptyParts);
@ -2540,7 +2532,7 @@ void PmuppGui::handleCmds()
if (tok.size() > 1) if (tok.size() > 1)
addY(tok[1]); addY(tok[1]);
else else
QMessageBox::critical(0, "ERROR", QString("Found command 'y' without variable.")); QMessageBox::critical(this, "ERROR", QString("Found command 'y' without variable."));
} else if (cmd.startsWith("ditto")) { } else if (cmd.startsWith("ditto")) {
addDitto(); addDitto();
} else if (cmd.startsWith("rmx")) { } else if (cmd.startsWith("rmx")) {
@ -2552,7 +2544,7 @@ void PmuppGui::handleCmds()
if (tok.size() > 1) if (tok.size() > 1)
removeX(tok[1]); removeX(tok[1]);
else else
QMessageBox::critical(0, "ERROR", QString("Found command 'rmx' without variable.")); QMessageBox::critical(this, "ERROR", QString("Found command 'rmx' without variable."));
} else if (cmd.startsWith("rmy")) { } else if (cmd.startsWith("rmy")) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QStringList tok = cmd.split(" ", QString::SkipEmptyParts); QStringList tok = cmd.split(" ", QString::SkipEmptyParts);
@ -2562,7 +2554,7 @@ void PmuppGui::handleCmds()
if (tok.size() > 1) if (tok.size() > 1)
removeY(tok[1]); removeY(tok[1]);
else else
QMessageBox::critical(0, "ERROR", QString("Found command 'rmy' without variable.")); QMessageBox::critical(this, "ERROR", QString("Found command 'rmy' without variable."));
} else if (cmd.startsWith("norm")) { } else if (cmd.startsWith("norm")) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QStringList tok = cmd.split(" ", QString::SkipEmptyParts); QStringList tok = cmd.split(" ", QString::SkipEmptyParts);

View File

@ -30,6 +30,8 @@
#ifndef _PMUPPGUI_H_ #ifndef _PMUPPGUI_H_
#define _PMUPPGUI_H_ #define _PMUPPGUI_H_
#include <memory>
#include <QMainWindow> #include <QMainWindow>
#include <QVector> #include <QVector>
#include <QString> #include <QString>
@ -171,44 +173,44 @@ private:
QString fMacroPath; QString fMacroPath;
QString fMacroName; QString fMacroName;
QWidget *fCentralWidget; std::unique_ptr<QWidget> fCentralWidget;
QMenu *fRecentFilesMenu; ///< recent file menu QMenu *fRecentFilesMenu; ///< recent file menu
QAction *fRecentFilesAction[MAX_RECENT_FILES]; ///< array of the recent file actions QAction *fRecentFilesAction[MAX_RECENT_FILES]; ///< array of the recent file actions
QAction *fNormalizeAction; std::unique_ptr<QAction> fNormalizeAction;
QBoxLayout *fBoxLayout_Main; // top->bottom (0) std::unique_ptr<QBoxLayout> fBoxLayout_Main; // top->bottom (0)
QBoxLayout *fBoxLayout_Top; // left->right (1) std::unique_ptr<QBoxLayout> fBoxLayout_Top; // left->right (1)
QGridLayout *fGridLayout_Left; // 2 columns, 3 rows std::unique_ptr<QGridLayout> fGridLayout_Left; // 2 columns, 3 rows
QGridLayout *fGridLayout_Right; // 2 columns, 6 rows std::unique_ptr<QGridLayout> fGridLayout_Right; // 2 columns, 6 rows
QBoxLayout *fBoxLayout_Cmd; // left->right (1) std::unique_ptr<QBoxLayout> fBoxLayout_Cmd; // left->right (1)
QLabel *fColLabel; std::unique_ptr<QLabel> fColLabel;
QSplitter *fColParamSplitter; std::unique_ptr<QSplitter> fColParamSplitter;
QListWidget *fColList; std::unique_ptr<QListWidget> fColList;
QListWidget *fParamList; std::unique_ptr<QListWidget> fParamList;
QPushButton *fRemoveCollection; std::unique_ptr<QPushButton> fRemoveCollection;
QPushButton *fRefreshCollection; std::unique_ptr<QPushButton> fRefreshCollection;
QLabel *fXaxisLabel; std::unique_ptr<QLabel> fXaxisLabel;
QLabel *fYaxisLabel; std::unique_ptr<QLabel> fYaxisLabel;
QListWidget *fViewX; std::unique_ptr<QListWidget> fViewX;
QListWidget *fViewY; std::unique_ptr<QListWidget> fViewY;
QPushButton *fAddX; std::unique_ptr<QPushButton> fAddX;
QPushButton *fAddY; std::unique_ptr<QPushButton> fAddY;
QPushButton *fAddDitto; std::unique_ptr<QPushButton> fAddDitto;
QPushButton *fRemoveX; std::unique_ptr<QPushButton> fRemoveX;
QPushButton *fRemoveY; std::unique_ptr<QPushButton> fRemoveY;
QPushButton *fPlot; std::unique_ptr<QPushButton> fPlot;
QSplitter *fCmdSplitter; std::unique_ptr<QSplitter> fCmdSplitter;
QPlainTextEdit *fCmdLineHistory; std::unique_ptr<QPlainTextEdit> fCmdLineHistory;
QLineEdit *fCmdLine; std::unique_ptr<QLineEdit> fCmdLine;
QPushButton *fExitButton; std::unique_ptr<QPushButton> fExitButton;
QVector<QString> fCmdHistory; ///< command history buffer QVector<QString> fCmdHistory; ///< command history buffer
PVarDialog *fVarDlg; ///< variable dialog std::unique_ptr<PVarDialog> fVarDlg; ///< variable dialog
QProcess *fMuppPlot; ///< mupp plotter std::unique_ptr<QProcess> fMuppPlot; ///< mupp plotter
void setupFileActions(); void setupFileActions();
void setupToolActions(); void setupToolActions();

View File

@ -49,31 +49,14 @@
PmuppScript::PmuppScript(QStringList script) : PmuppScript::PmuppScript(QStringList script) :
fScript(script) fScript(script)
{ {
fParamDataHandler = 0;
fLoadPath = QString("./"); fLoadPath = QString("./");
fSavePath = QString("./"); fSavePath = QString("./");
fSelected = -2; // nothing selected fSelected = -2; // nothing selected
fNorm = false; fNorm = false;
fAdmin = new PmuppAdmin(); fAdmin = std::make_unique<PmuppAdmin>();
} }
//--------------------------------------------------------------------------
/**
* @brief PmuppScript::~PmuppScript. Dtor
*/
PmuppScript::~PmuppScript()
{
if (fParamDataHandler) {
delete fParamDataHandler;
fParamDataHandler = 0;
}
if (fAdmin) {
delete fAdmin;
fAdmin = 0;
}
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* @brief PmuppScript::executeScript. Handles the script commands. * @brief PmuppScript::executeScript. Handles the script commands.
@ -81,8 +64,8 @@ PmuppScript::~PmuppScript()
*/ */
int PmuppScript::executeScript() int PmuppScript::executeScript()
{ {
fParamDataHandler = new PParamDataHandler(); fParamDataHandler = std::make_unique<PParamDataHandler>();
if (fParamDataHandler == 0) { if (fParamDataHandler == nullptr) {
std::cerr << std::endl << "**ERROR** couldn't invoke data handler ..." << std::endl << std::endl; std::cerr << std::endl << "**ERROR** couldn't invoke data handler ..." << std::endl << std::endl;
return -1; return -1;
} }

View File

@ -30,6 +30,8 @@
#ifndef _PMUPPSCRIPT_H_ #ifndef _PMUPPSCRIPT_H_
#define _PMUPPSCRIPT_H_ #define _PMUPPSCRIPT_H_
#include <memory>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
@ -55,7 +57,6 @@ class PmuppScript : public QObject
public: public:
PmuppScript(QStringList script); PmuppScript(QStringList script);
~PmuppScript();
void setLoadPath(const QString cmd); void setLoadPath(const QString cmd);
QString getLoadPath() { return fLoadPath; } QString getLoadPath() { return fLoadPath; }
@ -79,10 +80,10 @@ class PmuppScript : public QObject
void finished(); void finished();
private: private:
PmuppAdmin *fAdmin; ///< admin object std::unique_ptr<PmuppAdmin> fAdmin; ///< admin object
QStringList fScript; ///< script source QStringList fScript; ///< script source
PParamDataHandler *fParamDataHandler; ///< parameter data handler std::unique_ptr<PParamDataHandler> fParamDataHandler; ///< parameter data handler
int fSelected; ///< -2=nothing selected, -1=all selected, >=0 is the index if the selected collection int fSelected; ///< -2=nothing selected, -1=all selected, >=0 is the index if the selected collection
PmuppPlotEntry fPlotEntry; ///< plot entry object PmuppPlotEntry fPlotEntry; ///< plot entry object

View File

@ -291,10 +291,10 @@ bool PParamDataHandler::ReadParamFile(const QStringList fln, QString &errorMsg)
// make sure that the system environment variables are properly set // make sure that the system environment variables are properly set
QString cmd(""); QString cmd("");
fProc = new QProcess(this); fProc = std::make_unique<QProcess>(this);
connect( fProc, SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) ); connect( fProc.get(), SIGNAL( readyReadStandardOutput() ), this, SLOT( readFromStdOut() ) );
connect( fProc, SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) ); connect( fProc.get(), SIGNAL( readyReadStandardError() ), this, SLOT( readFromStdErr() ) );
connect( fProc, SIGNAL( finished(int, QProcess::ExitStatus) ), this, SLOT( processDone(int, QProcess::ExitStatus) ) ); connect( fProc.get(), SIGNAL( finished(int, QProcess::ExitStatus) ), this, SLOT( processDone(int, QProcess::ExitStatus) ) );
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
#if defined(Q_OS_DARWIN) #if defined(Q_OS_DARWIN)

View File

@ -30,6 +30,8 @@
#ifndef _PMUPP_H_ #ifndef _PMUPP_H_
#define _PMUPP_H_ #define _PMUPP_H_
#include <memory>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@ -156,7 +158,7 @@ class PParamDataHandler : public QObject {
void newData(); void newData();
private: private:
QProcess *fProc; ///< this will be needed if msr2data needs to be called std::unique_ptr<QProcess> fProc; ///< this will be needed if msr2data needs to be called
QVector<PmuppCollection> fCollection; ///< all the collections handeled QVector<PmuppCollection> fCollection; ///< all the collections handeled
bool analyzeFileList(const QStringList &fln, QString &collectionName, bool analyzeFileList(const QStringList &fln, QString &collectionName,

View File

@ -2199,7 +2199,7 @@ void PmuppGui::plot()
} }
// start native ROOT parameter plot application if not already running // start native ROOT parameter plot application if not already running
if (fMuppPlot == 0) { // not running yet if (fMuppPlot == nullptr) { // not running yet
startMuppPlot(); startMuppPlot();
} else { } else {
// check if mupp_plot is still running // check if mupp_plot is still running