app/sources/competition/result/brresultdetailsgeneralresult.cpp
Dorian Zedler 85c8760bed
- moved some stuff
- results work now (still basic)
2020-11-15 14:48:12 +01:00

44 lines
1.3 KiB
C++

#include "brresultdetailsgeneralresult.h"
#include "brcategory.h"
#include "brresult.h"
BRResultDetailsGeneralResult::BRResultDetailsGeneralResult() : BRResultDetails(BRResultDetails::GeneralResult)
{
}
QString BRResultDetailsGeneralResult::toString() {
QString resultString = "";
for(BRResult* result : this->getResults())
resultString += result->getDetails()->toString() + " | " ;
resultString = resultString.left(resultString.length() - 3);
return resultString;
}
QList<BRResult*> BRResultDetailsGeneralResult::getResults() {
if(this->getResult() == nullptr || this->getResult()->getRound() == nullptr || this->getResult()->getRound()->getCategory() == nullptr)
return {};
BRCategory* category = this->getResult()->getRound()->getCategory();
// get all results of this athlete from all rounds
QList<BRResult*> results;
for(BRRound* round : category->getRounds()) {
for(BRResult* result : round->getResults()) {
if(result->getAthlete()->getId() == this->getResult()->getAthlete()->getId()) {
results.append(result);
}
}
}
return results;
}
QList<QObject*> BRResultDetailsGeneralResult::getResultsQML() {
return this->listToQmlList(this->getResults());
}