app/headers/competition/brcompetition.h

95 lines
2.9 KiB
C
Raw Permalink Normal View History

2020-10-31 15:16:06 +01:00
#ifndef BRCOMPETITION_H
#define BRCOMPETITION_H
#include <QObject>
#include <QDate>
#include <QUrl>
#include <QDebug>
2020-10-31 15:16:06 +01:00
#include "brwidget.h"
#include "brcategory.h"
class BRLeague;
2020-10-31 15:16:06 +01:00
class BRCompetition : public BRWidget
{
Q_OBJECT
Q_PROPERTY(QString name READ getName 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<QUrl> infosheetUrls READ getInfosheetUrls NOTIFY metadataChanged)
Q_PROPERTY(bool pinned READ getPinned WRITE setPinned NOTIFY pinnedChanged)
Q_PROPERTY(QList<QObject*> categories READ getCategoriesQML NOTIFY categoriesChanged)
Q_PROPERTY(BRCategory* currentCategory READ getCurrentCategory WRITE setCurrentCategory NOTIFY currentCategoryChanged)
2020-11-04 17:25:28 +01:00
Q_PROPERTY(QList<QObject*> results READ getResultsQML NOTIFY resultsChanged)
2020-10-31 15:16:06 +01:00
public:
friend class BRProvider;
friend class BRLeague;
2020-10-31 15:16:06 +01:00
typedef struct BRCompetitionData {
const BRCompetition* competition;
QString name;
QDate startDate;
QDate endDate;
QUrl eventWebsiteUrl;
QList<QUrl> infosheetUrls;
bool pinned;
2020-11-04 17:25:28 +01:00
BRCategory* currentCategory;
QList<BRCategory*> categories;
} BRCompetitionData;
2020-10-31 15:16:06 +01:00
Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override;
Q_INVOKABLE QString getName();
Q_INVOKABLE QDate getStartDate();
Q_INVOKABLE QDate getEndDate();
Q_INVOKABLE QString getDateSpan();
Q_INVOKABLE BRLeague* getLeague();
Q_INVOKABLE QUrl getEventWebsiteUrl();
Q_INVOKABLE QList<QUrl> getInfosheetUrls();
Q_INVOKABLE bool getPinned();
Q_INVOKABLE void setPinned(bool pinned);
Q_INVOKABLE QList<QObject*> getCategoriesQML();
2020-11-04 17:25:28 +01:00
Q_INVOKABLE QList<BRCategory*> getCategories();
Q_INVOKABLE BRCategory* getCurrentCategory() const;
Q_INVOKABLE void setCurrentCategory(BRCategory* category);
2020-11-04 17:25:28 +01:00
Q_INVOKABLE QList<QObject*> getResultsQML();
static bool lessThan(BRCompetition* competition1, BRCompetition* competition2);
private:
explicit BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCompetitionData initialData);
void setLeague(BRLeague* league);
// metadata
2020-10-31 15:16:06 +01:00
QString name;
QDate startDate;
QDate endDate;
BRLeague* league;
QUrl eventWebsiteUrl;
QList<QUrl> infosheetUrls;
2020-10-31 15:16:06 +01:00
// data
bool pinned;
2020-10-31 15:16:06 +01:00
QList<BRCategory*> categories;
BRCategory* currentCategory;
2020-10-31 15:16:06 +01:00
void setData(BRCompetitionData data);
2020-10-31 15:16:06 +01:00
signals:
void metadataChanged();
void pinnedChanged();
void categoriesChanged();
void currentCategoryChanged();
2020-11-04 17:25:28 +01:00
void resultsChanged();
2020-10-31 15:16:06 +01:00
};
#endif // BRCOMPETITION_H