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

70 lines
1.8 KiB
C++

#include "brcalendar.h"
#include "brprovider.h"
BRCalendar::BRCalendar(BRProvider* provider, BRFederation federation) : BRWidget(provider, federation, -1)
{
this->currentSeason = nullptr;
this->seasons = {};
connect(this, &BRCalendar::currentSeasonChanged, this, &BRCalendar::titleChanged);
connect(this, &BRCalendar::seasonsChanged, this, &BRCalendar::titleChanged);
}
QString BRCalendar::getTitle() {
QString title = QStringList({"IFSC", "DAV", "SAC"})[this->getFederation()] + " " + tr("calendar");
if(this->currentSeason != nullptr)
title += " " + this->currentSeason->getName();
return title;
}
QList<QObject*> BRCalendar::getSeasonsQML() {
return this->listToQmlList(this->seasons);
}
BRSeason* BRCalendar::getCurrentSeason() {
return this->currentSeason;
}
void BRCalendar::setCurrentSeason(BRSeason* season) {
if(!this->seasons.contains(season))
return;
this->currentSeason = season;
this->currentSeason->load();
emit this->currentSeasonChanged();
}
BRWidget::BRWidgetStatusCode BRCalendar::load() {
if(this->getProvider() == nullptr)
return BRWidget::NoProviderError;
// reload all comp data using our providers
BRCalendarData newData {
this,
this->currentSeason,
this->seasons
};
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
if(statusCode != BRWidget::Success)
return statusCode;
if(this->seasons != newData.seasons) {
this->seasons.clear();
this->seasons = newData.seasons;
emit this->seasonsChanged();
}
if(this->currentSeason != newData.currentSeason) {
this->currentSeason = newData.currentSeason;
emit this->currentSeasonChanged();
}
return statusCode;
}