2020-11-15 14:48:12 +01:00
|
|
|
#include "brcalendar.h"
|
|
|
|
#include "brprovider.h"
|
2020-10-31 15:16:06 +01:00
|
|
|
|
2020-11-04 13:55:37 +01:00
|
|
|
BRCalendar::BRCalendar(BRProvider* provider, BRFederation federation) : BRWidget(provider, federation, -1)
|
2020-10-31 15:16:06 +01:00
|
|
|
{
|
2020-11-03 15:56:43 +01:00
|
|
|
this->currentSeason = nullptr;
|
|
|
|
this->seasons = {};
|
|
|
|
|
|
|
|
connect(this, &BRCalendar::currentSeasonChanged, this, &BRCalendar::titleChanged);
|
|
|
|
connect(this, &BRCalendar::seasonsChanged, this, &BRCalendar::titleChanged);
|
2020-10-31 15:16:06 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
QString BRCalendar::getTitle() {
|
|
|
|
QString title = QStringList({"IFSC", "DAV", "SAC"})[this->getFederation()] + " " + tr("calendar");
|
2020-10-31 15:16:06 +01:00
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
if(this->currentSeason != nullptr)
|
|
|
|
title += " " + this->currentSeason->getName();
|
2020-10-31 15:16:06 +01:00
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
return title;
|
2020-10-31 15:16:06 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
QList<QObject*> BRCalendar::getSeasonsQML() {
|
|
|
|
return this->listToQmlList(this->seasons);
|
2020-10-31 15:16:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
BRSeason* BRCalendar::getCurrentSeason() {
|
|
|
|
return this->currentSeason;
|
|
|
|
}
|
2020-10-31 15:16:06 +01:00
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
void BRCalendar::setCurrentSeason(BRSeason* season) {
|
|
|
|
if(!this->seasons.contains(season))
|
|
|
|
return;
|
|
|
|
|
|
|
|
this->currentSeason = season;
|
|
|
|
this->currentSeason->load();
|
|
|
|
emit this->currentSeasonChanged();
|
2020-10-31 15:16:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BRWidget::BRWidgetStatusCode BRCalendar::load() {
|
|
|
|
if(this->getProvider() == nullptr)
|
|
|
|
return BRWidget::NoProviderError;
|
|
|
|
|
|
|
|
// reload all comp data using our providers
|
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2020-10-31 15:16:06 +01:00
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
return statusCode;
|
2020-10-31 15:16:06 +01:00
|
|
|
}
|