app/sources/brcompetition.cpp

80 lines
2 KiB
C++
Raw Normal View History

#include "headers/brcompetition.h"
#include "headers/brleague.h"
2020-10-31 15:16:06 +01:00
BRCompetition::BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCompetitionData initialData) : BRWidget(provider, federation), id(id) {
this->setData(initialData);
}
void BRCompetition::setLeague(BRLeague* league) {
if(league == nullptr)
return;
this->league = league;
emit this->metadataChanged();
2020-10-31 15:16:06 +01:00
}
QString BRCompetition::getName() {
return this->name;
}
BRCompetition::BRDiscipline BRCompetition::getDiscipline() {
return this->discipline;
}
QDate BRCompetition::getStartDate() {
return this->startDate;
}
QDate BRCompetition::getEndDate() {
return this->endDate;
}
QString BRCompetition::getDateSpan() {
if(this->startDate == this->endDate)
return this->startDate.toString("d MMMM yyyy");
else
return this->startDate.toString("d MMMM yyyy") + " - " + this->endDate.toString("d MMMM yyyy");
}
BRLeague* BRCompetition::getLeague() {
return this->league;
}
QUrl BRCompetition::getEventWebsiteUrl() {
return this->eventWebsiteUrl;
}
QList<QUrl> BRCompetition::getInfosheetUrls() {
return this->infosheetUrls;
}
QList<QObject*> BRCompetition::getCategoriesQML() {
return this->listToQmlList(this->categories);
}
2020-10-31 15:16:06 +01:00
BRWidget::BRWidgetStatusCode BRCompetition::load() {
}
void BRCompetition::setData(BRCompetition::BRCompetitionData data) {
this->name = data.name;
this->discipline = data.discipline;
this->startDate = data.startDate;
this->endDate = data.endDate;
this->eventWebsiteUrl = data.eventWebsiteUrl;
this->infosheetUrls = data.infosheetUrls;
emit this->metadataChanged();
if(this->categories != data.categories) {
this->categories.clear();
this->categories = data.categories;
emit this->categoriesChanged();
}
}
bool BRCompetition::lessThan(BRCompetition* competition1, BRCompetition* competition2) {
return competition1->startDate < competition2->startDate;
}