changed more raw pointers to smart pointers
This commit is contained in:
@@ -17,7 +17,7 @@ using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
|
||||
WindowsSettings::WindowsSettings(std::shared_ptr<DataBase> db, QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::WindowsSettings) {
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -66,6 +66,15 @@ WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
|
||||
QObject::connect(this->ui->pBNewCarSave, SIGNAL(clicked()), this,
|
||||
SLOT(saveNewCar()));
|
||||
|
||||
QObject::connect(this->ui->pBCarClose, SIGNAL(clicked()), this,
|
||||
SLOT(closeWindow()));
|
||||
|
||||
QObject::connect(this->ui->pBNewDriverClose, SIGNAL(clicked()), this,
|
||||
SLOT(closeWindow()));
|
||||
|
||||
QObject::connect(this->ui->pBDriverEditClose, SIGNAL(clicked()), this,
|
||||
SLOT(closeWindow()));
|
||||
|
||||
this->ui->wNewCarColor->setAutoFillBackground(true);
|
||||
// update minimal lap time on changeing minimal sector time
|
||||
// QObject::connect(this->ui->lEMinTimeSec1,
|
||||
@@ -135,13 +144,13 @@ WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
|
||||
QAbstractItemView::ExtendedSelection);
|
||||
statement = "select name, id from fahrer";
|
||||
driversList = this->db->getData2(statement, 2);
|
||||
driversModel = new QStringListModel();
|
||||
driversModel = std::make_shared<QStringListModel>();
|
||||
QStringList qDriversList;
|
||||
std::for_each(
|
||||
driversList.begin(), driversList.end(),
|
||||
[&qDriversList](vector<QString> i) { qDriversList << i.at(0); });
|
||||
driversModel->setStringList(qDriversList);
|
||||
this->ui->lVDrivers->setModel(driversModel);
|
||||
this->ui->lVDrivers->setModel(driversModel.get());
|
||||
|
||||
// setup cars
|
||||
this->ui->lVCars->setSelectionMode(
|
||||
@@ -167,10 +176,10 @@ WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
|
||||
cout << "cars could not be read from database" << endl;
|
||||
}
|
||||
|
||||
carModel = new QStringListModel();
|
||||
carModel = std::make_shared<QStringListModel>();
|
||||
|
||||
carModel->setStringList(carNames);
|
||||
this->ui->lVCars->setModel(carModel);
|
||||
this->ui->lVCars->setModel(carModel.get());
|
||||
|
||||
} catch (std::exception & e) {
|
||||
Q_UNUSED(e);
|
||||
@@ -212,7 +221,7 @@ void WindowsSettings::saveEditCar() {
|
||||
|
||||
void WindowsSettings::openEditColor() {
|
||||
// cout << "hello from slot" << endl;
|
||||
this->colorDialogEditCar = new QColorDialog();
|
||||
this->colorDialogEditCar = std::make_shared<QColorDialog>();
|
||||
this->colorDialogEditCar->show();
|
||||
this->colorDialogEditCar->setCurrentColor(QColor(this->curCarColor));
|
||||
this->colorDialogEditCar->open(this, SLOT(changeColorEdit()));
|
||||
@@ -220,7 +229,7 @@ void WindowsSettings::openEditColor() {
|
||||
|
||||
void WindowsSettings::openNewColor() {
|
||||
// cout << "hello from slot" << endl;
|
||||
this->colorDialogNewCar = new QColorDialog();
|
||||
this->colorDialogNewCar = std::make_shared<QColorDialog>();
|
||||
this->colorDialogNewCar->show();
|
||||
|
||||
this->colorDialogNewCar->open(this, SLOT(changeColorNew()));
|
||||
@@ -338,10 +347,10 @@ void WindowsSettings::repaintCars() {
|
||||
<< id.at(0).toStdString() << " order by id DESC limit 1";
|
||||
carNames << this->db->getData2(ss.str(), 6).at(0).at(2);
|
||||
}
|
||||
this->carModel = new QStringListModel();
|
||||
this->carModel = std::make_shared<QStringListModel>();
|
||||
this->carModel->setStringList(carNames);
|
||||
this->ui->lVCarSavedCars->setModel(this->carModel);
|
||||
this->ui->lvNewCar->setModel(this->carModel);
|
||||
this->ui->lVCarSavedCars->setModel(this->carModel.get());
|
||||
this->ui->lvNewCar->setModel(this->carModel.get());
|
||||
|
||||
} catch (std::exception & e) {
|
||||
Q_UNUSED(e);
|
||||
@@ -399,7 +408,6 @@ void WindowsSettings::repaintMinCurLapTime() {
|
||||
}
|
||||
void WindowsSettings::AbbrechenSlot() {
|
||||
this->close();
|
||||
delete this;
|
||||
}
|
||||
void WindowsSettings::SaveDauerSlot() {
|
||||
string statement =
|
||||
|
||||
Reference in New Issue
Block a user