app/sources/brcategory.cpp
Dorian Zedler 9b762ea246
many new implementations:
- Results are now starting to work on VL
2020-11-04 13:55:37 +01:00

77 lines
1.8 KiB
C++

#include "../headers/brcategory.h"
#include "headers/brprovider.h"
BRCategory::BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData) : BRWidget(provider, federation, id)
{
this->currentRound = nullptr;
this->setData(initialData);
}
BRCompetition* BRCategory::getCompetition() const {
return this->competition;
}
QString BRCategory::getName() {
return this->name;
}
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);
}
void BRCategory::setData(BRCategoryData data) {
this->name = data.name;
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;
emit this->roundsChanged();
}
}
BRWidget::BRWidgetStatusCode BRCategory::load() {
BRCategoryData newData {
this,
this->name,
this->currentRound,
this->rounds
};
qDebug() << "LOADING CATEGORY";
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
if(statusCode != BRWidget::Success)
return statusCode;
this->setData(newData);
return BRWidget::Success;
}