From f24b4dcbd11336dabfd146c656e2437e4393b225 Mon Sep 17 00:00:00 2001 From: Steru Date: Fri, 16 Aug 2024 16:58:31 +0200 Subject: Integrated Sport class into SportModel class. --- src/model/Sport.h | 127 ------------------------------------------------------ 1 file changed, 127 deletions(-) (limited to 'src/model/Sport.h') diff --git a/src/model/Sport.h b/src/model/Sport.h index c5d1c66..e69de29 100644 --- a/src/model/Sport.h +++ b/src/model/Sport.h @@ -1,127 +0,0 @@ -#pragma once - -#include "MedalWinner.h" -#include "CompetitorWithResults.h" -#include -#include -#include -#include - -#include -#include -#include -#include -#include "EventInfo.h" - -using namespace std; - -class SportModel : public QAbstractListModel -{ - Q_OBJECT - - Q_PROPERTY(QString discipline READ discipline WRITE setDiscipline NOTIFY disciplineChanged); - -public: - enum Role - { - EventName = Qt::UserRole + 1, - Competitors - }; - - explicit SportModel(QObject *parent = nullptr); - - virtual int rowCount(const QModelIndex &parent) const override; - virtual QVariant data(const QModelIndex &index, int role) const override; - virtual QHash roleNames() const override; - - QString discipline() const; - void setDiscipline(const QString &discipline); -public slots: - void request(QString discipline); - void parseData(); - - signals: - void disciplineChanged(); - - private: - QList m_sportList; - QString m_discipline; - QNetworkAccessManager m_networkManager; - QNetworkReply *m_reply = nullptr; -}; - -class Sport -{ - -public: - Sport(QJsonObject discipline) - { - this->discipline = discipline; - } - - set getCategories(); - QList getCompetitorsByCategory(QString category); - QList getCompetitorsWithMedal(); - - // filter to change the current competitor array - void lastName(QList &competitors); - void filterByName(QList &competitors, QString name); - void filterByCountry(QList &competitors, QString nocShort); - - // sort functions to change the order of the current competitor array - void sortByName(QList &competitors); - void sortByCountry(QList &competitors); - void sortByResult(QList &competitors); - void sortByMedals(QList &competitors); - void reverseOrder(QList &competitors); - - // statistic function(s) - void addRelativeToFirst(QList &competitors); - - void setDiscipline(QJsonObject discipline) - { - this->discipline = QJsonObject(discipline); - } - -private: - /* - * Analysis of provided competitor objects: - * - * Attributes: - * - code - * - noc (national olympics comittee) - * - name (sometimes the country name? mostly the competitors name) - * - order - * [- results] (only if the results are out!) - * - * - * Analysis of provided result objects: - * - * Attributes: - * - position - * - mark - * - medalType - * - irk - * [- winnerLoserTie] (only if provided in the discipline?) - * - * Analysis of where to find the medal winners: - * - * Search for ... in category name. - * - "Bronze" - * - "Gold" - * - "Final" - * - * ! ATTENTION ! - * When searching for "Final" there might be "Final A", "Final B", etc. - * The results will only be in ONE of these categories! - * -> which is good... cause then we can count occurences. - */ - QJsonObject discipline; - - void filterCompetitors(QList &competitors, QString filter); - - bool validateDiscipline(); - QJsonObject createCompetitorWithMedals(QJsonObject medalComp); - - float calcRelativeStat(QString ref, QString val); -}; -- cgit v1.2.3