added second part of minimum sector times
This commit is contained in:
@@ -4,16 +4,18 @@
|
||||
#include <qcolor.h>
|
||||
|
||||
|
||||
TimeModel::TimeModel(QVector<QVector<int>> timeData, QObject *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> topTime, QObject *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
|
||||
@@ -62,6 +64,20 @@ QColor TimeModel::getColor(const QVector<QVector<int>> data, const int col, cons
|
||||
}
|
||||
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{
|
||||
// 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)){
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<int> compare;
|
||||
for(int i = 0; i <= row; i++){
|
||||
if(data.at(i).size() > col){
|
||||
|
||||
@@ -10,8 +10,8 @@ class TimeModel : public QAbstractTableModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TimeModel(QVector<QVector<int>> timeData, QObject *parent = nullptr);
|
||||
explicit TimeModel(QVector<QVector<int>> timeData, QVector<int> topTime, QObject *parent = nullptr);
|
||||
explicit TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes, QObject *parent = nullptr);
|
||||
explicit TimeModel(QVector<QVector<int>> timeData, QVector<int> minimumTimes, QVector<int> topTime, QObject *parent = nullptr);
|
||||
|
||||
// Header:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
@@ -32,6 +32,7 @@ private:
|
||||
QColor getColor(const QVector<QVector<int>> data, const int col, const int row) const; // row and col starts counting at 0
|
||||
QVector<QVector<int>> timeData;
|
||||
QVector<int> topTime;
|
||||
QVector<int> minimumTimes;
|
||||
};
|
||||
|
||||
#endif // TIMEMODEL_H
|
||||
|
||||
24
training.cpp
24
training.cpp
@@ -55,12 +55,20 @@ Training::Training(QWidget *parent, DataBase *db) :
|
||||
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;
|
||||
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(){
|
||||
this->VecShell.clear();
|
||||
|
||||
// this->ui->lWShellTime->clear();
|
||||
timeModelShell = new TimeModel(VecShell, this);
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
|
||||
this->ui->lBestZeitShell->setText("∞");
|
||||
@@ -71,7 +79,7 @@ void Training::ResetDea(){
|
||||
this->VecDea.clear();
|
||||
|
||||
//this->ui->lWDeaTime->clear();
|
||||
timeModelDea = new TimeModel(VecDea, this);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
this->ui->lBestZeitDea->setText("∞");
|
||||
@@ -117,7 +125,7 @@ void Training::shellSlot(int time, int sector){
|
||||
VecShell.push_back(QVector<int>());
|
||||
VecShell.last().push_back(time);
|
||||
|
||||
timeModelShell = new TimeModel(VecShell, this);
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
|
||||
break;
|
||||
@@ -126,7 +134,7 @@ void Training::shellSlot(int time, int sector){
|
||||
if(VecShell.last().size() == 1){
|
||||
// cout << time << sector << endl;
|
||||
VecShell.last().push_back(time);
|
||||
timeModelShell = new TimeModel(VecShell, this);
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
}
|
||||
@@ -141,7 +149,7 @@ void Training::shellSlot(int time, int sector){
|
||||
// add sum to vector
|
||||
VecShell.last().push_back(QVectorHelper::getCurTime(VecShell.last()));
|
||||
|
||||
timeModelShell = new TimeModel(VecShell, this);
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
// best time on widget
|
||||
@@ -183,7 +191,7 @@ void Training::deaSlot(int time, int sector){
|
||||
VecDea.push_back(QVector<int>());
|
||||
VecDea.last().push_back(time);
|
||||
// cout << "Dea Sektor 1" << endl;
|
||||
timeModelDea = new TimeModel(VecDea, this);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
break;
|
||||
@@ -192,7 +200,7 @@ void Training::deaSlot(int time, int sector){
|
||||
if(VecDea.last().size() == 1){
|
||||
// cout << time << sector << endl;
|
||||
VecDea[VecDea.size()-1].push_back(time);
|
||||
timeModelDea = new TimeModel(VecDea, this);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
}
|
||||
else{
|
||||
@@ -210,7 +218,7 @@ void Training::deaSlot(int time, int sector){
|
||||
// add sum to vector
|
||||
VecDea.last().push_back(QVectorHelper::getCurTime(VecDea.last()));
|
||||
|
||||
timeModelDea = new TimeModel(VecDea, this);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
}
|
||||
// best time on widget
|
||||
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
// timeModel
|
||||
TimeModel *timeModelDea;
|
||||
TimeModel *timeModelShell;
|
||||
QVector<int> minSecTime;
|
||||
|
||||
public slots:
|
||||
void ResetShell();
|
||||
|
||||
@@ -35,6 +35,14 @@ WindowRace::WindowRace(DataBase *db, QWidget *parent) :
|
||||
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";
|
||||
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;
|
||||
@@ -169,11 +177,11 @@ void WindowRace::prepareNextRace(){
|
||||
this->VecDea.clear();
|
||||
|
||||
// clear tableview shell
|
||||
timeModelShell = new TimeModel(VecShell);
|
||||
timeModelShell = new TimeModel(VecShell, minSecTime);
|
||||
ui->lWShellTime->setModel(timeModelShell);
|
||||
|
||||
// clear tableview dea
|
||||
timeModelDea = new TimeModel(VecDea);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime);
|
||||
ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
this->finished = false;
|
||||
@@ -348,7 +356,7 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, test, this);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
// this->ui->lWShellTime->setModel(this->timeModelShell);
|
||||
ui->lWShellTime->setModel(this->timeModelShell);
|
||||
break;
|
||||
@@ -363,7 +371,7 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, test, this);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
}
|
||||
@@ -384,7 +392,7 @@ void WindowRace::shellSlot(int time, int sector){
|
||||
test.append(1);
|
||||
test.append(2);
|
||||
test.append(3);
|
||||
this->timeModelShell = new TimeModel(VecShell, test, this);
|
||||
this->timeModelShell = new TimeModel(VecShell, minSecTime, test, this);
|
||||
// timeModelShell = new TimeModel(VecShell, this);
|
||||
this->ui->lWShellTime->setModel(timeModelShell);
|
||||
int zeit = QVectorHelper::getMin(VecShell);
|
||||
@@ -424,7 +432,7 @@ void WindowRace::deaSlot(int time, int sector){
|
||||
VecDea.push_back(QVector<int>());
|
||||
VecDea.last().push_back(time);
|
||||
cout << "Dea Sektor 1" << endl;
|
||||
timeModelDea = new TimeModel(VecDea, this);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
break;
|
||||
@@ -433,7 +441,7 @@ void WindowRace::deaSlot(int time, int sector){
|
||||
if(VecDea.last().size() == 1){
|
||||
cout << time << sector << endl;
|
||||
VecDea[VecDea.size()-1].push_back(time);
|
||||
timeModelDea = new TimeModel(VecDea, this);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
}
|
||||
else{
|
||||
@@ -453,7 +461,7 @@ void WindowRace::deaSlot(int time, int sector){
|
||||
|
||||
|
||||
|
||||
timeModelDea = new TimeModel(VecDea, this);
|
||||
timeModelDea = new TimeModel(VecDea, minSecTime, this);
|
||||
this->ui->lWDeaTime->setModel(timeModelDea);
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ private:
|
||||
int fahrzeit;
|
||||
int renn_id;
|
||||
int minimumTime;
|
||||
QVector<int> minSecTime;
|
||||
|
||||
public slots:
|
||||
void stopClicked();
|
||||
|
||||
Reference in New Issue
Block a user