fixes for usb-support
This commit is contained in:
24
.clang-format
Normal file
24
.clang-format
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
# We'll use defaults from the LLVM style, but with 4 columns indentation.
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
---
|
||||
Language: Cpp
|
||||
# Force pointers to the type for C++.
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Middle
|
||||
AlignTrailingComments: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
BeforeElse: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||
---
|
||||
Language: JavaScript
|
||||
# Use 100 columns for JS.
|
||||
ColumnLimit: 100
|
||||
---
|
||||
Language: Proto
|
||||
# Don't format .proto files.
|
||||
DisableFormat: true
|
||||
...
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.o
|
||||
moc_*
|
||||
@@ -51,8 +51,11 @@ FORMS += mainwindow.ui \
|
||||
|
||||
OTHER_FILES +=
|
||||
|
||||
INCLUDEPATH += /home/jpaehr/Dokumente/libusb/libusb
|
||||
#INCLUDEPATH += /home/johannes/Dokumente/libusb/libusb
|
||||
LIBS += -L "/usr/lib" -lusb
|
||||
|
||||
RESOURCES += \
|
||||
resource.qrc
|
||||
|
||||
DISTFILES += \
|
||||
.clang-format
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.4.0, 2017-09-12T15:10:06. -->
|
||||
<!-- Written by QtCreator 4.3.1, 2017-12-24T15:47:52. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{15687edb-7104-42fa-a53c-7d0294bb7338}</value>
|
||||
<value type="QByteArray">{fa7f3dc3-5b46-4468-a19f-ea195cf466a8}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
@@ -54,79 +54,21 @@
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap"/>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuelist type="QVariantList" key="ClangStaticAnalyzer.SuppressedDiagnostics"/>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e7c8e272-6c95-4fb7-9b69-d295b2ca02f0}</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.9.1 in PATH (qt5)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.9.1 in PATH (qt5)</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{48e51839-112c-4842-badf-f2eb9bcf81cb}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jpaehr/Dokumente/build-RennbahnZeitmessung-Desktop-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
|
||||
<value type="QString">-w</value>
|
||||
<value type="QString">-r</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jpaehr/Dokumente/build-RennbahnZeitmessung-Desktop-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/johannes/Dokumente/build-RennbahnZeitmessung-Qt_5_9_1_in_PATH_qt5-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -172,7 +114,7 @@
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
@@ -185,8 +127,8 @@
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jpaehr/Dokumente/build-RennbahnZeitmessung-Desktop-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/johannes/Dokumente/build-RennbahnZeitmessung-Qt_5_9_1_in_PATH_qt5-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -196,7 +138,7 @@
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
@@ -232,29 +174,29 @@
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Lokales Deployment</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
@@ -304,13 +246,13 @@
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">RennbahnZeitmessung</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jpaehr/Dokumente/rennbahnc/RennbahnZeitmessung.pro</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/johannes/Dokumente/rennbahnc/RennbahnZeitmessung.pro</value>
|
||||
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">RennbahnZeitmessung.pro</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/jpaehr/Dokumente/build-RennbahnZeitmessung-Desktop-Debug</value>
|
||||
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/johannes/Dokumente/build-RennbahnZeitmessung-Qt_5_9_1_in_PATH_qt5-Release</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
|
||||
14
ampel.cpp
14
ampel.cpp
@@ -1,25 +1,23 @@
|
||||
#include "ampel.h"
|
||||
#include <unistd.h>
|
||||
|
||||
Ampel::Ampel()
|
||||
{
|
||||
Ampel::Ampel() {
|
||||
this->running = 1;
|
||||
}
|
||||
void Ampel::setStop(){
|
||||
void Ampel::setStop() {
|
||||
this->running = 0;
|
||||
}
|
||||
|
||||
void Ampel::run(){
|
||||
void Ampel::run() {
|
||||
int anzahl = 0;
|
||||
while(this->running){
|
||||
while (this->running) {
|
||||
anzahl++;
|
||||
if(anzahl < 6){
|
||||
if (anzahl < 6) {
|
||||
usleep(800000);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
usleep(1400000);
|
||||
}
|
||||
emit ampelUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
#include "countdown.h"
|
||||
#include "unistd.h"
|
||||
Countdown::Countdown()
|
||||
{
|
||||
Countdown::Countdown() {
|
||||
this->running = 1;
|
||||
}
|
||||
void Countdown::setStop(){
|
||||
void Countdown::setStop() {
|
||||
this->running = 0;
|
||||
}
|
||||
|
||||
void Countdown::run(){
|
||||
while(this->running){
|
||||
void Countdown::run() {
|
||||
while (this->running) {
|
||||
sleep(1);
|
||||
emit CountdownUpdate();
|
||||
}
|
||||
|
||||
18
counter.cpp
18
counter.cpp
@@ -1,21 +1,19 @@
|
||||
#include "counter.h"
|
||||
#include <sys/time.h>
|
||||
#include <iostream>
|
||||
#include "counter.h"
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <sys/time.h>
|
||||
|
||||
Counter::Counter()
|
||||
{
|
||||
|
||||
Counter::Counter() {
|
||||
}
|
||||
|
||||
void Counter::start(){
|
||||
void Counter::start() {
|
||||
gettimeofday(&startTime, NULL);
|
||||
}
|
||||
|
||||
long Counter::getTime(){
|
||||
long Counter::getTime() {
|
||||
gettimeofday(&endTime, NULL);
|
||||
long back = (endTime.tv_usec-startTime.tv_usec)/1000+(endTime.tv_sec-startTime.tv_sec)*1000;
|
||||
long back = (endTime.tv_usec - startTime.tv_usec) / 1000 +
|
||||
(endTime.tv_sec - startTime.tv_sec) * 1000;
|
||||
this->start();
|
||||
return back;
|
||||
|
||||
}
|
||||
|
||||
47
database.cpp
47
database.cpp
@@ -1,66 +1,65 @@
|
||||
#include "database.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <QVariant>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using std::vector;
|
||||
|
||||
DataBase::DataBase()
|
||||
{
|
||||
DataBase::DataBase() {
|
||||
this->db = new QSqlDatabase();
|
||||
*this->db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
this->db->setDatabaseName("Renndatenbank.sqlite");
|
||||
std::cout << "Konstruktor Database" << std::endl;
|
||||
}
|
||||
DataBase::~DataBase(){
|
||||
DataBase::~DataBase() {
|
||||
std::cout << "Destruktor aus Datenbank" << std::endl;
|
||||
delete this->db;
|
||||
//delete this;
|
||||
// delete this;
|
||||
}
|
||||
|
||||
vector< vector<QString> > DataBase::getData2(std::string statement, int cols){
|
||||
vector<vector<QString>> DataBase::getData2(std::string statement, int cols) {
|
||||
|
||||
vector<QString> data;
|
||||
vector< vector<QString> > lines;
|
||||
vector<vector<QString>> lines;
|
||||
bool ok = this->db->open();
|
||||
QString qstr;
|
||||
if(ok){
|
||||
if (ok) {
|
||||
QSqlQuery query;
|
||||
query.exec(QString::fromStdString(statement));
|
||||
while(query.next()){
|
||||
while (query.next()) {
|
||||
|
||||
for(int i = 0; i < cols; i++){
|
||||
for (int i = 0; i < cols; i++) {
|
||||
qstr = query.value(i).toString();
|
||||
data.push_back(qstr);
|
||||
}
|
||||
lines.push_back(data);
|
||||
data.erase(data.begin(), data.begin()+cols);
|
||||
data.erase(data.begin(), data.begin() + cols);
|
||||
}
|
||||
}
|
||||
this->db->close();
|
||||
return lines;
|
||||
}
|
||||
|
||||
vector< vector<QString> > DataBase::getData(std::string statement, int cols){
|
||||
vector<vector<QString>> DataBase::getData(std::string statement, int cols) {
|
||||
|
||||
char * buffer = new char[statement.length()+1];
|
||||
strcpy(buffer,statement.c_str());
|
||||
char * buffer = new char[statement.length() + 1];
|
||||
strcpy(buffer, statement.c_str());
|
||||
vector<QString> data;
|
||||
vector< vector<QString> > lines;
|
||||
vector<vector<QString>> lines;
|
||||
bool ok = this->db->open();
|
||||
QString qstr;
|
||||
if(ok){
|
||||
if (ok) {
|
||||
QSqlQuery query(buffer);
|
||||
|
||||
while(query.next()){
|
||||
while (query.next()) {
|
||||
|
||||
for(int i = 0; i < cols; i++){
|
||||
for (int i = 0; i < cols; i++) {
|
||||
qstr = query.value(i).toString();
|
||||
data.push_back(qstr);
|
||||
}
|
||||
lines.push_back(data);
|
||||
data.erase(data.begin(), data.begin()+cols);
|
||||
data.erase(data.begin(), data.begin() + cols);
|
||||
}
|
||||
}
|
||||
this->db->close();
|
||||
@@ -68,11 +67,11 @@ vector< vector<QString> > DataBase::getData(std::string statement, int cols){
|
||||
return lines;
|
||||
}
|
||||
|
||||
void DataBase::setData(std::string statement){
|
||||
char * buffer = new char[statement.length()+1];
|
||||
strcpy(buffer,statement.c_str());
|
||||
void DataBase::setData(std::string statement) {
|
||||
char * buffer = new char[statement.length() + 1];
|
||||
strcpy(buffer, statement.c_str());
|
||||
bool ok = this->db->open();
|
||||
if(ok){
|
||||
if (ok) {
|
||||
QSqlQuery query(buffer);
|
||||
}
|
||||
this->db->close();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include <QDir>
|
||||
#include <QtSql/QSqlQuery>
|
||||
#include<vector>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using std::vector;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "hardwaresetup.h"
|
||||
#include <unistd.h>
|
||||
#include "sys/io.h"
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <usb.h>
|
||||
|
||||
#define USB_LED_ON 1
|
||||
@@ -17,53 +17,51 @@ using namespace std;
|
||||
// #define BASEPORT 0x378
|
||||
// #define BASEPORT 0xd000
|
||||
|
||||
HardwareSetup::HardwareSetup()
|
||||
{
|
||||
// if (ioperm(BASEPORT, 3, 1)) {
|
||||
// //perror("ioperm");
|
||||
// }
|
||||
HardwareSetup::HardwareSetup() {
|
||||
// if (ioperm(BASEPORT, 3, 1)) {
|
||||
// //perror("ioperm");
|
||||
// }
|
||||
this->stop = 0;
|
||||
this->handle = NULL;
|
||||
}
|
||||
void HardwareSetup::setStop(){
|
||||
void HardwareSetup::setStop() {
|
||||
this->stop = 1;
|
||||
}
|
||||
|
||||
HardwareSetup::~HardwareSetup(){
|
||||
HardwareSetup::~HardwareSetup() {
|
||||
/*if (ioperm(BASEPORT, 3, 0)) {
|
||||
//perror("ioperm");
|
||||
}*/
|
||||
std::cout << "Hardware beendet" << std::endl;
|
||||
this->stop = 1;
|
||||
if(this->handle){
|
||||
if (this->handle) {
|
||||
usb_close(this->handle);
|
||||
}
|
||||
this->handle = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Used to get descriptor strings for device identification */
|
||||
int HardwareSetup::usbGetDescriptorString(usb_dev_handle *dev, int index, int langid,
|
||||
char *buf, int buflen) {
|
||||
int HardwareSetup::usbGetDescriptorString(usb_dev_handle * dev, int index,
|
||||
int langid, char * buf, int buflen) {
|
||||
char buffer[256];
|
||||
int rval, i;
|
||||
|
||||
// make standard request GET_DESCRIPTOR, type string and given index
|
||||
// (e.g. dev->iProduct)
|
||||
rval = usb_control_msg(dev,
|
||||
USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) + index, langid,
|
||||
buffer, sizeof(buffer), 1000);
|
||||
rval = usb_control_msg(
|
||||
dev, USB_TYPE_STANDARD | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
USB_REQ_GET_DESCRIPTOR, (USB_DT_STRING << 8) + index, langid, buffer,
|
||||
sizeof(buffer), 1000);
|
||||
|
||||
if(rval < 0) // error
|
||||
if (rval < 0) // error
|
||||
return rval;
|
||||
|
||||
// rval should be bytes read, but buffer[0] contains the actual response size
|
||||
if((unsigned char)buffer[0] < rval)
|
||||
// rval should be bytes read, but buffer[0] contains the actual response
|
||||
// size
|
||||
if ((unsigned char)buffer[0] < rval)
|
||||
rval = (unsigned char)buffer[0]; // string is shorter than bytes read
|
||||
|
||||
if(buffer[1] != USB_DT_STRING) // second byte is the data type
|
||||
if (buffer[1] != USB_DT_STRING) // second byte is the data type
|
||||
return 0; // invalid return type
|
||||
|
||||
// we're dealing with UTF-16LE here so actual chars is half of rval,
|
||||
@@ -71,23 +69,21 @@ int HardwareSetup::usbGetDescriptorString(usb_dev_handle *dev, int index, int la
|
||||
rval /= 2;
|
||||
|
||||
/* lossy conversion to ISO Latin1 */
|
||||
for(i = 1; i < rval && i < buflen; i++) {
|
||||
if(buffer[2 * i + 1] == 0)
|
||||
buf[i-1] = buffer[2 * i];
|
||||
for (i = 1; i < rval && i < buflen; i++) {
|
||||
if (buffer[2 * i + 1] == 0)
|
||||
buf[i - 1] = buffer[2 * i];
|
||||
else
|
||||
buf[i-1] = '?'; /* outside of ISO Latin1 range */
|
||||
buf[i - 1] = '?'; /* outside of ISO Latin1 range */
|
||||
}
|
||||
buf[i-1] = 0;
|
||||
buf[i - 1] = 0;
|
||||
|
||||
return i-1;
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char *vendorName,
|
||||
int product, char *productName) {
|
||||
struct usb_bus *bus;
|
||||
struct usb_device *dev;
|
||||
usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char * vendorName,
|
||||
int product, char * productName) {
|
||||
struct usb_bus * bus;
|
||||
struct usb_device * dev;
|
||||
char devVendor[256], devProduct[256];
|
||||
|
||||
usb_dev_handle * handle = NULL;
|
||||
@@ -96,22 +92,23 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char *vendorName,
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
|
||||
for(bus=usb_get_busses(); bus; bus=bus->next) {
|
||||
for(dev=bus->devices; dev; dev=dev->next) {
|
||||
if(dev->descriptor.idVendor != vendor ||
|
||||
for (bus = usb_get_busses(); bus; bus = bus->next) {
|
||||
for (dev = bus->devices; dev; dev = dev->next) {
|
||||
if (dev->descriptor.idVendor != vendor ||
|
||||
dev->descriptor.idProduct != product)
|
||||
continue;
|
||||
|
||||
/* we need to open the device in order to query strings */
|
||||
if(!(handle = usb_open(dev))) {
|
||||
if (!(handle = usb_open(dev))) {
|
||||
fprintf(stderr, "Warning: cannot open USB device: %sn",
|
||||
usb_strerror());
|
||||
continue;
|
||||
}
|
||||
|
||||
/* get vendor name */
|
||||
if(usbGetDescriptorString(handle, dev->descriptor.iManufacturer,
|
||||
0x0409, devVendor, sizeof(devVendor)) < 0) {
|
||||
if (usbGetDescriptorString(handle, dev->descriptor.iManufacturer,
|
||||
0x0409, devVendor,
|
||||
sizeof(devVendor)) < 0) {
|
||||
fprintf(stderr,
|
||||
"Warning: cannot query manufacturer for device: %sn",
|
||||
usb_strerror());
|
||||
@@ -120,16 +117,15 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char *vendorName,
|
||||
}
|
||||
|
||||
/* get product name */
|
||||
if(usbGetDescriptorString(handle, dev->descriptor.iProduct,
|
||||
0x0409, devProduct, sizeof(devVendor)) < 0) {
|
||||
fprintf(stderr,
|
||||
"Warning: cannot query product for device: %sn",
|
||||
if (usbGetDescriptorString(handle, dev->descriptor.iProduct, 0x0409,
|
||||
devProduct, sizeof(devVendor)) < 0) {
|
||||
fprintf(stderr, "Warning: cannot query product for device: %sn",
|
||||
usb_strerror());
|
||||
usb_close(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(strcmp(devVendor, vendorName) == 0 &&
|
||||
if (strcmp(devVendor, vendorName) == 0 &&
|
||||
strcmp(devProduct, productName) == 0)
|
||||
return handle;
|
||||
else
|
||||
@@ -139,44 +135,41 @@ usb_dev_handle * HardwareSetup::usbOpenDevice(int vendor, char *vendorName,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void HardwareSetup::run(){
|
||||
void HardwareSetup::run() {
|
||||
|
||||
int nBytes = 0;
|
||||
//char buffer[256];
|
||||
struct TransStruct buffer[2];
|
||||
//struct TransStruct *buffer = buffer1;
|
||||
//cout << "thread started" << endl;
|
||||
// char buffer[256];
|
||||
struct TransStruct buffer[6];
|
||||
// struct TransStruct *buffer = buffer1;
|
||||
// cout << "thread started" << endl;
|
||||
|
||||
// if(argc < 2) {
|
||||
// printf("Usage:\n");
|
||||
// printf("usbtext.exe on\n");
|
||||
// printf("usbtext.exe off\n");
|
||||
// exit(1);
|
||||
// }
|
||||
while(!this->handle){
|
||||
// if(argc < 2) {
|
||||
// printf("Usage:\n");
|
||||
// printf("usbtext.exe on\n");
|
||||
// printf("usbtext.exe off\n");
|
||||
// exit(1);
|
||||
// }
|
||||
while (!this->handle) {
|
||||
this->handle = usbOpenDevice(0x16C0, "test01", 0x05DC, "USBExample");
|
||||
|
||||
if(this->handle == NULL) {
|
||||
if (this->handle == NULL) {
|
||||
fprintf(stderr, "Could not find USB device!\n");
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int index;
|
||||
while(!this->stop){
|
||||
while (!this->stop) {
|
||||
usleep(100000); // 100ms
|
||||
|
||||
//while(1){
|
||||
nBytes = usb_control_msg(this->handle,
|
||||
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
// while(1){
|
||||
nBytes = usb_control_msg(
|
||||
this->handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
|
||||
USB_DATA_OUT, 0, 0, (char *)buffer, sizeof(buffer), 5000);
|
||||
|
||||
for(int i = 0; i < 2; i++){
|
||||
if(buffer[i].update != 0){
|
||||
switch(buffer[i].id){
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (buffer[i].update != 0) {
|
||||
switch (buffer[i].id) {
|
||||
case 0:
|
||||
cout << "Shell Zeit 1: " << (int)buffer[i].time << endl;
|
||||
emit Shell((int)buffer[i].time, 1);
|
||||
@@ -204,70 +197,67 @@ void HardwareSetup::run(){
|
||||
}
|
||||
}
|
||||
}
|
||||
if(buffer[0].update != 0){
|
||||
cout << "Got " << nBytes << " bytes: " << (int)buffer[2].time << ", " << (int)buffer[2].id << endl;
|
||||
if (buffer[0].update != 0) {
|
||||
cout << "Got " << nBytes << " bytes: " << (int)buffer[2].time
|
||||
<< ", " << (int)buffer[2].id << endl;
|
||||
}
|
||||
//}
|
||||
|
||||
if(nBytes < 0)
|
||||
if (nBytes < 0)
|
||||
fprintf(stderr, "USB error: %sn", usb_strerror());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool HardwareSetup::getShell() {
|
||||
|
||||
bool HardwareSetup::getShell(){
|
||||
// int zahl[8] = {0};
|
||||
|
||||
// int zahl[8] = {0};
|
||||
// if(findBit(zahl, inb(BASEPORT + 1))[7] == 1){
|
||||
|
||||
// if(findBit(zahl, inb(BASEPORT + 1))[7] == 1){
|
||||
|
||||
|
||||
// return true;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
|
||||
}
|
||||
bool HardwareSetup::getDea(){
|
||||
bool HardwareSetup::getDea() {
|
||||
|
||||
// int zahl[8] = {0};
|
||||
// int zahl[8] = {0};
|
||||
|
||||
// if(findBit(zahl, inb(BASEPORT + 1))[6] == 0 ){
|
||||
// return true;
|
||||
// }
|
||||
// if(findBit(zahl, inb(BASEPORT + 1))[6] == 0 ){
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
int* HardwareSetup::findBit(int *array, int zahl){
|
||||
if(zahl >=128){
|
||||
int * HardwareSetup::findBit(int * array, int zahl) {
|
||||
if (zahl >= 128) {
|
||||
array[7] = 1;
|
||||
zahl -= 128;
|
||||
}
|
||||
if(zahl >=64){
|
||||
if (zahl >= 64) {
|
||||
array[6] = 1;
|
||||
zahl -= 64;
|
||||
}
|
||||
if(zahl >=32){
|
||||
if (zahl >= 32) {
|
||||
array[5] = 1;
|
||||
zahl -= 32;
|
||||
}
|
||||
if(zahl >=16){
|
||||
if (zahl >= 16) {
|
||||
array[4] = 1;
|
||||
zahl -= 16;
|
||||
}
|
||||
if(zahl >=8){
|
||||
if (zahl >= 8) {
|
||||
array[3] = 1;
|
||||
zahl -= 8;
|
||||
}
|
||||
if(zahl >=4){
|
||||
if (zahl >= 4) {
|
||||
array[2] = 1;
|
||||
zahl -= 4;
|
||||
}
|
||||
if(zahl >=2){
|
||||
if (zahl >= 2) {
|
||||
array[1] = 1;
|
||||
zahl -= 2;
|
||||
}
|
||||
if(zahl >=1){
|
||||
if (zahl >= 1) {
|
||||
array[0] = 1;
|
||||
zahl -= 1;
|
||||
}
|
||||
|
||||
3
main.cpp
3
main.cpp
@@ -1,8 +1,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char * argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
#include "mainwindow.h"
|
||||
#include "database.h"
|
||||
#include "hardwaresetup.h"
|
||||
#include "training.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "unistd.h"
|
||||
#include "windowrace.h"
|
||||
#include "windowrennliste2.h"
|
||||
#include "windowssettings.h"
|
||||
#include <QObject>
|
||||
#include <QShortcut>
|
||||
#include "windowssettings.h"
|
||||
#include <iostream>
|
||||
#include "hardwaresetup.h"
|
||||
#include "windowrace.h"
|
||||
#include "database.h"
|
||||
#include <vector>
|
||||
#include "windowrennliste2.h"
|
||||
#include "training.h"
|
||||
#include "unistd.h"
|
||||
using std::vector;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
MainWindow::MainWindow(QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
this->interfaceTraining = NULL;
|
||||
|
||||
@@ -24,50 +22,48 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
this->interfaceSettings = NULL;
|
||||
this->interfaceRennliste = NULL;
|
||||
|
||||
//test = new HardwareSetup;
|
||||
// test = new HardwareSetup;
|
||||
|
||||
//this->test->start();
|
||||
QObject::connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(NewWindowSettings()));
|
||||
// this->test->start();
|
||||
QObject::connect(ui->pushButton, SIGNAL(clicked()), this,
|
||||
SLOT(NewWindowSettings()));
|
||||
|
||||
QObject::connect(ui->pBRennen, SIGNAL(clicked()), this, SLOT(WindowRennen()));
|
||||
QObject::connect(this->ui->pBTraining, SIGNAL(clicked()), this, SLOT(WindowTraining()));
|
||||
|
||||
QShortcut *startTraining = new QShortcut(QKeySequence("Ctrl+t"), this);
|
||||
QShortcut *startRennen = new QShortcut(QKeySequence("Ctrl+r"), this);
|
||||
|
||||
QObject::connect(startTraining, SIGNAL(activated()), this, SLOT(WindowTraining()));
|
||||
QObject::connect(startRennen, SIGNAL(activated()), this, SLOT(WindowRennen()));
|
||||
QObject::connect(ui->pBRennen, SIGNAL(clicked()), this,
|
||||
SLOT(WindowRennen()));
|
||||
QObject::connect(this->ui->pBTraining, SIGNAL(clicked()), this,
|
||||
SLOT(WindowTraining()));
|
||||
|
||||
QShortcut * startTraining = new QShortcut(QKeySequence("Ctrl+t"), this);
|
||||
QShortcut * startRennen = new QShortcut(QKeySequence("Ctrl+r"), this);
|
||||
|
||||
QObject::connect(startTraining, SIGNAL(activated()), this,
|
||||
SLOT(WindowTraining()));
|
||||
QObject::connect(startRennen, SIGNAL(activated()), this,
|
||||
SLOT(WindowRennen()));
|
||||
|
||||
this->db = new DataBase;
|
||||
|
||||
vector< vector <QString> > daten = db->getData("select * from Fahrer", 2);
|
||||
|
||||
|
||||
vector<vector<QString>> daten = db->getData("select * from Fahrer", 2);
|
||||
}
|
||||
void MainWindow::closeEvent(QCloseEvent *event){
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent * event) {
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
MainWindow::~MainWindow() {
|
||||
delete this->db;
|
||||
delete ui;
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::WindowTraining(){
|
||||
void MainWindow::WindowTraining() {
|
||||
this->interfaceTraining = new Training(this, this->db);
|
||||
this->interfaceTraining->show();
|
||||
}
|
||||
|
||||
void MainWindow::NewWindowSettings(){
|
||||
void MainWindow::NewWindowSettings() {
|
||||
this->interfaceSettings = new WindowsSettings(this->db, this);
|
||||
this->interfaceSettings->show();
|
||||
}
|
||||
|
||||
void MainWindow::WindowRennen(){
|
||||
void MainWindow::WindowRennen() {
|
||||
this->interfaceRace = new WindowRace(this->db, this);
|
||||
this->interfaceRace->show();
|
||||
this->interfaceRennliste = new WindowRennliste(this->db, this);
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
#include "qvectorhelper.h"
|
||||
#include <qvector.h>
|
||||
|
||||
QVectorHelper::QVectorHelper()
|
||||
{
|
||||
|
||||
QVectorHelper::QVectorHelper() {
|
||||
}
|
||||
|
||||
int QVectorHelper::getCurTime(const QVector<int> x) {
|
||||
if(x.size() >= 3){
|
||||
return x.at(0)+ x.at(1) + x.at(2);
|
||||
if (x.size() >= 3) {
|
||||
return x.at(0) + x.at(1) + x.at(2);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return 9999;
|
||||
}
|
||||
}
|
||||
|
||||
int QVectorHelper::getMin(const QVector<QVector<int>> x){
|
||||
int QVectorHelper::getMin(const QVector<QVector<int>> x) {
|
||||
int min;
|
||||
if(x.size() > 0){
|
||||
if(x.at(0).size() >= 3){
|
||||
if (x.size() > 0) {
|
||||
if (x.at(0).size() >= 3) {
|
||||
min = getCurTime(x.at(0));
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return 9999;
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return 9999;
|
||||
}
|
||||
for(int i = 1; i < x.size(); i++){
|
||||
if(getCurTime(x.at(i)) < min){
|
||||
for (int i = 1; i < x.size(); i++) {
|
||||
if (getCurTime(x.at(i)) < min) {
|
||||
min = getCurTime(x.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
115
timemodel.cpp
115
timemodel.cpp
@@ -1,25 +1,24 @@
|
||||
#include "timemodel.h"
|
||||
#include<qvector.h>
|
||||
#include <iostream>
|
||||
#include <qcolor.h>
|
||||
#include <qvector.h>
|
||||
|
||||
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes,
|
||||
QObject * parent)
|
||||
: QAbstractTableModel(parent) {
|
||||
this->timeData = timeData;
|
||||
this->minimumTimes = minimumTimes;
|
||||
}
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes, QVector<int> topTime, QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes,
|
||||
QVector<int> topTime, QObject * parent)
|
||||
: QAbstractTableModel(parent) {
|
||||
this->topTime = topTime;
|
||||
this->timeData = timeData;
|
||||
this->minimumTimes = minimumTimes;
|
||||
}
|
||||
|
||||
QVariant TimeModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
QVariant TimeModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const {
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
@@ -43,123 +42,129 @@ QVariant TimeModel::headerData(int section, Qt::Orientation orientation, int rol
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int TimeModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
int TimeModel::rowCount(const QModelIndex & parent) const {
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
|
||||
return this->timeData.size();
|
||||
}
|
||||
|
||||
int TimeModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
int TimeModel::columnCount(const QModelIndex & parent) const {
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return 4;
|
||||
}
|
||||
|
||||
QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col, const int row) const{
|
||||
if(row == 0){
|
||||
QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col,
|
||||
const int row) const {
|
||||
if (row == 0) {
|
||||
return QColor(Qt::gray);
|
||||
}
|
||||
else if(data.size() > row){ // check for enough rows
|
||||
if(data.at(row).size() > col){ // check for enough cols
|
||||
if(col < 3){
|
||||
if(data.at(row).at(col) < this->minimumTimes.at(col)){
|
||||
else if (data.size() > row) { // check for enough rows
|
||||
if (data.at(row).size() > col) { // check for enough cols
|
||||
if (col < 3) {
|
||||
if (data.at(row).at(col) < this->minimumTimes.at(col)) {
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// lap time
|
||||
if( data.at(row).at(0) < this->minimumTimes.at(0)
|
||||
|| data.at(row).at(1) < this->minimumTimes.at(1)
|
||||
|| data.at(row).at(2) < this->minimumTimes.at(2)){
|
||||
if (data.at(row).at(0) < this->minimumTimes.at(0) ||
|
||||
data.at(row).at(1) < this->minimumTimes.at(1) ||
|
||||
data.at(row).at(2) < this->minimumTimes.at(2)) {
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<int> compare;
|
||||
for(int i = 0; i <= row; i++){
|
||||
if(data.at(i).size() > col){
|
||||
for (int i = 0; i <= row; i++) {
|
||||
if (data.at(i).size() > col) {
|
||||
compare.append(data.at(i).at(col));
|
||||
}
|
||||
}
|
||||
if(data.at(row).at(col) == getMin(compare)){ // at least personal best time
|
||||
if(col < 3){ // sector time
|
||||
// std::cout << this->topTime.size() << std::endl;
|
||||
if(this->topTime.size() > col){ // absolute top time exists
|
||||
// std::cout << "local besttime" << std::endl;
|
||||
if(this->topTime.at(col) >= data.at(row).at(col)){
|
||||
if (data.at(row).at(col) ==
|
||||
getMin(compare)) { // at least personal best time
|
||||
if (col < 3) { // sector time
|
||||
// std::cout << this->topTime.size() <<
|
||||
// std::endl;
|
||||
if (this->topTime.size() >
|
||||
col) { // absolute top time exists
|
||||
// std::cout << "local besttime"
|
||||
// << std::endl;
|
||||
if (this->topTime.at(col) >= data.at(row).at(col)) {
|
||||
return QColor(Qt::magenta);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{ // lap time
|
||||
if(this->topTime.size() == 3){
|
||||
if(this->topTime.at(0) + this->topTime.at(1) + this->topTime.at(2) >= data.at(row).at(col)){
|
||||
else { // lap time
|
||||
if (this->topTime.size() == 3) {
|
||||
if (this->topTime.at(0) + this->topTime.at(1) +
|
||||
this->topTime.at(2) >=
|
||||
data.at(row).at(col)) {
|
||||
return QColor(Qt::magenta);
|
||||
}
|
||||
}
|
||||
}
|
||||
return QColor(Qt::green);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return QColor(Qt::gray);
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return QColor(Qt::white);
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return QColor(Qt::white);
|
||||
}
|
||||
}
|
||||
|
||||
int TimeModel::getMin(const QVector<int> x) const{
|
||||
int TimeModel::getMin(const QVector<int> x) const {
|
||||
int min;
|
||||
if(x.size() > 0){
|
||||
if (x.size() > 0) {
|
||||
min = x.at(0);
|
||||
}
|
||||
for(int i = 1; i < x.size(); i++){
|
||||
if(x.at(i) < min){
|
||||
for (int i = 1; i < x.size(); i++) {
|
||||
if (x.at(i) < min) {
|
||||
min = x.at(i);
|
||||
}
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
QVariant TimeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
//std::cout << "data called" << std::endl;
|
||||
QVariant TimeModel::data(const QModelIndex & index, int role) const {
|
||||
// std::cout << "data called" << std::endl;
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if(role == Qt::DisplayRole){
|
||||
if(timeData.at(index.row()).size() > index.column()){
|
||||
return QString::number((double)timeData.at(index.row()).at(index.column())/1000);
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (timeData.at(index.row()).size() > index.column()) {
|
||||
return QString::number(
|
||||
(double)timeData.at(index.row()).at(index.column()) / 1000);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return QString("∞");
|
||||
}
|
||||
}
|
||||
else if(role == Qt::BackgroundColorRole){
|
||||
else if (role == Qt::BackgroundColorRole) {
|
||||
return getColor(timeData, index.column(), index.row());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool TimeModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
//std::cout << "insert triggert" << std::endl;
|
||||
bool TimeModel::insertRows(int row, int count, const QModelIndex & parent) {
|
||||
// std::cout << "insert triggert" << std::endl;
|
||||
beginInsertRows(parent, row, row + count - 1);
|
||||
// FIXME: Implement me!
|
||||
endInsertRows();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TimeModel::insertColumns(int column, int count, const QModelIndex &parent)
|
||||
{
|
||||
bool TimeModel::insertColumns(int column, int count,
|
||||
const QModelIndex & parent) {
|
||||
beginInsertColumns(parent, column, column + count - 1);
|
||||
// FIXME: Implement me!
|
||||
endInsertColumns();
|
||||
return true;
|
||||
}
|
||||
|
||||
183
training.cpp
183
training.cpp
@@ -1,27 +1,26 @@
|
||||
#include "training.h"
|
||||
#include "qvectorhelper.h"
|
||||
#include "timemodel.h"
|
||||
#include "ui_training.h"
|
||||
#include <QObject>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <QShortcut>
|
||||
#include "unistd.h"
|
||||
#include <QListWidgetItem>
|
||||
#include "timemodel.h"
|
||||
#include "qvectorhelper.h"
|
||||
#include <QObject>
|
||||
#include <QShortcut>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
Training::Training(QWidget *parent, DataBase *db) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::Training)
|
||||
{
|
||||
Training::Training(QWidget * parent, DataBase * db)
|
||||
: QMainWindow(parent), ui(new Ui::Training) {
|
||||
ui->setupUi(this);
|
||||
this->db = db;
|
||||
string statement = "select mindestrundendauer from renndauer where id like 1";
|
||||
string statement =
|
||||
"select mindestrundendauer from renndauer where id like 1";
|
||||
|
||||
this->minimumTime = this->db->getData(statement, 1)[0][0].toInt();
|
||||
this->finished = false;
|
||||
@@ -35,36 +34,38 @@ Training::Training(QWidget *parent, DataBase *db) :
|
||||
this->Hardware = new HardwareSetup;
|
||||
Hardware->start();
|
||||
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this,
|
||||
SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this,
|
||||
SLOT(shellSlot(int, int)));
|
||||
// QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this,
|
||||
// SLOT(prepareNextRace())); QObject::connect(this->ui->pBStop,
|
||||
// SIGNAL(clicked()), this, SLOT(stopClicked()));
|
||||
|
||||
|
||||
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this, SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this, SLOT(shellSlot(int, int)));
|
||||
//QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this, SLOT(prepareNextRace()));
|
||||
//QObject::connect(this->ui->pBStop, SIGNAL(clicked()), this, SLOT(stopClicked()));
|
||||
|
||||
QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+Q"), this);
|
||||
QShortcut *shellReset = new QShortcut(QKeySequence("Ctrl+s"), this);
|
||||
QShortcut *deaReset = new QShortcut(QKeySequence("Ctrl+d"), this);
|
||||
QShortcut * shortcut = new QShortcut(QKeySequence("Ctrl+Q"), this);
|
||||
QShortcut * shellReset = new QShortcut(QKeySequence("Ctrl+s"), this);
|
||||
QShortcut * deaReset = new QShortcut(QKeySequence("Ctrl+d"), this);
|
||||
|
||||
QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(close()));
|
||||
QObject::connect(shellReset, SIGNAL(activated()), this, SLOT(ResetShell()));
|
||||
QObject::connect(deaReset, SIGNAL(activated()), this, SLOT(ResetDea()));
|
||||
|
||||
QObject::connect(this->ui->pBReset, SIGNAL(clicked()), this, SLOT(Reset()));
|
||||
QObject::connect(this->ui->pBResetDea, SIGNAL(clicked()), this, SLOT(ResetDea()));
|
||||
QObject::connect(this->ui->pBResetShell, SIGNAL(clicked()), this, SLOT(ResetShell()));
|
||||
QObject::connect(this->ui->pBResetDea, SIGNAL(clicked()), this,
|
||||
SLOT(ResetDea()));
|
||||
QObject::connect(this->ui->pBResetShell, SIGNAL(clicked()), this,
|
||||
SLOT(ResetShell()));
|
||||
|
||||
// fill minSecTimes vector
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id DESC limit 1";
|
||||
vector< vector< QString > > res;
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id "
|
||||
"DESC limit 1";
|
||||
vector<vector<QString>> res;
|
||||
res = db->getData(statement, 3);
|
||||
this->minSecTime.append(res[0][0].toInt());
|
||||
this->minSecTime.append(res[0][1].toInt());
|
||||
this->minSecTime.append(res[0][2].toInt());
|
||||
|
||||
}
|
||||
void Training::ResetShell(){
|
||||
void Training::ResetShell() {
|
||||
this->VecShell.clear();
|
||||
|
||||
// this->ui->lWShellTime->clear();
|
||||
@@ -75,10 +76,10 @@ void Training::ResetShell(){
|
||||
this->ui->lCurRoundTimeShell->setText("∞");
|
||||
this->firstTimeShell = true;
|
||||
}
|
||||
void Training::ResetDea(){
|
||||
void Training::ResetDea() {
|
||||
this->VecDea.clear();
|
||||
|
||||
//this->ui->lWDeaTime->clear();
|
||||
// this->ui->lWDeaTime->clear();
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
@@ -87,11 +88,11 @@ void Training::ResetDea(){
|
||||
this->ui->lCurRoundDea->setText("∞");
|
||||
this->firstTimeDea = true;
|
||||
}
|
||||
void Training::Reset(){
|
||||
void Training::Reset() {
|
||||
this->ResetDea();
|
||||
this->ResetShell();
|
||||
}
|
||||
void Training::prepareNextRace(){
|
||||
void Training::prepareNextRace() {
|
||||
this->firstTimeShell = true;
|
||||
this->firstTimeDea = true;
|
||||
|
||||
@@ -108,19 +109,19 @@ void Training::prepareNextRace(){
|
||||
this->started = true;
|
||||
}
|
||||
|
||||
void Training::shellSlot(int time, int sector){
|
||||
void Training::shellSlot(int time, int sector) {
|
||||
// slot is called when a sector is finished
|
||||
// time is given in ms
|
||||
// counting of sector beginns at 1
|
||||
|
||||
cout << "received Shelltime: " << time << sector << endl;
|
||||
|
||||
if(started && !paused && !this->finished){
|
||||
if(firstTimeShell){
|
||||
if (started && !paused && !this->finished) {
|
||||
if (firstTimeShell) {
|
||||
firstTimeShell = false;
|
||||
}
|
||||
else{
|
||||
switch(sector){
|
||||
else {
|
||||
switch (sector) {
|
||||
case 1:
|
||||
VecShell.push_back(QVector<int>());
|
||||
VecShell.last().push_back(time);
|
||||
@@ -130,115 +131,133 @@ void Training::shellSlot(int time, int sector){
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if(VecShell.size() > 0){
|
||||
if(VecShell.last().size() == 1){
|
||||
// cout << time << sector << endl;
|
||||
if (VecShell.size() > 0) {
|
||||
if (VecShell.last().size() == 1) {
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecShell.last().push_back(time);
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(VecShell.size() > 0){
|
||||
//cout << "Time sec 3: " << time << endl;
|
||||
if(VecShell.last().size() == 2){
|
||||
// cout << time << sector << endl;
|
||||
if (VecShell.size() > 0) {
|
||||
// cout << "Time sec 3: " << time << endl;
|
||||
if (VecShell.last().size() == 2) {
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecShell.last().push_back(time);
|
||||
|
||||
// add sum to vector
|
||||
VecShell.last().push_back(QVectorHelper::getCurTime(VecShell.last()));
|
||||
VecShell.last().push_back(
|
||||
QVectorHelper::getCurTime(VecShell.last()));
|
||||
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
// best time on widget
|
||||
|
||||
if(QVectorHelper::getCurTime(VecShell.last()) <= QVectorHelper::getMin(VecShell)){
|
||||
ui->lBestZeitShell->setText(QString::number((double)QVectorHelper::getMin(VecShell)/1000));
|
||||
if (QVectorHelper::getCurTime(VecShell.last()) <=
|
||||
QVectorHelper::getMin(VecShell)) {
|
||||
ui->lBestZeitShell->setText(QString::number(
|
||||
(double)QVectorHelper::getMin(VecShell) / 1000));
|
||||
}
|
||||
ui->lCurRoundTimeShell->setText(QString::number((double)QVectorHelper::getCurTime(VecShell.last())/1000));
|
||||
ui->lCurRoundTimeShell->setText(QString::number(
|
||||
(double)QVectorHelper::getCurTime(VecShell.last()) /
|
||||
1000));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
ui->lWShellTime->scrollToBottom();
|
||||
ui->lWShellTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
|
||||
ui->lWShellTime->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Stretch);
|
||||
}
|
||||
}
|
||||
}
|
||||
void Training::closeEvent(QCloseEvent *event){
|
||||
void Training::closeEvent(QCloseEvent * event) {
|
||||
Hardware->setStop();
|
||||
//delete this->Hardware;
|
||||
// delete this->Hardware;
|
||||
}
|
||||
|
||||
void Training::deaSlot(int time, int sector){
|
||||
void Training::deaSlot(int time, int sector) {
|
||||
// slot is called when a sector is finished
|
||||
// time is given in ms
|
||||
// counting of sector beginns at 1
|
||||
|
||||
cout << "received Deatime: " << time << sector << endl;
|
||||
|
||||
|
||||
if(started && !paused && !this->finished){
|
||||
if(firstTimeDea){
|
||||
if (started && !paused && !this->finished) {
|
||||
if (firstTimeDea) {
|
||||
firstTimeDea = false;
|
||||
}
|
||||
else{
|
||||
switch(sector){
|
||||
else {
|
||||
switch (sector) {
|
||||
case 1:
|
||||
VecDea.push_back(QVector<int>());
|
||||
VecDea.last().push_back(time);
|
||||
// cout << "Dea Sektor 1" << endl;
|
||||
// cout << "Dea Sektor 1" << endl;
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if(VecDea.size() > 0){
|
||||
if(VecDea.last().size() == 1){
|
||||
// cout << time << sector << endl;
|
||||
VecDea[VecDea.size()-1].push_back(time);
|
||||
if (VecDea.size() > 0) {
|
||||
if (VecDea.last().size() == 1) {
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecDea[VecDea.size() - 1].push_back(time);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
}
|
||||
else{
|
||||
//VecDea[VecDea.size()-1].append(9999);
|
||||
else {
|
||||
// VecDea[VecDea.size()-1].append(9999);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(VecDea.size() > 0){
|
||||
//cout << "Time sec 3: " << time << endl;
|
||||
if(VecDea.last().size() == 2){
|
||||
// cout << time << sector << endl;
|
||||
if (VecDea.size() > 0) {
|
||||
// cout << "Time sec 3: " << time << endl;
|
||||
if (VecDea.last().size() == 2) {
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecDea.last().push_back(time);
|
||||
|
||||
// add sum to vector
|
||||
VecDea.last().push_back(QVectorHelper::getCurTime(VecDea.last()));
|
||||
VecDea.last().push_back(
|
||||
QVectorHelper::getCurTime(VecDea.last()));
|
||||
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
}
|
||||
// best time on widget
|
||||
// cout << "cur time: " << QVectorHelper::getCurTime(VecDea.last()) << endl;
|
||||
// cout << "min time: " << QVectorHelper::getMin(VecDea) << endl;
|
||||
if(QVectorHelper::getCurTime(VecDea.last()) <= QVectorHelper::getMin(VecDea)){
|
||||
ui->lBestZeitDea->setText(QString::number((double)QVectorHelper::getMin(VecDea)/1000));
|
||||
// cout << "cur time: " <<
|
||||
// QVectorHelper::getCurTime(VecDea.last())
|
||||
// << endl; cout << "min time: " <<
|
||||
// QVectorHelper::getMin(VecDea) <<
|
||||
// endl;
|
||||
if (QVectorHelper::getCurTime(VecDea.last()) <=
|
||||
QVectorHelper::getMin(VecDea)) {
|
||||
ui->lBestZeitDea->setText(QString::number(
|
||||
(double)QVectorHelper::getMin(VecDea) / 1000));
|
||||
}
|
||||
ui->lCurRoundDea->setText(QString::number((double)QVectorHelper::getCurTime(VecDea.last())/1000));
|
||||
ui->lCurRoundDea->setText(QString::number(
|
||||
(double)QVectorHelper::getCurTime(VecDea.last()) /
|
||||
1000));
|
||||
}
|
||||
break;
|
||||
}
|
||||
ui->lWDeaTime->scrollToBottom();
|
||||
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Stretch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Training::~Training()
|
||||
{
|
||||
Training::~Training() {
|
||||
cout << "destr Training" << endl;
|
||||
this->Hardware->setStop();
|
||||
usleep(1000000);
|
||||
|
||||
353
windowrace.cpp
353
windowrace.cpp
@@ -1,24 +1,22 @@
|
||||
#include "windowrace.h"
|
||||
#include "ui_windowrace.h"
|
||||
#include <QObject>
|
||||
#include <string>
|
||||
#include <QShortcut>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include "unistd.h"
|
||||
#include <QKeySequence>
|
||||
#include "qvectorhelper.h"
|
||||
#include "timemodel.h"
|
||||
#include "ui_windowrace.h"
|
||||
#include "unistd.h"
|
||||
#include <QKeySequence>
|
||||
#include <QObject>
|
||||
#include <QShortcut>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::WindowRace)
|
||||
{
|
||||
WindowRace::WindowRace(DataBase * db, QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::WindowRace) {
|
||||
ui->setupUi(this);
|
||||
this->ui->pBNextRace->setEnabled(false);
|
||||
this->finished = false;
|
||||
@@ -27,22 +25,23 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
|
||||
this->db = db;
|
||||
|
||||
vector< vector< QString > > res;
|
||||
vector<vector<QString>> res;
|
||||
res = db->getData("select dauer from renndauer", 1);
|
||||
this->fahrzeit = res[0][0].toInt();
|
||||
|
||||
string statement = "select minimumroundtime from rennen order by id DESC limit 1";
|
||||
string statement =
|
||||
"select minimumroundtime from rennen order by id DESC limit 1";
|
||||
res = db->getData(statement, 1);
|
||||
this->minimumTime = res[0][0].toInt();
|
||||
|
||||
// fill minSecTimes vector
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id DESC limit 1";
|
||||
statement = "select minsec1, minsec2, minsec3 from renndauer order by id "
|
||||
"DESC limit 1";
|
||||
res = db->getData(statement, 3);
|
||||
this->minSecTime.append(res[0][0].toInt());
|
||||
this->minSecTime.append(res[0][1].toInt());
|
||||
this->minSecTime.append(res[0][2].toInt());
|
||||
|
||||
|
||||
firstTimeDea = true;
|
||||
firstTimeShell = true;
|
||||
started = false;
|
||||
@@ -59,20 +58,27 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
Hardware = new HardwareSetup;
|
||||
Hardware->start();
|
||||
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this, SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this, SLOT(shellSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Dea(int, int)), this,
|
||||
SLOT(deaSlot(int, int)));
|
||||
QObject::connect(Hardware, SIGNAL(Shell(int, int)), this,
|
||||
SLOT(shellSlot(int, int)));
|
||||
QObject::connect(ui->pBStart, SIGNAL(clicked()), this, SLOT(go()));
|
||||
QObject::connect(countdown, SIGNAL(CountdownUpdate()), this, SLOT(countdownUpdate()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this, SLOT(ampelSlot()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this, SLOT(laufcheck()));
|
||||
QObject::connect(ui->pBBreak, SIGNAL(clicked()), this, SLOT(breakCounter()));
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this, SLOT(prepareNextRace()));
|
||||
QObject::connect(this->ui->pBStop, SIGNAL(clicked()), this, SLOT(stopClicked()));
|
||||
|
||||
QObject::connect(countdown, SIGNAL(CountdownUpdate()), this,
|
||||
SLOT(countdownUpdate()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this,
|
||||
SLOT(ampelSlot()));
|
||||
QObject::connect(startAmpelThread, SIGNAL(ampelUpdate()), this,
|
||||
SLOT(laufcheck()));
|
||||
QObject::connect(ui->pBBreak, SIGNAL(clicked()), this,
|
||||
SLOT(breakCounter()));
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this,
|
||||
SLOT(prepareNextRace()));
|
||||
QObject::connect(this->ui->pBStop, SIGNAL(clicked()), this,
|
||||
SLOT(stopClicked()));
|
||||
|
||||
ui->lCountdown->setText(timeWrapper(countdownValue));
|
||||
|
||||
//Ampelsetup
|
||||
// Ampelsetup
|
||||
ui->WAmpel15->hide();
|
||||
ui->WAmpel25->hide();
|
||||
ui->hW15->setVisible(true);
|
||||
@@ -94,38 +100,43 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
ui->hW11->setVisible(true);
|
||||
ui->hW21->setVisible(true);
|
||||
|
||||
|
||||
vector< vector<QString> > fahrer, autos, rennid, tableData;
|
||||
statement = "select id_rennen from aktrennen group by id_rennen order by id_rennen DESC limit 1";
|
||||
vector<vector<QString>> fahrer, autos, rennid, tableData;
|
||||
statement = "select id_rennen from aktrennen group by id_rennen order by "
|
||||
"id_rennen DESC limit 1";
|
||||
rennid = this->db->getData(statement, 1);
|
||||
this->renn_id = rennid[0][0].toInt();
|
||||
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid from aktrennen where id_rennen like "+rennid[0][0].toStdString()+" limit 1";
|
||||
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid "
|
||||
"from aktrennen where id_rennen like " +
|
||||
rennid[0][0].toStdString() + " limit 1";
|
||||
|
||||
tableData = db->getData2(statement, 4);
|
||||
|
||||
|
||||
statement = "select name from fahrer where id like " + tableData[0][0].toStdString();
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[0][0].toStdString();
|
||||
fahrer = this->db->getData2(statement, 1);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " + tableData[0][1].toStdString()+" order by seit DESC";
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[0][1].toStdString() + " order by seit DESC";
|
||||
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 " + tableData[0][2].toStdString();
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[0][2].toStdString();
|
||||
fahrer = this->db->getData2(statement, 1);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " + tableData[0][3].toStdString()+" order by seit DESC";
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[0][3].toStdString() + " order by seit DESC";
|
||||
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->shellCarId = tableData[0][1].toInt();
|
||||
this->deaDriverId = tableData[0][2].toInt();
|
||||
this->deaCarId = tableData[0][3].toInt();
|
||||
|
||||
//progressbar
|
||||
// progressbar
|
||||
this->ui->pbTime->setMaximum(this->fahrzeit);
|
||||
this->ui->pbTime->setMinimum(0);
|
||||
this->ui->pbTime->setTextVisible(false);
|
||||
@@ -133,35 +144,34 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
this->ui->pbTime->setValue(0);
|
||||
|
||||
QKeySequence ks(Qt::Key_Return); // btw, this is numpad enter
|
||||
QShortcut *keyReturn = new QShortcut(ks, this);
|
||||
QShortcut * keyReturn = new QShortcut(ks, this);
|
||||
QObject::connect(keyReturn, SIGNAL(activated()), this, SLOT(ReturnPress()));
|
||||
|
||||
//QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(close()));
|
||||
|
||||
// QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(close()));
|
||||
}
|
||||
|
||||
void WindowRace::ReturnPress(){
|
||||
//cout << "Return pressed" << endl;
|
||||
if(this->ui->pBNextRace->isEnabled()){
|
||||
void WindowRace::ReturnPress() {
|
||||
// cout << "Return pressed" << endl;
|
||||
if (this->ui->pBNextRace->isEnabled()) {
|
||||
this->prepareNextRace();
|
||||
if(this->wRennlisteSeted){
|
||||
if (this->wRennlisteSeted) {
|
||||
this->wRennliste->changeSelection();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
cout << "Problem with racelist" << endl;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(started){
|
||||
else {
|
||||
if (started) {
|
||||
this->breakCounter();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this->go();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowRace::prepareNextRace(){
|
||||
void WindowRace::prepareNextRace() {
|
||||
this->firstTimeShell = true;
|
||||
this->firstTimeDea = true;
|
||||
|
||||
@@ -194,14 +204,14 @@ void WindowRace::prepareNextRace(){
|
||||
this->ui->pBNextRace->setEnabled(false);
|
||||
this->ui->lCountdown->setText(timeWrapper(countdownValue));
|
||||
|
||||
//progressbar
|
||||
// progressbar
|
||||
this->ui->pbTime->setStyleSheet("QProgressBar::chunk { color: #05B8CC;}");
|
||||
this->ui->pbTime->setValue(0);
|
||||
|
||||
//countdown
|
||||
// countdown
|
||||
this->ui->lCountdown->setStyleSheet("QLabel { color: black; }");
|
||||
|
||||
//Ampel Setup
|
||||
// Ampel Setup
|
||||
ui->WAmpel15->hide();
|
||||
ui->WAmpel25->hide();
|
||||
ui->hW15->setVisible(true);
|
||||
@@ -223,29 +233,28 @@ void WindowRace::prepareNextRace(){
|
||||
ui->hW11->setVisible(true);
|
||||
ui->hW21->setVisible(true);
|
||||
}
|
||||
void WindowRace::setDriverAndCar(vector<QString> vec){
|
||||
this->ui->gbShell->setTitle("Shell, "+vec[0]+", "+vec[1]);
|
||||
this->ui->gbDea->setTitle("Dea, "+vec[2]+", "+vec[3]);
|
||||
void WindowRace::setDriverAndCar(vector<QString> vec) {
|
||||
this->ui->gbShell->setTitle("Shell, " + vec[0] + ", " + vec[1]);
|
||||
this->ui->gbDea->setTitle("Dea, " + vec[2] + ", " + vec[3]);
|
||||
}
|
||||
void WindowRace::stopClicked(){
|
||||
void WindowRace::stopClicked() {
|
||||
this->prepareNextRace();
|
||||
|
||||
}
|
||||
|
||||
void WindowRace::setWindowRennliste(WindowRennliste *ptrInstance){
|
||||
void WindowRace::setWindowRennliste(WindowRennliste * ptrInstance) {
|
||||
|
||||
this->wRennliste = ptrInstance;
|
||||
this->wRennlisteSeted = true;
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this->wRennliste, SLOT(changeSelection()));
|
||||
QObject::connect(this->ui->pBNextRace, SIGNAL(clicked()), this->wRennliste,
|
||||
SLOT(changeSelection()));
|
||||
}
|
||||
void WindowRace::setDriverAndCarId(vector<QString> vec){
|
||||
void WindowRace::setDriverAndCarId(vector<QString> vec) {
|
||||
this->shellDriverId = vec[0].toInt();
|
||||
this->shellCarId = vec[1].toInt();
|
||||
this->deaDriverId = vec[2].toInt();
|
||||
this->deaCarId = vec[3].toInt();
|
||||
|
||||
}
|
||||
void WindowRace::closeEvent(QCloseEvent *event){
|
||||
void WindowRace::closeEvent(QCloseEvent * event) {
|
||||
countdown->setStop();
|
||||
|
||||
QMessageBox msgBox;
|
||||
@@ -270,83 +279,82 @@ void WindowRace::closeEvent(QCloseEvent *event){
|
||||
}
|
||||
}
|
||||
|
||||
void WindowRace::breakCounter(){
|
||||
if(!paused){
|
||||
void WindowRace::breakCounter() {
|
||||
if (!paused) {
|
||||
paused = true;
|
||||
ui->pBBreak->setText("Weiter");
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ui->pBBreak->setText("Pause");
|
||||
paused = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WindowRace::laufcheck(){
|
||||
//std::cout << "thread lauft noch" << std::endl;
|
||||
void WindowRace::laufcheck() {
|
||||
// std::cout << "thread lauft noch" << std::endl;
|
||||
}
|
||||
|
||||
QString WindowRace::timeWrapper(long zahl){
|
||||
QString WindowRace::timeWrapper(long zahl) {
|
||||
|
||||
long min = zahl / 60;
|
||||
int sec = zahl % 60;
|
||||
QString sec_q;
|
||||
if(sec < 10){
|
||||
sec_q = "0"+QString::number(sec);
|
||||
if (sec < 10) {
|
||||
sec_q = "0" + QString::number(sec);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
sec_q = QString::number(sec);
|
||||
}
|
||||
QString min_q = QString::number(min);
|
||||
return min_q+":"+sec_q;
|
||||
return min_q + ":" + sec_q;
|
||||
}
|
||||
|
||||
void WindowRace::countdownUpdate(){
|
||||
if(!paused){
|
||||
void WindowRace::countdownUpdate() {
|
||||
if (!paused) {
|
||||
countdownValue -= 1;
|
||||
if(countdownValue <= 15){
|
||||
if (countdownValue <= 15) {
|
||||
this->ui->lCountdown->setStyleSheet("QLabel { color: red; }");
|
||||
this->ui->pbTime->setStyleSheet( "QProgressBar::chunk { background-color: orange; }");
|
||||
//this->ui->pbTime->
|
||||
this->ui->pbTime->setStyleSheet(
|
||||
"QProgressBar::chunk { background-color: orange; }");
|
||||
// this->ui->pbTime->
|
||||
}
|
||||
if(countdownValue <= -1){
|
||||
if (countdownValue <= -1) {
|
||||
this->finished = true;
|
||||
this->wRennliste->setBesttime(QVectorHelper::getMin(VecShell),QVectorHelper::getMin(this->VecDea));
|
||||
this->wRennliste->setBesttime(QVectorHelper::getMin(VecShell),
|
||||
QVectorHelper::getMin(this->VecDea));
|
||||
this->ui->pBNextRace->setEnabled(true);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
ui->lCountdown->setText(timeWrapper(countdownValue));
|
||||
this->ui->pbTime->setValue(this->fahrzeit-countdownValue);
|
||||
this->ui->pbTime->setValue(this->fahrzeit - countdownValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WindowRace::~WindowRace()
|
||||
{
|
||||
WindowRace::~WindowRace() {
|
||||
this->startAmpelThread->setStop();
|
||||
this->countdown->setStop();
|
||||
this->Hardware->setStop();
|
||||
usleep(1000010); //eine Sekunde
|
||||
usleep(1000010); // eine Sekunde
|
||||
|
||||
delete this->countdown;
|
||||
delete this->Hardware;
|
||||
delete this->startAmpelThread;
|
||||
|
||||
//delete this->db;
|
||||
// delete this->db;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
void WindowRace::shellSlot(int time, int sector){
|
||||
if(started && !paused && !this->finished){
|
||||
if(firstTimeShell){
|
||||
void WindowRace::shellSlot(int time, int sector) {
|
||||
if (started && !paused && !this->finished) {
|
||||
if (firstTimeShell) {
|
||||
firstTimeShell = false;
|
||||
// counterShell.start();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// long zeit = counterShell.getTime();
|
||||
QVector<int> test;
|
||||
switch(sector){
|
||||
switch (sector) {
|
||||
case 1:
|
||||
VecShell.append(QVector<int>());
|
||||
VecShell.last().append(time);
|
||||
@@ -356,14 +364,15 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
||||
ui->lWShellTime->setModel(this->timeModelShell);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if(VecShell.size() > 0){
|
||||
if(VecShell.last().size() == 1){
|
||||
if (VecShell.size() > 0) {
|
||||
if (VecShell.last().size() == 1) {
|
||||
VecShell.last().append(time);
|
||||
}
|
||||
// update tableview
|
||||
@@ -371,63 +380,75 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new TimeModel(VecShell, this);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new
|
||||
// TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(VecShell.size() > 0){
|
||||
if(VecShell.last().size() == 2){
|
||||
if (VecShell.size() > 0) {
|
||||
if (VecShell.last().size() == 2) {
|
||||
VecShell.last().append(time);
|
||||
VecShell.last().append(QVectorHelper::getCurTime(VecShell.last()));
|
||||
VecShell.last().append(
|
||||
QVectorHelper::getCurTime(VecShell.last()));
|
||||
|
||||
if(QVectorHelper::getCurTime(VecShell.last()) <= QVectorHelper::getMin(VecShell)){
|
||||
ui->lBestZeitShell->setText(QString::number((double)QVectorHelper::getMin(VecShell)/1000));
|
||||
if (QVectorHelper::getCurTime(VecShell.last()) <=
|
||||
QVectorHelper::getMin(VecShell)) {
|
||||
ui->lBestZeitShell->setText(QString::number(
|
||||
(double)QVectorHelper::getMin(VecShell) /
|
||||
1000));
|
||||
}
|
||||
ui->lCurRoundTimeShell->setText(QString::number((double)QVectorHelper::getCurTime(VecShell.last())/1000));
|
||||
ui->lCurRoundTimeShell->setText(QString::number(
|
||||
(double)QVectorHelper::getCurTime(VecShell.last()) /
|
||||
1000));
|
||||
|
||||
// update tableview
|
||||
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new TimeModel(VecShell, this);
|
||||
this->timeModelShell =
|
||||
new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new
|
||||
// TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
int zeit = QVectorHelper::getMin(VecShell);
|
||||
QString statement = "insert into Zeiten (id_rennen, id_fahrer, id_auto, id_bahn, zeit) values ("+QString::number(this->renn_id)+
|
||||
", "+QString::number(this->shellDriverId)+", "+QString::number(this->shellCarId)+", 1, "+QString::number(zeit)+")";
|
||||
QString statement =
|
||||
"insert into Zeiten (id_rennen, id_fahrer, "
|
||||
"id_auto, id_bahn, zeit) values (" +
|
||||
QString::number(this->renn_id) + ", " +
|
||||
QString::number(this->shellDriverId) + ", " +
|
||||
QString::number(this->shellCarId) + ", 1, " +
|
||||
QString::number(zeit) + ")";
|
||||
cout << statement.toStdString() << endl;
|
||||
|
||||
//this->db->setData(statement.toStdString());
|
||||
// this->db->setData(statement.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
if(sector == 3){
|
||||
if (sector == 3) {
|
||||
}
|
||||
|
||||
|
||||
ui->lWShellTime->scrollToBottom();
|
||||
}
|
||||
}
|
||||
ui->lWShellTime->scrollToBottom();
|
||||
ui->lWShellTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->lWShellTime->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Stretch);
|
||||
}
|
||||
void WindowRace::deaSlot(int time, int sector){
|
||||
if(started && !paused && !this->finished){
|
||||
if(firstTimeDea){
|
||||
void WindowRace::deaSlot(int time, int sector) {
|
||||
if (started && !paused && !this->finished) {
|
||||
if (firstTimeDea) {
|
||||
firstTimeDea = false;
|
||||
counterDea.start();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
|
||||
switch(sector){
|
||||
switch (sector) {
|
||||
case 1:
|
||||
VecDea.push_back(QVector<int>());
|
||||
VecDea.last().push_back(time);
|
||||
@@ -437,51 +458,57 @@ void WindowRace::deaSlot(int time, int sector){
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if(VecDea.size() > 0){
|
||||
if(VecDea.last().size() == 1){
|
||||
if (VecDea.size() > 0) {
|
||||
if (VecDea.last().size() == 1) {
|
||||
cout << time << sector << endl;
|
||||
VecDea[VecDea.size()-1].push_back(time);
|
||||
VecDea[VecDea.size() - 1].push_back(time);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
}
|
||||
else{
|
||||
//VecDea[VecDea.size()-1].append(9999);
|
||||
else {
|
||||
// VecDea[VecDea.size()-1].append(9999);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if(VecDea.size() > 0){
|
||||
//cout << "Time sec 3: " << time << endl;
|
||||
if(VecDea.last().size() == 2){
|
||||
// cout << time << sector << endl;
|
||||
if (VecDea.size() > 0) {
|
||||
// cout << "Time sec 3: " << time << endl;
|
||||
if (VecDea.last().size() == 2) {
|
||||
// cout << time << sector <<
|
||||
// endl;
|
||||
VecDea.last().push_back(time);
|
||||
|
||||
// add sum to vector
|
||||
VecDea.last().push_back(QVectorHelper::getCurTime(VecDea.last()));
|
||||
|
||||
|
||||
VecDea.last().push_back(
|
||||
QVectorHelper::getCurTime(VecDea.last()));
|
||||
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// best time on widget
|
||||
cout << "cur time: " << QVectorHelper::getCurTime(VecDea.last()) << endl;
|
||||
cout << "min time: " << QVectorHelper::getMin(VecDea) << endl;
|
||||
if(QVectorHelper::getCurTime(VecDea.last()) <= QVectorHelper::getMin(VecDea)){
|
||||
ui->lBestZeitDea->setText(QString::number((double)QVectorHelper::getMin(VecDea)/1000));
|
||||
cout << "cur time: "
|
||||
<< QVectorHelper::getCurTime(VecDea.last()) << endl;
|
||||
cout << "min time: " << QVectorHelper::getMin(VecDea)
|
||||
<< endl;
|
||||
if (QVectorHelper::getCurTime(VecDea.last()) <=
|
||||
QVectorHelper::getMin(VecDea)) {
|
||||
ui->lBestZeitDea->setText(QString::number(
|
||||
(double)QVectorHelper::getMin(VecDea) / 1000));
|
||||
}
|
||||
ui->lCurRoundDea->setText(QString::number((double)QVectorHelper::getCurTime(VecDea.last())/1000));
|
||||
ui->lCurRoundDea->setText(QString::number(
|
||||
(double)QVectorHelper::getCurTime(VecDea.last()) /
|
||||
1000));
|
||||
}
|
||||
int zeit = QVectorHelper::getMin(VecDea);
|
||||
QString statement = "insert into Zeiten (id_rennen, id_fahrer, id_auto, id_bahn, zeit) values ("+QString::number(this->renn_id)+
|
||||
", "+QString::number(this->deaDriverId)+", "+QString::number(this->deaCarId)+", 2, "+QString::number(zeit)+")";
|
||||
QString statement = "insert into Zeiten (id_rennen, id_fahrer, "
|
||||
"id_auto, id_bahn, zeit) values (" +
|
||||
QString::number(this->renn_id) + ", " +
|
||||
QString::number(this->deaDriverId) + ", " +
|
||||
QString::number(this->deaCarId) + ", 2, " +
|
||||
QString::number(zeit) + ")";
|
||||
cout << statement.toStdString() << endl;
|
||||
//this->db->setData(statement.toStdString());
|
||||
// this->db->setData(statement.toStdString());
|
||||
ui->lWDeaTime->scrollToBottom();
|
||||
|
||||
break;
|
||||
@@ -489,28 +516,28 @@ void WindowRace::deaSlot(int time, int sector){
|
||||
}
|
||||
}
|
||||
ui->lWDeaTime->scrollToBottom();
|
||||
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->lWDeaTime->horizontalHeader()->setSectionResizeMode(
|
||||
QHeaderView::Stretch);
|
||||
}
|
||||
|
||||
long WindowRace::getMinimum(std::vector<long> a){
|
||||
long WindowRace::getMinimum(std::vector<long> a) {
|
||||
long minimum = -1;
|
||||
for(unsigned int i = 0; i < a.size(); i++){
|
||||
if(minimum < 0){
|
||||
if(a[i] >= this->minimumTime){
|
||||
for (unsigned int i = 0; i < a.size(); i++) {
|
||||
if (minimum < 0) {
|
||||
if (a[i] >= this->minimumTime) {
|
||||
minimum = a[i];
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(a[i] < minimum && a[i] >= this->minimumTime){
|
||||
else {
|
||||
if (a[i] < minimum && a[i] >= this->minimumTime) {
|
||||
minimum = a[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return minimum;
|
||||
}
|
||||
void WindowRace::ampelSlot(){
|
||||
if(ampelCounter == 5){
|
||||
void WindowRace::ampelSlot() {
|
||||
if (ampelCounter == 5) {
|
||||
ui->WAmpel15->hide();
|
||||
ui->WAmpel25->hide();
|
||||
ui->hW15->setVisible(true);
|
||||
@@ -535,35 +562,35 @@ void WindowRace::ampelSlot(){
|
||||
started = true;
|
||||
countdown->start();
|
||||
}
|
||||
if(ampelCounter == 4){
|
||||
if (ampelCounter == 4) {
|
||||
ampelCounter = 5;
|
||||
ui->WAmpel15->setVisible(true);
|
||||
ui->WAmpel25->setVisible(true);
|
||||
ui->hW15->hide();
|
||||
ui->hW25->hide();
|
||||
}
|
||||
if(ampelCounter == 3){
|
||||
if (ampelCounter == 3) {
|
||||
ampelCounter = 4;
|
||||
ui->WAmpel14->setVisible(true);
|
||||
ui->WAmpel24->setVisible(true);
|
||||
ui->hW14->hide();
|
||||
ui->hW24->hide();
|
||||
}
|
||||
if(ampelCounter == 2){
|
||||
if (ampelCounter == 2) {
|
||||
ampelCounter = 3;
|
||||
ui->WAmpel13->setVisible(true);
|
||||
ui->WAmpel23->setVisible(true);
|
||||
ui->hW13->hide();
|
||||
ui->hW23->hide();
|
||||
}
|
||||
if(ampelCounter == 1){
|
||||
if (ampelCounter == 1) {
|
||||
ampelCounter = 2;
|
||||
ui->WAmpel12->setVisible(true);
|
||||
ui->WAmpel22->setVisible(true);
|
||||
ui->hW12->hide();
|
||||
ui->hw22->hide();
|
||||
}
|
||||
if(ampelCounter == 0){
|
||||
if (ampelCounter == 0) {
|
||||
ampelCounter = 1;
|
||||
ui->WAmpel11->setVisible(true);
|
||||
ui->WAmpel21->setVisible(true);
|
||||
@@ -572,6 +599,6 @@ void WindowRace::ampelSlot(){
|
||||
}
|
||||
}
|
||||
|
||||
void WindowRace::go(){
|
||||
void WindowRace::go() {
|
||||
startAmpelThread->start();
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
#include "windowrennliste.h"
|
||||
#include "ui_windowrennliste.h"
|
||||
#include <QColor>
|
||||
#include <QBrush>
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
#include "windowrace.h"
|
||||
using std::vector;
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
WindowRennliste::WindowRennliste(DataBase *db, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::WindowRennliste)
|
||||
{
|
||||
WindowRennliste::WindowRennliste(DataBase * db, QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::WindowRennliste) {
|
||||
ui->setupUi(this);
|
||||
|
||||
this->windowClose = false;
|
||||
@@ -21,81 +19,103 @@ WindowRennliste::WindowRennliste(DataBase *db, QWidget *parent) :
|
||||
this->ui->tWRennliste->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
this->ui->tWRennliste->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
QObject::connect(this->ui->tWRennliste, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(listClick(const QModelIndex&)));
|
||||
QObject::connect(this->ui->tWRennliste,
|
||||
SIGNAL(doubleClicked(const QModelIndex &)), this,
|
||||
SLOT(listClick(const QModelIndex &)));
|
||||
this->db = db;
|
||||
|
||||
string statement;
|
||||
vector< vector<QString> > fahrer, autos, rennid;
|
||||
statement = "select id_rennen from aktrennen group by id_rennen order by id_rennen DESC limit 1";
|
||||
vector<vector<QString>> fahrer, autos, rennid;
|
||||
statement = "select id_rennen from aktrennen group by id_rennen order by "
|
||||
"id_rennen DESC limit 1";
|
||||
rennid = this->db->getData(statement, 1);
|
||||
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid from aktrennen where id_rennen like "+rennid[0][0].toStdString();
|
||||
statement = "select fahrershellid, autoshellid, fahrerdeaid, autodeaid "
|
||||
"from aktrennen where id_rennen like " +
|
||||
rennid[0][0].toStdString();
|
||||
|
||||
this->tableData = db->getData(statement, 4);
|
||||
this->ui->tWRennliste->setRowCount(this->tableData.size());
|
||||
this->ui->tWRennliste->setColumnCount(6);
|
||||
QStringList header;
|
||||
header<< "Fahrer" << "Auto"<< "Zeit"<< "Fahrer"<< "Auto"<< "Zeit";
|
||||
header << "Fahrer"
|
||||
<< "Auto"
|
||||
<< "Zeit"
|
||||
<< "Fahrer"
|
||||
<< "Auto"
|
||||
<< "Zeit";
|
||||
|
||||
this->ui->tWRennliste->setHorizontalHeaderLabels(header);
|
||||
|
||||
|
||||
for(int i = 0; i < this->ui->tWRennliste->horizontalHeader()->count();i++){
|
||||
this->ui->tWRennliste->horizontalHeader()->setSectionResizeMode(i, QHeaderView::Stretch);
|
||||
for (int i = 0; i < this->ui->tWRennliste->horizontalHeader()->count();
|
||||
i++) {
|
||||
this->ui->tWRennliste->horizontalHeader()->setSectionResizeMode(
|
||||
i, QHeaderView::Stretch);
|
||||
}
|
||||
|
||||
|
||||
for(unsigned int i = 0; i < tableData.size(); i++){
|
||||
statement = "select name from fahrer where id like " + tableData[i][0].toStdString();
|
||||
for (unsigned int i = 0; i < tableData.size(); i++) {
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[i][0].toStdString();
|
||||
fahrer = this->db->getData(statement, 1);
|
||||
this->ui->tWRennliste->setItem(i, 0, new QTableWidgetItem(fahrer[0][0]));
|
||||
this->ui->tWRennliste->item(i,0)->setFlags(Qt::ItemIsEnabled);
|
||||
this->ui->tWRennliste->setItem(i, 0,
|
||||
new QTableWidgetItem(fahrer[0][0]));
|
||||
this->ui->tWRennliste->item(i, 0)->setFlags(Qt::ItemIsEnabled);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " + tableData[i][1].toStdString()+" order by seit DESC";
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[i][1].toStdString() + " order by seit DESC";
|
||||
autos = this->db->getData(statement, 1);
|
||||
this->ui->tWRennliste->setItem(i, 1, new QTableWidgetItem(autos[0][0]));
|
||||
this->ui->tWRennliste->item(i,1)->setFlags(Qt::ItemIsEnabled);
|
||||
this->ui->tWRennliste->item(i, 1)->setFlags(Qt::ItemIsEnabled);
|
||||
|
||||
this->ui->tWRennliste->setItem(i, 2, new QTableWidgetItem());
|
||||
|
||||
statement = "select name from fahrer where id like " + tableData[i][2].toStdString();
|
||||
statement = "select name from fahrer where id like " +
|
||||
tableData[i][2].toStdString();
|
||||
fahrer = this->db->getData(statement, 1);
|
||||
this->ui->tWRennliste->setItem(i, 3, new QTableWidgetItem(fahrer[0][0]));
|
||||
this->ui->tWRennliste->item(i,3)->setFlags(Qt::ItemIsEnabled);
|
||||
this->ui->tWRennliste->setItem(i, 3,
|
||||
new QTableWidgetItem(fahrer[0][0]));
|
||||
this->ui->tWRennliste->item(i, 3)->setFlags(Qt::ItemIsEnabled);
|
||||
|
||||
statement = "select name from AutoKonfiguration where id_auto like " + tableData[i][3].toStdString()+" order by seit DESC";
|
||||
statement = "select name from AutoKonfiguration where id_auto like " +
|
||||
tableData[i][3].toStdString() + " order by seit DESC";
|
||||
autos = this->db->getData(statement, 1);
|
||||
this->ui->tWRennliste->setItem(i, 4, new QTableWidgetItem(autos[0][0]));
|
||||
this->ui->tWRennliste->item(i,4)->setFlags(Qt::ItemIsEnabled);
|
||||
this->ui->tWRennliste->item(i, 4)->setFlags(Qt::ItemIsEnabled);
|
||||
|
||||
this->ui->tWRennliste->setItem(i, 5, new QTableWidgetItem());
|
||||
}
|
||||
for(int i = 0; i < 6; i++){
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this->ui->tWRennliste->item(0, i)->setBackground(Qt::green);
|
||||
}
|
||||
}
|
||||
void WindowRennliste::setWindowRace(WindowRace *instance){
|
||||
void WindowRennliste::setWindowRace(WindowRace * instance) {
|
||||
this->instanceWindowRace = instance;
|
||||
}
|
||||
vector<QString> WindowRennliste::getDriverAndCarSettings(){
|
||||
vector<QString> WindowRennliste::getDriverAndCarSettings() {
|
||||
vector<QString> vec;
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow+1, 0)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow+1, 1)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow+1, 3)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow+1, 4)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, 0)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, 1)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, 3)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, 4)->text());
|
||||
return vec;
|
||||
}
|
||||
vector<QString> WindowRennliste::getDriverAndCarId(){
|
||||
//shellFahrer shellAuto deaFahrer deaAuto
|
||||
vector<QString> WindowRennliste::getDriverAndCarId() {
|
||||
// shellFahrer shellAuto deaFahrer deaAuto
|
||||
return this->tableData[this->selectedRow];
|
||||
}
|
||||
|
||||
void WindowRennliste::setBesttime(int shell, int dea){
|
||||
this->ui->tWRennliste->item(this->selectedRow, 2)->setText(QString::number(shell/1000.0));
|
||||
this->ui->tWRennliste->item(this->selectedRow, 5)->setText(QString::number(dea/1000.0));
|
||||
//std::cout << this->selectedRow << std::endl;
|
||||
void WindowRennliste::setBesttime(int shell, int dea) {
|
||||
this->ui->tWRennliste->item(this->selectedRow, 2)
|
||||
->setText(QString::number(shell / 1000.0));
|
||||
this->ui->tWRennliste->item(this->selectedRow, 5)
|
||||
->setText(QString::number(dea / 1000.0));
|
||||
// std::cout << this->selectedRow << std::endl;
|
||||
}
|
||||
|
||||
void WindowRennliste::listClick(const QModelIndex & index){
|
||||
void WindowRennliste::listClick(const QModelIndex & index) {
|
||||
|
||||
QString driverShell = this->ui->tWRennliste->item(index.row(), 0)->text();
|
||||
QString carShell = this->ui->tWRennliste->item(index.row(), 1)->text();
|
||||
@@ -112,30 +132,29 @@ void WindowRennliste::listClick(const QModelIndex & index){
|
||||
this->instanceWindowRace->prepareNextRace();
|
||||
this->setSelection(index.row());
|
||||
this->sendIds();
|
||||
|
||||
}
|
||||
void WindowRennliste::closeEvent(QCloseEvent *event){
|
||||
if(!this->windowClose){
|
||||
void WindowRennliste::closeEvent(QCloseEvent * event) {
|
||||
if (!this->windowClose) {
|
||||
this->setWindowState(Qt::WindowMinimized);
|
||||
event->ignore();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
event->accept();
|
||||
}
|
||||
|
||||
}
|
||||
void WindowRennliste::schliessen(){
|
||||
void WindowRennliste::schliessen() {
|
||||
this->windowClose = true;
|
||||
this->close();
|
||||
delete this;
|
||||
}
|
||||
|
||||
void WindowRennliste::setSelection(int row){
|
||||
for(int i = 0; i < 6; i++){
|
||||
this->ui->tWRennliste->item(this->selectedRow, i)->setBackground(Qt::yellow);
|
||||
void WindowRennliste::setSelection(int row) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this->ui->tWRennliste->item(this->selectedRow, i)
|
||||
->setBackground(Qt::yellow);
|
||||
}
|
||||
this->selectedRow = row;
|
||||
for(int i = 0; i < 6; i++){
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this->ui->tWRennliste->item(row, i)->setBackground(Qt::green);
|
||||
}
|
||||
this->sendIds();
|
||||
@@ -145,32 +164,35 @@ void WindowRennliste::setSelection(int row){
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 3)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 4)->text());
|
||||
this->instanceWindowRace->setDriverAndCar(vec);
|
||||
|
||||
}
|
||||
void WindowRennliste::sendIds(){
|
||||
void WindowRennliste::sendIds() {
|
||||
this->instanceWindowRace->setDriverAndCarId(this->getDriverAndCarId());
|
||||
}
|
||||
|
||||
void WindowRennliste::changeSelection(){
|
||||
if(this->selectedRow + 1 < this->tableData.size()){
|
||||
for(unsigned int i = 0; i < 6; i++){
|
||||
this->ui->tWRennliste->item(this->selectedRow, i)->setBackground(Qt::gray);
|
||||
this->ui->tWRennliste->item(this->selectedRow+1, i)->setBackground(Qt::green);
|
||||
void WindowRennliste::changeSelection() {
|
||||
if (this->selectedRow + 1 < this->tableData.size()) {
|
||||
for (unsigned int i = 0; i < 6; i++) {
|
||||
this->ui->tWRennliste->item(this->selectedRow, i)
|
||||
->setBackground(Qt::gray);
|
||||
this->ui->tWRennliste->item(this->selectedRow + 1, i)
|
||||
->setBackground(Qt::green);
|
||||
}
|
||||
this->selectedRow += 1;
|
||||
this->sendIds();
|
||||
|
||||
vector<QString> vec;
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 0)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 1)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 3)->text());
|
||||
vec.push_back(this->ui->tWRennliste->item(this->selectedRow, 4)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow, 0)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow, 1)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow, 3)->text());
|
||||
vec.push_back(
|
||||
this->ui->tWRennliste->item(this->selectedRow, 4)->text());
|
||||
this->instanceWindowRace->setDriverAndCar(vec);
|
||||
}
|
||||
}
|
||||
|
||||
WindowRennliste::~WindowRennliste()
|
||||
{
|
||||
WindowRennliste::~WindowRennliste() {
|
||||
delete ui;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,43 +1,47 @@
|
||||
#include "windowssettings.h"
|
||||
#include "ui_windowssettings.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
|
||||
using std::vector;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::WindowsSettings)
|
||||
{
|
||||
WindowsSettings::WindowsSettings(DataBase * db, QWidget * parent)
|
||||
: QMainWindow(parent), ui(new Ui::WindowsSettings) {
|
||||
ui->setupUi(this);
|
||||
|
||||
QObject::connect(ui->pBSpeichernStrecke, SIGNAL(clicked()), this, SLOT(StreckeSpeichernSlot()));
|
||||
QObject::connect(ui->pBAbbrechenStrecke, SIGNAL(clicked()), this, SLOT(AbbrechenSlot()));
|
||||
QObject::connect(this->ui->pbAbbrechenDauer, SIGNAL(clicked()), this, SLOT(AbbrechenSlot()));
|
||||
QObject::connect(this->ui->pbSaveDauer, SIGNAL(clicked()), this, SLOT(SaveDauerSlot()));
|
||||
QObject::connect(this->ui->pbSaveAndExitDauer, SIGNAL(clicked()), this, SLOT(SaveDauerAndExitSlot()));
|
||||
QObject::connect(ui->pBSpeichernStrecke, SIGNAL(clicked()), this,
|
||||
SLOT(StreckeSpeichernSlot()));
|
||||
QObject::connect(ui->pBAbbrechenStrecke, SIGNAL(clicked()), this,
|
||||
SLOT(AbbrechenSlot()));
|
||||
QObject::connect(this->ui->pbAbbrechenDauer, SIGNAL(clicked()), this,
|
||||
SLOT(AbbrechenSlot()));
|
||||
QObject::connect(this->ui->pbSaveDauer, SIGNAL(clicked()), this,
|
||||
SLOT(SaveDauerSlot()));
|
||||
QObject::connect(this->ui->pbSaveAndExitDauer, SIGNAL(clicked()), this,
|
||||
SLOT(SaveDauerAndExitSlot()));
|
||||
|
||||
// update minimal lap time on changeing minimal sector time
|
||||
QObject::connect(this->ui->lEMinTimeSec1, SIGNAL(textChanged(QString)), this, SLOT(repaintMinLapTime()));
|
||||
QObject::connect(this->ui->lEMinTimeSec2, SIGNAL(textChanged(QString)), this, SLOT(repaintMinLapTime()));
|
||||
QObject::connect(this->ui->lEMinTimeSec3, SIGNAL(textChanged(QString)), this, SLOT(repaintMinLapTime()));
|
||||
|
||||
|
||||
|
||||
QObject::connect(this->ui->lEMinTimeSec1, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(repaintMinLapTime()));
|
||||
QObject::connect(this->ui->lEMinTimeSec2, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(repaintMinLapTime()));
|
||||
QObject::connect(this->ui->lEMinTimeSec3, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(repaintMinLapTime()));
|
||||
|
||||
this->db = db;
|
||||
|
||||
//Shell prepare
|
||||
string statement = "select geraden, kurven_aussen, "
|
||||
// Shell prepare
|
||||
string statement =
|
||||
"select geraden, kurven_aussen, "
|
||||
"kurven_innen, steilkurve_innen, steilkurve_aussen, seit "
|
||||
"from Strecke where id_bahn like 1 order by seit DESC limit 1";
|
||||
vector< vector<QString> > res;
|
||||
vector<vector<QString>> res;
|
||||
|
||||
res = db->getData(statement, 6);
|
||||
ui->lEShellGeraden->setText(res[0][0]);
|
||||
@@ -46,12 +50,11 @@ WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
|
||||
ui->lEShellSteilkurveInnen->setText(res[0][3]);
|
||||
ui->lEShellSteilkurveaussen->setText(res[0][4]);
|
||||
|
||||
//Dea prepare
|
||||
// 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]);
|
||||
@@ -59,8 +62,9 @@ WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
|
||||
ui->lEDeaSteilkurveInnen->setText(res[0][3]);
|
||||
ui->lEDeaSteilkurveAussen->setText(res[0][4]);
|
||||
|
||||
//duration prepare
|
||||
statement = "select dauer, mindestrundendauer, minsec1, minsec2, minsec3 from renndauer";
|
||||
// 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]);
|
||||
@@ -69,13 +73,13 @@ WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
|
||||
int minLapTime = res[0][2].toInt() + res[0][3].toInt() + res[0][4].toInt();
|
||||
this->ui->lEMinRundenzeit->setText(QString::number(minLapTime));
|
||||
|
||||
statement = "SELECT id, minimumroundtime FROM rennen order by id DESC limit 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]);
|
||||
|
||||
}
|
||||
void WindowsSettings::repaintMinLapTime(){
|
||||
void WindowsSettings::repaintMinLapTime() {
|
||||
int minlapTime = 0;
|
||||
minlapTime += this->ui->lEMinTimeSec1->text().toInt();
|
||||
minlapTime += this->ui->lEMinTimeSec2->text().toInt();
|
||||
@@ -83,41 +87,51 @@ void WindowsSettings::repaintMinLapTime(){
|
||||
this->ui->lEMinRundenzeit->setText(QString::number(minlapTime));
|
||||
this->ui->lEMinRundenzeitAktRennen->setText(QString::number(minlapTime));
|
||||
}
|
||||
void WindowsSettings::AbbrechenSlot(){
|
||||
void WindowsSettings::AbbrechenSlot() {
|
||||
this->close();
|
||||
delete this;
|
||||
}
|
||||
void WindowsSettings::SaveDauerSlot(){
|
||||
string statement = "update renndauer set "
|
||||
"dauer="+this->ui->leRenndauer->text().toStdString()+", "+
|
||||
"mindestrundendauer="+this->ui->lEMinRundenzeit->text().toStdString()+", "+
|
||||
"minsec1="+this->ui->lEMinTimeSec1->text().toStdString()+", "+
|
||||
"minsec2="+this->ui->lEMinTimeSec2->text().toStdString()+", "+
|
||||
"minsec3="+this->ui->lEMinTimeSec3->text().toStdString()+" "+
|
||||
void WindowsSettings::SaveDauerSlot() {
|
||||
string statement =
|
||||
"update renndauer set "
|
||||
"dauer=" +
|
||||
this->ui->leRenndauer->text().toStdString() + ", " +
|
||||
"mindestrundendauer=" +
|
||||
this->ui->lEMinRundenzeit->text().toStdString() + ", " +
|
||||
"minsec1=" + this->ui->lEMinTimeSec1->text().toStdString() + ", " +
|
||||
"minsec2=" + this->ui->lEMinTimeSec2->text().toStdString() + ", " +
|
||||
"minsec3=" + this->ui->lEMinTimeSec3->text().toStdString() + " " +
|
||||
" where id like 1";
|
||||
cout << statement << endl;
|
||||
this->db->setData(statement);
|
||||
statement = "update rennen set minimumroundtime="+this->ui->lEMinRundenzeitAktRennen->text().toStdString()+
|
||||
" where id like "+QString::number(this->rennId).toStdString();
|
||||
statement = "update rennen set minimumroundtime=" +
|
||||
this->ui->lEMinRundenzeitAktRennen->text().toStdString() +
|
||||
" where id like " + QString::number(this->rennId).toStdString();
|
||||
this->db->setData(statement);
|
||||
}
|
||||
void WindowsSettings::SaveDauerAndExitSlot(){
|
||||
void WindowsSettings::SaveDauerAndExitSlot() {
|
||||
this->SaveDauerSlot();
|
||||
this->AbbrechenSlot();
|
||||
}
|
||||
|
||||
|
||||
void WindowsSettings::StreckeSpeichernSlot(){
|
||||
QString shellGeraden, shellKurvenAussen, shellKurvenInnen, shellSteilAussen, shellSteilInnen;
|
||||
QString deaGeraden, deaKurvenAussen, deaKurvenInnen, deaSteilAussen, deaSteilInnen;
|
||||
void WindowsSettings::StreckeSpeichernSlot() {
|
||||
QString shellGeraden, shellKurvenAussen, shellKurvenInnen, shellSteilAussen,
|
||||
shellSteilInnen;
|
||||
QString deaGeraden, deaKurvenAussen, deaKurvenInnen, deaSteilAussen,
|
||||
deaSteilInnen;
|
||||
shellGeraden = ui->lEShellGeraden->text();
|
||||
shellKurvenAussen = ui->lEShellKurvenAussen->text();
|
||||
shellKurvenInnen = ui->lEShellKurvenInnen->text();
|
||||
shellSteilAussen = ui->lEShellSteilkurveaussen->text();
|
||||
shellSteilInnen = ui->lEShellSteilkurveInnen->text();
|
||||
QString statement = QString("insert into strecke (geraden, kurven_aussen, kurven_innen, steilkurve_innen, steilkurve_aussen, seit, id_bahn)"
|
||||
" values ("+shellGeraden+", "+shellKurvenAussen+", "+shellKurvenInnen+", "+shellSteilInnen+", "+shellSteilAussen+", '"+QString::fromStdString(currentDateTime())+"', 1)");
|
||||
//cout << statement.toStdString() << endl;
|
||||
QString statement = QString(
|
||||
"insert into strecke (geraden, kurven_aussen, kurven_innen, "
|
||||
"steilkurve_innen, steilkurve_aussen, seit, id_bahn)"
|
||||
" values (" +
|
||||
shellGeraden + ", " + shellKurvenAussen + ", " + shellKurvenInnen +
|
||||
", " + shellSteilInnen + ", " + shellSteilAussen + ", '" +
|
||||
QString::fromStdString(currentDateTime()) + "', 1)");
|
||||
// cout << statement.toStdString() << endl;
|
||||
db->setData(statement.toStdString());
|
||||
|
||||
deaGeraden = ui->lEDeaGeraden->text();
|
||||
@@ -125,14 +139,18 @@ void WindowsSettings::StreckeSpeichernSlot(){
|
||||
deaKurvenInnen = ui->lEDeaKurvenInnen->text();
|
||||
deaSteilAussen = ui->lEDeaSteilkurveAussen->text();
|
||||
deaSteilInnen = ui->lEDeaSteilkurveInnen->text();
|
||||
statement = QString("insert into strecke (geraden, kurven_aussen, kurven_innen, steilkurve_innen, steilkurve_aussen, seit, id_bahn)"
|
||||
" values ("+deaGeraden+", "+deaKurvenAussen+", "+deaKurvenInnen+", "+deaSteilInnen+", "+deaSteilAussen+", '"+QString::fromStdString(currentDateTime())+"', 2)");
|
||||
//cout << statement.toStdString() << endl;
|
||||
statement =
|
||||
QString("insert into strecke (geraden, kurven_aussen, kurven_innen, "
|
||||
"steilkurve_innen, steilkurve_aussen, seit, id_bahn)"
|
||||
" values (" +
|
||||
deaGeraden + ", " + deaKurvenAussen + ", " + deaKurvenInnen +
|
||||
", " + deaSteilInnen + ", " + deaSteilAussen + ", '" +
|
||||
QString::fromStdString(currentDateTime()) + "', 2)");
|
||||
// cout << statement.toStdString() << endl;
|
||||
db->setData(statement.toStdString());
|
||||
}
|
||||
|
||||
WindowsSettings::~WindowsSettings()
|
||||
{
|
||||
WindowsSettings::~WindowsSettings() {
|
||||
delete ui;
|
||||
std::cout << "Destruktor einstellungen" << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user