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

This commit is contained in:
suter_a 2023-10-24 13:08:30 +02:00
parent 51520868f1
commit 9911d88889
4 changed files with 56 additions and 52 deletions

View File

@ -100,13 +100,13 @@ PVarDialog::PVarDialog(QVector<PCollInfo> collection_list, bool darkTheme,
QWidget *parent, Qt::WindowFlags f) : QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f), fCollList(collection_list) QDialog(parent, f), fCollList(collection_list)
{ {
fVarEdit = new QPlainTextEdit(); fVarEdit = std::make_unique<QPlainTextEdit>();
fCollectionView = new QListWidget(); fCollectionView = std::make_unique<QListWidget>();
fCancel = new QPushButton("&Cancel", this); fCancel = std::make_unique<QPushButton>("&Cancel", this);
fCheck = new QPushButton("Chec&k", this); fCheck = std::make_unique<QPushButton>("Chec&k", this);
fAdd = new QPushButton("&Add", this); fAdd = std::make_unique<QPushButton>("&Add", this);
fHelp = new QPushButton("&Help", this); fHelp = std::make_unique<QPushButton>("&Help", this);
fShowVarName = new QPushButton("Show&VarName", this); fShowVarName = std::make_unique<QPushButton>("Show&VarName", this);
// fill collection view // fill collection view
for (int i=0; i<fCollList.count(); i++) { for (int i=0; i<fCollList.count(); i++) {
@ -118,23 +118,23 @@ PVarDialog::PVarDialog(QVector<PCollInfo> collection_list, bool darkTheme,
fCollectionView->setSelectionMode(QAbstractItemView::ExtendedSelection); fCollectionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
QHBoxLayout *hLayout0 = new QHBoxLayout; QHBoxLayout *hLayout0 = new QHBoxLayout;
hLayout0->addWidget(fShowVarName); hLayout0->addWidget(fShowVarName.get());
hLayout0->addWidget(fHelp); hLayout0->addWidget(fHelp.get());
QHBoxLayout *hLayout1 = new QHBoxLayout; QHBoxLayout *hLayout1 = new QHBoxLayout;
hLayout1->addWidget(fCancel); hLayout1->addWidget(fCancel.get());
hLayout1->addWidget(fCheck); hLayout1->addWidget(fCheck.get());
hLayout1->addWidget(fAdd); hLayout1->addWidget(fAdd.get());
QLabel *varLabel = new QLabel("Edit Variables:"); QLabel *varLabel = new QLabel("Edit Variables:");
QVBoxLayout *varVLayout = new QVBoxLayout; QVBoxLayout *varVLayout = new QVBoxLayout;
varVLayout->addWidget(varLabel); varVLayout->addWidget(varLabel);
varVLayout->addWidget(fVarEdit); varVLayout->addWidget(fVarEdit.get());
QLabel *collLabel = new QLabel("Collections:"); QLabel *collLabel = new QLabel("Collections:");
QVBoxLayout *collVLayout = new QVBoxLayout; QVBoxLayout *collVLayout = new QVBoxLayout;
collVLayout->addWidget(collLabel); collVLayout->addWidget(collLabel);
collVLayout->addWidget(fCollectionView); collVLayout->addWidget(fCollectionView.get());
QWidget *varWidget = new QWidget(this); // only needed since splitter needs a QWidget QWidget *varWidget = new QWidget(this); // only needed since splitter needs a QWidget
varWidget->setLayout(varVLayout); varWidget->setLayout(varVLayout);
@ -154,11 +154,11 @@ PVarDialog::PVarDialog(QVector<PCollInfo> collection_list, bool darkTheme,
setLayout(vLayout); setLayout(vLayout);
resize(600, 450); resize(600, 450);
connect(fCancel, SIGNAL( clicked() ), this, SLOT( reject() )); connect(fCancel.get(), SIGNAL( clicked() ), this, SLOT( reject() ));
connect(fCheck, SIGNAL( clicked() ), this, SLOT( check() )); connect(fCheck.get(), SIGNAL( clicked() ), this, SLOT( check() ));
connect(fAdd, SIGNAL( clicked() ), this, SLOT( add() )); connect(fAdd.get(), SIGNAL( clicked() ), this, SLOT( add() ));
connect(fHelp, SIGNAL( clicked() ), this, SLOT( help() )); connect(fHelp.get(), SIGNAL( clicked() ), this, SLOT( help() ));
connect(fShowVarName, SIGNAL( clicked() ), this, SLOT( showVarNames() )); connect(fShowVarName.get(), SIGNAL( clicked() ), this, SLOT( showVarNames() ));
QString iconName(""); QString iconName("");
if (darkTheme) if (darkTheme)

View File

@ -30,6 +30,8 @@
#ifndef _PVARDIALOG_H_ #ifndef _PVARDIALOG_H_
#define _PVARDIALOG_H_ #define _PVARDIALOG_H_
#include <memory>
#include <QDialog> #include <QDialog>
#include <QPushButton> #include <QPushButton>
#include <QPlainTextEdit> #include <QPlainTextEdit>
@ -73,13 +75,13 @@ class PVarDialog : public QDialog
Qt::WindowFlags f = Qt::WindowFlags()); Qt::WindowFlags f = Qt::WindowFlags());
private: private:
QPlainTextEdit *fVarEdit; std::unique_ptr<QPlainTextEdit> fVarEdit;
QListWidget *fCollectionView; std::unique_ptr<QListWidget> fCollectionView;
QPushButton *fCancel; std::unique_ptr<QPushButton> fCancel;
QPushButton *fAdd; std::unique_ptr<QPushButton> fAdd;
QPushButton *fCheck; std::unique_ptr<QPushButton> fCheck;
QPushButton *fHelp; std::unique_ptr<QPushButton> fHelp;
QPushButton *fShowVarName; std::unique_ptr<QPushButton> fShowVarName;
QVector<PCollInfo> fCollList; QVector<PCollInfo> fCollList;

View File

@ -96,13 +96,13 @@ PVarDialog::PVarDialog(QVector<PCollInfo> collection_list, bool darkTheme,
QWidget *parent, Qt::WindowFlags f) : QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f), fCollList(collection_list) QDialog(parent, f), fCollList(collection_list)
{ {
fVarEdit = new QPlainTextEdit(); fVarEdit = std::make_unique<QPlainTextEdit>();
fCollectionView = new QListWidget(); fCollectionView = std::make_unique<QListWidget>();
fCancel = new QPushButton("&Cancel", this); fCancel = std::make_unique<QPushButton>("&Cancel", this);
fCheck = new QPushButton("Chec&k", this); fCheck = std::make_unique<QPushButton>("Chec&k", this);
fAdd = new QPushButton("&Add", this); fAdd = std::make_unique<QPushButton>("&Add", this);
fHelp = new QPushButton("&Help", this); fHelp = std::make_unique<QPushButton>("&Help", this);
fShowVarName = new QPushButton("Show&VarName", this); fShowVarName = std::make_unique<QPushButton>("Show&VarName", this);
// fill collection view // fill collection view
for (int i=0; i<fCollList.count(); i++) { for (int i=0; i<fCollList.count(); i++) {
@ -114,23 +114,23 @@ PVarDialog::PVarDialog(QVector<PCollInfo> collection_list, bool darkTheme,
fCollectionView->setSelectionMode(QAbstractItemView::ExtendedSelection); fCollectionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
QHBoxLayout *hLayout0 = new QHBoxLayout; QHBoxLayout *hLayout0 = new QHBoxLayout;
hLayout0->addWidget(fShowVarName); hLayout0->addWidget(fShowVarName.get());
hLayout0->addWidget(fHelp); hLayout0->addWidget(fHelp.get());
QHBoxLayout *hLayout1 = new QHBoxLayout; QHBoxLayout *hLayout1 = new QHBoxLayout;
hLayout1->addWidget(fCancel); hLayout1->addWidget(fCancel.get());
hLayout1->addWidget(fCheck); hLayout1->addWidget(fCheck.get());
hLayout1->addWidget(fAdd); hLayout1->addWidget(fAdd.get());
QLabel *varLabel = new QLabel("Edit Variables:"); QLabel *varLabel = new QLabel("Edit Variables:");
QVBoxLayout *varVLayout = new QVBoxLayout; QVBoxLayout *varVLayout = new QVBoxLayout;
varVLayout->addWidget(varLabel); varVLayout->addWidget(varLabel);
varVLayout->addWidget(fVarEdit); varVLayout->addWidget(fVarEdit.get());
QLabel *collLabel = new QLabel("Collections:"); QLabel *collLabel = new QLabel("Collections:");
QVBoxLayout *collVLayout = new QVBoxLayout; QVBoxLayout *collVLayout = new QVBoxLayout;
collVLayout->addWidget(collLabel); collVLayout->addWidget(collLabel);
collVLayout->addWidget(fCollectionView); collVLayout->addWidget(fCollectionView.get());
QWidget *varWidget = new QWidget(this); // only needed since splitter needs a QWidget QWidget *varWidget = new QWidget(this); // only needed since splitter needs a QWidget
varWidget->setLayout(varVLayout); varWidget->setLayout(varVLayout);
@ -150,11 +150,11 @@ PVarDialog::PVarDialog(QVector<PCollInfo> collection_list, bool darkTheme,
setLayout(vLayout); setLayout(vLayout);
resize(600, 450); resize(600, 450);
connect(fCancel, SIGNAL( clicked() ), this, SLOT( reject() )); connect(fCancel.get(), SIGNAL( clicked() ), this, SLOT( reject() ));
connect(fCheck, SIGNAL( clicked() ), this, SLOT( check() )); connect(fCheck.get(), SIGNAL( clicked() ), this, SLOT( check() ));
connect(fAdd, SIGNAL( clicked() ), this, SLOT( add() )); connect(fAdd.get(), SIGNAL( clicked() ), this, SLOT( add() ));
connect(fHelp, SIGNAL( clicked() ), this, SLOT( help() )); connect(fHelp.get(), SIGNAL( clicked() ), this, SLOT( help() ));
connect(fShowVarName, SIGNAL( clicked() ), this, SLOT( showVarNames() )); connect(fShowVarName.get(), SIGNAL( clicked() ), this, SLOT( showVarNames() ));
QString iconName(""); QString iconName("");
if (darkTheme) if (darkTheme)

View File

@ -30,6 +30,8 @@
#ifndef _PVARDIALOG_H_ #ifndef _PVARDIALOG_H_
#define _PVARDIALOG_H_ #define _PVARDIALOG_H_
#include <memory>
#include <QDialog> #include <QDialog>
#include <QPushButton> #include <QPushButton>
#include <QPlainTextEdit> #include <QPlainTextEdit>
@ -73,13 +75,13 @@ class PVarDialog : public QDialog
Qt::WindowFlags f = Qt::WindowFlags()); Qt::WindowFlags f = Qt::WindowFlags());
private: private:
QPlainTextEdit *fVarEdit; std::unique_ptr<QPlainTextEdit> fVarEdit;
QListWidget *fCollectionView; std::unique_ptr<QListWidget> fCollectionView;
QPushButton *fCancel; std::unique_ptr<QPushButton> fCancel;
QPushButton *fAdd; std::unique_ptr<QPushButton> fAdd;
QPushButton *fCheck; std::unique_ptr<QPushButton> fCheck;
QPushButton *fHelp; std::unique_ptr<QPushButton> fHelp;
QPushButton *fShowVarName; std::unique_ptr<QPushButton> fShowVarName;
QVector<PCollInfo> fCollList; QVector<PCollInfo> fCollList;