app/sources/brcategory.cpp

88 lines
2.1 KiB
C++

#include "../headers/brcategory.h"
#include "headers/brprovider.h"
#include "headers/brcompetition.h"
BRCategory::BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData) : BRWidget(provider, federation, id)
{
this->currentRound = nullptr;
this->discipline = UnknownDiscipline;
this->setData(initialData);
}
BRCompetition* BRCategory::getCompetition() const {
return this->competition;
}
QString BRCategory::getName() {
return this->name;
}
BRCategory::BRDiscipline BRCategory::getDiscipline() {
return this->discipline;
}
BRCategory::BRCategoryStatus BRCategory::getStatus() {
return this->status;
}
BRRound* BRCategory::getCurrentRound() const {
return this->currentRound;
}
void BRCategory::setCurrentRound(BRRound* round) {
if(!this->rounds.contains(round))
return;
this->currentRound = round;
emit this->currentRoundChanged();
}
QList<BRRound*> BRCategory::getRounds() const {
return this->rounds;
}
QList<QObject*> BRCategory::getRoundsQML() {
return this->listToQmlList(this->rounds);
}
BRCategory::BRCategoryData BRCategory::getData() {
BRCategory::BRCategoryData data {
this,
this->name,
this->discipline,
this->status,
this->currentRound,
this->rounds
};
return data;
}
void BRCategory::setData(BRCategoryData data) {
this->name = data.name;
this->discipline = data.discipline;
this->status = data.status;
emit this->metadataChanged();
if(this->currentRound != data.currentRound) {
this->currentRound = data.currentRound;
emit this->currentRoundChanged();
}
if(this->rounds != data.rounds) {
this->rounds.clear();
this->rounds = data.rounds;
for(BRRound* round : this->rounds) {
round->category = this;
connect(round, &BRRound::resultsChanged, this, &BRCategory::resultsChanged);
}
emit this->roundsChanged();
}
}
BRWidget::BRWidgetStatusCode BRCategory::load() {
return BRWidget::OpeationNotSupportedError;
}