added first part of evaluation realised in Cpp

This commit is contained in:
2018-12-06 23:09:26 +01:00
parent 388084c40e
commit 6c01b76b9c
14 changed files with 875 additions and 55 deletions

View File

@@ -18,6 +18,9 @@ set(CMAKE_AUTOMOC ON)
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
# uncomment for ATMega based version (needs usb library)
#add_definitions(-DATMEGA)
# Find the QtWidgets library
find_package(Qt5Widgets CONFIG REQUIRED)
@@ -38,12 +41,17 @@ set(helloworld_SRCS
training.cpp
timemodel.cpp
qvectorhelper.cpp
resultmodel.cpp
result.cpp
evaluation.cpp
mainwindow.ui
windowrace.ui
windowssettings.ui
windowrennliste.ui
training.ui
result.ui
evaluation.ui
)
# Tell CMake to create the helloworld executable
add_executable(Rennbahn ${helloworld_SRCS})

23
evaluation.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include "evaluation.h"
#include "result.h"
#include "ui_evaluation.h"
#include <QStringListModel>
Evaluation::Evaluation(DataBase * db, QWidget * parent)
: QWidget(parent), ui(new Ui::Evaluation) {
ui->setupUi(this);
this->db = db;
QStringListModel * model = new QStringListModel();
QStringList list;
list << "datum 1"
<< "datum 2"
<< "datum 3";
model->setStringList(list);
this->ui->lVEvaluation->setModel(model);
this->interfaceResult = new Result(this->db);
this->interfaceResult->show();
}
Evaluation::~Evaluation() {
delete ui;
}

25
evaluation.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef EVALUATION_H
#define EVALUATION_H
#include "database.h"
#include "result.h"
#include <QWidget>
namespace Ui {
class Evaluation;
}
class Evaluation : public QWidget {
Q_OBJECT
public:
explicit Evaluation(DataBase * db, QWidget * parent = nullptr);
~Evaluation();
private:
Ui::Evaluation * ui;
Result * interfaceResult;
DataBase * db;
};
#endif // EVALUATION_H

35
evaluation.ui Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Evaluation</class>
<widget class="QWidget" name="Evaluation">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>598</width>
<height>457</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListView" name="lVEvaluation"/>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Schließen</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -30,6 +30,9 @@ MainWindow::MainWindow(QWidget * parent)
QObject::connect(this->ui->pBTraining, SIGNAL(clicked()), this,
SLOT(WindowTraining()));
QObject::connect(this->ui->pBEvaluation, SIGNAL(clicked()), this,
SLOT(WindowEvaluation()));
QShortcut * startTraining = new QShortcut(QKeySequence("Ctrl+t"), this);
QShortcut * startRennen = new QShortcut(QKeySequence("Ctrl+r"), this);
@@ -69,3 +72,8 @@ void MainWindow::WindowRennen() {
this->interfaceRace->setWindowRennliste(this->interfaceRennliste);
this->interfaceRennliste->setWindowRace(this->interfaceRace);
}
void MainWindow::WindowEvaluation() {
this->interfaceEvaluation = new Evaluation(this->db);
this->interfaceEvaluation->show();
}

View File

@@ -4,41 +4,40 @@
#include <QMainWindow>
//#include "mainwindow2.h"
#include "evaluation.h"
#include "hardwaresetup.h"
#include "training.h"
#include "windowrace.h"
#include "windowssettings.h"
#include "windowrennliste.h"
#include "windowrennliste2.h"
#include "training.h"
#include "windowssettings.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
public:
explicit MainWindow(QWidget * parent = 0);
~MainWindow();
public slots:
public slots:
void NewWindowSettings();
void WindowRennen();
void WindowTraining();
void WindowEvaluation();
private:
Training *interfaceTraining;
void closeEvent(QCloseEvent *event);
DataBase *db;
Ui::MainWindow *ui;
WindowRace *interfaceRace;
WindowsSettings *interfaceSettings;
WindowRennliste *interfaceRennliste;
private:
Training * interfaceTraining;
void closeEvent(QCloseEvent * event);
DataBase * db;
Ui::MainWindow * ui;
WindowRace * interfaceRace;
WindowsSettings * interfaceSettings;
WindowRennliste * interfaceRennliste;
Evaluation * interfaceEvaluation;
};
#endif // MAINWINDOW_H

View File

@@ -16,7 +16,7 @@
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,1">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,1,0">
<item>
<widget class="QPushButton" name="pBRennen">
<property name="text">
@@ -38,6 +38,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pBEvaluation">
<property name="text">
<string>Auswertung</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@@ -48,7 +55,7 @@
<x>0</x>
<y>0</y>
<width>512</width>
<height>20</height>
<height>24</height>
</rect>
</property>
</widget>

471
result.cpp Normal file
View File

@@ -0,0 +1,471 @@
#include "result.h"
#include "ui_result.h"
#include <QTableWidgetItem>
#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <iomanip> // setprecision
#include <iostream>
#include <math.h>
#include <qcolor.h>
#include <string>
#include <vector>
using std::cout;
using std::endl;
using std::string;
using std::vector;
Result::Result(DataBase * db, QWidget * parent)
: QWidget(parent), ui(new Ui::Result) {
ui->setupUi(this);
this->db = db;
// prepare dummy data
vector<std::string> header;
// dummy for now
this->rennid = 39;
// test data
header.push_back("Spalte 1");
header.push_back("Spalte 2");
vector<vector<int>> data;
vector<int> subData;
subData.push_back(1);
subData.push_back(2);
data.push_back(subData);
data.push_back(subData);
this->ui->tWResult->resizeColumnsToContents();
this->ui->tWResult->horizontalHeader()->setStretchLastSection(true);
this->ui->tWResult->verticalHeader()->setVisible(true);
// this->model->setHeaderData(0, Qt::Horizontal, "Test");
// connects
// this->ui->pbClose->clicked()
std::stringstream statement;
statement << "select date from rennen where id like "
<< boost::lexical_cast<string>(rennid);
try {
QString renndatum = this->db->getData2(statement.str(), 1).at(0).at(0);
this->setWindowTitle(renndatum);
} catch (std::exception & e) {
Q_UNUSED(e);
cout << "Renndatum konnt aus Datenbank nicht gelesen werden" << endl;
}
// clear stringstream
statement.str(std::string());
statement << "select minimumroundtime from rennen where id like "
<< boost::lexical_cast<string>(rennid);
try {
this->minimumTime =
this->db->getData2(statement.str(), 1).at(0).at(0).toInt();
} catch (std::exception & e) {
Q_UNUSED(e);
cout << "Minimalzeit pro Runde konnte aus Datenbank nicht gelesen "
"werden."
<< endl;
}
vector<string> Fahrernamen;
for (size_t i = 0; i < this->getFahrerIds(this->rennid).size(); i++) {
Fahrernamen.push_back(
this->getFahrerName(this->getFahrerIds(this->rennid).at(i)));
}
vector<int> AutoIds = this->getAutoIds(this->rennid);
this->ui->tWResult->setRowCount(static_cast<int>(AutoIds.size()) * 2 + 4);
this->ui->tWResult->setColumnCount(static_cast<int>(Fahrernamen.size()) +
4);
int row = 0;
int col = 0;
this->ui->tWResult->setItem(row, col, new QTableWidgetItem("Auto"));
row += 0;
col += 1;
this->ui->tWResult->setItem(row, col, new QTableWidgetItem("Bahn"));
col += 1;
for (string fahrername : Fahrernamen) {
this->ui->tWResult->setItem(
row, col, new QTableWidgetItem(QString::fromStdString(fahrername)));
col += 1;
}
this->ui->tWResult->setItem(row, col,
new QTableWidgetItem("Durchschnitt Auto"));
col += 1;
this->ui->tWResult->setItem(
row, col, new QTableWidgetItem("Durchschnitt Auto gesamt"));
this->ui->tWResult->resizeColumnsToContents();
row = 1;
col = 1;
for (size_t i = 0; i <= AutoIds.size(); i++) {
this->ui->tWResult->setItem(row, col, new QTableWidgetItem("Shell"));
row += 1;
this->ui->tWResult->setItem(row, col, new QTableWidgetItem("Dea"));
row += 1;
}
vector<string> AutoNamen;
for (size_t i = 0; i < AutoIds.size(); i++) {
AutoNamen.push_back(this->getAutoName(AutoIds.at(i)));
}
col = 0;
row = 1;
for (string autoname : AutoNamen) {
this->ui->tWResult->setItem(
row, col, new QTableWidgetItem(QString::fromStdString(autoname)));
row += 2;
}
this->ui->tWResult->setItem(row, col,
new QTableWidgetItem("Durchschnitt Person"));
row += 2;
this->ui->tWResult->setItem(
row, col, new QTableWidgetItem("Durchschnitt Person ges"));
row = 1;
col = 2;
vector<vector<float>> zeiten;
vector<float> subZeiten;
for (int fahrer : this->getFahrerIds(this->rennid)) {
for (int car : this->getAutoIds(this->rennid)) {
int shellmin = this->getMinimum(fahrer, 1, this->rennid, car,
this->minimumTime);
int deamin = this->getMinimum(fahrer, 2, this->rennid, car,
this->minimumTime);
subZeiten.push_back(static_cast<float>(shellmin) / 1000);
subZeiten.push_back(static_cast<float>(deamin) / 1000);
this->ui->tWResult->setItem(
row, col,
new QTableWidgetItem(QString::fromStdString(
this->myRound(static_cast<double>(shellmin) / 1000, 3))));
row += 1;
this->ui->tWResult->setItem(
row, col,
new QTableWidgetItem(QString::fromStdString(
this->myRound(static_cast<double>(deamin) / 1000, 3))));
row += 1;
}
zeiten.push_back(subZeiten);
subZeiten.clear();
col += 1;
row = 1;
}
// Durchschnitt Fahrer Shell und Dea
row = static_cast<int>(AutoNamen.size()) * 2 + 1;
col = 2;
for (size_t i = 0; i < Fahrernamen.size(); i++) {
vector<float> shellListe;
vector<float> dealiste;
for (size_t k = 0; k < zeiten.at(i).size(); k++) {
if (k % 2 == 0) {
shellListe.push_back(zeiten.at(i).at(k));
}
else {
dealiste.push_back(zeiten.at(i).at(k));
}
}
this->ui->tWResult->setItem(
row, col,
new QTableWidgetItem(QString::fromStdString(
this->myRound(this->meanVal(shellListe), 3))));
row += 1;
this->ui->tWResult->setItem(
row, col,
new QTableWidgetItem(QString::fromStdString(
this->myRound(this->meanVal(dealiste), 3))));
row -= 1;
col += 1;
shellListe.clear();
dealiste.clear();
}
// Durchschnitt Auto Shell und Dea
col = static_cast<int>(Fahrernamen.size()) + 2;
row = 1;
vector<float> durschnittAuto;
for (size_t i = 0; i < AutoIds.size() * 2; i++) { //*2 weil 2 Bahnen
for (size_t k = 0; k < Fahrernamen.size(); k++) {
durschnittAuto.push_back(zeiten.at(k).at(i));
}
this->ui->tWResult->setItem(
row, col,
new QTableWidgetItem(QString::fromStdString(
this->myRound(this->meanVal(durschnittAuto), 3))));
row += 1;
durschnittAuto.clear();
}
// Durchschnitt Fahrer ges
row = static_cast<int>(AutoIds.size()) * 2 + 3;
col = 2;
for (size_t i = 0; i < Fahrernamen.size(); i++) {
this->ui->tWResult->setItem(
row, col,
new QTableWidgetItem(QString::fromStdString(
this->myRound(this->meanVal(zeiten.at(i)), 3))));
col += 1;
}
// Durchschnitt Auto ges
col = static_cast<int>(Fahrernamen.size()) + 3;
row = 1;
for (size_t i = 0; i < AutoIds.size() * 2; i++) { //*2 weil 2 Bahnen
if (i % 2 == 0) {
vector<float> durschnittAuto;
for (size_t k = 0; k < Fahrernamen.size(); k++) {
durschnittAuto.push_back(zeiten.at(k).at(i));
durschnittAuto.push_back(zeiten.at(k).at(i + 1));
}
this->ui->tWResult->setItem(
row, col,
new QTableWidgetItem(QString::fromStdString(
this->myRound(this->meanVal(durschnittAuto), 3))));
row += 2;
durschnittAuto.clear();
}
}
// Minimum durchschnitt markieren
row = static_cast<int>(AutoIds.size()) * 2 + 3;
col = 2;
vector<float> avgList;
for (size_t i = 0; i < Fahrernamen.size(); i++) {
QString value = this->ui->tWResult->item(row, col)->text();
avgList.push_back(value.toFloat());
col += 1;
}
row = static_cast<int>(AutoIds.size()) * 2 + 3;
col = 2;
for (size_t i = 0; i < Fahrernamen.size(); i++) {
if (this->myMin(avgList) ==
this->ui->tWResult->item(row, col)->text().toFloat()) {
this->ui->tWResult->item(row, col)->setBackground(
QColor(118, 238, 0));
}
col += 1;
}
// minimum abs markieren
// minimum finden
vector<float> temp;
for (size_t i = 0; i < zeiten.size(); i++) {
temp.push_back(this->myMin(zeiten.at(i)));
}
float minimum = this->myMin(temp);
col = 2;
row = 1;
for (size_t i = 0; i < Fahrernamen.size(); i++) {
for (size_t k = 0; k < AutoIds.size() * 2; k++) {
// self.tWRennergebnis.item(row + k, col +
// i).setBackground(QtGui.QColor(255, 215, 0))
if (this->ui->tWResult->item(row + k, col + i)->text().toFloat() ==
minimum) {
this->ui->tWResult
->item(row + static_cast<int>(k), col + static_cast<int>(i))
->setBackground(QColor(255, 215, 0));
}
}
}
this->ui->tWResult->resizeColumnsToContents();
this->ui->tWResult->horizontalHeader()->setStretchLastSection(true);
}
Result::~Result() {
cout << "result closed" << endl;
}
template <typename T> T Result::myMin(vector<T> vec) {
T min;
if (vec.size() > 0) {
min = vec.at(0);
}
else {
return 9999;
}
for (T minItr : vec) {
if (min > minItr) {
min = minItr;
}
}
return min;
}
template <typename T> double Result::meanVal(vector<T> vec) {
T sum = std::accumulate(vec.begin(), vec.end(), 0.0);
double mean = static_cast<double>(sum) / vec.size();
return mean;
}
string Result::myRound(double x, int d = 0) {
std::stringstream stream;
stream << std::fixed << std::setprecision(d) << x;
return stream.str();
}
void Result::closeWindow() {
this->close();
}
vector<int> Result::getFahrerIds(int rennid) {
std::stringstream statement;
statement << "select id_fahrer from zeiten where id_rennen like "
<< boost::lexical_cast<string>(rennid) << " group by id_fahrer";
vector<int> vecToRet;
try {
vector<vector<QString>> ret = this->db->getData2(statement.str(), 1);
for (size_t i = 0; i < ret.size(); i++) {
string strValue = ret.at(i).at(0).toStdString();
vecToRet.push_back(boost::lexical_cast<int>(strValue));
}
return vecToRet;
} catch (std::exception & e) {
Q_UNUSED(e);
cout << "FahrerIds konnten nicht aus Datenbank gelesen "
"werden."
<< endl;
}
return vecToRet;
}
vector<int> Result::getAutoIds(int rennid) {
std::stringstream statement;
statement << "select id_auto from zeiten where id_rennen like "
<< boost::lexical_cast<string>(rennid) << " group by id_auto";
vector<vector<QString>> ret = this->db->getData2(statement.str(), 1);
vector<int> vecToRet;
try {
vector<vector<QString>> ret = this->db->getData2(statement.str(), 1);
for (size_t i = 0; i < ret.size(); i++) {
string strValue = ret.at(i).at(0).toStdString();
vecToRet.push_back(boost::lexical_cast<int>(strValue));
}
return vecToRet;
} catch (std::exception & e) {
Q_UNUSED(e);
cout << "AutoIds konnten nicht aus Datenbank gelesen werden." << endl;
}
return vecToRet;
}
int Result::getMinimum(int fahrerId, int bahnId, int rennId, int autoid,
int minTime) {
std::stringstream statement;
statement << "select zeit from Zeiten where id_rennen like "
<< boost::lexical_cast<string>(rennId) << " and id_fahrer like "
<< boost::lexical_cast<string>(fahrerId) << " and id_auto like "
<< boost::lexical_cast<string>(autoid) << " and id_bahn like "
<< boost::lexical_cast<string>(bahnId);
try {
vector<vector<QString>> res = this->db->getData2(statement.str(), 1);
// filter impossible values
vector<int> validTimes;
for (size_t i = 0; i < res.size(); i++) {
int timeToCompare = res.at(i).at(0).toInt();
if (timeToCompare >= minTime) {
validTimes.push_back(timeToCompare);
}
}
if (validTimes.size() > 0) {
std::vector<int>::iterator result =
std::min_element(validTimes.begin(), validTimes.end());
return *result;
}
else {
return 9999;
}
} catch (std::exception & e) {
Q_UNUSED(e);
cout << "Minimalzeit konnte aus Datenbank nicht gelesen "
"werden."
<< endl;
}
return 9999;
}
float Result::getMean(int fahrerid, int bahnid, int rennid) {
vector<int> autoids = this->getAutoIds(rennid);
vector<int> avg;
for (int car : autoids) {
avg.push_back(
this->getMinimum(fahrerid, bahnid, rennid, car, this->minimumTime));
}
int sum = std::accumulate(avg.begin(), avg.end(), 0);
float floatAvg = 9999;
if (avg.size() > 0) {
floatAvg = static_cast<float>(sum) / static_cast<int>(avg.size());
cout << "avg:" << floatAvg << endl;
return floatAvg;
}
return 9999;
}
string Result::getFahrerName(int id) {
std::stringstream statement;
statement << "select name from fahrer where id like "
<< boost::lexical_cast<string>(id);
vector<vector<QString>> result = this->db->getData2(statement.str(), 1);
if (result.size() > 0) {
try {
return result.at(0).at(0).toStdString();
} catch (std::exception & e) {
Q_UNUSED(e);
cout << "Fehler beim Lesen vom Fahrernamen." << endl;
return "Leer";
}
}
return "Leer";
}
string Result::getAutoName(int id) {
std::stringstream statement;
statement << "select date from Rennen where id like "
<< boost::lexical_cast<string>(this->rennid);
string renndatum;
try {
QString qstrRenndatum =
this->db->getData2(statement.str(), 1).at(0).at(0);
renndatum = qstrRenndatum.toStdString();
} catch (std::exception & e) {
Q_UNUSED(e);
cout << "Renndatum konnte nicht gelesen werden." << endl;
return "nix";
}
try {
// clear stringstream
statement.str(std::string());
statement << "select name from Autokonfiguration where "
"id_auto like "
<< boost::lexical_cast<string>(id) << " and seit < '"
<< renndatum << "' order by seit DESC limit 1";
QString name = this->db->getData2(statement.str(), 1).at(0).at(0);
return name.toStdString();
} catch (std::exception & e) {
Q_UNUSED(e);
}
return "name";
}

44
result.h Normal file
View File

@@ -0,0 +1,44 @@
#ifndef RESULT_H
#define RESULT_H
#include "database.h"
#include "resultmodel.h"
#include <QWidget>
#include <string>
#include <vector>
using std::string;
using std::vector;
namespace Ui {
class Result;
}
class Result : public QWidget {
Q_OBJECT
public:
explicit Result(DataBase * db, QWidget * parent = nullptr);
~Result();
public slots:
void closeWindow();
private:
vector<int> getFahrerIds(int rennid);
vector<int> getAutoIds(int rennid);
int getMinimum(int fahrerId, int bahnId, int rennId, int autoid,
int minZeit);
float getMean(int fahrerid, int bahnid, int rennid);
string getFahrerName(int id);
string getAutoName(int id);
string myRound(double, int);
template <typename T> double meanVal(vector<T> vec);
template <typename T> T myMin(vector<T> vec);
Ui::Result * ui;
ResultModel * model;
DataBase * db;
int rennid;
int minimumTime;
};
#endif // RESULT_H

35
result.ui Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Result</class>
<widget class="QWidget" name="Result">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>617</width>
<height>494</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="tWResult"/>
</item>
<item>
<widget class="QPushButton" name="pbClose">
<property name="text">
<string>Schließen</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

65
resultmodel.cpp Normal file
View File

@@ -0,0 +1,65 @@
#include "resultmodel.h"
#include <boost/lexical_cast.hpp>
#include <iostream>
using std::cout;
using std::endl;
using std::string;
using std::vector;
ResultModel::ResultModel(vector<vector<int>> inputData, vector<string> header,
QObject * parent)
: QAbstractTableModel(parent) {
this->inputData = inputData;
this->headers = header;
}
QVariant ResultModel::headerData(int section, Qt::Orientation orientation,
int role) const {
if (role == Qt::DisplayRole) {
if (orientation == Qt::Horizontal) {
if (section < static_cast<int>(this->headers.size())) {
unsigned long index = static_cast<unsigned long>(section);
string strToReturn = this->headers.at(index);
QString qStrToReturn = QString::fromStdString(strToReturn);
return qStrToReturn;
}
else {
return QVariant();
}
}
}
return QVariant();
}
int ResultModel::rowCount(const QModelIndex & parent) const {
Q_UNUSED(parent);
return static_cast<int>(this->inputData.size());
}
int ResultModel::columnCount(const QModelIndex & parent) const {
Q_UNUSED(parent);
if (this->inputData.size() > 0) {
return static_cast<int>(this->inputData.at(0).size());
}
else {
return 0;
}
}
QVariant ResultModel::data(const QModelIndex & index, int role) const {
try {
if (role == Qt::EditRole || role == Qt::DisplayRole) {
unsigned long row = static_cast<unsigned long>(index.row());
unsigned long col = static_cast<unsigned long>(index.column());
int value = this->inputData.at(row).at(col);
return QString::fromStdString(boost::lexical_cast<string>(value));
}
} catch (std::exception & e) {
Q_UNUSED(e);
}
return QVariant();
}

33
resultmodel.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef RESULTMODEL_H
#define RESULTMODEL_H
#include <QAbstractTableModel>
#include <string>
#include <vector>
using std::vector;
using std::string;
class ResultModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit ResultModel(vector<vector<int>> inputData,
vector<string> header, QObject *parent = nullptr);
// Header:
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
// Basic functionality:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
private:
std::vector<std::vector<int>> inputData;
std::vector<std::string> headers;
};
#endif // RESULTMODEL_H

View File

@@ -49,44 +49,51 @@ WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
"from Strecke where id_bahn like 1 order by seit DESC limit 1";
vector<vector<QString>> res;
res = db->getData(statement, 6);
ui->lEShellGeraden->setText(res[0][0]);
ui->lEShellKurvenAussen->setText(res[0][1]);
ui->lEShellKurvenInnen->setText(res[0][2]);
ui->lEShellSteilkurveInnen->setText(res[0][3]);
ui->lEShellSteilkurveaussen->setText(res[0][4]);
try {
res = db->getData(statement, 6);
ui->lEShellGeraden->setText(res.at(0).at(0));
ui->lEShellKurvenAussen->setText(res.at(0).at(1));
ui->lEShellKurvenInnen->setText(res.at(0).at(2));
ui->lEShellSteilkurveInnen->setText(res.at(0).at(3));
ui->lEShellSteilkurveaussen->setText(res.at(0).at(4));
// Dea prepare
statement = "select geraden, kurven_aussen, "
"kurven_innen, steilkurve_innen, steilkurve_aussen, seit "
"from Strecke where id_bahn like 2 order by seit DESC limit 1";
// Dea prepare
statement =
"select geraden, kurven_aussen, "
"kurven_innen, steilkurve_innen, steilkurve_aussen, seit "
"from Strecke where id_bahn like 2 order by seit DESC limit 1";
res = db->getData(statement, 6);
ui->lEDeaGeraden->setText(res[0][0]);
ui->lEDeaKurvenAussen->setText(res[0][1]);
ui->lEDeaKurvenInnen->setText(res[0][2]);
ui->lEDeaSteilkurveInnen->setText(res[0][3]);
ui->lEDeaSteilkurveAussen->setText(res[0][4]);
res = db->getData(statement, 6);
ui->lEDeaGeraden->setText(res.at(0).at(0));
ui->lEDeaKurvenAussen->setText(res.at(0).at(1));
ui->lEDeaKurvenInnen->setText(res.at(0).at(2));
ui->lEDeaSteilkurveInnen->setText(res.at(0).at(3));
ui->lEDeaSteilkurveAussen->setText(res.at(0).at(4));
// duration prepare
statement = "select dauer, mindestrundendauer, minsec1, minsec2, minsec3 "
"from renndauer";
res = db->getData(statement, 5);
this->ui->leRenndauer->setText(res[0][0]);
this->ui->lEMinTimeSec1->setText(res[0][2]);
this->ui->lEMinTimeSec2->setText(res[0][3]);
this->ui->lEMinTimeSec3->setText(res[0][4]);
// duration prepare
statement =
"select dauer, mindestrundendauer, minsec1, minsec2, minsec3 "
"from renndauer";
res = db->getData(statement, 5);
this->ui->leRenndauer->setText(res.at(0).at(0));
this->ui->lEMinTimeSec1->setText(res.at(0).at(2));
this->ui->lEMinTimeSec2->setText(res.at(0).at(3));
this->ui->lEMinTimeSec3->setText(res.at(0).at(4));
// changed -> not reasonable
// int minLapTime = res[0][2].toInt() + res[0][3].toInt() +
// res[0][4].toInt();
this->ui->lEMinRundenzeit->setText(res[0][1]);
// changed -> not reasonable
// int minLapTime = res[0][2].toInt() + res[0][3].toInt() +
// res[0][4].toInt();
this->ui->lEMinRundenzeit->setText(res.at(0).at(1));
statement =
"SELECT id, minimumroundtime FROM rennen order by id DESC limit 1";
res = this->db->getData(statement, 2);
this->rennId = res[0][0].toInt();
this->ui->lEMinRundenzeitAktRennen->setText(res[0][1]);
statement =
"SELECT id, minimumroundtime FROM rennen order by id DESC limit 1";
res = this->db->getData(statement, 2);
this->rennId = res[0][0].toInt();
this->ui->lEMinRundenzeitAktRennen->setText(res.at(0).at(1));
} catch (std::exception & e) {
cout << "missing database :(" << endl;
}
}
void WindowsSettings::repaintMinLapTime() {
int minlapTime = 0;

View File

@@ -17,8 +17,11 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="Strecke">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Rennliste Erstellen&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="Dauer">
<attribute name="title">
@@ -381,6 +384,63 @@
</property>
</widget>
</widget>
<widget class="QWidget" name="CreateList">
<attribute name="title">
<string>Rennliste Erstellen</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<layout class="QVBoxLayout" name="verticalLayout_26">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QGroupBox" name="groupBox_19">
<property name="title">
<string>Fahrer</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
<item>
<widget class="QListView" name="lVDrivers"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_20">
<property name="title">
<string>Autos</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
<item>
<widget class="QListView" name="lVCars"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPushButton" name="pBCancel">
<property name="text">
<string>Abbrechen</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pBcreateListClose">
<property name="text">
<string>Liste Erstellen und Schließen</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@@ -391,7 +451,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
<height>24</height>
</rect>
</property>
</widget>