- moved some stuff
- results work now (still basic)
This commit is contained in:
parent
9d8e1c7c42
commit
85c8760bed
37 changed files with 611 additions and 226 deletions
53
blueROCK.pro
53
blueROCK.pro
|
@ -30,20 +30,22 @@ SOURCES += \
|
||||||
sources/brleague.cpp \
|
sources/brleague.cpp \
|
||||||
sources/appsettings.cpp \
|
sources/appsettings.cpp \
|
||||||
sources/brcalendar.cpp \
|
sources/brcalendar.cpp \
|
||||||
sources/brcategory.cpp \
|
sources/competition/brround.cpp \
|
||||||
sources/brcompetition.cpp \
|
|
||||||
sources/brcontroller.cpp \
|
|
||||||
sources/brcup.cpp \
|
|
||||||
sources/brprovider.cpp \
|
|
||||||
sources/brproviderdr.cpp \
|
|
||||||
sources/brprovidervl.cpp \
|
|
||||||
sources/brresult.cpp \
|
|
||||||
sources/brresultdetails.cpp \
|
|
||||||
sources/brround.cpp \
|
|
||||||
sources/brseason.cpp \
|
sources/brseason.cpp \
|
||||||
sources/brserverconnector.cpp \
|
sources/brserverconnector.cpp \
|
||||||
sources/brwidget.cpp \
|
sources/brwidget.cpp \
|
||||||
sources/main.cpp
|
sources/competition/result/brresultdetailsgeneralresult.cpp \
|
||||||
|
sources/main.cpp \
|
||||||
|
sources/brcontroller.cpp \
|
||||||
|
sources/provider/brprovider.cpp \
|
||||||
|
sources/provider/brproviderdr.cpp \
|
||||||
|
sources/provider/brprovidervl.cpp \
|
||||||
|
sources/competition/brcategory.cpp \
|
||||||
|
sources/competition/brcompetition.cpp \
|
||||||
|
sources/competition/result/brresult.cpp \
|
||||||
|
sources/competition/result/brresultdetails.cpp \
|
||||||
|
sources/competition/result/brresultdetailsunknown.cpp \
|
||||||
|
sources/cup/brcup.cpp
|
||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
@ -51,19 +53,28 @@ HEADERS += \
|
||||||
headers/brleague.h \
|
headers/brleague.h \
|
||||||
headers/appsettings.h \
|
headers/appsettings.h \
|
||||||
headers/brcalendar.h \
|
headers/brcalendar.h \
|
||||||
headers/brcategory.h \
|
headers/competition/brcategory.h \
|
||||||
headers/brcompetition.h \
|
headers/competition/brcompetition.h \
|
||||||
headers/brcontroller.h \
|
headers/brcontroller.h \
|
||||||
headers/brcup.h \
|
|
||||||
headers/brprovider.h \
|
|
||||||
headers/brproviderdr.h \
|
|
||||||
headers/brprovidervl.h \
|
|
||||||
headers/brresult.h \
|
|
||||||
headers/brresultdetails.h \
|
|
||||||
headers/brround.h \
|
|
||||||
headers/brseason.h \
|
headers/brseason.h \
|
||||||
headers/brserverconnector.h \
|
headers/brserverconnector.h \
|
||||||
headers/brwidget.h
|
headers/brwidget.h \
|
||||||
|
headers/competition/result/brresultdetailsgeneralresult.h \
|
||||||
|
headers/provider/brprovider.h \
|
||||||
|
headers/provider/brproviderdr.h \
|
||||||
|
headers/provider/brprovidervl.h \
|
||||||
|
headers/competition/brround.h \
|
||||||
|
headers/competition/result/brresult.h \
|
||||||
|
headers/competition/result/brresultdetails.h \
|
||||||
|
headers/competition/result/brresultdetailsunknown.h \
|
||||||
|
headers/cup/brcup.h
|
||||||
|
|
||||||
|
INCLUDEPATH += \
|
||||||
|
headers \
|
||||||
|
headers/provider \
|
||||||
|
headers/competition \
|
||||||
|
headers/competition/result \
|
||||||
|
headers/cup
|
||||||
|
|
||||||
RESOURCES += resources/qml/qml.qrc \
|
RESOURCES += resources/qml/qml.qrc \
|
||||||
resources/shared/shared.qrc \
|
resources/shared/shared.qrc \
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
#ifndef BRRESULTDATA_H
|
|
||||||
#define BRRESULTDATA_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class BRResultDetails : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
BRResultDetails();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // BRRESULTDATA_H
|
|
|
@ -12,12 +12,24 @@ class BRWidget : public QObject
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum BRFederation {
|
enum BRFederation {
|
||||||
|
UnknownFederation = -1,
|
||||||
IFSC,
|
IFSC,
|
||||||
DAV,
|
DAV,
|
||||||
SAC
|
SAC
|
||||||
};
|
};
|
||||||
Q_ENUM(BRFederation)
|
Q_ENUM(BRFederation)
|
||||||
|
|
||||||
|
|
||||||
|
enum BRDiscipline {
|
||||||
|
UnknownDiscipline = -1,
|
||||||
|
Speed,
|
||||||
|
Lead,
|
||||||
|
Boulder,
|
||||||
|
Combined,
|
||||||
|
AllDisciplines = 99
|
||||||
|
};
|
||||||
|
Q_ENUM(BRDiscipline)
|
||||||
|
|
||||||
enum BRWidgetState {
|
enum BRWidgetState {
|
||||||
Unconfigured = -1,
|
Unconfigured = -1,
|
||||||
Configured,
|
Configured,
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "brwidget.h"
|
#include "brwidget.h"
|
||||||
#include "brround.h"
|
#include "brround.h"
|
||||||
#include "brathlete.h"
|
#include "brathlete.h"
|
||||||
|
#include "brresultdetailsgeneralresult.h"
|
||||||
|
|
||||||
class BRCompetition;
|
class BRCompetition;
|
||||||
|
|
||||||
|
@ -16,25 +17,19 @@ class BRCategory : public BRWidget
|
||||||
Q_PROPERTY(BRDiscipline discipline READ getDiscipline NOTIFY metadataChanged)
|
Q_PROPERTY(BRDiscipline discipline READ getDiscipline NOTIFY metadataChanged)
|
||||||
Q_PROPERTY(BRCategoryStatus status READ getStatus NOTIFY metadataChanged)
|
Q_PROPERTY(BRCategoryStatus status READ getStatus NOTIFY metadataChanged)
|
||||||
Q_PROPERTY(BRRound* currentRound READ getCurrentRound WRITE setCurrentRound NOTIFY currentRoundChanged)
|
Q_PROPERTY(BRRound* currentRound READ getCurrentRound WRITE setCurrentRound NOTIFY currentRoundChanged)
|
||||||
|
Q_PROPERTY(BRRound* generalResult READ getGeneralResult NOTIFY generalResultChanged)
|
||||||
Q_PROPERTY(QList<QObject*> rounds READ getRoundsQML NOTIFY roundsChanged)
|
Q_PROPERTY(QList<QObject*> rounds READ getRoundsQML NOTIFY roundsChanged)
|
||||||
public:
|
public:
|
||||||
friend class BRProvider;
|
friend class BRProvider;
|
||||||
friend class BRCompetition;
|
friend class BRCompetition;
|
||||||
|
|
||||||
enum BRDiscipline {
|
|
||||||
UnknownDiscipline = -1,
|
|
||||||
Speed,
|
|
||||||
Lead,
|
|
||||||
Boulder,
|
|
||||||
Combined
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BRCategoryStatus {
|
enum BRCategoryStatus {
|
||||||
UnknownStatus = -1,
|
UnknownStatus = -1,
|
||||||
Registration,
|
Registration,
|
||||||
Startlist,
|
Startlist,
|
||||||
Result
|
Result
|
||||||
};
|
};
|
||||||
|
Q_ENUM(BRCategoryStatus)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const BRCategory* category;
|
const BRCategory* category;
|
||||||
|
@ -42,6 +37,8 @@ public:
|
||||||
BRDiscipline discipline;
|
BRDiscipline discipline;
|
||||||
BRCategoryStatus status;
|
BRCategoryStatus status;
|
||||||
BRRound* currentRound;
|
BRRound* currentRound;
|
||||||
|
BRRound* generalResult;
|
||||||
|
|
||||||
QList<BRRound*> rounds;
|
QList<BRRound*> rounds;
|
||||||
} BRCategoryData;
|
} BRCategoryData;
|
||||||
|
|
||||||
|
@ -51,8 +48,9 @@ public:
|
||||||
Q_INVOKABLE BRDiscipline getDiscipline();
|
Q_INVOKABLE BRDiscipline getDiscipline();
|
||||||
Q_INVOKABLE BRCategoryStatus getStatus();
|
Q_INVOKABLE BRCategoryStatus getStatus();
|
||||||
Q_INVOKABLE BRRound* getCurrentRound() const;
|
Q_INVOKABLE BRRound* getCurrentRound() const;
|
||||||
Q_INVOKABLE void setCurrentRound(BRRound* round);
|
Q_INVOKABLE void setCurrentRound(BRRound* round = nullptr);
|
||||||
Q_INVOKABLE QList<BRRound*> getRounds() const;
|
Q_INVOKABLE BRRound* getGeneralResult();
|
||||||
|
Q_INVOKABLE QList<BRRound*> getRounds(bool includeGeneralResult = false) const;
|
||||||
Q_INVOKABLE QList<QObject*> getRoundsQML();
|
Q_INVOKABLE QList<QObject*> getRoundsQML();
|
||||||
|
|
||||||
BRCategoryData getData();
|
BRCategoryData getData();
|
||||||
|
@ -67,12 +65,14 @@ private:
|
||||||
QString name;
|
QString name;
|
||||||
BRDiscipline discipline;
|
BRDiscipline discipline;
|
||||||
BRCategoryStatus status;
|
BRCategoryStatus status;
|
||||||
|
BRRound* generalResult;
|
||||||
QList<BRRound*> rounds;
|
QList<BRRound*> rounds;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void metadataChanged();
|
void metadataChanged();
|
||||||
void currentRoundChanged();
|
void currentRoundChanged();
|
||||||
void roundsChanged();
|
void roundsChanged();
|
||||||
|
void generalResultChanged();
|
||||||
void resultsChanged();
|
void resultsChanged();
|
||||||
|
|
||||||
};
|
};
|
|
@ -18,7 +18,7 @@ public:
|
||||||
friend class BRCategory;
|
friend class BRCategory;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const BRRound* round;
|
BRRound* round;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
QList<BRResult*> results;
|
QList<BRResult*> results;
|
||||||
|
@ -28,16 +28,22 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE BRCategory* getCategory() const;
|
Q_INVOKABLE BRCategory* getCategory() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE bool isGeneralResult() const;
|
||||||
|
|
||||||
Q_INVOKABLE QString getName();
|
Q_INVOKABLE QString getName();
|
||||||
|
Q_INVOKABLE QList<BRResult*> getResults();
|
||||||
Q_INVOKABLE QList<QObject*> getResultsQML();
|
Q_INVOKABLE QList<QObject*> getResultsQML();
|
||||||
|
|
||||||
BRRoundData getData();
|
BRRoundData getData();
|
||||||
|
|
||||||
|
static bool lessThan(BRRound* round1, BRRound* round2);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRRound(BRProvider* provider, BRWidget::BRFederation federation, int id, BRRoundData initialData);
|
BRRound(BRProvider* provider, BRWidget::BRFederation federation, int id, BRRoundData initialData, bool generalResult = false);
|
||||||
void setData(BRRoundData data);
|
void setData(BRRoundData data);
|
||||||
|
|
||||||
BRCategory* category;
|
BRCategory* category;
|
||||||
|
bool generalResult;
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
QList<BRResult*> results;
|
QList<BRResult*> results;
|
|
@ -7,38 +7,48 @@
|
||||||
#include "brresultdetails.h"
|
#include "brresultdetails.h"
|
||||||
|
|
||||||
class BRAthlete;
|
class BRAthlete;
|
||||||
|
class BRRound;
|
||||||
|
|
||||||
class BRResult : public BRWidget
|
class BRResult : public BRWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int rank READ getRank NOTIFY metadataChanged)
|
Q_PROPERTY(int rank READ getRank NOTIFY metadataChanged)
|
||||||
|
Q_PROPERTY(int startNumber READ getStartNumber NOTIFY metadataChanged)
|
||||||
Q_PROPERTY(BRResultDetails* details READ getDetails NOTIFY metadataChanged)
|
Q_PROPERTY(BRResultDetails* details READ getDetails NOTIFY metadataChanged)
|
||||||
Q_PROPERTY(BRAthlete* athlete READ getAthlete NOTIFY metadataChanged)
|
Q_PROPERTY(BRAthlete* athlete READ getAthlete NOTIFY metadataChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend class BRProvider;
|
friend class BRProvider;
|
||||||
|
friend class BRRound;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const BRResult* result;
|
const BRResult* result;
|
||||||
|
|
||||||
int rank;
|
int rank;
|
||||||
BRResultDetails* data;
|
int startNumber;
|
||||||
|
BRResultDetails* details;
|
||||||
BRAthlete* athlete;
|
BRAthlete* athlete;
|
||||||
} BRResultData;
|
} BRResultData;
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode load() override;
|
BRWidget::BRWidgetStatusCode load() override;
|
||||||
|
|
||||||
Q_INVOKABLE int getRank() const;
|
Q_INVOKABLE int getRank() const;
|
||||||
|
Q_INVOKABLE int getStartNumber() const;
|
||||||
Q_INVOKABLE BRResultDetails* getDetails() const;
|
Q_INVOKABLE BRResultDetails* getDetails() const;
|
||||||
Q_INVOKABLE BRAthlete* getAthlete() const;
|
Q_INVOKABLE BRAthlete* getAthlete() const;
|
||||||
|
Q_INVOKABLE BRRound* getRound() const;
|
||||||
|
|
||||||
|
static bool lessThan(BRResult* result1, BRResult* result2);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRResult(BRProvider* provider, BRWidget::BRFederation federation, int id, BRResultData initialData);
|
BRResult(BRResultData initialData);
|
||||||
void setData(BRResultData data);
|
void setData(BRResultData data);
|
||||||
|
|
||||||
int rank;
|
int rank;
|
||||||
|
int startNumber;
|
||||||
BRResultDetails* details;
|
BRResultDetails* details;
|
||||||
BRAthlete* athlete;
|
BRAthlete* athlete;
|
||||||
|
BRRound* round;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void metadataChanged();
|
void metadataChanged();
|
50
headers/competition/result/brresultdetails.h
Normal file
50
headers/competition/result/brresultdetails.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef BRRESULTDATA_H
|
||||||
|
#define BRRESULTDATA_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brwidget.h"
|
||||||
|
|
||||||
|
class BRResult;
|
||||||
|
|
||||||
|
class BRResultDetails : public BRWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(BRResultDetailsType type READ getType NOTIFY metadataChanged)
|
||||||
|
public:
|
||||||
|
friend class BRResult;
|
||||||
|
|
||||||
|
enum BRResultDetailsType {
|
||||||
|
UnknownResultType = -1,
|
||||||
|
GeneralResult,
|
||||||
|
SpeedQualificationResult,
|
||||||
|
SpeedFinalResult,
|
||||||
|
LeadResult,
|
||||||
|
BoulderResult,
|
||||||
|
CombinedResult
|
||||||
|
};
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode load() final override;
|
||||||
|
Q_INVOKABLE virtual QString toString() = 0;
|
||||||
|
|
||||||
|
Q_INVOKABLE virtual QString string() final;
|
||||||
|
|
||||||
|
Q_INVOKABLE BRResultDetailsType getType();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BRResultDetails(BRResultDetailsType type);
|
||||||
|
|
||||||
|
BRResult* getResult();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
BRResult* result;
|
||||||
|
BRResultDetailsType type;
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRDiscipline getDiscipline();
|
||||||
|
signals:
|
||||||
|
void metadataChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRRESULTDATA_H
|
28
headers/competition/result/brresultdetailsgeneralresult.h
Normal file
28
headers/competition/result/brresultdetailsgeneralresult.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef BRGENERALRESULT_H
|
||||||
|
#define BRGENERALRESULT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "brresultdetails.h"
|
||||||
|
|
||||||
|
class BRResult;
|
||||||
|
|
||||||
|
class BRResultDetailsGeneralResult : public BRResultDetails
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QList<QObject*> results READ getResultsQML NOTIFY resultsChanged)
|
||||||
|
public:
|
||||||
|
BRResultDetailsGeneralResult();
|
||||||
|
|
||||||
|
QList<BRResult*> getResults();
|
||||||
|
QList<QObject*> getResultsQML();
|
||||||
|
|
||||||
|
Q_INVOKABLE QString toString() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void resultsChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRGENERALRESULT_H
|
27
headers/competition/result/brresultdetailsunknown.h
Normal file
27
headers/competition/result/brresultdetailsunknown.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef BRRESULTDETAILSUNKNOWN_H
|
||||||
|
#define BRRESULTDETAILSUNKNOWN_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "brresultdetails.h"
|
||||||
|
|
||||||
|
class BRResultDetailsUnknown : public BRResultDetails
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString score READ toString NOTIFY metadataChanged())
|
||||||
|
public:
|
||||||
|
BRResultDetailsUnknown(QString score);
|
||||||
|
|
||||||
|
Q_INVOKABLE QString toString() {
|
||||||
|
return this->score;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString score;
|
||||||
|
|
||||||
|
BRDiscipline getType() {
|
||||||
|
return BRWidget::UnknownDiscipline;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BRRESULTDETAILSUNKNOWN_H
|
|
@ -15,6 +15,7 @@
|
||||||
#include "brathlete.h"
|
#include "brathlete.h"
|
||||||
#include "brcup.h"
|
#include "brcup.h"
|
||||||
#include "brresult.h"
|
#include "brresult.h"
|
||||||
|
#include "brresultdetailsunknown.h"
|
||||||
|
|
||||||
class BRProvider : public QObject
|
class BRProvider : public QObject
|
||||||
{
|
{
|
||||||
|
@ -41,8 +42,8 @@ protected:
|
||||||
virtual BRCup* getCup(BRWidget::BRFederation federation, int id, BRCup::BRCupData 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 BRCategory* getCategory(BRWidget::BRFederation federation, int id, BRCategory::BRCategoryData initialData) final;
|
||||||
virtual BRAthlete* getAthlete(BRWidget::BRFederation federation, int id, BRAthlete::BRAthleteData initialData) final;
|
virtual BRAthlete* getAthlete(BRWidget::BRFederation federation, int id, BRAthlete::BRAthleteData initialData) final;
|
||||||
virtual BRRound* getRound(BRWidget::BRFederation federation, int id, BRRound::BRRoundData initialData) final;
|
virtual BRRound* getRound(BRWidget::BRFederation federation, int id, BRRound::BRRoundData initialData, bool generalResult = false) final;
|
||||||
virtual BRResult* getResult(BRWidget::BRFederation federation, int id, BRResult::BRResultData initialData) final;
|
virtual BRResult* getResult(BRResult::BRResultData initialData) final;
|
||||||
|
|
||||||
virtual void setCategoryData(BRCategory* category, BRCategory::BRCategoryData data) final {
|
virtual void setCategoryData(BRCategory* category, BRCategory::BRCategoryData data) final {
|
||||||
category->setData(data);
|
category->setData(data);
|
|
@ -30,6 +30,12 @@ protected:
|
||||||
BRCategory::BRCategoryData parseCategoryData(QVariantMap rawData);
|
BRCategory::BRCategoryData parseCategoryData(QVariantMap rawData);
|
||||||
void parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData);
|
void parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData);
|
||||||
|
|
||||||
|
void parseRoundData(BRRound::BRRoundData* roundData, QVariantMap rawData, QString resultKeyAttachment = "");
|
||||||
|
|
||||||
|
BRAthlete::BRAthleteData parseAthletedata(QVariantMap rawData);
|
||||||
|
|
||||||
|
BRResult::BRResultData parseResultData(QVariantMap rawData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<BRWidget::BRFederation, QList<QVariantMap>> leagues;
|
QMap<BRWidget::BRFederation, QList<QVariantMap>> leagues;
|
||||||
|
|
|
@ -26,7 +26,7 @@ protected:
|
||||||
BRCup::BRCupData parseCupData(QVariantMap rawData, QVariantList globalCategoriesList);
|
BRCup::BRCupData parseCupData(QVariantMap rawData, QVariantList globalCategoriesList);
|
||||||
|
|
||||||
BRCategory::BRCategoryData parseCategoryData(QVariantMap rawData);
|
BRCategory::BRCategoryData parseCategoryData(QVariantMap rawData);
|
||||||
void parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData);
|
//void parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData);
|
||||||
|
|
||||||
BRRound::BRRoundData parseRoundData(QVariantMap rawData);
|
BRRound::BRRoundData parseRoundData(QVariantMap rawData);
|
||||||
void parseRoundData(BRRound::BRRoundData* roundData, QVariantMap rawData);
|
void parseRoundData(BRRound::BRRoundData* roundData, QVariantMap rawData);
|
|
@ -51,6 +51,7 @@ Dialog {
|
||||||
text: control.title
|
text: control.title
|
||||||
|
|
||||||
onLinkActivated: {
|
onLinkActivated: {
|
||||||
|
console.log("Opening " + link)
|
||||||
Qt.openUrlExternally(link)
|
Qt.openUrlExternally(link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +73,7 @@ Dialog {
|
||||||
text: control.subTitle
|
text: control.subTitle
|
||||||
|
|
||||||
onLinkActivated: {
|
onLinkActivated: {
|
||||||
|
console.log("Opening " + link)
|
||||||
Qt.openUrlExternally(link)
|
Qt.openUrlExternally(link)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ BRWidgetPage {
|
||||||
bottom: routeSelectTb.top
|
bottom: routeSelectTb.top
|
||||||
}
|
}
|
||||||
|
|
||||||
model: control.data.currentCategory.currentRound.results
|
model: control.data.results
|
||||||
|
|
||||||
onRefresh: {
|
onRefresh: {
|
||||||
control.data.load()
|
control.data.load()
|
||||||
|
@ -172,7 +172,7 @@ BRWidgetPage {
|
||||||
|
|
||||||
enabled: speedFlowChartBackgroundRect.state === "hidden"
|
enabled: speedFlowChartBackgroundRect.state === "hidden"
|
||||||
|
|
||||||
width: parent.width
|
width: resultLv.width
|
||||||
height: 70
|
height: 70
|
||||||
|
|
||||||
text: ""
|
text: ""
|
||||||
|
@ -215,7 +215,7 @@ BRWidgetPage {
|
||||||
id: partDelFirstRow
|
id: partDelFirstRow
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height // TODO - partDelSecondRow.height
|
height: parent.height - partDelSecondRow.height
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
@ -264,13 +264,13 @@ BRWidgetPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Row {
|
Row {
|
||||||
id: partDelSecondRow
|
id: partDelSecondRow
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 0 // TODO multiResRow.active || multiGenResRow.active || resultLa.acitve ? parent.height / 2 : 0
|
height: resultLa.acitve ? parent.height / 2 : 0 // TODO multiResRow.active || multiGenResRow.active || resultLa.acitve ? parent.height / 2 : 0
|
||||||
|
/*
|
||||||
Row {
|
Row {
|
||||||
id: multiResRow
|
id: multiResRow
|
||||||
|
|
||||||
|
@ -585,28 +585,28 @@ BRWidgetPage {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
Label {
|
Label {
|
||||||
id: resultLa
|
id: resultLa
|
||||||
|
|
||||||
property bool acitve: false // TODO ( boulderResRep.model > 0 || widgetData["discipline"] !== "boulder" ) && parseInt(widgetData[ "route_order" ]) > -1
|
property bool acitve: true // TODO ( boulderResRep.model > 0 || widgetData["discipline"] !== "boulder" ) && parseInt(widgetData[ "route_order" ]) > -1
|
||||||
|
|
||||||
width: enabled ? parent.width * 0.25:0
|
width: enabled ? parent.width * 0.75:0
|
||||||
height: enabled ? parent.height:0
|
height: enabled ? parent.height:0
|
||||||
|
|
||||||
enabled: ( boulderResRep.model > 0 || widgetData["discipline"] !== "boulder" ) && parseInt(widgetData[ "route_order" ]) > -1
|
enabled: true //( boulderResRep.model > 0 || widgetData["discipline"] !== "boulder" ) && parseInt(widgetData[ "route_order" ]) > -1
|
||||||
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
|
||||||
fontSizeMode: Text.Fit
|
fontSizeMode: Text.Fit
|
||||||
font.pixelSize: Math.abs( height * 0.6 )
|
font.pixelSize: Math.abs( height * 0.6 )
|
||||||
minimumPixelSize: 1
|
minimumPixelSize: 1
|
||||||
|
|
||||||
text: widgetData[ "participants" ][partDel.ind]["result"] === undefined ? "":widgetData[ "participants" ][partDel.ind]["result"]
|
text: partDel.thisData.details.string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,25 +652,10 @@ BRWidgetPage {
|
||||||
|
|
||||||
position: TabBar.Footer
|
position: TabBar.Footer
|
||||||
|
|
||||||
currentIndex: getIndex(control.data.currentCategory.currentRound)
|
currentIndex: tabs.indexOf(control.data.currentCategory.currentRound)
|
||||||
|
|
||||||
function getIndex(round) {
|
onTabsChanged: {
|
||||||
//console.log("getting index for route number: " + routeNumber)
|
console.log("tabs: " + tabs + " rounds: " + control.data.currentCategory.rounds)
|
||||||
|
|
||||||
if(tabs === undefined){
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var i = 0; i < tabs.length; i++){
|
|
||||||
//console.log(tabs[i])
|
|
||||||
if(tabs[i] === round){
|
|
||||||
//console.log("found index: " + i)
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
|
@ -679,7 +664,7 @@ BRWidgetPage {
|
||||||
model: routeSelectTb.tabs
|
model: routeSelectTb.tabs
|
||||||
|
|
||||||
onModelChanged: {
|
onModelChanged: {
|
||||||
routeSelectTb.setCurrentIndex(routeSelectTb.getIndex(control.data.currentCategory.currentRound))
|
//routeSelectTb.setCurrentIndex(routeSelectTb.tabs.indexOf(control.data.currentCategory.currentRound))
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: TabButton {
|
delegate: TabButton {
|
||||||
|
@ -693,7 +678,6 @@ BRWidgetPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -702,13 +686,13 @@ BRWidgetPage {
|
||||||
state: "hidden"
|
state: "hidden"
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: parent.top
|
top: control.top
|
||||||
bottom: parent.bottom
|
bottom: control.bottom
|
||||||
left: parent.right
|
left: control.right
|
||||||
}
|
}
|
||||||
|
|
||||||
width: parent.width
|
width: control.width
|
||||||
height: parent.height
|
height: control.height
|
||||||
|
|
||||||
color: Material.background
|
color: Material.background
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../headers/brathlete.h"
|
#include "brathlete.h"
|
||||||
|
|
||||||
BRAthlete::BRAthlete(BRProvider* provider, BRWidget::BRFederation federation, int id, BRAthleteData initialData) : BRWidget(provider, federation, id)
|
BRAthlete::BRAthlete(BRProvider* provider, BRWidget::BRFederation federation, int id, BRAthleteData initialData) : BRWidget(provider, federation, id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "../headers/brcalendar.h"
|
#include "brcalendar.h"
|
||||||
#include "headers/brprovider.h"
|
#include "brprovider.h"
|
||||||
|
|
||||||
BRCalendar::BRCalendar(BRProvider* provider, BRFederation federation) : BRWidget(provider, federation, -1)
|
BRCalendar::BRCalendar(BRProvider* provider, BRFederation federation) : BRWidget(provider, federation, -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../headers/brcontroller.h"
|
#include "brcontroller.h"
|
||||||
|
|
||||||
BRController::BRController(QObject *parent) : QObject(parent)
|
BRController::BRController(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "headers/brleague.h"
|
#include "brleague.h"
|
||||||
#include "headers/brprovider.h"
|
#include "brprovider.h"
|
||||||
|
|
||||||
BRLeague::BRLeague(BRProvider* provider, BRWidget::BRFederation federation, int id, BRLeagueData initialData) : BRWidget(provider, federation, id)
|
BRLeague::BRLeague(BRProvider* provider, BRWidget::BRFederation federation, int id, BRLeagueData initialData) : BRWidget(provider, federation, id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
#include "headers/brresult.h"
|
|
||||||
|
|
||||||
BRResult::BRResult(BRProvider* provider, BRWidget::BRFederation federation, int id, BRResultData initialData) : BRWidget(provider, federation, id)
|
|
||||||
{
|
|
||||||
this->setData(initialData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int BRResult::getRank() const {
|
|
||||||
return this->rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
BRAthlete* BRResult::getAthlete() const {
|
|
||||||
return this->athlete;
|
|
||||||
}
|
|
||||||
|
|
||||||
BRResultDetails* BRResult::getDetails() const {
|
|
||||||
return this->details;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BRResult::setData(BRResultData data) {
|
|
||||||
this->rank = data.rank;
|
|
||||||
this->athlete = data.athlete;
|
|
||||||
emit this->metadataChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode BRResult::load() {
|
|
||||||
return BRWidget::OpeationNotSupportedError;
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
#include "../headers/brresultdetails.h"
|
|
||||||
|
|
||||||
BRResultDetails::BRResultDetails()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "headers/brseason.h"
|
#include "brseason.h"
|
||||||
#include "headers/brprovider.h"
|
#include "brprovider.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "headers/brserverconnector.h"
|
#include "brserverconnector.h"
|
||||||
|
|
||||||
BRServerConnector::BRServerConnector(QObject *parent) : QObject(parent)
|
BRServerConnector::BRServerConnector(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "../headers/brwidget.h"
|
#include "brwidget.h"
|
||||||
|
|
||||||
#include "headers/brprovider.h"
|
#include "brprovider.h"
|
||||||
|
|
||||||
BRWidget::BRWidget(BRProvider* provider, BRFederation federation, int id) : QObject(provider), provider(provider), federation(federation), id(id)
|
BRWidget::BRWidget(BRProvider* provider, BRFederation federation, int id) : QObject(provider), provider(provider), federation(federation), id(id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
#include "../headers/brcategory.h"
|
#include "brcategory.h"
|
||||||
#include "headers/brprovider.h"
|
#include "brprovider.h"
|
||||||
#include "headers/brcompetition.h"
|
#include "brcompetition.h"
|
||||||
|
|
||||||
BRCategory::BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData) : BRWidget(provider, federation, id)
|
BRCategory::BRCategory(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCategoryData initialData) : BRWidget(provider, federation, id)
|
||||||
{
|
{
|
||||||
this->currentRound = nullptr;
|
this->currentRound = nullptr;
|
||||||
this->discipline = UnknownDiscipline;
|
this->discipline = UnknownDiscipline;
|
||||||
|
this->generalResult = nullptr;
|
||||||
|
connect(this, &BRCategory::generalResultChanged, this, &BRCategory::resultsChanged);
|
||||||
|
connect(this, &BRCategory::roundsChanged, this, &BRCategory::resultsChanged);
|
||||||
this->setData(initialData);
|
this->setData(initialData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,28 +33,39 @@ BRRound* BRCategory::getCurrentRound() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BRCategory::setCurrentRound(BRRound* round) {
|
void BRCategory::setCurrentRound(BRRound* round) {
|
||||||
if(!this->rounds.contains(round))
|
if(!this->rounds.contains(round) && this->generalResult != round)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this->currentRound = round;
|
this->currentRound = round;
|
||||||
emit this->currentRoundChanged();
|
emit this->currentRoundChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<BRRound*> BRCategory::getRounds() const {
|
BRRound* BRCategory::getGeneralResult() {
|
||||||
return this->rounds;
|
return this->generalResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRRound*> BRCategory::getRounds(bool includeGeneralResult) const {
|
||||||
|
QList<BRRound*> rounds;
|
||||||
|
if(includeGeneralResult && this->generalResult != nullptr)
|
||||||
|
rounds.append(this->generalResult);
|
||||||
|
|
||||||
|
rounds.append(this->rounds);
|
||||||
|
|
||||||
|
return rounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QObject*> BRCategory::getRoundsQML() {
|
QList<QObject*> BRCategory::getRoundsQML() {
|
||||||
return this->listToQmlList(this->rounds);
|
return this->listToQmlList(this->getRounds(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
BRCategory::BRCategoryData BRCategory::getData() {
|
BRCategory::BRCategoryData BRCategory::getData() {
|
||||||
BRCategory::BRCategoryData data {
|
BRCategory::BRCategoryData data {
|
||||||
this,
|
this,
|
||||||
this->name,
|
this->name,
|
||||||
this->discipline,
|
this->discipline,
|
||||||
this->status,
|
this->status,
|
||||||
this->currentRound,
|
this->currentRound,
|
||||||
|
this->generalResult,
|
||||||
this->rounds
|
this->rounds
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,6 +83,13 @@ void BRCategory::setData(BRCategoryData data) {
|
||||||
emit this->currentRoundChanged();
|
emit this->currentRoundChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this->generalResult != data.generalResult) {
|
||||||
|
this->generalResult = data.generalResult;
|
||||||
|
this->generalResult->category = this;
|
||||||
|
connect(this->generalResult, &BRRound::resultsChanged, this, &BRCategory::generalResultChanged);
|
||||||
|
emit this->generalResultChanged();
|
||||||
|
}
|
||||||
|
|
||||||
if(this->rounds != data.rounds) {
|
if(this->rounds != data.rounds) {
|
||||||
this->rounds.clear();
|
this->rounds.clear();
|
||||||
this->rounds = data.rounds;
|
this->rounds = data.rounds;
|
|
@ -1,11 +1,12 @@
|
||||||
#include "headers/brcompetition.h"
|
#include "brcompetition.h"
|
||||||
#include "headers/brleague.h"
|
#include "brleague.h"
|
||||||
#include "headers/brprovider.h"
|
#include "brprovider.h"
|
||||||
|
|
||||||
BRCompetition::BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCompetitionData initialData) : BRWidget(provider, federation, id) {
|
BRCompetition::BRCompetition(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCompetitionData initialData) : BRWidget(provider, federation, id) {
|
||||||
this->currentCategory = nullptr;
|
this->currentCategory = nullptr;
|
||||||
this->eventWebsiteUrl = "";
|
this->eventWebsiteUrl = "";
|
||||||
this->pinned = false;
|
this->pinned = false;
|
||||||
|
connect(this, &BRCompetition::categoriesChanged, this, &BRCompetition::resultsChanged);
|
||||||
this->setData(initialData);
|
this->setData(initialData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,9 +82,13 @@ void BRCompetition::setCurrentCategory(BRCategory* category) {
|
||||||
QString currentRoundName = this->currentCategory->getCurrentRound()->getName();
|
QString currentRoundName = this->currentCategory->getCurrentRound()->getName();
|
||||||
|
|
||||||
// search round name in new category
|
// search round name in new category
|
||||||
for(BRRound* round : category->getRounds())
|
for(BRRound* round : category->getRounds()) {
|
||||||
|
qDebug() << "Trying to restore round: " << currentRoundName << " with round: " << round->getName();
|
||||||
if(round->getName() == currentRoundName)
|
if(round->getName() == currentRoundName)
|
||||||
category->setCurrentRound(round);
|
category->setCurrentRound(round);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Restored round with ID: " << category->currentRound->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->currentCategory = category;
|
this->currentCategory = category;
|
||||||
|
@ -91,10 +96,16 @@ void BRCompetition::setCurrentCategory(BRCategory* category) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QObject*> BRCompetition::getResultsQML() {
|
QList<QObject*> BRCompetition::getResultsQML() {
|
||||||
if(this->currentCategory == nullptr || this->currentCategory->getCurrentRound() == nullptr)
|
if(this->currentCategory == nullptr)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return this->currentCategory->getCurrentRound()->getResultsQML();
|
qDebug() << "getting results";
|
||||||
|
if( this->currentCategory->getCurrentRound() != nullptr)
|
||||||
|
return this->currentCategory->getCurrentRound()->getResultsQML();
|
||||||
|
else if(this->currentCategory->getGeneralResult() != nullptr)
|
||||||
|
return this->currentCategory->getGeneralResult()->getResultsQML();
|
||||||
|
else
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BRWidget::BRWidgetStatusCode BRCompetition::load() {
|
BRWidget::BRWidgetStatusCode BRCompetition::load() {
|
|
@ -1,8 +1,10 @@
|
||||||
#include "../headers/brround.h"
|
#include "brround.h"
|
||||||
#include "headers/brprovider.h"
|
#include "brprovider.h"
|
||||||
|
|
||||||
BRRound::BRRound(BRProvider* provider, BRWidget::BRFederation federation, int id, BRRoundData initialData) : BRWidget(provider, federation, id)
|
BRRound::BRRound(BRProvider* provider, BRWidget::BRFederation federation, int id, BRRoundData initialData, bool generalResult) : BRWidget(provider, federation, id)
|
||||||
{
|
{
|
||||||
|
this->generalResult = generalResult;
|
||||||
|
this->results = {};
|
||||||
this->setData(initialData);
|
this->setData(initialData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +12,18 @@ BRCategory* BRRound::getCategory() const {
|
||||||
return this->category;
|
return this->category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BRRound::isGeneralResult() const {
|
||||||
|
return this->generalResult;
|
||||||
|
}
|
||||||
|
|
||||||
QString BRRound::getName() {
|
QString BRRound::getName() {
|
||||||
return this->name;
|
return this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<BRResult*> BRRound::getResults() {
|
||||||
|
return this->results;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QObject*> BRRound::getResultsQML() {
|
QList<QObject*> BRRound::getResultsQML() {
|
||||||
return this->listToQmlList(this->results);
|
return this->listToQmlList(this->results);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +49,17 @@ void BRRound::setData(BRRoundData data) {
|
||||||
if(this->results != data.results) {
|
if(this->results != data.results) {
|
||||||
this->results.clear();
|
this->results.clear();
|
||||||
this->results = data.results;
|
this->results = data.results;
|
||||||
|
|
||||||
|
for(BRResult* result : this->results)
|
||||||
|
result->round = this;
|
||||||
|
|
||||||
emit this->resultsChanged();
|
emit this->resultsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool BRRound::lessThan(BRRound* round1, BRRound* round2) {
|
||||||
|
// TODO ??
|
||||||
|
return round1->getId() < round2->getId();
|
||||||
|
}
|
||||||
|
|
55
sources/competition/result/brresult.cpp
Normal file
55
sources/competition/result/brresult.cpp
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#include "brresult.h"
|
||||||
|
#include "brround.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
|
||||||
|
BRResult::BRResult(BRResultData initialData) : BRWidget(nullptr, BRWidget::UnknownFederation, -1)
|
||||||
|
{
|
||||||
|
this->round = nullptr;
|
||||||
|
this->setData(initialData);
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRResult::getRank() const {
|
||||||
|
return this->rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
int BRResult::getStartNumber() const {
|
||||||
|
return this->startNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRAthlete* BRResult::getAthlete() const {
|
||||||
|
return this->athlete;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRResultDetails* BRResult::getDetails() const {
|
||||||
|
return this->details;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRRound* BRResult::getRound() const {
|
||||||
|
return this->round;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BRResult::setData(BRResultData data) {
|
||||||
|
this->rank = data.rank;
|
||||||
|
this->startNumber = data.startNumber;
|
||||||
|
|
||||||
|
this->details = data.details;
|
||||||
|
if(data.details != nullptr)
|
||||||
|
this->details->result = this;
|
||||||
|
|
||||||
|
this->athlete = data.athlete;
|
||||||
|
emit this->metadataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRResult::load() {
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool BRResult::lessThan(BRResult* result1, BRResult* result2) {
|
||||||
|
if(result1->getAthlete()->getId() == result2->getAthlete()->getId())
|
||||||
|
return BRRound::lessThan(result1->getRound(), result2->getRound());
|
||||||
|
else
|
||||||
|
return result1->getRank() < result2->getRank();
|
||||||
|
|
||||||
|
}
|
42
sources/competition/result/brresultdetails.cpp
Normal file
42
sources/competition/result/brresultdetails.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include "brresultdetails.h"
|
||||||
|
|
||||||
|
BRResultDetails::BRResultDetails(BRResultDetailsType type) : BRWidget(nullptr, BRWidget::UnknownFederation, -1)
|
||||||
|
{
|
||||||
|
this->type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRResultDetails::string() {
|
||||||
|
return this->toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
BRResultDetails::BRResultDetailsType BRResultDetails::getType() {
|
||||||
|
return this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRResult* BRResultDetails::getResult() {
|
||||||
|
return this->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRDiscipline BRResultDetails::getDiscipline() {
|
||||||
|
switch (this->type) {
|
||||||
|
case GeneralResult:
|
||||||
|
return BRWidget::AllDisciplines;
|
||||||
|
case SpeedQualificationResult:
|
||||||
|
case SpeedFinalResult:
|
||||||
|
return BRWidget::Speed;
|
||||||
|
case LeadResult:
|
||||||
|
return BRWidget::Lead;
|
||||||
|
case BoulderResult:
|
||||||
|
return BRWidget::Boulder;
|
||||||
|
case CombinedResult:
|
||||||
|
return BRWidget::Combined;
|
||||||
|
case UnknownResultType:
|
||||||
|
return BRWidget::AllDisciplines;
|
||||||
|
default:
|
||||||
|
return BRWidget::UnknownDiscipline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRWidget::BRWidgetStatusCode BRResultDetails::load() {
|
||||||
|
return BRWidget::OpeationNotSupportedError;
|
||||||
|
}
|
44
sources/competition/result/brresultdetailsgeneralresult.cpp
Normal file
44
sources/competition/result/brresultdetailsgeneralresult.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#include "brresultdetailsgeneralresult.h"
|
||||||
|
#include "brcategory.h"
|
||||||
|
#include "brresult.h"
|
||||||
|
|
||||||
|
BRResultDetailsGeneralResult::BRResultDetailsGeneralResult() : BRResultDetails(BRResultDetails::GeneralResult)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BRResultDetailsGeneralResult::toString() {
|
||||||
|
QString resultString = "";
|
||||||
|
|
||||||
|
for(BRResult* result : this->getResults())
|
||||||
|
resultString += result->getDetails()->toString() + " | " ;
|
||||||
|
|
||||||
|
resultString = resultString.left(resultString.length() - 3);
|
||||||
|
|
||||||
|
return resultString;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<BRResult*> BRResultDetailsGeneralResult::getResults() {
|
||||||
|
|
||||||
|
if(this->getResult() == nullptr || this->getResult()->getRound() == nullptr || this->getResult()->getRound()->getCategory() == nullptr)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
BRCategory* category = this->getResult()->getRound()->getCategory();
|
||||||
|
|
||||||
|
// get all results of this athlete from all rounds
|
||||||
|
QList<BRResult*> results;
|
||||||
|
for(BRRound* round : category->getRounds()) {
|
||||||
|
for(BRResult* result : round->getResults()) {
|
||||||
|
if(result->getAthlete()->getId() == this->getResult()->getAthlete()->getId()) {
|
||||||
|
results.append(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QObject*> BRResultDetailsGeneralResult::getResultsQML() {
|
||||||
|
return this->listToQmlList(this->getResults());
|
||||||
|
}
|
||||||
|
|
6
sources/competition/result/brresultdetailsunknown.cpp
Normal file
6
sources/competition/result/brresultdetailsunknown.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "brresultdetailsunknown.h"
|
||||||
|
|
||||||
|
BRResultDetailsUnknown::BRResultDetailsUnknown(QString score) : BRResultDetails(BRResultDetails::UnknownResultType)
|
||||||
|
{
|
||||||
|
this->score = score;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../headers/brcup.h"
|
#include "brcup.h"
|
||||||
|
|
||||||
BRCup::BRCup(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCupData initialData) : BRWidget(provider, federation, id)
|
BRCup::BRCup(BRProvider* provider, BRWidget::BRFederation federation, int id, BRCupData initialData) : BRWidget(provider, federation, id)
|
||||||
{
|
{
|
|
@ -23,9 +23,9 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
|
||||||
#include "headers/brserverconnector.h"
|
#include "brserverconnector.h"
|
||||||
#include "headers/appsettings.h"
|
#include "appsettings.h"
|
||||||
#include "headers/brcontroller.h"
|
#include "brcontroller.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../headers/brprovider.h"
|
#include "brprovider.h"
|
||||||
|
|
||||||
BRProvider::BRProvider(QObject *parent) : QObject(parent)
|
BRProvider::BRProvider(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
@ -35,13 +35,13 @@ BRAthlete* BRProvider::getAthlete(BRWidget::BRFederation federation, int id, BRA
|
||||||
return new BRAthlete(this, federation, id, initialData);
|
return new BRAthlete(this, federation, id, initialData);
|
||||||
}
|
}
|
||||||
|
|
||||||
BRRound* BRProvider::getRound(BRWidget::BRFederation federation, int id, BRRound::BRRoundData initialData) {
|
BRRound* BRProvider::getRound(BRWidget::BRFederation federation, int id, BRRound::BRRoundData initialData, bool generalResult) {
|
||||||
return new BRRound(this, federation, id, initialData);
|
return new BRRound(this, federation, id, initialData, generalResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRResult* BRProvider::getResult(BRWidget::BRFederation federation, int id, BRResult::BRResultData initialData) {
|
BRResult* BRProvider::getResult(BRResult::BRResultData initialData) {
|
||||||
return new BRResult(this, federation, id, initialData);
|
return new BRResult(initialData);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap BRProvider::serverRequest(QUrl serviceUrl, QList<QStringList> additionalHeaders, QUrlQuery postData)
|
QVariantMap BRProvider::serverRequest(QUrl serviceUrl, QList<QStringList> additionalHeaders, QUrlQuery postData)
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../headers/brproviderdr.h"
|
#include "brproviderdr.h"
|
||||||
|
|
||||||
BRProviderDr::BRProviderDr(QObject *parent) : BRProvider(parent)
|
BRProviderDr::BRProviderDr(QObject *parent) : BRProvider(parent)
|
||||||
{
|
{
|
||||||
|
@ -210,21 +210,32 @@ BRWidget::BRWidgetStatusCode BRProviderDr::getWidgetData(BRCompetition::BRCompet
|
||||||
|
|
||||||
// reload all data
|
// reload all data
|
||||||
BRCategory* currentCategory = competitionData->competition->getCurrentCategory();
|
BRCategory* currentCategory = competitionData->competition->getCurrentCategory();
|
||||||
|
QVariantMap ret;
|
||||||
|
int retryCount = 0;
|
||||||
|
|
||||||
// load category data
|
// handle route not found errors
|
||||||
QString competitionId = QString::number(currentCategory->getCompetition()->getId());
|
do {
|
||||||
QString categoryId = QString::number(currentCategory->getId());
|
retryCount ++;
|
||||||
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?comp=" + competitionId + "&cat=" + categoryId;
|
// load category data
|
||||||
|
QString competitionId = QString::number(currentCategory->getCompetition()->getId());
|
||||||
|
QString categoryId = QString::number(currentCategory->getId());
|
||||||
|
QString requestUrl = "https://www.digitalrock.de/egroupware/ranking/json.php?comp=" + competitionId + "&cat=" + categoryId;
|
||||||
|
|
||||||
if(currentCategory->getCurrentRound() != nullptr && currentCategory->getCurrentRound()->getId() >= 0)
|
if(currentCategory->getCurrentRound() != nullptr && currentCategory->getCurrentRound()->getId() >= 0)
|
||||||
requestUrl += "&route=" + QString::number(currentCategory->getCurrentRound()->getId());
|
requestUrl += "&route=" + QString::number(currentCategory->getCurrentRound()->getId());
|
||||||
|
|
||||||
QVariantMap ret = this->serverRequest(QUrl(requestUrl));
|
ret = this->serverRequest(QUrl(requestUrl));
|
||||||
|
|
||||||
if(ret["status"] != 200){
|
// handle route not found errors
|
||||||
// request was a failure
|
if(ret["status"] != 200 && (ret["status"] != 404 || retryCount > 1)){
|
||||||
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
// request was a failure
|
||||||
}
|
return BRWidget::BRWidgetStatusCode(ret["status"].toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
// if 404 is returned, the route probaply does not exist -> try again without route
|
||||||
|
currentCategory->setCurrentRound(currentCategory->getGeneralResult());
|
||||||
|
|
||||||
|
} while(ret["status"] != 200);
|
||||||
|
|
||||||
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
|
||||||
|
@ -271,16 +282,19 @@ BRCompetition::BRCompetitionData BRProviderDr::parseCompetitionData(QVariantMap
|
||||||
|
|
||||||
// parse discipline
|
// parse discipline
|
||||||
QString discipline;
|
QString discipline;
|
||||||
if(rawData.contains("discipline"))
|
if(rawData.contains("discipline")) {
|
||||||
// all categories have the same discipline
|
// all categories have the same discipline
|
||||||
discipline = rawData["discipline"].toString();
|
discipline = rawData["discipline"].toString();
|
||||||
|
// remove numbers (the Year of a competition is in the discipline somtimes)
|
||||||
|
discipline = discipline.remove( QRegExp("/[0-9]/g") );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
// categories discipline may differ
|
// categories discipline may differ
|
||||||
// search category in global categories list
|
// search category in global categories list
|
||||||
for(QVariant globalCategoryVar : globalCategoriesList) {
|
for(QVariant globalCategoryVar : globalCategoriesList) {
|
||||||
QVariantMap globalCategoryMap = globalCategoryVar.toMap();
|
QVariantMap globalCategoryMap = globalCategoryVar.toMap();
|
||||||
if(categoryMap["GrpId"].toInt() == globalCategoryMap["GrpId"].toInt()) {
|
if(categoryMap["GrpId"].toInt() == globalCategoryMap["GrpId"].toInt()) {
|
||||||
// TODO: sex / gender
|
// TODO: gender
|
||||||
discipline = globalCategoryMap["discipline"].toString();
|
discipline = globalCategoryMap["discipline"].toString();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -330,6 +344,7 @@ void BRProviderDr::parseCompetitionData(BRCompetition::BRCompetitionData* compet
|
||||||
}
|
}
|
||||||
|
|
||||||
categoryData.currentRound = nullptr;
|
categoryData.currentRound = nullptr;
|
||||||
|
categoryData.generalResult = nullptr;
|
||||||
|
|
||||||
qDebug() << "Loading category: " << categoryData.name << " with discipline: " << categoryData.discipline;
|
qDebug() << "Loading category: " << categoryData.name << " with discipline: " << categoryData.discipline;
|
||||||
|
|
||||||
|
@ -337,13 +352,10 @@ void BRProviderDr::parseCompetitionData(BRCompetition::BRCompetitionData* compet
|
||||||
// check if route_names are given:
|
// check if route_names are given:
|
||||||
if(rawData.contains("route_names"))
|
if(rawData.contains("route_names"))
|
||||||
roundList = rawData["route_names"].toMap();
|
roundList = rawData["route_names"].toMap();
|
||||||
else
|
|
||||||
// if they are not -> insert Qualification
|
|
||||||
roundList.insert("-1", "Qualifikation");
|
|
||||||
|
|
||||||
// load rounds
|
// load rounds
|
||||||
for(QString roundId : roundList.keys()) {
|
for(QString roundId : roundList.keys()) {
|
||||||
if(roundId.toInt() > categoryMap["route_order"].toInt())
|
if(roundId.toInt() < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BRRound::BRRoundData roundData;
|
BRRound::BRRoundData roundData;
|
||||||
|
@ -356,9 +368,14 @@ void BRProviderDr::parseCompetitionData(BRCompetition::BRCompetitionData* compet
|
||||||
categoryData.currentRound = round;
|
categoryData.currentRound = round;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// general result
|
||||||
|
BRRound::BRRoundData generalResultRoundData;
|
||||||
|
generalResultRoundData.name = "Gesamtergebnis";
|
||||||
|
categoryData.generalResult = this->getRound(competitionData->competition->getFederation(), -1, generalResultRoundData, true);
|
||||||
|
|
||||||
// set default round if it was not restored
|
// set default round if it was not restored
|
||||||
if(categoryData.currentRound == nullptr && categoryData.rounds.length() > 0)
|
if(categoryData.currentRound == nullptr)
|
||||||
categoryData.currentRound = categoryData.rounds[0];
|
categoryData.currentRound = categoryData.generalResult;
|
||||||
|
|
||||||
BRCategory* category = this->getCategory(federation, categoryId, categoryData);
|
BRCategory* category = this->getCategory(federation, categoryId, categoryData);
|
||||||
competitionData->categories.append(category);
|
competitionData->categories.append(category);
|
||||||
|
@ -367,37 +384,21 @@ void BRProviderDr::parseCompetitionData(BRCompetition::BRCompetitionData* compet
|
||||||
if(category->getId() == rawData["GrpId"]) {
|
if(category->getId() == rawData["GrpId"]) {
|
||||||
competitionData->currentCategory = category;
|
competitionData->currentCategory = category;
|
||||||
|
|
||||||
|
// if we have a currentRound or a general result
|
||||||
if(categoryData.currentRound != nullptr) {
|
if(categoryData.currentRound != nullptr) {
|
||||||
|
qDebug() << "-- Current Round is: " << categoryData.currentRound->getName() << " with id: " << categoryData.currentRound->getId();
|
||||||
BRRound::BRRoundData roundData = categoryData.currentRound->getData();
|
BRRound::BRRoundData roundData = categoryData.currentRound->getData();
|
||||||
roundData.results = {};
|
this->parseRoundData(&roundData, rawData);
|
||||||
// load results
|
|
||||||
QVariantList resultList = rawData["participants"].toList();
|
|
||||||
for(QVariant resultVar : resultList) {
|
|
||||||
QVariantMap resultMap = resultVar.toMap();
|
|
||||||
// load athlete
|
|
||||||
BRAthlete::BRAthleteData athleteData;
|
|
||||||
// TODO: start number
|
|
||||||
athleteData.firstName = resultMap["firstname"].toString();
|
|
||||||
athleteData.lastName = resultMap["lastname"].toString();
|
|
||||||
athleteData.federation = resultMap["federation"].toString();
|
|
||||||
athleteData.federationUrl = resultMap["fed_url"].toUrl();
|
|
||||||
athleteData.nation = resultMap["nation"].toString();
|
|
||||||
athleteData.city = resultMap["city"].toString();
|
|
||||||
athleteData.yearOfBirth = resultMap["birthyear"].toInt();
|
|
||||||
qDebug() << "--- Adding athlete: " << athleteData.firstName << " " << athleteData.lastName;
|
|
||||||
|
|
||||||
BRAthlete* athlete = this->getAthlete(BRWidget::IFSC, resultMap["athlete_id"].toInt(), athleteData);
|
|
||||||
|
|
||||||
// load result
|
|
||||||
QString resultNumber = categoryData.currentRound->getId() < 0 ? "":QString::number(categoryData.currentRound->getId());
|
|
||||||
BRResult::BRResultData resultData;
|
|
||||||
resultData.rank = resultMap["result_rank"].toInt();
|
|
||||||
resultData.athlete = athlete;
|
|
||||||
BRResult* result = this->getResult(federation, -1, resultData);
|
|
||||||
roundData.results.append(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setRoundData(categoryData.currentRound, roundData);
|
this->setRoundData(categoryData.currentRound, roundData);
|
||||||
|
|
||||||
|
// if we have a general result -> load all other round results
|
||||||
|
if(categoryData.currentRound->isGeneralResult()) {
|
||||||
|
for(BRRound* round : categoryData.rounds) {
|
||||||
|
BRRound::BRRoundData roundData = round->getData();
|
||||||
|
this->parseRoundData(&roundData, rawData, QString::number(round->getId()));
|
||||||
|
this->setRoundData(round, roundData);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,6 +442,7 @@ BRCategory::BRCategoryData BRProviderDr::parseCategoryData(QVariantMap rawData)
|
||||||
|
|
||||||
data.name = rawData["name"].toString();
|
data.name = rawData["name"].toString();
|
||||||
data.currentRound = nullptr;
|
data.currentRound = nullptr;
|
||||||
|
data.generalResult = nullptr;
|
||||||
|
|
||||||
QMap<int, BRCategory::BRCategoryStatus> statusTranslations = {
|
QMap<int, BRCategory::BRCategoryStatus> statusTranslations = {
|
||||||
{4, BRCategory::Registration},
|
{4, BRCategory::Registration},
|
||||||
|
@ -477,3 +479,51 @@ void BRProviderDr::parseCategoryData(BRCategory::BRCategoryData* categoryData, Q
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BRProviderDr::parseRoundData(BRRound::BRRoundData* roundData, QVariantMap rawData, QString resultKeyAttachment) {
|
||||||
|
roundData->results = {};
|
||||||
|
// load results
|
||||||
|
QVariantList resultList = rawData["participants"].toList();
|
||||||
|
for(QVariant resultVar : resultList) {
|
||||||
|
QVariantMap resultMap = resultVar.toMap();
|
||||||
|
// load athlete
|
||||||
|
BRAthlete* athlete = this->getAthlete(roundData->round->getFederation(), resultMap["PerId"].toInt(), this->parseAthletedata(resultMap));
|
||||||
|
|
||||||
|
// load result
|
||||||
|
// TODO: start number
|
||||||
|
BRResult::BRResultData resultData;
|
||||||
|
resultData.startNumber = resultMap["start_number"].toInt();
|
||||||
|
resultData.athlete = athlete;
|
||||||
|
resultData.rank = resultMap["result_rank" + resultKeyAttachment].toInt();
|
||||||
|
resultData.details = nullptr;
|
||||||
|
|
||||||
|
// load details:
|
||||||
|
// - check if we have a general result
|
||||||
|
if(roundData->round->isGeneralResult())
|
||||||
|
resultData.details = new BRResultDetailsGeneralResult();
|
||||||
|
else
|
||||||
|
resultData.details = new BRResultDetailsUnknown(resultMap["result" + resultKeyAttachment].toString());
|
||||||
|
|
||||||
|
BRResult* result = this->getResult(resultData);
|
||||||
|
roundData->results.append(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BRAthlete::BRAthleteData BRProviderDr::parseAthletedata(QVariantMap rawData) {
|
||||||
|
BRAthlete::BRAthleteData data;
|
||||||
|
|
||||||
|
data.firstName = rawData["firstname"].toString();
|
||||||
|
data.lastName = rawData["lastname"].toString();
|
||||||
|
data.federation = rawData["federation"].toString();
|
||||||
|
data.federationUrl = rawData["fed_url"].toUrl();
|
||||||
|
data.nation = rawData["nation"].toString();
|
||||||
|
data.city = rawData["city"].toString();
|
||||||
|
data.yearOfBirth = rawData["birthyear"].toInt();
|
||||||
|
qDebug() << "--- Parsing athlete: " << data.firstName << " " << data.lastName;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRResult::BRResultData BRProviderDr::parseResultData(QVariantMap rawData) {
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
#include "headers/brprovidervl.h"
|
#include "brprovidervl.h"
|
||||||
|
|
||||||
BRProviderVl::BRProviderVl(QObject *parent) : BRProvider(parent)
|
BRProviderVl::BRProviderVl(QObject *parent) : BRProvider(parent)
|
||||||
{
|
{
|
||||||
|
@ -165,8 +165,9 @@ BRWidget::BRWidgetStatusCode BRProviderVl::getWidgetData(BRCompetition::BRCompet
|
||||||
|
|
||||||
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
QVariantMap data = QJsonDocument::fromJson(ret["text"].toString().toUtf8()).toVariant().toMap();
|
||||||
|
|
||||||
|
// TODO: reload all rounds, as they may change!
|
||||||
|
// (load category instead of competition)
|
||||||
this->parseRoundData(&roundData, data);
|
this->parseRoundData(&roundData, data);
|
||||||
|
|
||||||
this->setRoundData(currentRound, roundData);
|
this->setRoundData(currentRound, roundData);
|
||||||
|
|
||||||
return BRWidget::Success;
|
return BRWidget::Success;
|
||||||
|
@ -186,7 +187,7 @@ BRCompetition::BRCompetitionData BRProviderVl::parseCompetitionData(QVariantMap
|
||||||
for(int i = 0; i < 2; i++) {
|
for(int i = 0; i < 2; i++) {
|
||||||
QString infosheetName = QStringList({"infosheet_url", "additional_info_url"})[i];
|
QString infosheetName = QStringList({"infosheet_url", "additional_info_url"})[i];
|
||||||
if(rawData.contains(infosheetName) && !rawData[infosheetName].isNull()) {
|
if(rawData.contains(infosheetName) && !rawData[infosheetName].isNull()) {
|
||||||
data.infosheetUrls.append(rawData[infosheetName].toString());
|
data.infosheetUrls.append("https://ifsc.results.info" + rawData[infosheetName].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +246,6 @@ BRCup::BRCupData BRProviderVl::parseCupData(QVariantMap rawData, QVariantList gl
|
||||||
|
|
||||||
|
|
||||||
BRCategory::BRCategoryData BRProviderVl::parseCategoryData(QVariantMap rawData) {
|
BRCategory::BRCategoryData BRProviderVl::parseCategoryData(QVariantMap rawData) {
|
||||||
// TODO: status
|
|
||||||
BRCategory::BRCategoryData data;
|
BRCategory::BRCategoryData data;
|
||||||
|
|
||||||
data.name = rawData["name"].toString();
|
data.name = rawData["name"].toString();
|
||||||
|
@ -280,10 +280,14 @@ BRCategory::BRCategoryData BRProviderVl::parseCategoryData(QVariantMap rawData)
|
||||||
|
|
||||||
data.currentRound = nullptr;
|
data.currentRound = nullptr;
|
||||||
|
|
||||||
|
BRRound::BRRoundData roundData;
|
||||||
|
roundData.name = "General result";
|
||||||
|
qDebug() << "--- Adding round: " << roundData.name;
|
||||||
|
data.generalResult = this->getRound(BRWidget::IFSC, -1, roundData, true);
|
||||||
|
|
||||||
// load rounds
|
// load rounds
|
||||||
QVariantList roundsList = rawData["category_rounds"].toList();
|
QVariantList roundsList = rawData["category_rounds"].toList();
|
||||||
// insert general result
|
// insert general result
|
||||||
roundsList.insert(0, QVariantMap({{"name", "General result"}, {"category_round_id", -1}}));
|
|
||||||
for(QVariant roundVar : roundsList) {
|
for(QVariant roundVar : roundsList) {
|
||||||
QVariantMap roundMap = roundVar.toMap();
|
QVariantMap roundMap = roundVar.toMap();
|
||||||
|
|
||||||
|
@ -294,12 +298,12 @@ BRCategory::BRCategoryData BRProviderVl::parseCategoryData(QVariantMap rawData)
|
||||||
data.rounds.append(round);
|
data.rounds.append(round);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.currentRound = data.rounds[0];
|
data.currentRound = data.generalResult;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BRProviderVl::parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData) {
|
/*void BRProviderVl::parseCategoryData(BRCategory::BRCategoryData* categoryData, QVariantMap rawData) {
|
||||||
|
|
||||||
// no need to load rounds, they were already loaded when the whole competition was loaded!
|
// no need to load rounds, they were already loaded when the whole competition was loaded!
|
||||||
|
|
||||||
|
@ -327,7 +331,7 @@ void BRProviderVl::parseCategoryData(BRCategory::BRCategoryData* categoryData, Q
|
||||||
BRResult::BRResultData resultData;
|
BRResult::BRResultData resultData;
|
||||||
resultData.rank = resultMap["rank"].toInt();
|
resultData.rank = resultMap["rank"].toInt();
|
||||||
resultData.athlete = tmpAthletes[athleteId];
|
resultData.athlete = tmpAthletes[athleteId];
|
||||||
BRResult* result = this->getResult(BRWidget::IFSC, -1, resultData);
|
BRResult* result = this->getResult(resultData);
|
||||||
roundData.results.append(result);
|
roundData.results.append(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,9 +339,7 @@ void BRProviderVl::parseCategoryData(BRCategory::BRCategoryData* categoryData, Q
|
||||||
qDebug() << "General result round: " << generalResultRound;
|
qDebug() << "General result round: " << generalResultRound;
|
||||||
categoryData->rounds.insert(0, generalResultRound);
|
categoryData->rounds.insert(0, generalResultRound);
|
||||||
categoryData->currentRound = generalResultRound;
|
categoryData->currentRound = generalResultRound;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BRRound::BRRoundData BRProviderVl::parseRoundData(QVariantMap rawData) {
|
BRRound::BRRoundData BRProviderVl::parseRoundData(QVariantMap rawData) {
|
||||||
BRRound::BRRoundData data;
|
BRRound::BRRoundData data;
|
||||||
|
@ -350,12 +352,29 @@ void BRProviderVl::parseRoundData(BRRound::BRRoundData* roundData, QVariantMap r
|
||||||
// TODO status
|
// TODO status
|
||||||
|
|
||||||
// clear up
|
// clear up
|
||||||
for(BRResult* result : roundData->results)
|
qDebug() << "clearing";
|
||||||
result->deleteLater();
|
QList<BRRound*> clearRounds;
|
||||||
|
clearRounds.append(roundData->round);
|
||||||
|
|
||||||
|
if(roundData->round->isGeneralResult()) {
|
||||||
|
// if we are parsing a general result -> clear all rounds
|
||||||
|
clearRounds.append(roundData->round->getCategory()->getRounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
for(BRRound* round : clearRounds) {
|
||||||
|
for(BRResult* result : round->getResults())
|
||||||
|
result->deleteLater();
|
||||||
|
|
||||||
|
BRRound::BRRoundData roundData = round->getData();
|
||||||
|
roundData.results.clear();
|
||||||
|
this->setRoundData(round, roundData);
|
||||||
|
}
|
||||||
|
|
||||||
roundData->results.clear();
|
roundData->results.clear();
|
||||||
|
qDebug() << "finished clearing";
|
||||||
|
|
||||||
// parse RankingQVariantList resultList = rawData["ranking"].toList();
|
|
||||||
|
// parse Ranking
|
||||||
QVariantList resultList = rawData["ranking"].toList();
|
QVariantList resultList = rawData["ranking"].toList();
|
||||||
for(QVariant resultVar : resultList) {
|
for(QVariant resultVar : resultList) {
|
||||||
QVariantMap resultMap = resultVar.toMap();
|
QVariantMap resultMap = resultVar.toMap();
|
||||||
|
@ -376,8 +395,36 @@ void BRProviderVl::parseRoundData(BRRound::BRRoundData* roundData, QVariantMap r
|
||||||
BRResult::BRResultData resultData;
|
BRResult::BRResultData resultData;
|
||||||
resultData.rank = resultMap["rank"].toInt();
|
resultData.rank = resultMap["rank"].toInt();
|
||||||
resultData.athlete = athlete;
|
resultData.athlete = athlete;
|
||||||
BRResult* result = this->getResult(BRWidget::IFSC, -1, resultData);
|
|
||||||
|
// if this is the general result -> parse all other rounds as well
|
||||||
|
if(roundData->round->isGeneralResult()) {
|
||||||
|
qDebug() << "THIS is general result!!";
|
||||||
|
resultData.details = new BRResultDetailsGeneralResult();
|
||||||
|
|
||||||
|
// add results of other rounds
|
||||||
|
for(QVariant subRoundVar : resultMap["rounds"].toList()) {
|
||||||
|
QVariantMap subRoundMap = subRoundVar.toMap();
|
||||||
|
for(BRRound* subRound : roundData->round->getCategory()->getRounds(false)) {
|
||||||
|
if(subRound->getId() == subRoundMap["category_round_id"].toInt()) {
|
||||||
|
BRResult::BRResultData subResultData;
|
||||||
|
subResultData.rank = subRoundMap["rank"].toInt();
|
||||||
|
subResultData.athlete = athlete;
|
||||||
|
subResultData.details = new BRResultDetailsUnknown(subRoundMap["score"].toString());
|
||||||
|
|
||||||
|
|
||||||
|
qDebug() << "Adding subResult: rank: " << resultMap["rank"];
|
||||||
|
|
||||||
|
BRRound::BRRoundData subRoundData = subRound->getData();
|
||||||
|
subRoundData.results.append(this->getResult(subResultData));
|
||||||
|
this->setRoundData(subRound, subRoundData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resultData.details = new BRResultDetailsUnknown(resultMap["score"].toString());
|
||||||
|
|
||||||
|
BRResult* result = this->getResult(resultData);
|
||||||
roundData->results.append(result);
|
roundData->results.append(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue