itat_challenge/src/model/Competitor.h

53 lines
1.2 KiB
C
Raw Normal View History

2024-08-12 22:09:50 +02:00
#pragma once
2024-08-12 22:09:50 +02:00
#include <QString>
#include <QMap>
#include <QJsonObject>
#include <QObject>
2024-08-16 15:39:05 +02:00
#include <qqml.h>
2024-08-12 22:09:50 +02:00
using namespace std;
class Competitor : public QObject {
2024-08-12 22:09:50 +02:00
2024-08-15 19:21:02 +02:00
Q_OBJECT
Q_PROPERTY(int code READ code NOTIFY nCode)
Q_PROPERTY(QString name READ name NOTIFY nName)
Q_PROPERTY(QString noc READ noc NOTIFY nNoc)
2024-08-15 19:21:02 +02:00
2024-08-12 22:09:50 +02:00
public:
2024-08-16 15:39:05 +02:00
explicit Competitor(QObject *parent) : QObject(parent) {}
2024-08-15 19:21:02 +02:00
int getCode() { return this->m_code; }
QString getName() { return this->m_name; }
QString getNOC() { return this->m_noc; }
2024-08-12 22:09:50 +02:00
void setCode(int code) { this->m_code = code; }
void setName(QString name) { this->m_name = name; }
void setNOC(QString noc) { this->m_noc = noc; }
2024-08-12 22:09:50 +02:00
bool setCompetitor(const QJsonObject &competitor);
2024-08-16 15:39:05 +02:00
bool setCompetitor(const Competitor &competitor);
2024-08-12 22:09:50 +02:00
static bool compareName(const Competitor &left, const Competitor &right) {
return left.m_name.compare(right.m_name) < 0;
}
static bool compareNOC(const Competitor &left, const Competitor &right) {
return left.m_noc.compare(right.m_noc) < 0;
}
signals:
void nCode();
void nName();
void nNoc();
2024-08-12 22:09:50 +02:00
private:
int m_code;
QString m_name;
QString m_noc;
2024-08-12 22:09:50 +02:00
};