app/sources/brcategory.cpp

76 lines
1.8 KiB
C++
Raw Normal View History

2020-10-31 15:16:06 +01:00
#include "../headers/brcategory.h"
#include "headers/brprovider.h"
2020-11-04 17:25:28 +01:00
#include "headers/brcompetition.h"
2020-10-31 15:16:06 +01:00
BRCategory::BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData) : BRWidget(provider, federation, id)
2020-10-31 15:16:06 +01:00
{
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);
}
2020-11-04 17:25:28 +01:00
BRCategory::BRCategoryData BRCategory::getData() {
BRCategory::BRCategoryData data {
this,
this->name,
this->currentRound,
this->rounds
};
return data;
}
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;
2020-11-04 17:25:28 +01:00
for(BRRound* round : this->rounds) {
round->category = this;
2020-11-04 17:25:28 +01:00
connect(round, &BRRound::resultsChanged, this, &BRCategory::resultsChanged);
}
emit this->roundsChanged();
}
}
2020-10-31 15:16:06 +01:00
BRWidget::BRWidgetStatusCode BRCategory::load() {
2020-11-04 17:25:28 +01:00
return BRWidget::OpeationNotSupportedError;
2020-10-31 15:16:06 +01:00
}