-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleaderboardslot.cpp
45 lines (37 loc) · 1.09 KB
/
leaderboardslot.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
#include "leaderboardslot.h"
#include "leaderboard.h"
#include <QtDebug>
LeaderboardSlot::LeaderboardSlot(Leaderboard *lb, HeroStats *hS)
: gridLayout(lb->getLayout())
{
int row = gridLayout->rowCount();
QLabel * lPlace = new QLabel(QString::number(row));
gridLayout->addWidget(lPlace, row, 0);
gridLayout->addWidget(lName, row, 1);
gridLayout->addWidget(lKills, row, 2);
gridLayout->addWidget(lDeaths, row, 3);
if (hS)
setHeroStats(hS);
connect(this, SIGNAL(changed()), lb, SLOT(update()));
}
void LeaderboardSlot::setHeroStats(HeroStats *hS)
{
if (heroStats != hS)
{
heroStats = hS;
heroStats->setSlot(this);
lName->setText(heroStats->getName());
lKills->setText(QString::number(heroStats->getKills()));
lDeaths->setText(QString::number(heroStats->getDeaths()));
}
}
void LeaderboardSlot::updateKills()
{
lKills->setText(QString::number(heroStats->getKills()));
emit changed();
}
void LeaderboardSlot::updateDeaths()
{
lDeaths->setText(QString::number(heroStats->getDeaths()));
emit changed();
}