forked from shervinkh/sgu-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
competitiondetail.cpp
66 lines (52 loc) · 2.09 KB
/
competitiondetail.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
#include "competitiondetail.h"
#include "accountmanager.h"
#include <QtGui>
CompetitionDetail::CompetitionDetail(AccountManager *am, const CompetitionInfo &inf, const QString &summary,
QWidget *parent) :
QDialog(parent)
{
AccountProcessor ap = am->infoOf(inf.target());
isVal = ap.isValid();
if (isVal)
{
info = new QLabel(tr("<h2>Details about competition</h2>"));
target = new QLabel(tr("<strong>Target:</strong> %1").arg("<font color=darkGreen>" + ap.name() + "</font>"));
compto = new QLabel(tr("<strong>Compared</strong> To: %1").arg("<font color=blue>" + am->ownInfo().name() + "</font>"));
hb = new QHBoxLayout;
hb->addWidget(target);
hb->addStretch();
hb->addWidget(compto);
summ = new QLabel(tr("<strong>Summary:</strong> %1").arg(summary));
if (inf.type() == MoreAc || inf.type() == NearAc)
{
fir = new QLabel(tr("<strong>Your accepts:</strong> %1").arg(QString::number(am->ownInfo().numAccepts())));
sec = new QLabel(tr("<strong>Target's accepts:</strong> %1").arg(QString::number(ap.numAccepts())));
}
else
{
fir = new QLabel(tr("<strong>Those problems are:</strong>"));
if (inf.type() == DiffAc)
sec = new QLabel("<font color=red>" + toStr(ap.acceptedProblems()-am->ownInfo().acceptedProblems()) + "</font>");
else
sec = new QLabel("<font color=red>" + toStr(am->submitsOf(inf.target())-am->ownInfo().acceptedProblems()) + "</font>");
sec->setWordWrap(true);
}
lay = new QVBoxLayout;
lay->addWidget(info);
lay->addLayout(hb);
lay->addWidget(summ);
lay->addWidget(fir);
lay->addWidget(sec);
setLayout(lay);
setWindowTitle(tr("Competition Details"));
}
}
QString CompetitionDetail::toStr(const QSet<int> &in) const
{
QString res;
QList<int> kop = QList<int>::fromSet(in);
qSort(kop);
foreach (int i, kop)
res += QString::number(i)+" ";
return res;
}