#ifndef BRCOMPETITION_H #define BRCOMPETITION_H #include #include #include #include #include "brwidget.h" #include "brcategory.h" class BRLeague; class BRCompetition : public BRWidget { Q_OBJECT Q_PROPERTY(QString name READ getName NOTIFY metadataChanged) Q_PROPERTY(QString discipline READ getDiscipline NOTIFY metadataChanged) Q_PROPERTY(QDate startDate READ getStartDate NOTIFY metadataChanged) Q_PROPERTY(QDate endDate READ getEndDate NOTIFY metadataChanged) Q_PROPERTY(QString dateSpan READ getDateSpan NOTIFY metadataChanged) Q_PROPERTY(BRLeague* league READ getLeague NOTIFY metadataChanged) Q_PROPERTY(QUrl eventWebsiteUrl READ getEventWebsiteUrl NOTIFY metadataChanged) Q_PROPERTY(QList infosheetUrls READ getInfosheetUrls NOTIFY metadataChanged) Q_PROPERTY(QList categories READ getCategoriesQML NOTIFY categoriesChanged) public: friend class BRProvider; friend class BRLeague; enum BRDiscipline { Unknown = -1, Boulder, Lead, Speed }; Q_ENUM(BRDiscipline) typedef struct BRCompetitionData { const BRCompetition* competition; QString name; BRDiscipline discipline; QDate startDate; QDate endDate; QUrl eventWebsiteUrl; QList infosheetUrls; QList categories; } BRCompetitionData; Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override; Q_INVOKABLE QString getName(); Q_INVOKABLE BRDiscipline getDiscipline(); Q_INVOKABLE QDate getStartDate(); Q_INVOKABLE QDate getEndDate(); Q_INVOKABLE QString getDateSpan(); Q_INVOKABLE BRLeague* getLeague(); Q_INVOKABLE QUrl getEventWebsiteUrl(); Q_INVOKABLE QList getInfosheetUrls(); Q_INVOKABLE QList getCategoriesQML(); static bool lessThan(BRCompetition* competition1, BRCompetition* competition2); private: explicit BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCompetitionData initialData); void setLeague(BRLeague* league); // metadata const int id; QString name; BRDiscipline discipline; QDate startDate; QDate endDate; BRLeague* league; QUrl eventWebsiteUrl; QList infosheetUrls; // data QList categories; void setData(BRCompetitionData data); signals: void metadataChanged(); void categoriesChanged(); }; #endif // BRCOMPETITION_H