Many more implementations!
Calendar works now for VL and DR API
This commit is contained in:
parent
0c7f5a42e4
commit
c44380d1bf
29 changed files with 1477 additions and 656 deletions
|
@ -25,3 +25,16 @@
|
||||||
# layer 4
|
# layer 4
|
||||||
- QML
|
- QML
|
||||||
- Will call functions from Layer 2 and get Objects from Layer 3
|
- Will call functions from Layer 2 and get Objects from Layer 3
|
||||||
|
|
||||||
|
|
||||||
|
# Season and Leagues handling
|
||||||
|
1. Calendar loads
|
||||||
|
-> Calendar gets available seasons (which get available leagues)
|
||||||
|
-> Data loader decides on default season and default league(s)
|
||||||
|
-> Data loader loads default competitions
|
||||||
|
2. Calendar displays competitions
|
||||||
|
3. Current season is changed:
|
||||||
|
-> calendar reloads
|
||||||
|
-> Data loader sees that the availableSeasons are already
|
||||||
|
4. Current League is changed:
|
||||||
|
-> calendar reloads
|
||||||
|
|
|
@ -25,6 +25,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
sources/brleague.cpp \
|
||||||
sources/appsettings.cpp \
|
sources/appsettings.cpp \
|
||||||
sources/brcalendar.cpp \
|
sources/brcalendar.cpp \
|
||||||
sources/brcategory.cpp \
|
sources/brcategory.cpp \
|
||||||
|
@ -33,12 +34,15 @@ SOURCES += \
|
||||||
sources/brcup.cpp \
|
sources/brcup.cpp \
|
||||||
sources/brprovider.cpp \
|
sources/brprovider.cpp \
|
||||||
sources/brproviderdr.cpp \
|
sources/brproviderdr.cpp \
|
||||||
|
sources/brprovidervl.cpp \
|
||||||
|
sources/brseason.cpp \
|
||||||
sources/brserverconnector.cpp \
|
sources/brserverconnector.cpp \
|
||||||
sources/brwidget.cpp \
|
sources/brwidget.cpp \
|
||||||
sources/main.cpp
|
sources/main.cpp
|
||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
headers/brleague.h \
|
||||||
headers/appsettings.h \
|
headers/appsettings.h \
|
||||||
headers/brcalendar.h \
|
headers/brcalendar.h \
|
||||||
headers/brcategory.h \
|
headers/brcategory.h \
|
||||||
|
@ -47,6 +51,8 @@ HEADERS += \
|
||||||
headers/brcup.h \
|
headers/brcup.h \
|
||||||
headers/brprovider.h \
|
headers/brprovider.h \
|
||||||
headers/brproviderdr.h \
|
headers/brproviderdr.h \
|
||||||
|
headers/brprovidervl.h \
|
||||||
|
headers/brseason.h \
|
||||||
headers/brserverconnector.h \
|
headers/brserverconnector.h \
|
||||||
headers/brwidget.h
|
headers/brwidget.h
|
||||||
|
|
||||||
|
|
|
@ -3,38 +3,46 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "brcompetition.h"
|
|
||||||
#include "brwidget.h"
|
#include "brwidget.h"
|
||||||
|
#include "brseason.h"
|
||||||
|
#include "brcompetition.h"
|
||||||
#include "brcategory.h"
|
#include "brcategory.h"
|
||||||
#include "brcup.h"
|
#include "brcup.h"
|
||||||
|
|
||||||
class BRProvider;
|
|
||||||
|
|
||||||
class BRCalendar : public BRWidget
|
class BRCalendar : public BRWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString title READ getTitle NOTIFY titleChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> seasons READ getSeasonsQML NOTIFY seasonsChanged)
|
||||||
|
Q_PROPERTY(BRSeason* currentSeason READ getCurrentSeason WRITE setCurrentSeason NOTIFY currentSeasonChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class BRProvider;
|
friend class BRProvider;
|
||||||
friend class BRProviderDr;
|
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode load() override;
|
typedef struct {
|
||||||
|
BRCalendar* calendar;
|
||||||
|
BRSeason* currentSeason;
|
||||||
|
QList<BRSeason*> seasons;
|
||||||
|
} BRCalendarData;
|
||||||
|
|
||||||
Q_INVOKABLE int getYear();
|
Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override;
|
||||||
int getLeague();
|
|
||||||
QList<BRCompetition*> getCompetitions();
|
Q_INVOKABLE QString getTitle();
|
||||||
QList<QObject*> getCompetitionsQML();
|
Q_INVOKABLE QList<QObject*> getSeasonsQML();
|
||||||
|
Q_INVOKABLE BRSeason* getCurrentSeason();
|
||||||
|
Q_INVOKABLE void setCurrentSeason(BRSeason* season);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit BRCalendar(BRProvider* provider, BRFederation federation, int year, int league);
|
explicit BRCalendar(BRProvider* provider, BRFederation federation);
|
||||||
|
void setData(BRCalendarData data);
|
||||||
|
|
||||||
int year;
|
QList<BRSeason*> seasons;
|
||||||
int league;
|
BRSeason* currentSeason;
|
||||||
QList<BRCompetition*> competitions;
|
|
||||||
QList<BRCategory*> categories;
|
|
||||||
QList<BRCup*> cups;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void titleChanged();
|
||||||
|
void seasonsChanged();
|
||||||
|
void currentSeasonChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BRCALENDAR_H
|
#endif // BRCALENDAR_H
|
||||||
|
|
|
@ -3,13 +3,33 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class BRCategory : public QObject
|
#include "brwidget.h"
|
||||||
|
|
||||||
|
class BRCategory : public BRWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
public:
|
public:
|
||||||
explicit BRCategory(QObject *parent = nullptr);
|
friend class BRProvider;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRCategory* category;
|
||||||
|
QString name;
|
||||||
|
} BRCategoryData;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData);
|
||||||
|
void setData(BRCategoryData data);
|
||||||
|
|
||||||
|
const int id;
|
||||||
|
QString name;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,37 +3,88 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "brwidget.h"
|
#include "brwidget.h"
|
||||||
#include "brcategory.h"
|
#include "brcategory.h"
|
||||||
|
|
||||||
|
class BRLeague;
|
||||||
|
|
||||||
class BRCompetition : public BRWidget
|
class BRCompetition : public BRWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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<QUrl> infosheetUrls READ getInfosheetUrls NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> categories READ getCategoriesQML NOTIFY categoriesChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class BRProvider;
|
friend class BRProvider;
|
||||||
friend class BRProviderDr;
|
friend class BRLeague;
|
||||||
|
|
||||||
Q_INVOKABLE QString getName();
|
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode load() override;
|
|
||||||
private:
|
|
||||||
explicit BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id);
|
|
||||||
|
|
||||||
enum BRDiscipline {
|
enum BRDiscipline {
|
||||||
|
Unknown = -1,
|
||||||
Boulder,
|
Boulder,
|
||||||
Lead,
|
Lead,
|
||||||
Speed
|
Speed
|
||||||
};
|
};
|
||||||
|
Q_ENUM(BRDiscipline)
|
||||||
|
|
||||||
int id;
|
typedef struct BRCompetitionData {
|
||||||
|
const BRCompetition* competition;
|
||||||
QString name;
|
QString name;
|
||||||
BRDiscipline discipline;
|
BRDiscipline discipline;
|
||||||
QDate startDate;
|
QDate startDate;
|
||||||
QDate endDate;
|
QDate endDate;
|
||||||
|
QUrl eventWebsiteUrl;
|
||||||
|
QList<QUrl> infosheetUrls;
|
||||||
|
|
||||||
QList<BRCategory*> categories;
|
QList<BRCategory*> 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<QUrl> getInfosheetUrls();
|
||||||
|
Q_INVOKABLE QList<QObject*> 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<QUrl> infosheetUrls;
|
||||||
|
|
||||||
|
// data
|
||||||
|
QList<BRCategory*> categories;
|
||||||
|
|
||||||
|
void setData(BRCompetitionData data);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void categoriesChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "brproviderdr.h"
|
#include "brproviderdr.h"
|
||||||
|
#include "brprovidervl.h"
|
||||||
#include "brwidget.h"
|
#include "brwidget.h"
|
||||||
|
|
||||||
class BRCalendar;
|
class BRCalendar;
|
||||||
|
@ -14,10 +15,11 @@ class BRController : public QObject
|
||||||
public:
|
public:
|
||||||
explicit BRController(QObject *parent = nullptr);
|
explicit BRController(QObject *parent = nullptr);
|
||||||
|
|
||||||
Q_INVOKABLE BRCalendar* getCalendar(BRWidget::BRFederation federation, int year, int league = 0);
|
Q_INVOKABLE BRCalendar* getCalendar(BRWidget::BRFederation federation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRProvider* providerDr;
|
BRProvider* providerDr;
|
||||||
|
BRProvider* providerVl;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,42 @@
|
||||||
#define BRCUP_H
|
#define BRCUP_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "brwidget.h"
|
#include "brwidget.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
|
||||||
class BRCup : public BRWidget
|
class BRCup : public BRWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> categories READ getCategoriesQML NOTIFY categoriesChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BRCup(BRProvider* provider, BRWidget::BRFederation federation);
|
friend class BRProvider;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRCup* cup;
|
||||||
|
QString name;
|
||||||
|
QList<BRCategory*> categories;
|
||||||
|
} BRCupData;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QList<QObject*> getCategoriesQML();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRCup(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCupData initialData);
|
||||||
|
void setData(BRCupData data);
|
||||||
|
|
||||||
|
const int id;
|
||||||
|
QString name;
|
||||||
|
QList<BRCategory*> categories;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void categoriesChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BRCUP_H
|
#endif // BRCUP_H
|
||||||
|
|
59
headers/brleague.h
Normal file
59
headers/brleague.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#ifndef BRLEAGUE_H
|
||||||
|
#define BRLEAGUE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brcompetition.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
#include "brcup.h"
|
||||||
|
|
||||||
|
class BRLeague : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QColor color READ getColor NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> competitions READ getCompetitionsQML NOTIFY competitionsChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> cups READ getCupsQML NOTIFY cupsChanged)
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRLeague* league;
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
|
||||||
|
QList<BRCompetition*> competitions;
|
||||||
|
QList<BRCup*> cups;
|
||||||
|
} BRLeagueData;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
int getId() const;
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QColor getColor();
|
||||||
|
Q_INVOKABLE QList<BRCompetition*> getCompetitions();
|
||||||
|
Q_INVOKABLE QList<QObject*> getCompetitionsQML();
|
||||||
|
Q_INVOKABLE QList<QObject*> getCupsQML();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BRLeague(BRProvider* provider, BRWidget::BRFederation federation, int id, BRLeagueData initialData);
|
||||||
|
void setData(BRLeagueData data);
|
||||||
|
|
||||||
|
const int id;
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QColor color;
|
||||||
|
|
||||||
|
QList<BRCompetition*> competitions;
|
||||||
|
QList<BRCup*> cups;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void competitionsChanged();
|
||||||
|
void cupsChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRLEAGUE_H
|
|
@ -9,8 +9,9 @@
|
||||||
|
|
||||||
#include "brwidget.h"
|
#include "brwidget.h"
|
||||||
#include "brcalendar.h"
|
#include "brcalendar.h"
|
||||||
|
#include "brseason.h"
|
||||||
|
#include "brleague.h"
|
||||||
#include "brcompetition.h"
|
#include "brcompetition.h"
|
||||||
#include "brcategory.h"
|
|
||||||
#include "brcup.h"
|
#include "brcup.h"
|
||||||
|
|
||||||
class BRProvider : public QObject
|
class BRProvider : public QObject
|
||||||
|
@ -19,13 +20,27 @@ class BRProvider : public QObject
|
||||||
public:
|
public:
|
||||||
explicit BRProvider(QObject *parent = nullptr);
|
explicit BRProvider(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
friend class BRController;
|
||||||
friend class BRCalendar;
|
friend class BRCalendar;
|
||||||
|
friend class BRSeason;
|
||||||
|
friend class BRLeague;
|
||||||
|
friend class BRCompetition;
|
||||||
|
|
||||||
BRCalendar* getCalendar(BRWidget::BRFederation federation, int year, int league);
|
|
||||||
protected:
|
protected:
|
||||||
QVariantMap serverRequest(QUrl serviceUrl, QUrlQuery pdata = QUrlQuery());
|
QVariantMap serverRequest(QUrl serviceUrl, QList<QStringList> additionalHeaders = {}, QUrlQuery postData = QUrlQuery());
|
||||||
|
|
||||||
|
virtual BRCalendar* getCalendar(BRWidget::BRFederation federation) final;
|
||||||
|
virtual BRSeason* getSeason(BRWidget::BRFederation federation, int id, BRSeason::BRSeasonData initialData) final;
|
||||||
|
virtual BRLeague* getLeague(BRWidget::BRFederation federation, int id, BRLeague::BRLeagueData initialData) final;
|
||||||
|
virtual BRCompetition* getCompetition(BRWidget::BRFederation federation, int id, BRCompetition::BRCompetitionData initialData) final;
|
||||||
|
virtual BRCup* getCup(BRWidget::BRFederation federation, int id, BRCup::BRCupData initialData) final;
|
||||||
|
virtual BRCategory* getCategory(BRWidget::BRFederation federation, int id, BRCategory::BRCategoryData initialData) final;
|
||||||
|
|
||||||
|
virtual BRWidget::BRWidgetStatusCode getWidgetData(BRCalendar::BRCalendarData* calendarData) = 0;
|
||||||
|
virtual BRWidget::BRWidgetStatusCode getWidgetData(BRSeason::BRSeasonData* seasonData) = 0;
|
||||||
|
virtual BRWidget::BRWidgetStatusCode getWidgetData(BRLeague::BRLeagueData* leagueData) = 0;
|
||||||
|
virtual BRWidget::BRWidgetStatusCode getWidgetData(BRCompetition::BRCompetitionData* competitionData) = 0;
|
||||||
|
|
||||||
virtual BRWidget::BRWidgetStatusCode loadCalendarData(BRCalendar* calendar) = 0;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "brprovider.h"
|
#include "brprovider.h"
|
||||||
#include "brcalendar.h"
|
|
||||||
#include "brcompetition.h"
|
|
||||||
|
|
||||||
class BRProviderDr : public BRProvider
|
class BRProviderDr : public BRProvider
|
||||||
{
|
{
|
||||||
|
@ -14,11 +12,24 @@ public:
|
||||||
explicit BRProviderDr(QObject *parent = nullptr);
|
explicit BRProviderDr(QObject *parent = nullptr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BRWidget::BRWidgetStatusCode loadCalendarData(BRCalendar* calendar);
|
BRWidget::BRWidgetStatusCode getWidgetData(BRCalendar::BRCalendarData* calendarData) override;
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode loadCompetitionData(BRCompetition* competition, QVariantMap data);
|
BRWidget::BRWidgetStatusCode getWidgetData(BRSeason::BRSeasonData* seasonData) override;
|
||||||
|
BRSeason::BRSeasonData parseSeasonData(int id, QVariantMap rawData);
|
||||||
|
void parseSeasonData(BRSeason::BRSeasonData* seasonData, int id, QVariantMap rawData);
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRLeague::BRLeagueData* leagueData) override;
|
||||||
|
BRLeague::BRLeagueData parseLeagueData(QVariantMap leagueProperties, QVariantMap rawData);
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRCompetition::BRCompetitionData* competitionData) override;
|
||||||
|
BRCompetition::BRCompetitionData parseCompetitionData(QVariantMap rawData, BRWidget::BRFederation federation);
|
||||||
|
|
||||||
|
BRCup::BRCupData parseCupData(QVariantList categoriesList, QVariantMap rawData, BRWidget::BRFederation federation);
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData parseCategoryData(QVariantMap rawData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QMap<BRWidget::BRFederation, QList<QVariantMap>> leagues;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
35
headers/brprovidervl.h
Normal file
35
headers/brprovidervl.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef BRPROVIDERVL_H
|
||||||
|
#define BRPROVIDERVL_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brprovider.h"
|
||||||
|
|
||||||
|
class BRProviderVl : public BRProvider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BRProviderVl(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRCalendar::BRCalendarData* calendarData) override;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRSeason::BRSeasonData* seasonData) override;
|
||||||
|
BRSeason::BRSeasonData parseSeasonData(QVariantMap rawData);
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRLeague::BRLeagueData* leagueData) override;
|
||||||
|
void parseLeagueData(BRLeague::BRLeagueData* leagueData, QVariantMap rawData);
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode getWidgetData(BRCompetition::BRCompetitionData* competitionData) override;
|
||||||
|
BRCompetition::BRCompetitionData parseCompetitionData(QVariantMap rawData, BRWidget::BRFederation federation);
|
||||||
|
|
||||||
|
BRCup::BRCupData parseCupData(QVariantMap rawData);
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData parseCategoryData(QVariantMap rawData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap<BRWidget::BRFederation, QList<QVariantMap>> leagues;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRPROVIDERVL_H
|
61
headers/brseason.h
Normal file
61
headers/brseason.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#ifndef BRSEASON_H
|
||||||
|
#define BRSEASON_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
#include "brleague.h"
|
||||||
|
|
||||||
|
class BRSeason : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int year READ getYear NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QString name READ getName NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> leagues READ getLeaguesQML NOTIFY leaguesChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> competitions READ getCompetitionsQML NOTIFY competitionsChanged)
|
||||||
|
Q_PROPERTY(QList<QObject*> cups READ getCupsQML NOTIFY cupsChanged)
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
friend class BRProvider;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const BRSeason* season;
|
||||||
|
|
||||||
|
int year;
|
||||||
|
QString name;
|
||||||
|
bool nativeMultiLeagueSupport;
|
||||||
|
|
||||||
|
QList<BRLeague*> leagues;
|
||||||
|
} BRSeasonData;
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
|
Q_INVOKABLE int getYear() const;
|
||||||
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QList<QObject*> getLeaguesQML();
|
||||||
|
QList<BRLeague*> getLeagues() const;
|
||||||
|
Q_INVOKABLE QList<QObject*> getCompetitionsQML();
|
||||||
|
Q_INVOKABLE QList<QObject*> getCupsQML();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit BRSeason(BRProvider* provider, BRWidget::BRFederation federation, int id, BRSeasonData initialData);
|
||||||
|
void setData(BRSeasonData data);
|
||||||
|
|
||||||
|
const int id;
|
||||||
|
int year;
|
||||||
|
QString name;
|
||||||
|
bool multiLeagueSupport;
|
||||||
|
|
||||||
|
QList<BRLeague*> leagues;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
void leaguesChanged();
|
||||||
|
void competitionsChanged();
|
||||||
|
void cupsChanged();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRSEASON_H
|
|
@ -19,21 +19,33 @@ public:
|
||||||
|
|
||||||
enum BRWidgetStatusCode {
|
enum BRWidgetStatusCode {
|
||||||
Success = 200,
|
Success = 200,
|
||||||
NoProviderError = 510
|
InternalError = 900,
|
||||||
|
NoProviderError = 901,
|
||||||
|
NotImplementedError = 902
|
||||||
};
|
};
|
||||||
Q_ENUM(BRWidgetStatusCode)
|
Q_ENUM(BRWidgetStatusCode)
|
||||||
|
|
||||||
explicit BRWidget(BRProvider* provider, BRFederation federation);
|
|
||||||
|
|
||||||
Q_INVOKABLE virtual BRWidget::BRWidgetStatusCode load() = 0;
|
Q_INVOKABLE virtual BRWidget::BRWidgetStatusCode load() = 0;
|
||||||
BRFederation getFederation();
|
|
||||||
|
Q_INVOKABLE BRFederation getFederation() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
explicit BRWidget(BRProvider* provider, BRFederation federation);
|
||||||
BRProvider* getProvider();
|
BRProvider* getProvider();
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
QList<QObject*> listToQmlList(QList<T*> list) {
|
||||||
|
QList<QObject*> tmpList;
|
||||||
|
|
||||||
|
for(T* item : list)
|
||||||
|
tmpList.append(static_cast<QObject*>(item));
|
||||||
|
|
||||||
|
return tmpList;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRProvider* provider;
|
BRProvider* provider;
|
||||||
BRFederation federation;
|
const BRFederation federation;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ Page {
|
||||||
|
|
||||||
property BRWidget data
|
property BRWidget data
|
||||||
property Component headerComponent
|
property Component headerComponent
|
||||||
|
property alias selector: selectorPu
|
||||||
|
|
||||||
property string subTitle
|
property string subTitle
|
||||||
property bool titleIsPageTitle: true
|
property bool titleIsPageTitle: true
|
||||||
|
@ -38,9 +39,17 @@ Page {
|
||||||
property int status: -1
|
property int status: -1
|
||||||
property bool ready: false
|
property bool ready: false
|
||||||
|
|
||||||
|
signal loadingFinished()
|
||||||
|
signal selectionFinished(int index, var data)
|
||||||
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
data.load()
|
var status = data.load()
|
||||||
|
if(status !== BRWidget.Success)
|
||||||
|
ready = false
|
||||||
|
else
|
||||||
|
ready = true
|
||||||
|
loadingFinished()
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadData(params) {
|
function loadData(params) {
|
||||||
|
@ -88,8 +97,6 @@ Page {
|
||||||
property var dataObj
|
property var dataObj
|
||||||
property string subTitle: ""
|
property string subTitle: ""
|
||||||
|
|
||||||
signal selectionFinished(int index, var data)
|
|
||||||
|
|
||||||
x: 0 //root.width / 2 - width / 2
|
x: 0 //root.width / 2 - width / 2
|
||||||
y: root.height - selectorPu.height * 0.7//root.height - height //root.height / 2 - height / 2
|
y: root.height - selectorPu.height * 0.7//root.height - height //root.height / 2 - height / 2
|
||||||
|
|
||||||
|
@ -210,7 +217,7 @@ Page {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
selectorPu.close()
|
selectorPu.close()
|
||||||
selectorPu.selectionFinished(index, selectorPu.dataObj[index].data)
|
control.selectionFinished(index, selectorPu.dataObj[index].data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import "../Components"
|
||||||
BRWidgetPage {
|
BRWidgetPage {
|
||||||
id: control
|
id: control
|
||||||
|
|
||||||
title: "New Calendar"//(params.nation === "ICC" ? "IFSC":params.nation === "GER" ? "DAV":"SAC") + " " + qsTr("calendar") + " " + control.year
|
title: control.data.title
|
||||||
headerComponent: RowLayout {
|
headerComponent: RowLayout {
|
||||||
|
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
@ -38,9 +38,7 @@ BRWidgetPage {
|
||||||
ToolButton {
|
ToolButton {
|
||||||
id:yearToolBt
|
id:yearToolBt
|
||||||
|
|
||||||
onClicked: {
|
onClicked: control.changeSeason()
|
||||||
control.changeYear()
|
|
||||||
}
|
|
||||||
|
|
||||||
icon.name: "year"
|
icon.name: "year"
|
||||||
}
|
}
|
||||||
|
@ -48,27 +46,7 @@ BRWidgetPage {
|
||||||
ToolButton {
|
ToolButton {
|
||||||
id: filterToolBt
|
id: filterToolBt
|
||||||
|
|
||||||
onClicked: {
|
onClicked: control.changeLeagues()
|
||||||
var obj = app.compCats
|
|
||||||
var compCats = new Array
|
|
||||||
|
|
||||||
for(var prop in obj) {
|
|
||||||
// go through the whole array and search for data keys
|
|
||||||
if (obj.hasOwnProperty(prop) && obj[prop]["nation"] === params.nation) {
|
|
||||||
//console.log("found cat: " + obj[prop]['label'])
|
|
||||||
|
|
||||||
compCats.push( {"text": obj[prop]['label'], "data": obj[prop]} )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compCats.push( {"text": qsTr("Pinned"), "data": {"sort_rank":0, "cat_id":[-1]}} )
|
|
||||||
|
|
||||||
compCats.sort(function(a, b) {
|
|
||||||
return a['data']['sort_rank'] - b['data']['sort_rank'];
|
|
||||||
});
|
|
||||||
|
|
||||||
filterSelectPu.appear(compCats, qsTr("Select Filters"), "")
|
|
||||||
}
|
|
||||||
|
|
||||||
icon.name: "filter"
|
icon.name: "filter"
|
||||||
}
|
}
|
||||||
|
@ -76,31 +54,126 @@ BRWidgetPage {
|
||||||
ToolButton {
|
ToolButton {
|
||||||
id: cupToolBt
|
id: cupToolBt
|
||||||
|
|
||||||
onClicked: {
|
onClicked: control.openCup()
|
||||||
control.openCup()
|
|
||||||
}
|
|
||||||
|
|
||||||
icon.name: "cup"
|
icon.name: "cup"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLoadingFinished: {
|
||||||
|
calendarLv.autoScroll()
|
||||||
|
}
|
||||||
|
|
||||||
|
onSelectionFinished: {
|
||||||
|
if(data.task === "competition"){
|
||||||
|
app.openWidget({comp: data.comp, cat: data.cat, type:data.status === 4 ? 'starters':''})
|
||||||
|
}
|
||||||
|
else if(data.task === "season"){
|
||||||
|
loadingDl.open()
|
||||||
|
control.data.currentSeason = data.season
|
||||||
|
loadingDl.close()
|
||||||
|
}
|
||||||
|
else if(data.task === "cup1"){
|
||||||
|
control.openCup(data)
|
||||||
|
}
|
||||||
|
else if(data.task === "cup2"){
|
||||||
|
app.openWidget({cup: data.cup, cat: data.cat})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeSeason(){
|
||||||
|
var selectOptions = []
|
||||||
|
|
||||||
|
for(var i = 0; i < control.data.seasons.length; i++){
|
||||||
|
selectOptions.push({text: control.data.seasons[i].name, data:{task: "season", season: control.data.seasons[i]}})
|
||||||
|
}
|
||||||
|
|
||||||
|
selector.appear(selectOptions, qsTr("select season"))
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCompetition(competition){
|
||||||
|
var selectOptions = []
|
||||||
|
var categories = competition.categories
|
||||||
|
for(var i = 0; i < categories.length; i++){
|
||||||
|
selectOptions.push({text: categories[i].name, data:{task: "competition", cat: categories[i], comp: competition, status:categories.status}})
|
||||||
|
}
|
||||||
|
|
||||||
|
var infoUrls = competition.infosheetUrls
|
||||||
|
var infosheet = "";
|
||||||
|
if(infoUrls.length >= 1)
|
||||||
|
infosheet += ("<a href='" + infoUrls[0] + "'>" + qsTr('infosheet') + "</a>")
|
||||||
|
if(infoUrls.length === 2)
|
||||||
|
infosheet += (", <a href='" + infoUrls[1] + "'>" + qsTr('further infos') + "</a>")
|
||||||
|
|
||||||
|
var eventWebsite = competition.eventWebsiteUrl.toString() !== "" ? ("<a href='" + competition.eventWebsiteUrl + "'>" + qsTr('Event Website') + "</a>"):""
|
||||||
|
|
||||||
|
selector.appear(selectOptions, competition.name, eventWebsite + ((eventWebsite !== "" && infosheet !== "") ? ", ":"") + infosheet )
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCup(data) {
|
||||||
|
|
||||||
|
var cups = control.data.currentSeason.cups
|
||||||
|
|
||||||
|
var prop
|
||||||
|
var selectOptions = []
|
||||||
|
var selectTitle = ""
|
||||||
|
|
||||||
|
if(data === undefined){
|
||||||
|
// opened for the first time -> select cup
|
||||||
|
selectTitle = qsTr("select cup")
|
||||||
|
|
||||||
|
for(var i = 0; i < cups.length; i++){
|
||||||
|
selectOptions.push({text: cups[i].name, data:{task: "cup1", cup: cups[i]}})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(data.task === "cup1"){
|
||||||
|
// opened for the second time -> select cat
|
||||||
|
var cup = data.cup
|
||||||
|
|
||||||
|
selectTitle = cup['name'] + ": " + qsTr("select category")
|
||||||
|
|
||||||
|
for(var c = 0; c < cup.categories.length; c++){
|
||||||
|
selectOptions.push({text: cup.categories[c].name, data:{task: "cup2", cup: data.cup, cat: cup.categories[c]}})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
selector.appear(selectOptions, selectTitle)
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeLeagues() {
|
||||||
|
var leagues = control.data.currentSeason.leagues
|
||||||
|
var selectOptions = []
|
||||||
|
|
||||||
|
for(var i = 0; i < leagues.length; i++) {
|
||||||
|
//console.log("found cat: " + obj[prop]['label'])
|
||||||
|
|
||||||
|
selectOptions.push( {text: leagues[i].name, data:{task:"leagues", league: selectOptions}} )
|
||||||
|
}
|
||||||
|
|
||||||
|
//compCats.push( {"text": qsTr("Pinned"), "data": {"sort_rank":0, "cat_id":[-1]}} )
|
||||||
|
console.log("leagues: " + leagues)
|
||||||
|
filterSelectPu.appear(selectOptions, qsTr("Select Filters"), "")
|
||||||
|
}
|
||||||
|
|
||||||
DataListView {
|
DataListView {
|
||||||
|
id: calendarLv
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
//boundsBehavior: Flickable.StopAtBounds
|
//boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
model: widgetData["competitions"].length
|
model: control.data.currentSeason.competitions
|
||||||
|
|
||||||
//listData: widgetData['competitions']
|
//listData: widgetData['competitions']
|
||||||
|
|
||||||
onRefresh: {
|
onRefresh: {
|
||||||
updateData({}, false)
|
control.data.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
//initFilters()
|
//initFilters()
|
||||||
//initFavorites()
|
//initFavorites()
|
||||||
|
|
||||||
if(model){
|
/*if(model){
|
||||||
control.status = 200
|
control.status = 200
|
||||||
control.ready = true
|
control.ready = true
|
||||||
}
|
}
|
||||||
|
@ -108,9 +181,7 @@ BRWidgetPage {
|
||||||
control.ready = false
|
control.ready = false
|
||||||
control.status = 901
|
control.status = 901
|
||||||
return
|
return
|
||||||
}
|
}*/
|
||||||
|
|
||||||
autoScroll()
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
onWidgetDataChanged: {
|
onWidgetDataChanged: {
|
||||||
|
@ -122,38 +193,16 @@ BRWidgetPage {
|
||||||
*/
|
*/
|
||||||
function autoScroll() {
|
function autoScroll() {
|
||||||
// function to scroll to the next competition that is not already over
|
// function to scroll to the next competition that is not already over
|
||||||
var compList = control.widgetData["competitions"]
|
var compList = calendarLv.model
|
||||||
|
|
||||||
//console.log("scrolling")
|
if(control.data.currentSeason.year === new Date().getFullYear()){
|
||||||
|
console.log("SCROLLING")
|
||||||
if(parseInt(control.year) === new Date().getFullYear()){
|
|
||||||
for(var i = 0; i < compList.length; i ++){
|
for(var i = 0; i < compList.length; i ++){
|
||||||
// get the start date of the competition
|
if(compList[i].endDate.getTime() < new Date().getTime()){
|
||||||
var startDate = Date.fromLocaleString(Qt.locale(), compList[i]["date"], "yyyy-MM-dd")
|
|
||||||
//control.widgetData["competitions"][i]["month"] = startDate.getMonth()
|
|
||||||
|
|
||||||
//console.log("got date: " + startDate + " from string: " + compList[i]["date"] + " -> month is: " + compList[i]["month"])
|
|
||||||
|
|
||||||
// get the duration of the competition
|
|
||||||
var durationString = compList[i]["duration"] === undefined ? "1":compList[i]["duration"]
|
|
||||||
var days = parseInt(durationString.replace(/\D/g,''))
|
|
||||||
// calculate the end date of the competition
|
|
||||||
var endDate = new Date(startDate.valueOf())
|
|
||||||
endDate.setDate(endDate.getDate() + days);
|
|
||||||
|
|
||||||
//console.log(compList[i]["date"] + ": " + startDate + " to " + endDate)
|
|
||||||
|
|
||||||
if(endDate.getTime() < new Date().getTime()){
|
|
||||||
// end date is already over -> move the list view down!
|
// end date is already over -> move the list view down!
|
||||||
control.positionViewAtIndex(i, ListView.Top)
|
calendarLv.positionViewAtIndex(i, ListView.Top)
|
||||||
//console.log("moving down!")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//control.widgetData = control.widgetData
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//console.log("not current year")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,130 +218,6 @@ BRWidgetPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openComp(compIndex){
|
|
||||||
var cats = control.widgetData["competitions"][compIndex]["cats"]
|
|
||||||
|
|
||||||
cats.sort(function(a, b) {
|
|
||||||
return parseInt(a["GrpId"]) - parseInt(b["GrpId"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
var selectOptions = []
|
|
||||||
|
|
||||||
for(var prop in cats){
|
|
||||||
if (cats.hasOwnProperty(prop)) {
|
|
||||||
selectOptions.push({text: cats[prop]["name"], data:{cat: cats[prop]["GrpId"], comp: control.widgetData["competitions"][compIndex]["WetId"], status:cats[prop]["status"]}})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var infoUrls = getCompInfoUrls(compIndex)
|
|
||||||
var infosheet = "";
|
|
||||||
if(infoUrls.length >= 1)
|
|
||||||
infosheet += ("<a href='" + getCompInfoUrls(compIndex)[0] + "'>" + qsTr('infosheet') + "</a>")
|
|
||||||
if(infoUrls.length === 2)
|
|
||||||
infosheet += (", <a href='" + getCompInfoUrls(compIndex)[1] + "'>" + qsTr('further infos') + "</a>")
|
|
||||||
|
|
||||||
console.log("Infosheet: " + infosheet)
|
|
||||||
|
|
||||||
var eventWebsite = control.widgetData["competitions"][compIndex]["homepage"] !== undefined ? ("<a href='" + control.widgetData["competitions"][compIndex]["homepage"] + "'>" + qsTr('Event Website') + "</a>"):""
|
|
||||||
|
|
||||||
selector.appear(selectOptions, control.widgetData["competitions"][compIndex]['name'], eventWebsite + ((eventWebsite !== "" && infosheet !== "") ? ", ":"") + infosheet )
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeYear(){
|
|
||||||
var years = control.widgetData["years"]
|
|
||||||
|
|
||||||
var selectOptions = []
|
|
||||||
|
|
||||||
for(var prop in years){
|
|
||||||
if (years.hasOwnProperty(prop)) {
|
|
||||||
selectOptions.push({text: years[prop], data:{year: years[prop]}})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
selector.appear(selectOptions, qsTr("select year"))
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCup(state, data) {
|
|
||||||
var cups = control.widgetData["cups"]
|
|
||||||
|
|
||||||
var prop
|
|
||||||
var selectOptions = []
|
|
||||||
var selectTitle = ""
|
|
||||||
|
|
||||||
if(state === undefined){
|
|
||||||
// opened for the first time -> select cup
|
|
||||||
selectTitle = qsTr("select cup")
|
|
||||||
|
|
||||||
cups.sort(function(a, b) {
|
|
||||||
return parseInt(b["SerId"]) - parseInt(a["SerId"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
for(prop in cups){
|
|
||||||
if (cups.hasOwnProperty(prop)) {
|
|
||||||
selectOptions.push({text: cups[prop]["name"], data:{cup: cups[prop]["SerId"]}})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(state === 1){
|
|
||||||
// opened for the second time -> select cat
|
|
||||||
var cup
|
|
||||||
|
|
||||||
// find the selected cup
|
|
||||||
for(prop in cups){
|
|
||||||
if (cups.hasOwnProperty(prop) && cups[prop]['SerId'] === data.cup) {
|
|
||||||
cup = cups[prop]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cup === undefined){
|
|
||||||
// cup was not found
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
selectTitle = cup['name'] + ": " + qsTr("select category")
|
|
||||||
|
|
||||||
// build a list with all cat in the cup out of the cat keys (rkey) given in the cup.cats
|
|
||||||
for(prop in cup['cats']){
|
|
||||||
if (cup['cats'].hasOwnProperty(prop)) {
|
|
||||||
|
|
||||||
// search the rkey in the cat list
|
|
||||||
for(var i = 0; i < control.widgetData["cats"].length; i ++ ){
|
|
||||||
if(control.widgetData["cats"][i]["rkey"] === cup["cats"][prop] && control.widgetData["cats"][i]["sex"] !== undefined){
|
|
||||||
// found it -> append it to the select list
|
|
||||||
var catName = control.widgetData["cats"][i]["name"] // name of cat
|
|
||||||
var catId = control.widgetData["cats"][i]["GrpId"] // id of cat
|
|
||||||
selectOptions.push({text: catName, data:{cup: data.cup, cat: catId}})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
selector.appear(selectOptions, selectTitle)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCompInfoUrls(compIndex) {
|
|
||||||
|
|
||||||
var urls = [];
|
|
||||||
|
|
||||||
if(control.widgetData["competitions"][compIndex].hasOwnProperty("info")) {
|
|
||||||
if(params.nation === "GER")
|
|
||||||
urls.push("http://ranking.alpenverein.de/" + control.year + "/GER/" + control.widgetData["competitions"][compIndex]['rkey'] + ".pdf")
|
|
||||||
else
|
|
||||||
urls.push(control.widgetData["competitions"][compIndex]['info'])
|
|
||||||
}
|
|
||||||
|
|
||||||
if(control.widgetData["competitions"][compIndex].hasOwnProperty("info2")) {
|
|
||||||
if(params.nation === "GER")
|
|
||||||
urls.push("http://ranking.alpenverein.de/" + control.year + "/GER/i" + control.widgetData["competitions"][compIndex]['rkey'] + ".pdf")
|
|
||||||
else
|
|
||||||
urls.push(control.widgetData["competitions"][compIndex]['info2'])
|
|
||||||
}
|
|
||||||
|
|
||||||
return urls;
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterCats(display, cats) {
|
function filterCats(display, cats) {
|
||||||
//console.log("filtering cats: " + cats + " displaying: " + display)
|
//console.log("filtering cats: " + cats + " displaying: " + display)
|
||||||
for(var i = 0; i < cats.length; i ++){
|
for(var i = 0; i < cats.length; i ++){
|
||||||
|
@ -361,26 +286,6 @@ BRWidgetPage {
|
||||||
console.log(control.compFavorites)
|
console.log(control.compFavorites)
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: parent.selector
|
|
||||||
onSelectionFinished: {
|
|
||||||
if(data.comp !== undefined){
|
|
||||||
//console.log(data.status)
|
|
||||||
app.openWidget({comp: data.comp, cat: data.cat, type:data.status === 4 ? 'starters':''})
|
|
||||||
}
|
|
||||||
else if(data.year !== undefined){
|
|
||||||
updateData({year: data.year}, true)
|
|
||||||
control.year = data.year
|
|
||||||
}
|
|
||||||
else if(data.cup !== undefined && data.cat === undefined){
|
|
||||||
control.openCup(1,data)
|
|
||||||
}
|
|
||||||
else if(data.cup !== undefined && data.cat !== undefined){
|
|
||||||
app.openWidget({cup: data.cup, cat: data.cat})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
header: Item {
|
header: Item {
|
||||||
id: topSpacerItm
|
id: topSpacerItm
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -397,16 +302,16 @@ BRWidgetPage {
|
||||||
id: competitionDel
|
id: competitionDel
|
||||||
|
|
||||||
property bool over
|
property bool over
|
||||||
property var thisData: control.widgetData["competitions"][index]
|
property var thisData: modelData
|
||||||
|
|
||||||
property string name: thisData["name"]
|
property string name: thisData.name
|
||||||
property string date: thisData["date_span"]
|
property string date: thisData.dateSpan //"test" // TODO thisData["date_span"]
|
||||||
property var cats: thisData["cats"]
|
property var cats: thisData["cats"]
|
||||||
property int catId: thisData["cat_id"] === undefined ? 0:thisData["cat_id"]
|
property int catId: thisData["cat_id"] === undefined ? 0:thisData["cat_id"]
|
||||||
|
|
||||||
property bool thisIsFavored: control.compFavorites.indexOf(parseInt(thisData['WetId'])) >= 0
|
property bool thisIsFavored: true //control.compFavorites.indexOf(parseInt(thisData['WetId'])) >= 0
|
||||||
property bool includedByFavorites: control.displayedCompCats.indexOf(-1) >= 0 && thisIsFavored
|
property bool includedByFavorites: true //control.displayedCompCats.indexOf(-1) >= 0 && thisIsFavored
|
||||||
property bool includedByFilter: control.displayedCompCats.indexOf(parseInt(thisData['cat_id'])) >= 0
|
property bool includedByFilter: true//control.displayedCompCats.indexOf(parseInt(thisData['cat_id'])) >= 0
|
||||||
property bool thisIsVisible: includedByFavorites || includedByFilter
|
property bool thisIsVisible: includedByFavorites || includedByFilter
|
||||||
|
|
||||||
function updateVisibility() {
|
function updateVisibility() {
|
||||||
|
@ -418,7 +323,7 @@ BRWidgetPage {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: thisIsVisible ? compDelCol.height + 10 : 0
|
height: thisIsVisible ? compDelCol.height + 10 : 0
|
||||||
|
|
||||||
enabled: ((thisData["cats"] !== undefined && thisData["cats"].length > 0) || competitionDel.thisData["homepage"] !== undefined || getCompInfoUrls(index).length > 0) && height > 0
|
enabled: true//((thisData["cats"] !== undefined && thisData["cats"].length > 0) || competitionDel.thisData["homepage"] !== undefined || getCompInfoUrls(index).length > 0) && height > 0
|
||||||
//visible: includedByFilter
|
//visible: includedByFilter
|
||||||
|
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
@ -457,7 +362,7 @@ BRWidgetPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
control.openComp(index)
|
control.openCompetition(thisData)
|
||||||
}
|
}
|
||||||
|
|
||||||
ParallelAnimation {
|
ParallelAnimation {
|
||||||
|
@ -479,7 +384,7 @@ BRWidgetPage {
|
||||||
|
|
||||||
opacity: 0.5
|
opacity: 0.5
|
||||||
|
|
||||||
color: control.getCompCatData(catId) === undefined ? "white":control.getCompCatData(catId)["bgcolor"]
|
color: competitionDel.thisData.league.color
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
@ -570,6 +475,7 @@ BRWidgetPage {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: section
|
text: section
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: filterSelectPu
|
id: filterSelectPu
|
||||||
|
@ -580,7 +486,7 @@ BRWidgetPage {
|
||||||
signal selectionFinished(int index, var data)
|
signal selectionFinished(int index, var data)
|
||||||
|
|
||||||
x: 0 - control.anchors.leftMargin //root.width / 2 - width / 2
|
x: 0 - control.anchors.leftMargin //root.width / 2 - width / 2
|
||||||
y: root.height - filterSelectPu.height * 0.7//root.height - height //root.height / 2 - height / 2
|
y: control.height - filterSelectPu.height * 0.7//root.height - height //root.height / 2 - height / 2
|
||||||
|
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
||||||
|
@ -667,7 +573,7 @@ BRWidgetPage {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
implicitWidth: parent.width
|
implicitWidth: parent.width
|
||||||
implicitHeight: root.height * 0.7 < ( (delegateHeight + spacing) * model ) ? root.height * 0.7 : (delegateHeight + spacing) * model + 100
|
implicitHeight: control.height * 0.7 < ( (delegateHeight + spacing) * model ) ? root.height * 0.7 : (delegateHeight + spacing) * model + 100
|
||||||
|
|
||||||
model: filterSelectPu.dataObj !== undefined ? filterSelectPu.dataObj.length:0
|
model: filterSelectPu.dataObj !== undefined ? filterSelectPu.dataObj.length:0
|
||||||
|
|
||||||
|
@ -720,7 +626,7 @@ BRWidgetPage {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
control.filterCats(checked, filterSelectPu.dataObj[index].data.cat_id)
|
control.filterCats(checked, filterSelectPu.dataObj[index].data.cat_id)
|
||||||
if(control.displayedCompCats.length == 0){
|
if(control.displayedCompCats.length === 0){
|
||||||
control.filterCats(true, filterSelectPu.dataObj[index].data.cat_id)
|
control.filterCats(true, filterSelectPu.dataObj[index].data.cat_id)
|
||||||
checked = true
|
checked = true
|
||||||
}
|
}
|
||||||
|
@ -737,7 +643,7 @@ BRWidgetPage {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
property: "y"
|
property: "y"
|
||||||
//from: root.height - filterSelectPu.height * 0.7
|
//from: root.height - filterSelectPu.height * 0.7
|
||||||
to: root.height - filterSelectPu.height
|
to: control.height - filterSelectPu.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,9 +656,9 @@ BRWidgetPage {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
property: "y"
|
property: "y"
|
||||||
//from: root.height - filterSelectPu.height
|
//from: root.height - filterSelectPu.height
|
||||||
to: root.height - filterSelectPu.height * 0.7
|
to: control.height - filterSelectPu.height * 0.7
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,10 +61,7 @@ Page {
|
||||||
|
|
||||||
image: "qrc:/icons/ifsc.png"
|
image: "qrc:/icons/ifsc.png"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: app.openCalendar(BRWidget.IFSC)
|
||||||
app.openWidget({nation:"ICC"})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FancyButton {
|
FancyButton {
|
||||||
|
@ -75,10 +72,7 @@ Page {
|
||||||
|
|
||||||
image: "qrc:/icons/dav.png"
|
image: "qrc:/icons/dav.png"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: app.openCalendar(BRWidget.DAV)
|
||||||
app.openCalendar(BRWidget.DAV, 2020, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FancyButton {
|
FancyButton {
|
||||||
|
@ -89,10 +83,7 @@ Page {
|
||||||
|
|
||||||
image: "qrc:/icons/sac.png"
|
image: "qrc:/icons/sac.png"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: app.openCalendar(BRWidget.SAC)
|
||||||
app.openWidget({nation:"SUI"})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,174 +39,6 @@ Window {
|
||||||
|
|
||||||
property int errorCode: -1
|
property int errorCode: -1
|
||||||
|
|
||||||
// comp cats source:
|
|
||||||
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/icc_calendar.php
|
|
||||||
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/dav_calendar.php
|
|
||||||
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/sac_calendar.php
|
|
||||||
|
|
||||||
property var compCats: {
|
|
||||||
|
|
||||||
// --- ICC ---
|
|
||||||
|
|
||||||
/*'int' : {
|
|
||||||
'label' : 'International',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_^E]{1}[^YJ]{1,1}.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_(WC|TR){1,1}.*',
|
|
||||||
'rang_title': 'CUWR continuously updated WORLDRANKING',
|
|
||||||
'bgcolor' : '#B8C8FF',
|
|
||||||
'nat_team_ranking' : '',
|
|
||||||
'cat_id' : [68,86]//[68,69,70,86,259]
|
|
||||||
},*/
|
|
||||||
'worldcup': {
|
|
||||||
'label' : 'World Cups',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'bgcolor' : '#B8C8FF',
|
|
||||||
'sort_rank': 1,
|
|
||||||
'cat_id' : [69]
|
|
||||||
},
|
|
||||||
'youth' : {
|
|
||||||
'label' : 'Youth Events',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}(EYC|_J|_Y){1,1}.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_EYC',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#D8E8FF',
|
|
||||||
'sort_rank': 2,
|
|
||||||
'cat_id' : [71,258]
|
|
||||||
},
|
|
||||||
'cont': {
|
|
||||||
'label' : 'Continental Events',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'bgcolor' : '#B8C8FF',
|
|
||||||
'sort_rank': 3,
|
|
||||||
'cat_id' : [262]
|
|
||||||
},
|
|
||||||
'masters' : {
|
|
||||||
'label' : 'Masters and Promo Events',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_[^PWERASL]{1}.*',
|
|
||||||
// 'serie_reg' : '^[0-9]{2,2}_(WC|TR){1,1}.*',
|
|
||||||
// 'rang_title': 'CUWR continuously updated WORLDRANKING',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 4,
|
|
||||||
'cat_id' : [70]
|
|
||||||
},
|
|
||||||
'para' : {
|
|
||||||
'label' : 'Paraclimbing Events',
|
|
||||||
'nation' : 'ICC',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_PE.*',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 5,
|
|
||||||
'cat_id' : [256,259]
|
|
||||||
},
|
|
||||||
'games': {
|
|
||||||
'label': 'Games',
|
|
||||||
'nation': 'ICC',
|
|
||||||
'bgcolor' : '#B8C8FF',
|
|
||||||
'sort_rank': 6,
|
|
||||||
'cat_id': [68,86]
|
|
||||||
},
|
|
||||||
|
|
||||||
// --- GER ---
|
|
||||||
|
|
||||||
/*'ger_boulder' : {
|
|
||||||
'label' : 'Bouldern',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_B+.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_BC',
|
|
||||||
'bgcolor' : '#FFDBA8', //'#f59d30'
|
|
||||||
'cat_id' : [59]
|
|
||||||
},
|
|
||||||
'ger' : {
|
|
||||||
'label' : 'Lead',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_J]{1,1}[^WLJ]+.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_DC',
|
|
||||||
'bgcolor' : '#A8F0A8', //'#69b9a9'
|
|
||||||
'cat_id' : [57]
|
|
||||||
},
|
|
||||||
'ger_speed' : {
|
|
||||||
'label' : 'Speed',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_J]{1,1}[^WLJ]+.*',
|
|
||||||
'serie_reg' : '',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#A8F0A8', //'#e72e5d'
|
|
||||||
'cat_id' : [60]
|
|
||||||
},*/
|
|
||||||
|
|
||||||
'ger_meisterschaft' : {
|
|
||||||
'label' : 'Deutsche Meisterschaft',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'bgcolor' : '#A8F0A8',
|
|
||||||
'sort_rank': 1,
|
|
||||||
'cat_id' : [57, 59, 60]
|
|
||||||
},
|
|
||||||
|
|
||||||
'ger_jugend' : {
|
|
||||||
'label' : 'Deutscher Jugendcup',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_J]{1,1}[^WL]+.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}_JC',
|
|
||||||
// 'rang_title': 'Deutsche Jugend RANGLISTE',
|
|
||||||
'bgcolor' : '#D8FFD8',
|
|
||||||
'sort_rank': 2,
|
|
||||||
'cat_id' : [58]
|
|
||||||
},
|
|
||||||
'ger_state' : {
|
|
||||||
'label' : 'Landesmeisterschaft',
|
|
||||||
'nation' : 'GER',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}[_J]{1,1}LM.*',
|
|
||||||
'serie_reg' : '^[0-9]{2,2}[_J]{1,1}LM.*',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 3,
|
|
||||||
'cat_id' : [61,56]
|
|
||||||
},
|
|
||||||
|
|
||||||
// --- SUI ---
|
|
||||||
|
|
||||||
'sui' : {
|
|
||||||
'label' : 'Erwachsene',
|
|
||||||
'nation' : 'SUI',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_[^R].*',
|
|
||||||
'serie_reg' : '.*',
|
|
||||||
'rang_title': 'SWISS RANKING',
|
|
||||||
'bgcolor' : '#A8F0A8',
|
|
||||||
'sort_rank': 1,
|
|
||||||
'cat_id' : [62,63]
|
|
||||||
},
|
|
||||||
'sui_jugend' : {
|
|
||||||
'label' : 'Jugend',
|
|
||||||
'nation' : 'SUI',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_[^R].*',
|
|
||||||
'serie_reg' : '.*',
|
|
||||||
'rang_title': 'SWISS RANKING',
|
|
||||||
'bgcolor' : '#D8FFD8',
|
|
||||||
'sort_rank': 2,
|
|
||||||
'cat_id' : [65]
|
|
||||||
},
|
|
||||||
'sui_local' : {
|
|
||||||
'label' : 'RegioCups',
|
|
||||||
'nation' : 'SUI',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_RG_.*',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 3,
|
|
||||||
'cat_id' : [64]
|
|
||||||
},
|
|
||||||
'sui_ice' : {
|
|
||||||
'label' : 'Iceclimbing',
|
|
||||||
'nation' : 'SUI',
|
|
||||||
'wettk_reg' : '^[0-9]{2,2}_RC_.*',
|
|
||||||
'rang_title': '',
|
|
||||||
'bgcolor' : '#F0F0F0',
|
|
||||||
'sort_rank': 4,
|
|
||||||
'cat_id' : [84]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -613,13 +445,13 @@ Window {
|
||||||
loadingDl.close()
|
loadingDl.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
function openCalendar(federation, year, season) {
|
function openCalendar(federation) {
|
||||||
loadingDl.open()
|
loadingDl.open()
|
||||||
var newPageComp = Qt.createComponent("qrc:/Pages/CalendarPage.qml").createObject(null, {"data": brController.getCalendar(BRWidget.DAV, year, season)})
|
var newPageComp = Qt.createComponent("qrc:/Pages/CalendarPage.qml").createObject(null, {"data": brController.getCalendar(federation)})
|
||||||
|
|
||||||
app.errorCode = newPageComp.status
|
app.errorCode = newPageComp.status
|
||||||
|
|
||||||
if(calComp.ready){
|
if(newPageComp.ready){
|
||||||
mainStack.push(newPageComp)
|
mainStack.push(newPageComp)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1,32 +1,40 @@
|
||||||
#include "../headers/brcalendar.h"
|
#include "../headers/brcalendar.h"
|
||||||
#include "headers/brprovider.h"
|
#include "headers/brprovider.h"
|
||||||
|
|
||||||
BRCalendar::BRCalendar(BRProvider* provider, BRFederation federation, int year, int league) : BRWidget(provider, federation)
|
BRCalendar::BRCalendar(BRProvider* provider, BRFederation federation) : BRWidget(provider, federation)
|
||||||
{
|
{
|
||||||
this->year = year;
|
this->currentSeason = nullptr;
|
||||||
this->league = league;
|
this->seasons = {};
|
||||||
|
|
||||||
|
connect(this, &BRCalendar::currentSeasonChanged, this, &BRCalendar::titleChanged);
|
||||||
|
connect(this, &BRCalendar::seasonsChanged, this, &BRCalendar::titleChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRCalendar::getTitle() {
|
||||||
|
QString title = QStringList({"IFSC", "DAV", "SAC"})[this->getFederation()] + " " + tr("calendar");
|
||||||
|
|
||||||
|
if(this->currentSeason != nullptr)
|
||||||
|
title += " " + this->currentSeason->getName();
|
||||||
|
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRCalendar::getSeasonsQML() {
|
||||||
|
return this->listToQmlList(this->seasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BRCalendar::getYear() {
|
BRSeason* BRCalendar::getCurrentSeason() {
|
||||||
return this->year;
|
return this->currentSeason;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BRCalendar::getLeague() {
|
void BRCalendar::setCurrentSeason(BRSeason* season) {
|
||||||
return this->league;
|
if(!this->seasons.contains(season))
|
||||||
}
|
return;
|
||||||
|
|
||||||
QList<BRCompetition*> BRCalendar::getCompetitions() {
|
this->currentSeason = season;
|
||||||
return this->competitions;
|
this->currentSeason->load();
|
||||||
}
|
emit this->currentSeasonChanged();
|
||||||
|
|
||||||
QList<QObject*> BRCalendar::getCompetitionsQML() {
|
|
||||||
QList<QObject*> tmpCompetitions;
|
|
||||||
|
|
||||||
for(BRCompetition* competition : this->competitions)
|
|
||||||
tmpCompetitions.append(competition);
|
|
||||||
|
|
||||||
return tmpCompetitions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode BRCalendar::load() {
|
BRWidget::BRWidgetStatusCode BRCalendar::load() {
|
||||||
|
@ -34,11 +42,29 @@ BRWidget::BRWidgetStatusCode BRCalendar::load() {
|
||||||
return BRWidget::NoProviderError;
|
return BRWidget::NoProviderError;
|
||||||
|
|
||||||
// reload all comp data using our providers
|
// reload all comp data using our providers
|
||||||
this->competitions.clear();
|
|
||||||
this->categories.clear();
|
|
||||||
this->cups.clear();
|
|
||||||
|
|
||||||
// TODO: handle changes dynamically
|
BRCalendarData newData {
|
||||||
|
this,
|
||||||
|
this->currentSeason,
|
||||||
|
this->seasons
|
||||||
|
};
|
||||||
|
|
||||||
return this->getProvider()->loadCalendarData(this);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return statusCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
#include "../headers/brcategory.h"
|
#include "../headers/brcategory.h"
|
||||||
|
|
||||||
BRCategory::BRCategory(QObject *parent) : QObject(parent)
|
BRCategory::BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData) : BRWidget(provider, federation), id(id)
|
||||||
{
|
{
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRCategory::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCategory::setData(BRCategoryData data) {
|
||||||
|
this->name = data.name;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRCategory::load() {
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,79 @@
|
||||||
#include "../headers/brcompetition.h"
|
#include "headers/brcompetition.h"
|
||||||
|
#include "headers/brleague.h"
|
||||||
|
|
||||||
BRCompetition::BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id) : BRWidget(provider, federation)
|
BRCompetition::BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCompetitionData initialData) : BRWidget(provider, federation), id(id) {
|
||||||
{
|
this->setData(initialData);
|
||||||
this->id = id;
|
}
|
||||||
|
|
||||||
|
void BRCompetition::setLeague(BRLeague* league) {
|
||||||
|
if(league == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->league = league;
|
||||||
|
emit this->metadataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BRCompetition::getName() {
|
QString BRCompetition::getName() {
|
||||||
return this->name;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode BRCompetition::load() {
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -3,9 +3,13 @@
|
||||||
BRController::BRController(QObject *parent) : QObject(parent)
|
BRController::BRController(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
this->providerDr = new BRProviderDr(this);
|
this->providerDr = new BRProviderDr(this);
|
||||||
|
this->providerVl = new BRProviderVl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRCalendar* BRController::getCalendar(BRWidget::BRFederation federation, int year, int league) {
|
BRCalendar* BRController::getCalendar(BRWidget::BRFederation federation) {
|
||||||
return this->providerDr->getCalendar(federation, year, -1);
|
if(federation == BRWidget::IFSC)
|
||||||
|
return this->providerVl->getCalendar(federation);
|
||||||
|
else
|
||||||
|
return this->providerDr->getCalendar(federation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,31 @@
|
||||||
#include "../headers/brcup.h"
|
#include "../headers/brcup.h"
|
||||||
|
|
||||||
BRCup::BRCup(BRProvider* provider, BRFederation federation) : BRWidget(provider, federation)
|
BRCup::BRCup(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCupData initialData) : BRWidget(provider, federation), id(id)
|
||||||
{
|
{
|
||||||
|
this->categories = {};
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRCup::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRCup::getCategoriesQML() {
|
||||||
|
return this->listToQmlList(this->categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRCup::setData(BRCupData data) {
|
||||||
|
this->name = data.name;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->categories != data.categories) {
|
||||||
|
this->categories.clear();
|
||||||
|
this->categories = data.categories;
|
||||||
|
emit this->categoriesChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRCup::load() {
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
83
sources/brleague.cpp
Normal file
83
sources/brleague.cpp
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
#include "headers/brleague.h"
|
||||||
|
#include "headers/brprovider.h"
|
||||||
|
|
||||||
|
BRLeague::BRLeague(BRProvider* provider, BRWidget::BRFederation federation, int id, BRLeagueData initialData) : BRWidget(provider, federation), id(id)
|
||||||
|
{
|
||||||
|
this->competitions = {};
|
||||||
|
this->competitions = {};
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRLeague::getId() const {
|
||||||
|
return this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRLeague::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor BRLeague::getColor() {
|
||||||
|
return this->color;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRCompetition*> BRLeague::getCompetitions() {
|
||||||
|
return this->competitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRLeague::getCompetitionsQML() {
|
||||||
|
return this->listToQmlList(this->competitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRLeague::getCupsQML() {
|
||||||
|
return this->listToQmlList(this->cups);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRLeague::setData(BRLeagueData data) {
|
||||||
|
|
||||||
|
this->name = data.name;
|
||||||
|
this->color = data.color;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->competitions != data.competitions) {
|
||||||
|
this->competitions.clear();
|
||||||
|
this->competitions = data.competitions;
|
||||||
|
|
||||||
|
for(BRCompetition* competition : this->competitions)
|
||||||
|
competition->setLeague(this);
|
||||||
|
|
||||||
|
emit this->competitionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->cups != data.cups) {
|
||||||
|
this->cups.clear();
|
||||||
|
this->cups = data.cups;
|
||||||
|
emit this->cupsChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRLeague::load() {
|
||||||
|
if(this->getProvider() == nullptr)
|
||||||
|
return BRWidget::NoProviderError;
|
||||||
|
|
||||||
|
// reload all comp data using our providers
|
||||||
|
|
||||||
|
BRLeagueData newData {
|
||||||
|
this,
|
||||||
|
this->name,
|
||||||
|
this->color,
|
||||||
|
this->competitions,
|
||||||
|
this->cups
|
||||||
|
};
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
|
||||||
|
|
||||||
|
if(statusCode != BRWidget::Success)
|
||||||
|
return statusCode;
|
||||||
|
|
||||||
|
qDebug() << "new Data: " << newData.competitions;
|
||||||
|
|
||||||
|
this->setData(newData);
|
||||||
|
|
||||||
|
return statusCode;
|
||||||
|
}
|
|
@ -5,11 +5,32 @@ BRProvider::BRProvider(QObject *parent) : QObject(parent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BRCalendar* BRProvider::getCalendar(BRWidget::BRFederation federation, int year, int league) {
|
BRCalendar* BRProvider::getCalendar(BRWidget::BRFederation federation) {
|
||||||
return new BRCalendar(this, federation, year, league);
|
return new BRCalendar(this, federation);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap BRProvider::serverRequest(QUrl serviceUrl, QUrlQuery pdata)
|
BRSeason* BRProvider::getSeason(BRWidget::BRFederation federation, int id, BRSeason::BRSeasonData initialData) {
|
||||||
|
return new BRSeason(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRLeague* BRProvider::getLeague(BRWidget::BRFederation federation, int id, BRLeague::BRLeagueData initialData) {
|
||||||
|
return new BRLeague(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCompetition* BRProvider::getCompetition(BRWidget::BRFederation federation, int id, BRCompetition::BRCompetitionData initialData) {
|
||||||
|
return new BRCompetition(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRCup* BRProvider::getCup(BRWidget::BRFederation federation, int id, BRCup::BRCupData initialData) {
|
||||||
|
return new BRCup(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory* BRProvider::getCategory(BRWidget::BRFederation federation, int id, BRCategory::BRCategoryData initialData) {
|
||||||
|
return new BRCategory(this, federation, id, initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap BRProvider::serverRequest(QUrl serviceUrl, QList<QStringList> additionalHeaders, QUrlQuery postData)
|
||||||
{
|
{
|
||||||
qDebug() << "requesting: " << serviceUrl;
|
qDebug() << "requesting: " << serviceUrl;
|
||||||
|
|
||||||
|
@ -20,8 +41,13 @@ QVariantMap BRProvider::serverRequest(QUrl serviceUrl, QUrlQuery pdata)
|
||||||
|
|
||||||
// Create network request
|
// Create network request
|
||||||
QNetworkRequest request(serviceUrl);
|
QNetworkRequest request(serviceUrl);
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader,
|
|
||||||
"application/x-www-form-urlencoded");
|
// insert additional headers
|
||||||
|
for(QStringList additionalHeader : additionalHeaders) {
|
||||||
|
if(additionalHeader.length() == 2)
|
||||||
|
request.setRawHeader(additionalHeader[0].toUtf8(), additionalHeader[1].toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//QSslConfiguration config = QSslConfiguration::defaultConfiguration();
|
//QSslConfiguration config = QSslConfiguration::defaultConfiguration();
|
||||||
//config.setProtocol(QSsl::TlsV1_2);
|
//config.setProtocol(QSsl::TlsV1_2);
|
||||||
|
@ -31,13 +57,13 @@ QVariantMap BRProvider::serverRequest(QUrl serviceUrl, QUrlQuery pdata)
|
||||||
|
|
||||||
QNetworkReply *reply;
|
QNetworkReply *reply;
|
||||||
|
|
||||||
if(pdata.isEmpty()){
|
if(postData.isEmpty()){
|
||||||
// if no post data is given -> send a GET request
|
// if no post data is given -> send a GET request
|
||||||
reply = networkManager->get(request);
|
reply = networkManager->get(request);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// if post data is given -> send POST request
|
// if post data is given -> send POST request
|
||||||
reply = networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8());
|
reply = networkManager->post(request, postData.toString(QUrl::FullyEncoded).toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop to wait until the request has finished before processing the data
|
// loop to wait until the request has finished before processing the data
|
||||||
|
@ -58,6 +84,8 @@ QVariantMap BRProvider::serverRequest(QUrl serviceUrl, QUrlQuery pdata)
|
||||||
//get the status code
|
//get the status code
|
||||||
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
||||||
|
|
||||||
|
qDebug() << "Finished: " << status_code;
|
||||||
|
|
||||||
ret.insert("status", status_code.toInt());
|
ret.insert("status", status_code.toInt());
|
||||||
|
|
||||||
//get the full text response
|
//get the full text response
|
||||||
|
|
|
@ -2,14 +2,71 @@
|
||||||
|
|
||||||
BRProviderDr::BRProviderDr(QObject *parent) : BRProvider(parent)
|
BRProviderDr::BRProviderDr(QObject *parent) : BRProvider(parent)
|
||||||
{
|
{
|
||||||
|
// leagues source:
|
||||||
|
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/dav_calendar.php
|
||||||
|
// - https://github.com/ralfbecker/ranking/blob/master/sitemgr/digitalrock/sac_calendar.php
|
||||||
|
|
||||||
|
this->leagues.insert(
|
||||||
|
BRWidget::DAV,
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{"id", 0},
|
||||||
|
{"name", "Deutsche Meisterschaft"},
|
||||||
|
{"color", "#A8F0A8"},
|
||||||
|
{"leagueIDs", QVariantList({59, 57, 60})}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{"id", 1},
|
||||||
|
{"name", "Deutscher Jugendcup"},
|
||||||
|
{"color", "#D8FFD8"},
|
||||||
|
{"leagueIDs", QVariantList({58})}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{"id", 2},
|
||||||
|
{"name", "Landesmeisterschaft"},
|
||||||
|
{"color", "#F0F0F0"},
|
||||||
|
{"leagueIDs", QVariantList({61, 56})}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this->leagues.insert(
|
||||||
|
BRWidget::SAC,
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{"id", 0},
|
||||||
|
{"name", "Erwachsene"},
|
||||||
|
{"color", "#A8F0A8"},
|
||||||
|
{"leagueIDs", QVariantList({57, 59, 60})}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{"id", 1},
|
||||||
|
{"name", "Jugend"},
|
||||||
|
{"color", "#D8FFD8"},
|
||||||
|
{"leagueIDs", QVariantList({65})}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{"id", 2},
|
||||||
|
{"name", "RegioCups"},
|
||||||
|
{"color", "#F0F0F0"},
|
||||||
|
{"leagueIDs", QVariantList({64})}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{"id", 3},
|
||||||
|
{"name", "Iceclimbing"},
|
||||||
|
{"color", "#F0F0F0"},
|
||||||
|
{"leagueIDs", QVariantList({84})}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode BRProviderDr::loadCalendarData(BRCalendar* calendar)
|
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCalendar::BRCalendarData* calendarData)
|
||||||
{
|
{
|
||||||
// load some data
|
// load some data
|
||||||
QString nationStr = calendar->getFederation() == BRWidget::SAC ? "SUI":"GER";
|
QString nationStr = calendarData->calendar->getFederation() == BRWidget::SAC ? "SUI":"GER";
|
||||||
QVariantMap ret = this->serverRequest(QUrl("https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr));
|
qDebug() << "Nation str: " << nationStr << " federation: " << calendarData->calendar->getFederation();
|
||||||
|
int year = QDate::currentDate().year();
|
||||||
|
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr + "&year=" + QString::number(year);
|
||||||
|
QVariantMap ret = this->serverRequest(QUrl(requestUrl));
|
||||||
|
|
||||||
if(ret["status"] != 200){
|
if(ret["status"] != 200){
|
||||||
// request was a failure
|
// request was a failure
|
||||||
|
@ -17,28 +74,138 @@ BRWidget::BRWidgetStatusCode BRProviderDr::loadCalendarData(BRCalendar* calendar
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
data.insert("year", year);
|
||||||
|
data.insert("federation", calendarData->calendar->getFederation());
|
||||||
|
|
||||||
// parse competitions
|
// create seasons
|
||||||
QVariantList competitions = data["competitions"].toList();
|
QVariantList seasons = data["years"].toList();
|
||||||
QList<BRCompetition*> tmpCompetitions;
|
|
||||||
|
|
||||||
for(QVariant competitionVar : competitions) {
|
for(QVariant seasonVar : seasons) {
|
||||||
BRCompetition* competition = new BRCompetition(this, calendar->getFederation(), competitionVar.toMap()["WetId"].toInt());
|
int seasonId = seasonVar.toString().toInt();
|
||||||
this->loadCompetitionData(competition, competitionVar.toMap());
|
BRSeason* season = this->getSeason(
|
||||||
tmpCompetitions.append(competition);
|
calendarData->calendar->getFederation(),
|
||||||
|
seasonId,
|
||||||
|
this->parseSeasonData(seasonId, data)
|
||||||
|
);
|
||||||
|
|
||||||
|
calendarData->seasons.append(season);
|
||||||
|
|
||||||
|
if(seasonId == year)
|
||||||
|
calendarData->currentSeason = season;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(calendar->competitions != tmpCompetitions)
|
|
||||||
calendar->competitions = tmpCompetitions;
|
|
||||||
|
|
||||||
return BRWidget::Success;
|
return BRWidget::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode BRProviderDr::loadCompetitionData(BRCompetition* competition, QVariantMap data) {
|
|
||||||
|
|
||||||
// load basic properties
|
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRSeason::BRSeasonData* seasonData) {
|
||||||
competition->name = data["name"].toString();
|
if(seasonData->season->getLeagues().length() > 0) {
|
||||||
|
// leagues are already loaded
|
||||||
|
|
||||||
|
// load some data
|
||||||
|
QString nationStr = seasonData->season->getFederation() == BRWidget::SAC ? "SUI":"GER";
|
||||||
|
qDebug() << "Nation str: " << nationStr << " federation: " << seasonData->season->getFederation();
|
||||||
|
int year = seasonData->season->getYear();
|
||||||
|
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?nation=" + nationStr + "&year=" + QString::number(year);
|
||||||
|
QVariantMap ret = this->serverRequest(QUrl(requestUrl));
|
||||||
|
|
||||||
|
if(ret["status"] != 200){
|
||||||
|
// request was a failure
|
||||||
|
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
data.insert("year", year);
|
||||||
|
data.insert("federation", seasonData->season->getFederation());
|
||||||
|
|
||||||
|
// populate season
|
||||||
|
QVariantList seasons = data["years"].toList();
|
||||||
|
|
||||||
|
this->parseSeasonData(seasonData, year, data);
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// should never happen
|
||||||
|
return BRWidget::NotImplementedError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRSeason::BRSeasonData BRProviderDr::parseSeasonData(int id, QVariantMap rawData) {
|
||||||
|
BRSeason::BRSeasonData data;
|
||||||
|
this->parseSeasonData(&data, id, rawData);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRProviderDr::parseSeasonData(BRSeason::BRSeasonData* seasonData, int id, QVariantMap rawData) {
|
||||||
|
seasonData->year = id;
|
||||||
|
seasonData->nativeMultiLeagueSupport = true;
|
||||||
|
seasonData->name = QString::number(id);
|
||||||
|
|
||||||
|
BRWidget::BRFederation federation = BRWidget::BRFederation(rawData["federation"].toInt(0));
|
||||||
|
|
||||||
|
// insert the leagues
|
||||||
|
for(QVariantMap leagueVar : this->leagues[federation]) {
|
||||||
|
BRLeague* league = this->getLeague(federation, leagueVar["id"].toInt(), this->parseLeagueData(leagueVar, rawData));
|
||||||
|
seasonData->leagues.append(league);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRLeague::BRLeagueData* leagueData) {
|
||||||
|
Q_UNUSED(leagueData)
|
||||||
|
return BRWidget::NotImplementedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRLeague::BRLeagueData BRProviderDr::parseLeagueData(QVariantMap leagueProperties, QVariantMap rawData) {
|
||||||
|
|
||||||
|
BRLeague::BRLeagueData data;
|
||||||
|
|
||||||
|
BRWidget::BRFederation federation = BRWidget::BRFederation(rawData["federation"].toInt(0));
|
||||||
|
|
||||||
|
data.name = leagueProperties["name"].toString();
|
||||||
|
data.color = QColor(leagueProperties["color"].toString());
|
||||||
|
|
||||||
|
qDebug() << "Adding league: " << data.name;
|
||||||
|
|
||||||
|
// parse competitions
|
||||||
|
QVariantList competitionsVar = rawData["competitions"].toList();
|
||||||
|
|
||||||
|
// TODO: make more efficient
|
||||||
|
|
||||||
|
for(QVariant competitionVar : competitionsVar) {
|
||||||
|
QVariantMap competitionMap = competitionVar.toMap();
|
||||||
|
|
||||||
|
// check if this competition is part of this league
|
||||||
|
if(leagueProperties["leagueIDs"].toList().contains(competitionMap["cat_id"].toInt())) {
|
||||||
|
BRCompetition* competition = this->getCompetition(federation, competitionVar.toMap()["WetId"].toInt(), this->parseCompetitionData(competitionMap, federation));
|
||||||
|
data.competitions.append(competition);
|
||||||
|
qDebug() << "- Adding competition: " << competition->getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if this is league with id 0
|
||||||
|
if(leagueProperties["id"].toInt() == 0) {
|
||||||
|
// parse cups
|
||||||
|
QVariantList cupsVar = rawData["cups"].toList();
|
||||||
|
|
||||||
|
for(QVariant cupVar : cupsVar) {
|
||||||
|
QVariantMap cupMap = cupVar.toMap();
|
||||||
|
BRCup* cup = this->getCup(federation, cupMap["SerId"].toInt(), this->parseCupData(rawData["cats"].toList(), cupMap, federation));
|
||||||
|
data.cups.append(cup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCompetition::BRCompetitionData* competitionData) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCompetition::BRCompetitionData BRProviderDr::parseCompetitionData(QVariantMap rawData, BRWidget::BRFederation federation) {
|
||||||
|
|
||||||
QMap<QString, BRCompetition::BRDiscipline> disciplineTranslations = {
|
QMap<QString, BRCompetition::BRDiscipline> disciplineTranslations = {
|
||||||
{"boulder", BRCompetition::Boulder},
|
{"boulder", BRCompetition::Boulder},
|
||||||
|
@ -46,14 +213,69 @@ BRWidget::BRWidgetStatusCode BRProviderDr::loadCompetitionData(BRCompetition* co
|
||||||
{"speed", BRCompetition::Speed}
|
{"speed", BRCompetition::Speed}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(disciplineTranslations.contains(data["discipline"].toString()))
|
BRCompetition::BRCompetitionData data;
|
||||||
competition->discipline = disciplineTranslations[data["discipline"].toString()];
|
|
||||||
|
|
||||||
competition->startDate = QDate::fromString(data["date"].toString());
|
data.name = rawData["name"].toString();
|
||||||
competition->endDate = QDate::fromString(data["date_end"].toString());
|
|
||||||
|
|
||||||
// TODO load categories
|
if(disciplineTranslations.contains(rawData["discipline"].toString()))
|
||||||
//competition->categories.clear();
|
data.discipline = disciplineTranslations[rawData["discipline"].toString()];
|
||||||
|
|
||||||
|
data.startDate = QDate::fromString(rawData["date"].toString(), "yyyy-MM-dd");
|
||||||
|
data.endDate = QDate::fromString(rawData["date_end"].toString(), "yyyy-MM-dd");
|
||||||
|
|
||||||
|
data.eventWebsiteUrl = rawData["homepage"].toString();
|
||||||
|
|
||||||
|
for(int i = 0; i < 2; i++) {
|
||||||
|
QString infosheetName = QStringList({"info", "info2"})[i];
|
||||||
|
if(rawData.contains(infosheetName)) {
|
||||||
|
QString url = rawData[infosheetName].toString();
|
||||||
|
|
||||||
|
if(federation == BRWidget::DAV)
|
||||||
|
url = "http://ranking.alpenverein.de/" + QString::number(data.startDate.year()) + "/GER/" + rawData["rkey"].toString() + ".pdf";
|
||||||
|
|
||||||
|
data.infosheetUrls.append(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantList categoriesList = rawData["cats"].toList();
|
||||||
|
for(QVariant categoryVar : categoriesList) {
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
BRCategory* category = this->getCategory(federation, rawData["GrpId"].toInt(), this->parseCategoryData(categoryMap));
|
||||||
|
data.categories.append(category);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO load results
|
// TODO load results
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRCup::BRCupData BRProviderDr::parseCupData(QVariantList categoriesList, QVariantMap rawData, BRWidget::BRFederation federation) {
|
||||||
|
BRCup::BRCupData data;
|
||||||
|
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
|
||||||
|
// parse categories
|
||||||
|
for(QVariant categoryName : rawData["cats"].toList()) {
|
||||||
|
// find category name in cats:
|
||||||
|
|
||||||
|
for(QVariant categoryVar : categoriesList) {
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
if(categoryMap["rkey"].toString() == categoryName.toString()) {
|
||||||
|
|
||||||
|
BRCategory* category = this->getCategory(federation, rawData["GrpId"].toInt(), this->parseCategoryData(categoryMap));
|
||||||
|
data.categories.append(category);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData BRProviderDr::parseCategoryData(QVariantMap rawData) {
|
||||||
|
// TODO: status
|
||||||
|
// TODO: sex
|
||||||
|
BRCategory::BRCategoryData data;
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
199
sources/brprovidervl.cpp
Normal file
199
sources/brprovidervl.cpp
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
#include "headers/brprovidervl.h"
|
||||||
|
|
||||||
|
BRProviderVl::BRProviderVl(QObject *parent) : BRProvider(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRCalendar::BRCalendarData* calendarData)
|
||||||
|
{
|
||||||
|
// load some data
|
||||||
|
QString requestUrl = "https://ifsc.results.info/api/v1/";
|
||||||
|
QVariantMap ret = this->serverRequest(QUrl(requestUrl), {{"x-auth-token", "cc7375f680648e7e6171e035e70351eb"}});
|
||||||
|
|
||||||
|
if(ret["status"] != 200){
|
||||||
|
// request was a failure
|
||||||
|
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
|
||||||
|
// create seasons
|
||||||
|
QVariantList seasons = data["seasons"].toList();
|
||||||
|
|
||||||
|
for(QVariant seasonVar : seasons) {
|
||||||
|
QVariantMap seasonMap = seasonVar.toMap();
|
||||||
|
int seasonId = seasonMap["name"].toInt();
|
||||||
|
BRSeason* season = this->getSeason(
|
||||||
|
calendarData->calendar->getFederation(),
|
||||||
|
seasonId,
|
||||||
|
this->parseSeasonData(seasonMap)
|
||||||
|
);
|
||||||
|
|
||||||
|
calendarData->seasons.append(season);
|
||||||
|
qDebug() << "Inserted season:" << season->getName();
|
||||||
|
|
||||||
|
if(seasonId == data["current"].toMap()["season"].toInt())
|
||||||
|
calendarData->currentSeason = season;
|
||||||
|
}
|
||||||
|
|
||||||
|
// load default league of current season
|
||||||
|
calendarData->currentSeason->getLeagues()[0]->load();
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRSeason::BRSeasonData* seasonData) {
|
||||||
|
if(seasonData->season->getLeagues().length() > 0) {
|
||||||
|
// leagues are already loaded
|
||||||
|
|
||||||
|
// load default league
|
||||||
|
seasonData->season->getLeagues()[0]->load();
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// should never happen
|
||||||
|
return BRWidget::NotImplementedError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRSeason::BRSeasonData BRProviderVl::parseSeasonData(QVariantMap rawData) {
|
||||||
|
BRSeason::BRSeasonData data;
|
||||||
|
data.year = rawData["name"].toInt();
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
data.nativeMultiLeagueSupport = false;
|
||||||
|
|
||||||
|
// insert the leagues
|
||||||
|
for(QVariant leagueVar : rawData["leagues"].toList()) {
|
||||||
|
QVariantMap leagueMap = leagueVar.toMap();
|
||||||
|
|
||||||
|
BRLeague::BRLeagueData leagueData;
|
||||||
|
leagueData.name = leagueMap["name"].toString();
|
||||||
|
int leagueId = leagueMap["url"].toString().split("/").last().toInt();
|
||||||
|
|
||||||
|
BRLeague* league = this->getLeague(BRWidget::IFSC, leagueId, leagueData);
|
||||||
|
data.leagues.append(league);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRLeague::BRLeagueData* leagueData) {
|
||||||
|
// load some data
|
||||||
|
QString requestUrl = "https://ifsc.results.info/api/v1/season_leagues/" + QString::number(leagueData->league->getId());
|
||||||
|
QVariantMap ret = this->serverRequest(QUrl(requestUrl), {{"x-auth-token", "cc7375f680648e7e6171e035e70351eb"}});
|
||||||
|
|
||||||
|
if(ret["status"] != 200){
|
||||||
|
// request was a failure
|
||||||
|
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
|
||||||
|
this->parseLeagueData(leagueData, data);
|
||||||
|
|
||||||
|
return BRWidget::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRProviderVl::parseLeagueData(BRLeague::BRLeagueData* data, QVariantMap rawData) {
|
||||||
|
|
||||||
|
BRWidget::BRFederation federation = BRWidget::BRFederation(rawData["federation"].toInt(0));
|
||||||
|
|
||||||
|
data->name = rawData["league"].toString();
|
||||||
|
data->color = QColor("#ffffff"); // TODO
|
||||||
|
|
||||||
|
qDebug() << "Adding league: " << data->name;
|
||||||
|
|
||||||
|
// parse competitions
|
||||||
|
QVariantList competitionsVar = rawData["events"].toList();
|
||||||
|
|
||||||
|
for(QVariant competitionVar : competitionsVar) {
|
||||||
|
QVariantMap competitionMap = competitionVar.toMap();
|
||||||
|
|
||||||
|
BRCompetition* competition = this->getCompetition(federation, competitionVar.toMap()["event_id"].toInt(), this->parseCompetitionData(competitionMap, federation));
|
||||||
|
data->competitions.append(competition);
|
||||||
|
qDebug() << "- Adding competition: " << competition->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse cups
|
||||||
|
QVariantList cupsVar = rawData["cups"].toList();
|
||||||
|
|
||||||
|
for(QVariant cupVar : cupsVar) {
|
||||||
|
QVariantMap cupMap = cupVar.toMap();
|
||||||
|
BRCup* cup = this->getCup(federation, cupMap["cup_id"].toInt(), this->parseCupData(cupMap));
|
||||||
|
data->cups.append(cup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRCompetition::BRCompetitionData* competitionData) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCompetition::BRCompetitionData BRProviderVl::parseCompetitionData(QVariantMap rawData, BRWidget::BRFederation federation) {
|
||||||
|
|
||||||
|
QMap<QString, BRCompetition::BRDiscipline> disciplineTranslations = {
|
||||||
|
{"boulder", BRCompetition::Boulder},
|
||||||
|
{"lead", BRCompetition::Lead},
|
||||||
|
{"speed", BRCompetition::Speed}
|
||||||
|
};
|
||||||
|
|
||||||
|
BRCompetition::BRCompetitionData data;
|
||||||
|
|
||||||
|
data.name = rawData["event"].toString();
|
||||||
|
data.discipline = BRCompetition::Unknown;
|
||||||
|
|
||||||
|
data.startDate = QDate::fromString(rawData["starts_at"].toString().split(" ")[0], "yyyy-MM-dd");
|
||||||
|
data.endDate = QDate::fromString(rawData["ends_at"].toString().split(" ")[0], "yyyy-MM-dd");
|
||||||
|
|
||||||
|
data.eventWebsiteUrl = "";
|
||||||
|
|
||||||
|
for(int i = 0; i < 2; i++) {
|
||||||
|
QString infosheetName = QStringList({"infosheet_url", "additional_info_url"})[i];
|
||||||
|
if(rawData.contains(infosheetName) && !rawData[infosheetName].isNull()) {
|
||||||
|
data.infosheetUrls.append(rawData[infosheetName].toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantList categoriesList = rawData["d_cats"].toList();
|
||||||
|
for(QVariant categoryVar : categoriesList) {
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
BRCategory* category = this->getCategory(federation, rawData["id"].toInt(), this->parseCategoryData(categoryMap));
|
||||||
|
data.categories.append(category);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO load results
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRCup::BRCupData BRProviderVl::parseCupData(QVariantMap rawData) {
|
||||||
|
BRCup::BRCupData data;
|
||||||
|
|
||||||
|
data.name = rawData["cup"].toString();
|
||||||
|
|
||||||
|
// parse categories
|
||||||
|
for(QVariant categoryVar : rawData["d_cats"].toList()) {
|
||||||
|
// find category name in cats:
|
||||||
|
|
||||||
|
QVariantMap categoryMap = categoryVar.toMap();
|
||||||
|
|
||||||
|
int categoryId = categoryMap["ranking_url"].toString().split("/").last().toInt();
|
||||||
|
BRCategory* category = this->getCategory(BRWidget::IFSC, categoryId, this->parseCategoryData(categoryMap));
|
||||||
|
data.categories.append(category);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRCategory::BRCategoryData BRProviderVl::parseCategoryData(QVariantMap rawData) {
|
||||||
|
// TODO: status
|
||||||
|
// TODO: sex
|
||||||
|
BRCategory::BRCategoryData data;
|
||||||
|
data.name = rawData["name"].toString();
|
||||||
|
return data;
|
||||||
|
}
|
93
sources/brseason.cpp
Normal file
93
sources/brseason.cpp
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
#include "headers/brseason.h"
|
||||||
|
#include "headers/brprovider.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
BRSeason::BRSeason(BRProvider* provider, BRWidget::BRFederation federation, int id, BRSeasonData initialData) : BRWidget(provider, federation), id(id)
|
||||||
|
{
|
||||||
|
connect(this, &BRSeason::leaguesChanged, this, &BRSeason::competitionsChanged);
|
||||||
|
connect(this, &BRSeason::leaguesChanged, this, &BRSeason::cupsChanged);
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRSeason::getYear() const {
|
||||||
|
return this->year;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRSeason::getName() {
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRSeason::getLeaguesQML() {
|
||||||
|
return this->listToQmlList(this->leagues);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRLeague*> BRSeason::getLeagues() const {
|
||||||
|
return this->leagues;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRSeason::getCompetitionsQML() {
|
||||||
|
QList<BRCompetition*> allCompetitions;
|
||||||
|
|
||||||
|
for(BRLeague* league : this->leagues) {
|
||||||
|
allCompetitions.append(league->getCompetitions());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(allCompetitions.begin(), allCompetitions.end(), BRCompetition::lessThan);
|
||||||
|
|
||||||
|
qDebug() << "competitions: " << allCompetitions;
|
||||||
|
|
||||||
|
return this->listToQmlList(allCompetitions);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRSeason::getCupsQML() {
|
||||||
|
QList<QObject*> allCups;
|
||||||
|
|
||||||
|
for(BRLeague* league : this->leagues) {
|
||||||
|
allCups.append(league->getCupsQML());
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->listToQmlList(allCups);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRSeason::setData(BRSeasonData data) {
|
||||||
|
this->year = data.year;
|
||||||
|
this->name = data.name;
|
||||||
|
this->multiLeagueSupport = data.nativeMultiLeagueSupport;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
|
||||||
|
if(this->leagues != data.leagues) {
|
||||||
|
this->leagues.clear();
|
||||||
|
this->leagues = data.leagues;
|
||||||
|
emit this->leaguesChanged();
|
||||||
|
|
||||||
|
for(BRLeague* league : this->leagues) {
|
||||||
|
connect(league, &BRLeague::competitionsChanged, this, &BRSeason::competitionsChanged);
|
||||||
|
connect(league, &BRLeague::cupsChanged, this, &BRSeason::cupsChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRSeason::load() {
|
||||||
|
if(this->getProvider() == nullptr)
|
||||||
|
return BRWidget::NoProviderError;
|
||||||
|
|
||||||
|
// reload all comp data using our providers
|
||||||
|
|
||||||
|
BRSeasonData newData {
|
||||||
|
this,
|
||||||
|
this->year,
|
||||||
|
this->name,
|
||||||
|
this->multiLeagueSupport,
|
||||||
|
this->leagues
|
||||||
|
};
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode statusCode = this->getProvider()->getWidgetData(&newData);
|
||||||
|
|
||||||
|
if(statusCode != BRWidget::Success)
|
||||||
|
return statusCode;
|
||||||
|
|
||||||
|
this->setData(newData);
|
||||||
|
|
||||||
|
return statusCode;
|
||||||
|
}
|
|
@ -2,13 +2,11 @@
|
||||||
|
|
||||||
#include "headers/brprovider.h"
|
#include "headers/brprovider.h"
|
||||||
|
|
||||||
BRWidget::BRWidget(BRProvider* provider, BRFederation federation) : QObject(provider)
|
BRWidget::BRWidget(BRProvider* provider, BRFederation federation) : QObject(provider), provider(provider), federation(federation)
|
||||||
{
|
{
|
||||||
this->provider = provider;
|
|
||||||
this->federation = federation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BRWidget::BRFederation BRWidget::getFederation() {
|
BRWidget::BRFederation BRWidget::getFederation() const {
|
||||||
return this->federation;
|
return this->federation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,14 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
qmlRegisterType<BRController>("de.itsblue.blueRock", 2, 0, "BRController");
|
qmlRegisterType<BRController>("de.itsblue.blueRock", 2, 0, "BRController");
|
||||||
qmlRegisterUncreatableType<BRCalendar>("de.itsblue.blueRock", 2, 0, "BRCalendar", "BRCalendar is not creatable");
|
qmlRegisterUncreatableType<BRCalendar>("de.itsblue.blueRock", 2, 0, "BRCalendar", "BRCalendar is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRSeason>("de.itsblue.blueRock", 2, 0, "BRSeason", "BRSeason is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRLeague>("de.itsblue.blueRock", 2, 0, "BRLeague", "BRLeague is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRCompetition>("de.itsblue.blueRock", 2, 0, "BRCompetition", "BRCompetition is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRCup>("de.itsblue.blueRock", 2, 0, "BRCup", "BRCup is not creatable");
|
||||||
|
qmlRegisterUncreatableType<BRCategory>("de.itsblue.blueRock", 2, 0, "BRCategory", "BRCategory is not creatable");
|
||||||
qmlRegisterUncreatableType<BRWidget>("de.itsblue.blueRock", 2, 0, "BRWidget", "BRWidget is not creatable");
|
qmlRegisterUncreatableType<BRWidget>("de.itsblue.blueRock", 2, 0, "BRWidget", "BRWidget is not creatable");
|
||||||
qRegisterMetaType<BRWidget::BRFederation>("BRWidget::BRFederation");
|
qRegisterMetaType<BRWidget::BRFederation>("BRWidget::BRFederation");
|
||||||
|
qRegisterMetaType<BRWidget::BRWidgetStatusCode>("BRWidget::BRWidgetStatusCode");
|
||||||
//qmlRegisterType<BRController>("de.itsblue.blueRock", 2, 0, "BRController");
|
//qmlRegisterType<BRController>("de.itsblue.blueRock", 2, 0, "BRController");
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
Loading…
Reference in a new issue