summaryrefslogtreecommitdiff
path: root/src/model/Competitor.h
diff options
context:
space:
mode:
authorSteru <jerrydream111@gmail.com>2024-08-15 23:27:54 +0200
committerOrangerot <purple@orangerot.dev>2024-08-26 11:19:38 +0200
commitb6c86f02ff7ecb74cc96af61d8216b232bcecb3e (patch)
tree26def991cecebcaf8704a5194ae84d4bfe137951 /src/model/Competitor.h
parentdb2d0c21c48698d336ac6e60c42cc2533648b51d (diff)
Made Competitor a QObject and tidied up some code.
Diffstat (limited to 'src/model/Competitor.h')
-rw-r--r--src/model/Competitor.h50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/model/Competitor.h b/src/model/Competitor.h
index 51fc3b1..79552a5 100644
--- a/src/model/Competitor.h
+++ b/src/model/Competitor.h
@@ -4,11 +4,12 @@
#include <QString>
#include <QMap>
#include <QJsonObject>
-#include <QAbstractListModel>
+#include <QObject>
+
using namespace std;
-class Competitor {
+class Competitor : public QObject {
Q_OBJECT
@@ -17,42 +18,35 @@ class Competitor {
Q_PROPERTY(QString noc READ noc NOTIFY nNoc)
public:
- Competitor() {
- this->code = 0;
- this->name = "";
- this->noc = "";
- }
+ Competitor() : m_code(0), m_name(""), m_noc("") {}
+ Competitor(const Competitor &competitor) : m_code(competitor.m_code), m_name(competitor.m_name), m_noc(competitor.m_noc) {}
+ Competitor(const QJsonObject &competitor) { setCompetitor(competitor); }
- Competitor(const Competitor &competitor) {
- this->code = competitor.code;
- this->name = competitor.name;
- this->noc = competitor.noc;
- }
+ int getCode() { return this->m_code; }
+ QString getName() { return this->m_name; }
+ QString getNOC() { return this->m_noc; }
- Competitor(const QJsonObject &competitor) {
- setCompetitor(competitor);
- }
-
- int getCode() { return this->code; }
- QString getName() { return this->name; }
- QString getNOC() { return this->noc; }
-
- void setCode(int code) { this->code = code; }
- void setName(QString name) { this->name = name; }
- void setNOC(QString noc) { this->noc = noc; }
+ void setCode(int code) { this->m_code = code; }
+ void setName(QString name) { this->m_name = name; }
+ void setNOC(QString noc) { this->m_noc = noc; }
bool setCompetitor(const QJsonObject &competitor);
static bool compareName(const Competitor &left, const Competitor &right) {
- return left.name.compare(right.name) < 0;
+ return left.m_name.compare(right.m_name) < 0;
}
static bool compareNOC(const Competitor &left, const Competitor &right) {
- return left.noc.compare(right.noc) < 0;
+ return left.m_noc.compare(right.m_noc) < 0;
}
+signals:
+ void nCode();
+ void nName();
+ void nNoc();
+
private:
- int code;
- QString name;
- QString noc;
+ int m_code;
+ QString m_name;
+ QString m_noc;
};