fix: crash of closeEvent in racewindow and settingsmenu + code cleanup
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
Evaluation::Evaluation(DataBase * db, QWidget * parent)
|
Evaluation::Evaluation(std::shared_ptr<DataBase> db, QWidget * parent)
|
||||||
: QWidget(parent), ui(new Ui::Evaluation) {
|
: QWidget(parent), ui(new Ui::Evaluation) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->db = db;
|
this->db = db;
|
||||||
@@ -43,7 +43,7 @@ void Evaluation::listClick(const QModelIndex & ind) {
|
|||||||
unsigned long index = static_cast<unsigned long>(ind.row());
|
unsigned long index = static_cast<unsigned long>(ind.row());
|
||||||
int id = this->result.at(index).at(1).toInt();
|
int id = this->result.at(index).at(1).toInt();
|
||||||
|
|
||||||
this->interfaceResult = new Result(this->db, id);
|
this->interfaceResult = std::make_shared<Result>(this->db, id);
|
||||||
this->interfaceResult->show();
|
this->interfaceResult->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "result.h"
|
#include "result.h"
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <memory>
|
||||||
#include <qstring.h>
|
#include <qstring.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -18,13 +19,14 @@ class Evaluation : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Evaluation(DataBase * db, QWidget * parent = nullptr);
|
explicit Evaluation(std::shared_ptr<DataBase> db,
|
||||||
|
QWidget * parent = nullptr);
|
||||||
~Evaluation();
|
~Evaluation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Evaluation * ui;
|
Ui::Evaluation * ui;
|
||||||
Result * interfaceResult;
|
std::shared_ptr<Result> interfaceResult;
|
||||||
DataBase * db;
|
std::shared_ptr<DataBase> db;
|
||||||
vector<vector<QString>> result;
|
vector<vector<QString>> result;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ HardwareSetup::~HardwareSetup() {
|
|||||||
//perror("ioperm");
|
//perror("ioperm");
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
std::cout << "Hardware beendet" << std::endl;
|
std::cout << "Destructor of Hardware" << std::endl;
|
||||||
this->stop = 1;
|
this->stop = 1;
|
||||||
|
|
||||||
if (HARDWARE_VERSION == 2) {
|
if (HARDWARE_VERSION == 2) {
|
||||||
|
|||||||
@@ -111,13 +111,13 @@ void MainWindow::WindowRennen() {
|
|||||||
this->interfaceRace = std::make_shared<WindowRace>(this->db, this);
|
this->interfaceRace = std::make_shared<WindowRace>(this->db, this);
|
||||||
this->interfaceRace->show();
|
this->interfaceRace->show();
|
||||||
this->interfaceRennliste =
|
this->interfaceRennliste =
|
||||||
std::make_shared<WindowRennliste>(this->db.get(), this);
|
std::make_shared<WindowRennliste>(this->db, this);
|
||||||
this->interfaceRennliste->show();
|
this->interfaceRennliste->show();
|
||||||
this->interfaceRace->setWindowRennliste(this->interfaceRennliste);
|
this->interfaceRace->setWindowRennliste(this->interfaceRennliste);
|
||||||
this->interfaceRennliste->setWindowRace(this->interfaceRace.get());
|
this->interfaceRennliste->setWindowRace(this->interfaceRace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::WindowEvaluation() {
|
void MainWindow::WindowEvaluation() {
|
||||||
this->interfaceEvaluation = std::make_shared<Evaluation>(this->db.get());
|
this->interfaceEvaluation = std::make_shared<Evaluation>(this->db);
|
||||||
this->interfaceEvaluation->show();
|
this->interfaceEvaluation->show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ using std::endl;
|
|||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
Result::Result(DataBase * db, int rennid, QWidget * parent)
|
Result::Result(std::shared_ptr<DataBase> db, int rennid, QWidget * parent)
|
||||||
: QWidget(parent), ui(new Ui::Result) {
|
: QWidget(parent), ui(new Ui::Result) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->db = db;
|
this->db = db;
|
||||||
|
|||||||
8
result.h
8
result.h
@@ -4,6 +4,7 @@
|
|||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "resultmodel.h"
|
#include "resultmodel.h"
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -23,7 +24,8 @@ class Result : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Result(DataBase * db, int rennid, QWidget * parent = nullptr);
|
explicit Result(std::shared_ptr<DataBase> db, int rennid,
|
||||||
|
QWidget * parent = nullptr);
|
||||||
~Result();
|
~Result();
|
||||||
public slots:
|
public slots:
|
||||||
void closeWindow();
|
void closeWindow();
|
||||||
@@ -46,8 +48,8 @@ class Result : public QWidget {
|
|||||||
void drawPlots(int rennid);
|
void drawPlots(int rennid);
|
||||||
|
|
||||||
Ui::Result * ui;
|
Ui::Result * ui;
|
||||||
ResultModel * model;
|
std::shared_ptr<ResultModel> model;
|
||||||
DataBase * db;
|
std::shared_ptr<DataBase> db;
|
||||||
int rennid;
|
int rennid;
|
||||||
int minimumTime;
|
int minimumTime;
|
||||||
QString renndatum;
|
QString renndatum;
|
||||||
|
|||||||
@@ -121,29 +121,29 @@ WindowRace::WindowRace(std::shared_ptr<DataBase> db, QWidget * parent)
|
|||||||
tableData = db->getData2(statement, 4);
|
tableData = db->getData2(statement, 4);
|
||||||
|
|
||||||
statement = "select name from fahrer where id like " +
|
statement = "select name from fahrer where id like " +
|
||||||
tableData[0][0].toStdString();
|
tableData.at(0).at(0).toStdString();
|
||||||
fahrer = this->db->getData2(statement, 1);
|
fahrer = this->db->getData2(statement, 1);
|
||||||
|
|
||||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||||
tableData[0][1].toStdString() + " order by seit DESC";
|
tableData.at(0).at(1).toStdString() + " order by seit DESC";
|
||||||
autos = this->db->getData2(statement, 1);
|
autos = this->db->getData2(statement, 1);
|
||||||
|
|
||||||
this->ui->gbShell->setTitle("Shell, " + fahrer[0][0] + ", " + autos[0][0]);
|
this->ui->gbShell->setTitle("Shell, " + fahrer[0][0] + ", " + autos[0][0]);
|
||||||
|
|
||||||
statement = "select name from fahrer where id like " +
|
statement = "select name from fahrer where id like " +
|
||||||
tableData[0][2].toStdString();
|
tableData.at(0).at(2).toStdString();
|
||||||
fahrer = this->db->getData2(statement, 1);
|
fahrer = this->db->getData2(statement, 1);
|
||||||
|
|
||||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||||
tableData[0][3].toStdString() + " order by seit DESC";
|
tableData.at(0).at(3).toStdString() + " order by seit DESC";
|
||||||
autos = this->db->getData2(statement, 1);
|
autos = this->db->getData2(statement, 1);
|
||||||
|
|
||||||
this->ui->gbDea->setTitle("Dea, " + fahrer[0][0] + ", " + autos[0][0]);
|
this->ui->gbDea->setTitle("Dea, " + fahrer[0][0] + ", " + autos[0][0]);
|
||||||
|
|
||||||
this->shellDriverId = tableData[0][0].toInt();
|
this->shellDriverId = tableData.at(0).at(0).toInt();
|
||||||
this->shellCarId = tableData[0][1].toInt();
|
this->shellCarId = tableData.at(0).at(1).toInt();
|
||||||
this->deaDriverId = tableData[0][2].toInt();
|
this->deaDriverId = tableData.at(0).at(2).toInt();
|
||||||
this->deaCarId = tableData[0][3].toInt();
|
this->deaCarId = tableData.at(0).at(3).toInt();
|
||||||
|
|
||||||
// progressbar
|
// progressbar
|
||||||
this->ui->pbTime->setMaximum(this->fahrzeit);
|
this->ui->pbTime->setMaximum(this->fahrzeit);
|
||||||
@@ -153,8 +153,9 @@ WindowRace::WindowRace(std::shared_ptr<DataBase> db, QWidget * parent)
|
|||||||
this->ui->pbTime->setValue(0);
|
this->ui->pbTime->setValue(0);
|
||||||
|
|
||||||
QKeySequence ks(Qt::Key_Return); // btw, this is numpad enter
|
QKeySequence ks(Qt::Key_Return); // btw, this is numpad enter
|
||||||
QShortcut * keyReturn = new QShortcut(ks, this);
|
this->keyReturn = std::make_shared<QShortcut>(ks, this);
|
||||||
QObject::connect(keyReturn, SIGNAL(activated()), this, SLOT(ReturnPress()));
|
QObject::connect(keyReturn.get(), SIGNAL(activated()), this,
|
||||||
|
SLOT(ReturnPress()));
|
||||||
|
|
||||||
// QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(close()));
|
// QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(close()));
|
||||||
}
|
}
|
||||||
@@ -210,12 +211,12 @@ void WindowRace::prepareNextRace() {
|
|||||||
this->VecDea.clear();
|
this->VecDea.clear();
|
||||||
|
|
||||||
// clear tableview shell
|
// clear tableview shell
|
||||||
timeModelShell = new TimeModel(VecShell, minSecTime);
|
timeModelShell = std::make_shared<TimeModel>(VecShell, minSecTime);
|
||||||
ui->lWShellTime->setModel(timeModelShell);
|
ui->lWShellTime->setModel(timeModelShell.get());
|
||||||
|
|
||||||
// clear tableview dea
|
// clear tableview dea
|
||||||
timeModelDea = new TimeModel(VecDea, minSecTime);
|
timeModelDea = std::make_shared<TimeModel>(VecDea, minSecTime);
|
||||||
ui->lWDeaTime->setModel(timeModelDea);
|
ui->lWDeaTime->setModel(timeModelDea.get());
|
||||||
|
|
||||||
this->finished = false;
|
this->finished = false;
|
||||||
this->paused = false;
|
this->paused = false;
|
||||||
@@ -293,7 +294,7 @@ void WindowRace::closeEvent(QCloseEvent * event) {
|
|||||||
event->ignore();
|
event->ignore();
|
||||||
break;
|
break;
|
||||||
case QMessageBox::Yes:
|
case QMessageBox::Yes:
|
||||||
this->wRennliste->schliessen();
|
this->wRennliste->closeRaceList();
|
||||||
this->Hardware->setStop();
|
this->Hardware->setStop();
|
||||||
event->accept();
|
event->accept();
|
||||||
break;
|
break;
|
||||||
@@ -362,8 +363,6 @@ WindowRace::~WindowRace() {
|
|||||||
this->Hardware->setStop();
|
this->Hardware->setStop();
|
||||||
usleep(1000000); // 1 second
|
usleep(1000000); // 1 second
|
||||||
|
|
||||||
// delete this->db;
|
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
void WindowRace::shellSlot(int time, int sector) {
|
void WindowRace::shellSlot(int time, int sector) {
|
||||||
@@ -385,10 +384,10 @@ void WindowRace::shellSlot(int time, int sector) {
|
|||||||
test.append(1);
|
test.append(1);
|
||||||
test.append(2);
|
test.append(2);
|
||||||
test.append(3);
|
test.append(3);
|
||||||
this->timeModelShell =
|
this->timeModelShell = std::make_shared<TimeModel>(
|
||||||
new TimeModel(VecShell, minSecTime, test, this);
|
VecShell, minSecTime, test, this);
|
||||||
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
||||||
ui->lWShellTime->setModel(this->timeModelShell);
|
ui->lWShellTime->setModel(this->timeModelShell.get());
|
||||||
|
|
||||||
this->ui->lBridgeShell->setText(QString::number(
|
this->ui->lBridgeShell->setText(QString::number(
|
||||||
static_cast<double>(QVectorHelper::getMinSec1(VecShell)) /
|
static_cast<double>(QVectorHelper::getMinSec1(VecShell)) /
|
||||||
@@ -405,11 +404,11 @@ void WindowRace::shellSlot(int time, int sector) {
|
|||||||
test.append(1);
|
test.append(1);
|
||||||
test.append(2);
|
test.append(2);
|
||||||
test.append(3);
|
test.append(3);
|
||||||
this->timeModelShell =
|
this->timeModelShell = std::make_shared<TimeModel>(
|
||||||
new TimeModel(VecShell, minSecTime, test, this);
|
VecShell, minSecTime, test, this);
|
||||||
// timeModelShell = new
|
// timeModelShell = new
|
||||||
// TimeModel(VecShell, this);
|
// TimeModel(VecShell, this);
|
||||||
this->ui->lWShellTime->setModel(timeModelShell);
|
this->ui->lWShellTime->setModel(timeModelShell.get());
|
||||||
this->ui->lStraightShell->setText(QString::number(
|
this->ui->lStraightShell->setText(QString::number(
|
||||||
static_cast<double>(
|
static_cast<double>(
|
||||||
QVectorHelper::getMinSec2(VecShell)) /
|
QVectorHelper::getMinSec2(VecShell)) /
|
||||||
@@ -440,11 +439,11 @@ void WindowRace::shellSlot(int time, int sector) {
|
|||||||
test.append(1);
|
test.append(1);
|
||||||
test.append(2);
|
test.append(2);
|
||||||
test.append(3);
|
test.append(3);
|
||||||
this->timeModelShell =
|
this->timeModelShell = std::make_shared<TimeModel>(
|
||||||
new TimeModel(VecShell, minSecTime, test, this);
|
VecShell, minSecTime, test, this);
|
||||||
// timeModelShell = new
|
// timeModelShell = new
|
||||||
// TimeModel(VecShell, this);
|
// TimeModel(VecShell, this);
|
||||||
this->ui->lWShellTime->setModel(timeModelShell);
|
this->ui->lWShellTime->setModel(timeModelShell.get());
|
||||||
|
|
||||||
this->ui->lCurvesShell->setText(QString::number(
|
this->ui->lCurvesShell->setText(QString::number(
|
||||||
static_cast<double>(
|
static_cast<double>(
|
||||||
@@ -507,8 +506,9 @@ void WindowRace::deaSlot(int time, int sector) {
|
|||||||
VecDea.push_back(QVector<int>());
|
VecDea.push_back(QVector<int>());
|
||||||
VecDea.last().push_back(time);
|
VecDea.last().push_back(time);
|
||||||
cout << "Dea Sektor 1" << endl;
|
cout << "Dea Sektor 1" << endl;
|
||||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
timeModelDea =
|
||||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
std::make_shared<TimeModel>(VecDea, minSecTime, this);
|
||||||
|
this->ui->lWDeaTime->setModel(timeModelDea.get());
|
||||||
|
|
||||||
this->ui->lBridgeDea->setText(QString::number(
|
this->ui->lBridgeDea->setText(QString::number(
|
||||||
static_cast<double>(QVectorHelper::getMinSec1(VecDea)) /
|
static_cast<double>(QVectorHelper::getMinSec1(VecDea)) /
|
||||||
@@ -520,8 +520,9 @@ void WindowRace::deaSlot(int time, int sector) {
|
|||||||
if (VecDea.last().size() == 1) {
|
if (VecDea.last().size() == 1) {
|
||||||
cout << time << sector << endl;
|
cout << time << sector << endl;
|
||||||
VecDea[VecDea.size() - 1].push_back(time);
|
VecDea[VecDea.size() - 1].push_back(time);
|
||||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
timeModelDea = std::make_shared<TimeModel>(
|
||||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
VecDea, minSecTime, this);
|
||||||
|
this->ui->lWDeaTime->setModel(timeModelDea.get());
|
||||||
this->ui->lStraightDea->setText(QString::number(
|
this->ui->lStraightDea->setText(QString::number(
|
||||||
static_cast<double>(
|
static_cast<double>(
|
||||||
QVectorHelper::getMinSec2(VecDea)) /
|
QVectorHelper::getMinSec2(VecDea)) /
|
||||||
@@ -544,8 +545,9 @@ void WindowRace::deaSlot(int time, int sector) {
|
|||||||
VecDea.last().push_back(
|
VecDea.last().push_back(
|
||||||
QVectorHelper::getCurTime(VecDea.last()));
|
QVectorHelper::getCurTime(VecDea.last()));
|
||||||
|
|
||||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
timeModelDea = std::make_shared<TimeModel>(
|
||||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
VecDea, minSecTime, this);
|
||||||
|
this->ui->lWDeaTime->setModel(timeModelDea.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// best time on widget
|
// best time on widget
|
||||||
@@ -609,13 +611,13 @@ long WindowRace::getMinimum(std::vector<long> a) {
|
|||||||
long minimum = -1;
|
long minimum = -1;
|
||||||
for (unsigned int i = 0; i < a.size(); i++) {
|
for (unsigned int i = 0; i < a.size(); i++) {
|
||||||
if (minimum < 0) {
|
if (minimum < 0) {
|
||||||
if (a[i] >= this->minimumTime) {
|
if (a.at(i) >= this->minimumTime) {
|
||||||
minimum = a[i];
|
minimum = a.at(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (a[i] < minimum && a[i] >= this->minimumTime) {
|
if (a.at(i) < minimum && a.at(i) >= this->minimumTime) {
|
||||||
minimum = a[i];
|
minimum = a.at(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "windowrennliste.h"
|
#include "windowrennliste.h"
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QShortcut>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -48,8 +49,8 @@ class WindowRace : public QMainWindow {
|
|||||||
bool firstTimeDea;
|
bool firstTimeDea;
|
||||||
QVector<QVector<int>> VecShell;
|
QVector<QVector<int>> VecShell;
|
||||||
QVector<QVector<int>> VecDea;
|
QVector<QVector<int>> VecDea;
|
||||||
TimeModel * timeModelShell;
|
std::shared_ptr<TimeModel> timeModelShell;
|
||||||
TimeModel * timeModelDea;
|
std::shared_ptr<TimeModel> timeModelDea;
|
||||||
long getMinimum(std::vector<long> a);
|
long getMinimum(std::vector<long> a);
|
||||||
QString timeWrapper(long zahl);
|
QString timeWrapper(long zahl);
|
||||||
long countdownValue; // in sec
|
long countdownValue; // in sec
|
||||||
@@ -72,6 +73,9 @@ class WindowRace : public QMainWindow {
|
|||||||
int theoreticalMinDea;
|
int theoreticalMinDea;
|
||||||
int deltaDea;
|
int deltaDea;
|
||||||
|
|
||||||
|
// shortcuts
|
||||||
|
std::shared_ptr<QShortcut> keyReturn;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void stopClicked();
|
void stopClicked();
|
||||||
void prepareNextRace();
|
void prepareNextRace();
|
||||||
|
|||||||
@@ -5,10 +5,13 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
WindowRennliste::WindowRennliste(DataBase * db, QWidget * parent)
|
WindowRennliste::WindowRennliste(std::shared_ptr<DataBase> db, QWidget * parent)
|
||||||
: QMainWindow(parent), ui(new Ui::WindowRennliste) {
|
: QMainWindow(parent), ui(new Ui::WindowRennliste) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@@ -96,7 +99,7 @@ WindowRennliste::WindowRennliste(DataBase * db, QWidget * parent)
|
|||||||
this->ui->tWRennliste->item(0, i)->setBackground(Qt::green);
|
this->ui->tWRennliste->item(0, i)->setBackground(Qt::green);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void WindowRennliste::setWindowRace(WindowRace * instance) {
|
void WindowRennliste::setWindowRace(std::shared_ptr<WindowRace> instance) {
|
||||||
this->instanceWindowRace = instance;
|
this->instanceWindowRace = instance;
|
||||||
}
|
}
|
||||||
vector<QString> WindowRennliste::getDriverAndCarSettings() {
|
vector<QString> WindowRennliste::getDriverAndCarSettings() {
|
||||||
@@ -155,10 +158,10 @@ void WindowRennliste::closeEvent(QCloseEvent * event) {
|
|||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void WindowRennliste::schliessen() {
|
void WindowRennliste::closeRaceList() {
|
||||||
this->windowClose = true;
|
this->windowClose = true;
|
||||||
this->close();
|
this->close();
|
||||||
delete this;
|
// delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowRennliste::setSelection(int row) {
|
void WindowRennliste::setSelection(int row) {
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ class WindowRennliste : public QMainWindow {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void schliessen();
|
explicit WindowRennliste(std::shared_ptr<DataBase> db,
|
||||||
explicit WindowRennliste(DataBase * db, QWidget * parent = 0);
|
QWidget * parent = nullptr);
|
||||||
~WindowRennliste();
|
~WindowRennliste();
|
||||||
void setWindowRace(WindowRace * instance);
|
void closeRaceList();
|
||||||
|
void setWindowRace(std::shared_ptr<WindowRace> instance);
|
||||||
vector<QString> getDriverAndCarSettings();
|
vector<QString> getDriverAndCarSettings();
|
||||||
vector<QString> getDriverAndCarId();
|
vector<QString> getDriverAndCarId();
|
||||||
void sendIds();
|
void sendIds();
|
||||||
@@ -32,10 +33,10 @@ class WindowRennliste : public QMainWindow {
|
|||||||
bool windowClose;
|
bool windowClose;
|
||||||
void closeEvent(QCloseEvent * event);
|
void closeEvent(QCloseEvent * event);
|
||||||
void setSelection(int row);
|
void setSelection(int row);
|
||||||
WindowRace * instanceWindowRace;
|
std::shared_ptr<WindowRace> instanceWindowRace;
|
||||||
unsigned int selectedRow;
|
unsigned int selectedRow;
|
||||||
vector<vector<QString>> tableData;
|
vector<vector<QString>> tableData;
|
||||||
DataBase * db;
|
std::shared_ptr<DataBase> db;
|
||||||
Ui::WindowRennliste * ui;
|
Ui::WindowRennliste * ui;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
@@ -140,8 +140,10 @@ WindowsSettings::WindowsSettings(std::shared_ptr<DataBase> db, QWidget * parent)
|
|||||||
|
|
||||||
// setup Rennliste
|
// setup Rennliste
|
||||||
// setup drivers
|
// setup drivers
|
||||||
|
|
||||||
this->ui->lVDrivers->setSelectionMode(
|
this->ui->lVDrivers->setSelectionMode(
|
||||||
QAbstractItemView::ExtendedSelection);
|
QAbstractItemView::ExtendedSelection);
|
||||||
|
/*
|
||||||
statement = "select name, id from fahrer";
|
statement = "select name, id from fahrer";
|
||||||
driversList = this->db->getData2(statement, 2);
|
driversList = this->db->getData2(statement, 2);
|
||||||
driversModel = std::make_shared<QStringListModel>();
|
driversModel = std::make_shared<QStringListModel>();
|
||||||
@@ -151,15 +153,17 @@ WindowsSettings::WindowsSettings(std::shared_ptr<DataBase> db, QWidget * parent)
|
|||||||
[&qDriversList](vector<QString> i) { qDriversList << i.at(0); });
|
[&qDriversList](vector<QString> i) { qDriversList << i.at(0); });
|
||||||
driversModel->setStringList(qDriversList);
|
driversModel->setStringList(qDriversList);
|
||||||
this->ui->lVDrivers->setModel(driversModel.get());
|
this->ui->lVDrivers->setModel(driversModel.get());
|
||||||
|
*/
|
||||||
// setup cars
|
// setup cars
|
||||||
this->ui->lVCars->setSelectionMode(
|
this->ui->lVCars->setSelectionMode(
|
||||||
QAbstractItemView::ExtendedSelection);
|
QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
|
/*
|
||||||
QStringList carNames;
|
QStringList carNames;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
try {
|
try {
|
||||||
statement = "select id from autos";
|
statement = "select id from autos";
|
||||||
|
cout << "hier gehts noch" << endl;
|
||||||
this->carIds = this->db->getData2(statement, 1);
|
this->carIds = this->db->getData2(statement, 1);
|
||||||
|
|
||||||
for (vector<QString> carId : carIds) {
|
for (vector<QString> carId : carIds) {
|
||||||
@@ -168,6 +172,9 @@ WindowsSettings::WindowsSettings(std::shared_ptr<DataBase> db, QWidget * parent)
|
|||||||
<< carId.at(0).toStdString()
|
<< carId.at(0).toStdString()
|
||||||
<< " order by seit DESC limit 1";
|
<< " order by seit DESC limit 1";
|
||||||
carNames << this->db->getData2(ss.str(), 1).at(0).at(0);
|
carNames << this->db->getData2(ss.str(), 1).at(0).at(0);
|
||||||
|
cout
|
||||||
|
<< this->db->getData2(ss.str(), 1).at(0).at(0).toStdString()
|
||||||
|
<< endl;
|
||||||
ss.str(std::string());
|
ss.str(std::string());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,10 +184,9 @@ WindowsSettings::WindowsSettings(std::shared_ptr<DataBase> db, QWidget * parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
carModel = std::make_shared<QStringListModel>();
|
carModel = std::make_shared<QStringListModel>();
|
||||||
|
|
||||||
carModel->setStringList(carNames);
|
carModel->setStringList(carNames);
|
||||||
this->ui->lVCars->setModel(carModel.get());
|
this->ui->lVCars->setModel(carModel.get());
|
||||||
|
*/
|
||||||
} catch (std::exception & e) {
|
} catch (std::exception & e) {
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
cout << "missing database :(" << endl;
|
cout << "missing database :(" << endl;
|
||||||
@@ -324,13 +330,17 @@ void WindowsSettings::listClickEditCar(const QModelIndex & index) {
|
|||||||
|
|
||||||
void WindowsSettings::repaintDrivers() {
|
void WindowsSettings::repaintDrivers() {
|
||||||
string statement = "select id, name from fahrer";
|
string statement = "select id, name from fahrer";
|
||||||
this->driversLV = this->db->getData2(statement, 2);
|
// this->driversLV;
|
||||||
QStringListModel * driverModel = new QStringListModel();
|
this->driversList = this->db->getData2(statement, 2);
|
||||||
|
// driversList = this->driversLV;
|
||||||
|
// QStringListModel *
|
||||||
|
this->driversModel = std::make_shared<QStringListModel>();
|
||||||
QStringList driverList =
|
QStringList driverList =
|
||||||
DataHelper::vectorListToQstringList(this->driversLV, 1);
|
DataHelper::vectorListToQstringList(this->driversList, 1);
|
||||||
driverModel->setStringList(driverList);
|
this->driversModel->setStringList(driverList);
|
||||||
this->ui->lVDriverEditSavedDrivers->setModel(driverModel);
|
this->ui->lVDriverEditSavedDrivers->setModel(this->driversModel.get());
|
||||||
this->ui->lVNewDriverSavedDrivers->setModel(driverModel);
|
this->ui->lVNewDriverSavedDrivers->setModel(this->driversModel.get());
|
||||||
|
this->ui->lVDrivers->setModel(this->driversModel.get());
|
||||||
}
|
}
|
||||||
void WindowsSettings::repaintCars() {
|
void WindowsSettings::repaintCars() {
|
||||||
QStringList carNames;
|
QStringList carNames;
|
||||||
@@ -351,7 +361,7 @@ void WindowsSettings::repaintCars() {
|
|||||||
this->carModel->setStringList(carNames);
|
this->carModel->setStringList(carNames);
|
||||||
this->ui->lVCarSavedCars->setModel(this->carModel.get());
|
this->ui->lVCarSavedCars->setModel(this->carModel.get());
|
||||||
this->ui->lvNewCar->setModel(this->carModel.get());
|
this->ui->lvNewCar->setModel(this->carModel.get());
|
||||||
|
this->ui->lVCars->setModel(this->carModel.get());
|
||||||
} catch (std::exception & e) {
|
} catch (std::exception & e) {
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
cout << "Error on repainting cars" << endl;
|
cout << "Error on repainting cars" << endl;
|
||||||
@@ -470,7 +480,6 @@ void WindowsSettings::StreckeSpeichernSlot() {
|
|||||||
|
|
||||||
WindowsSettings::~WindowsSettings() {
|
WindowsSettings::~WindowsSettings() {
|
||||||
delete ui;
|
delete ui;
|
||||||
std::cout << "Destruktor einstellungen" << std::endl;
|
|
||||||
}
|
}
|
||||||
// Get current date/time, format is YYYY-MM-DD.HH:mm:ss
|
// Get current date/time, format is YYYY-MM-DD.HH:mm:ss
|
||||||
|
|
||||||
@@ -501,7 +510,7 @@ void WindowsSettings::createRaceListAndClose() {
|
|||||||
this->ui->lVDrivers->selectionModel()->selectedIndexes()) {
|
this->ui->lVDrivers->selectionModel()->selectedIndexes()) {
|
||||||
selectedDriverIds.push_back(
|
selectedDriverIds.push_back(
|
||||||
this->driversList.at(static_cast<unsigned long>(index.row()))
|
this->driversList.at(static_cast<unsigned long>(index.row()))
|
||||||
.at(1)
|
.at(0)
|
||||||
.toInt());
|
.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<string><html><head/><body><p>Rennliste Erstellen</p></body></html></string>
|
<string><html><head/><body><p>Rennliste Erstellen</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="Dauer">
|
<widget class="QWidget" name="Dauer">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|||||||
Reference in New Issue
Block a user