forked from DOMjudge/DOMjura
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteam.cpp
67 lines (58 loc) · 1.82 KB
/
team.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "team.h"
#include <QJsonObject>
#include <QJsonArray>
#include "group.h"
namespace DJ
{
namespace Model
{
Team::Team(QJsonObject team, QHash<QString, Group *> groups, QObject *parent) : QObject(parent)
{
this->id = team.value("id").toString();
this->name = team.value("name").toString("UNKNOWN");
this->affilation = team.value("affilation").toString("UNKNOWN");
this->nationality = team.value("nationality").toString("UNKNOWN");
this->group = nullptr;
QJsonArray groups_ids = team.value("group_ids").toArray();
if (groups_ids.size() > 0)
{
QString groupId = groups_ids[0].toString();
if (groups.contains(groupId))
{
this->group = groups[groupId];
this->group->addTeam(this);
}
}
}
QString Team::getId()
{
return this->id;
}
QString Team::getName()
{
return this->name;
}
Group *Team::getGroup()
{
return this->group;
}
QString Team::getAffilation()
{
return this->affilation;
}
QString Team::getNationality()
{
return this->nationality;
}
QString Team::toString()
{
QString s;
s += " id = " + this->id + "\n";
s += " name = " + this->name + "\n";
s += " affilation = " + this->affilation + "\n";
s += " nationality = " + this->nationality + "\n";
s += " group = " + (this->group ? this->group->getId() + " (" + this->group->getName() + ")\n" : "NONE\n");
return s;
}
}
}