fixed some heavy pointermistakes

This commit is contained in:
2014-09-24 21:35:04 +02:00
parent b18e3f9943
commit ff954eced0
19 changed files with 751 additions and 56 deletions

View File

@@ -23,7 +23,8 @@ SOURCES += main.cpp\
countdown.cpp \
ampel.cpp \
database.cpp \
windowrennliste.cpp
windowrennliste.cpp \
training.cpp
HEADERS += \
mainwindow.h \
@@ -34,12 +35,14 @@ HEADERS += \
countdown.h \
ampel.h \
database.h \
windowrennliste.h
windowrennliste.h \
training.h
FORMS += mainwindow.ui \
windowrace.ui \
windowssettings.ui \
windowrennliste.ui
windowrennliste.ui \
training.ui
OTHER_FILES +=

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.0.1, 2014-09-13T13:57:17. -->
<!-- Written by QtCreator 3.0.1, 2014-09-24T20:28:48. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>

View File

@@ -3,11 +3,15 @@
Ampel::Ampel()
{
this->running = 1;
}
void Ampel::setStop(){
this->running = 0;
}
void Ampel::run(){
int anzahl = 0;
while(1){
while(this->running){
anzahl++;
if(anzahl < 6){
usleep(800000);

View File

@@ -7,8 +7,10 @@ class Ampel:public QThread
Q_OBJECT
public:
Ampel();
void setStop();
protected:
void run();
bool running;
signals:
void ampelUpdate();
};

View File

@@ -2,9 +2,14 @@
#include "unistd.h"
Countdown::Countdown()
{
this->running = 1;
}
void Countdown::setStop(){
this->running = 0;
}
void Countdown::run(){
while(1){
while(this->running){
sleep(1);
emit CountdownUpdate();
}

View File

@@ -7,7 +7,9 @@ class Countdown : public QThread
Q_OBJECT
protected:
void run();
bool running;
public:
void setStop();
Countdown();
signals:
void CountdownUpdate();

View File

@@ -13,6 +13,12 @@ DataBase::DataBase()
this->db->setDatabaseName("Renndatenbank.sqlite");
std::cout << "Konstruktor Database" << std::endl;
}
DataBase::~DataBase(){
std::cout << "Destruktor aus Datenbank" << std::endl;
delete this->db;
//delete this;
}
vector< vector<QString> > DataBase::getData2(std::string statement, int cols){
vector<QString> data;

View File

@@ -13,6 +13,7 @@ class DataBase
{
public:
DataBase();
~DataBase();
vector< vector<QString> > getData(std::string statement, int cols);
vector< vector<QString> > getData2(std::string statement, int cols);
void setData(std::string statement);

View File

@@ -12,17 +12,23 @@ HardwareSetup::HardwareSetup()
}
shellBefore = false;
deaBefore = false;
this->stop = 0;
}
void HardwareSetup::setStop(){
this->stop = 1;
}
}
HardwareSetup::~HardwareSetup(){
if (ioperm(BASEPORT, 3, 0)) {
/*if (ioperm(BASEPORT, 3, 0)) {
//perror("ioperm");
}
}*/
std::cout << "Hardware beendet" << std::endl;
}
void HardwareSetup::run(){
while(1){
usleep(10000);
while(!this->stop){
usleep(500);
if(getDea()){
if(!deaBefore){
deaBefore = true;

View File

@@ -15,7 +15,9 @@ private:
bool getShell();
bool getDea();
int* findBit(int *array, int zahl);
bool stop;
public:
void setStop();
~HardwareSetup();
HardwareSetup();
signals:

View File

@@ -8,6 +8,8 @@
#include "database.h"
#include <vector>
#include "windowrennliste2.h"
#include "training.h"
#include "unistd.h"
using std::vector;
MainWindow::MainWindow(QWidget *parent) :
@@ -16,23 +18,36 @@ MainWindow::MainWindow(QWidget *parent) :
{
ui->setupUi(this);
test = new HardwareSetup;
//test = new HardwareSetup;
this->test->start();
//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()));
this->db = new DataBase;
vector< vector <QString> > daten = db->getData("select * from Fahrer", 2);
}
void MainWindow::closeEvent(QCloseEvent *event){
}
MainWindow::~MainWindow()
{
delete this->db;
delete ui;
}
void MainWindow::WindowTraining(){
}
void MainWindow::NewWindowSettings(){
this->interfaceSettings = new WindowsSettings(this->db, this);
this->interfaceSettings->show();

View File

@@ -27,11 +27,12 @@ public:
public slots:
void NewWindowSettings();
void WindowRennen();
void WindowTraining();
private:
void closeEvent(QCloseEvent *event);
DataBase *db;
HardwareSetup *test;
Ui::MainWindow *ui;
WindowRace *interfaceRace;
WindowsSettings *interfaceSettings;

View File

@@ -6,57 +6,48 @@
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<height>427</height>
<width>512</width>
<height>235</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>410</x>
<y>10</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Einstellungen</string>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,1">
<item>
<widget class="QPushButton" name="pBRennen">
<property name="geometry">
<rect>
<x>410</x>
<y>60</y>
<width>80</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Rennen</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>140</x>
<y>100</y>
<width>113</width>
<height>23</height>
</rect>
</item>
<item>
<widget class="QPushButton" name="pBTraining">
<property name="text">
<string>Training</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Einstellungen</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>568</width>
<width>512</width>
<height>20</height>
</rect>
</property>

14
training.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include "training.h"
#include "ui_training.h"
Training::Training(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Training)
{
ui->setupUi(this);
}
Training::~Training()
{
delete ui;
}

22
training.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef TRAINING_H
#define TRAINING_H
#include <QMainWindow>
namespace Ui {
class Training;
}
class Training : public QMainWindow
{
Q_OBJECT
public:
explicit Training(QWidget *parent = 0);
~Training();
private:
Ui::Training *ui;
};
#endif // TRAINING_H

609
training.ui Normal file
View File

@@ -0,0 +1,609 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Training</class>
<widget class="QMainWindow" name="Training">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="gbShell">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="title">
<string>Shell</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Bestzeit</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="lBestZeitShell">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Zeit aktueller Runde</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="lCurRoundTimeShell">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="lWShellTime">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6" stretch="0,0,1">
<item alignment="Qt::AlignHCenter|Qt::AlignTop">
<widget class="QLabel" name="lCountdown">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>17</pointsize>
</font>
</property>
<property name="text">
<string>Verbleibende Zeit</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>170</width>
<height>100</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QWidget" name="hW11" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel11" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QWidget" name="hW21" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel21" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QWidget" name="hW12" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel12" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QWidget" name="hw22" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel22" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QWidget" name="hW13" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel13" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QWidget" name="hW23" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel23" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QWidget" name="hW14" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel14" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QWidget" name="hW24" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel24" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QWidget" name="hW15" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel15" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QWidget" name="hW25" native="true">
<property name="minimumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="WAmpel25" native="true">
<property name="maximumSize">
<size>
<width>23</width>
<height>23</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/new/prefix1/ampel.png);</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="gbDea">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="title">
<string>Dea</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Bestzeit</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="lBestZeitDea">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>Zeit aktueller Runde</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="lCurRoundDea">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>∞</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="lWDeaTime">
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -4,6 +4,7 @@
#include <string>
#include <sstream>
#include <iostream>
#include "unistd.h"
using std::vector;
using std::string;
@@ -175,8 +176,8 @@ void WindowRace::setDriverAndCarId(vector<QString> vec){
}
void WindowRace::closeEvent(QCloseEvent *event){
QMessageBox msgBox;
msgBox.setText("The document has been modified.");
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setText("Wirklich schliessen?");
msgBox.setInformativeText("");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
@@ -235,6 +236,15 @@ void WindowRace::countdownUpdate(){
WindowRace::~WindowRace()
{
this->startAmpelThread->setStop();
this->countdown->setStop();
this->Hardware->setStop();
usleep(1000010); //eine Sekunde
delete this->countdown;
delete this->Hardware;
delete this->startAmpelThread;
delete ui;
}
void WindowRace::shellSlot(){
@@ -362,5 +372,4 @@ void WindowRace::ampelSlot(){
void WindowRace::go(){
startAmpelThread->start();
}

View File

@@ -121,6 +121,7 @@ void WindowRennliste::closeEvent(QCloseEvent *event){
void WindowRennliste::schliessen(){
this->windowClose = true;
this->close();
delete this;
}
void WindowRennliste::setSelection(int row){

View File

@@ -60,6 +60,7 @@ WindowsSettings::WindowsSettings(DataBase *db, QWidget *parent) :
}
void WindowsSettings::AbbrechenSlot(){
this->close();
delete this;
}
void WindowsSettings::SaveDauerSlot(){
string statement = "update renndauer set dauer="+this->ui->leRenndauer->text().toStdString()+" where id like 1";
@@ -98,6 +99,7 @@ void WindowsSettings::StreckeSpeichernSlot(){
WindowsSettings::~WindowsSettings()
{
delete ui;
std::cout << "Destruktor einstellungen" << std::endl;
}
// Get current date/time, format is YYYY-MM-DD.HH:mm:ss