#include "headers/brcompetition.h" #include "headers/brleague.h" 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(); } 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 BRCompetition::getInfosheetUrls() { return this->infosheetUrls; } QList BRCompetition::getCategoriesQML() { return this->listToQmlList(this->categories); } 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; }