diff --git a/windowrace.cpp b/windowrace.cpp index fc85fff..fca3188 100644 --- a/windowrace.cpp +++ b/windowrace.cpp @@ -124,6 +124,9 @@ void WindowRace::prepareNextRace(){ this->ui->lCurRoundTimeShell->setText("∞"); this->ui->lCurRoundDea->setText("∞"); + this->VecShell.clear(); + this->VecDea.clear(); + this->finished = false; this->paused = false; @@ -230,6 +233,7 @@ void WindowRace::countdownUpdate(){ } if(countdownValue <= -1){ this->finished = true; + this->wRennliste->setBesttime(getMinimum(this->VecShell),getMinimum(this->VecDea)); this->ui->pBNextRace->setEnabled(true); } else{ @@ -313,18 +317,22 @@ void WindowRace::deaSlot(){ } long WindowRace::getMinimum(std::vector a){ - long minimum = a[0]; //could be wrong + long minimum = -1; for(unsigned int i = 0; i < a.size(); i++){ - if(a[i] < minimum && a[i] >= this->minimumTime){ - minimum = a[i]; + if(minimum < 0){ + if(a[i] >= this->minimumTime){ + minimum = a[i]; + } } + else{ + if(a[i] < minimum && a[i] >= this->minimumTime){ + minimum = a[i]; + } + } + } - if(minimum >= this->minimumTime){ - return minimum; - } - else{ - return -1; - } + return minimum; + } void WindowRace::ampelSlot(){ if(ampelCounter == 5){ diff --git a/windowrennliste.cpp b/windowrennliste.cpp index 7ea06b3..f8d9c98 100644 --- a/windowrennliste.cpp +++ b/windowrennliste.cpp @@ -89,6 +89,12 @@ vector WindowRennliste::getDriverAndCarId(){ 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::listClick(const QModelIndex & index){ QString driverShell = this->ui->tWRennliste->item(index.row(), 0)->text(); diff --git a/windowrennliste.h b/windowrennliste.h index cb2f2f8..426ad95 100644 --- a/windowrennliste.h +++ b/windowrennliste.h @@ -26,6 +26,7 @@ public: vector getDriverAndCarSettings(); vector getDriverAndCarId(); void sendIds(); + void setBesttime(int shell, int dea); private: bool windowClose; void closeEvent(QCloseEvent *event);