app/sources/brleague.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.7 KiB
C++

#include "headers/brleague.h"
#include "headers/brprovider.h"
BRLeague::BRLeague(BRProvider* provider, BRWidget::BRFederation federation, int id, BRLeagueData initialData) : BRWidget(provider, federation, id)
{
this->competitions = {};
this->competitions = {};
this->setData(initialData);
}
QString BRLeague::getName() {
return this->name;
}
QColor BRLeague::getColor() {
return this->color;
}
QList<BRCompetition*> BRLeague::getCompetitions() {
return this->competitions;
}
QList<QObject*> BRLeague::getCompetitionsQML() {
return this->listToQmlList(this->competitions);
}
QList<QObject*> BRLeague::getCupsQML() {
return this->listToQmlList(this->cups);
}
void BRLeague::setData(BRLeagueData data) {
this->name = data.name;
this->color = data.color;
emit this->metadataChanged();
if(this->competitions != data.competitions) {
this->competitions.clear();
this->competitions = data.competitions;
for(BRCompetition* competition : this->competitions)
competition->setLeague(this);
emit this->competitionsChanged();
}
if(this->cups != data.cups) {
this->cups.clear();
this->cups = data.cups;
emit this->cupsChanged();
}
}
BRWidget::BRWidgetStatusCode BRLeague::load() {
if(this->getProvider() == nullptr)
return BRWidget::NoProviderError;
// reload all comp data using our providers
BRLeagueData newData {
this,
this->name,
this->color,
this->competitions,
this->cups
};
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
if(statusCode != BRWidget::Success)
return statusCode;
this->setData(newData);
return statusCode;
}