1 /*******************************************************************
2 Jan Cermak | johniez | aspt.johniez.com
3 Creative Commons 2.5 Attribution-NonCommercial-NoDerivs 2.5 license
4 http://creativecommons.org/licenses/by-nc-nd/2.5/legalcode
5 *******************************************************************/
7 #include "stadiumtab.h"
10 * \brief Stadium Tab constructor.
12 StadiumTab::StadiumTab(QWidget *parent) : QWidget(parent) {
13 mainLayout = new QVBoxLayout;
14 setLayout(mainLayout);
19 * \brief Stadium Tab destructor.
21 StadiumTab::~StadiumTab() {
27 * \brief Print info about stadium from parsed data.
29 void StadiumTab::init() {
30 int cap = stadium.cap_n.toInt() + stadium.cap_e.toInt() + stadium.cap_w.toInt() + stadium.cap_s.toInt();
32 text = "<table cellspacing=\"3\">";
33 text += "<tr><td>" + tr("Stadium") + "</td><td><span style=\"color:red;\">" + stadium.name + "</span></td></tr>";
34 text += "<tr><td>" + tr("Field condition") + "</td><td>" + stadium.field_status + "%</td></tr>";
35 text += "<tr><td></td><td></td></tr>";
36 text += "<tr><td>" + tr("Fan base") + "</td><td>" + stadium.fans + "</td></tr>";
37 text += "<tr><td>" + tr("satisfaction") + "</td><td>" + stadium.fanSatis + "%</td></tr>";
38 text += "<tr><td>" + tr("Capacity") + "</td><td><span style=\"color:red;\">" + QString().setNum(cap) + "</span></td></tr>";
39 text += "<tr><td></td><td></td></tr>";
40 text += "<tr><td>" + tr("Parking") + "</td><td>" + stadium.parking + "</td><td>(" + tr("minimal") + " " + QString().setNum((int)((float)cap/3)) + ")";
41 if(stadium.park_fu) text += " <span style=\"color:red;\">" + tr("unhappy!!") + "</span>";
43 text += "<tr><td>" + tr("Toilets") + "</td><td>" + stadium.wc + "</td><td>(" + tr("minimal") + " " + QString().setNum(cap*0.01) + ")";
44 if(stadium.wc_fu) text += " <span style=\"color:red;\">" + tr("unhappy!!") + "</span>";
46 text += "<tr><td>" + tr("Buffets") + "</td><td>" + stadium.bar + "</td><td>(" + tr("minimal") + " " + QString().setNum((int)(cap*0.0044)) + ")";
47 if(stadium.bar_fu) text += " <span style=\"color:red;\">" + tr("unhappy!!") + "</span>";
48 text += "</td></tr></table><hr>";
49 text += "<table cellspacing=\"3\">";
50 text += "<tr><td>" + tr("Price league") + "</td><td>" + stadium.priceLeague + "€ (" + QString().setNum(cap) + " " + tr("attendance gives cca. ") + QString().setNum(stadium.priceLeague.toInt()*(0.9*cap)) + "€)</td></tr>";
51 text += "<tr><td>" + tr("Price cup") + "</td><td>" + stadium.priceCup + "€ (" + QString().setNum(cap) + " " + tr("attendance gives cca. ") + QString().setNum(stadium.priceCup.toInt()*(0.9*cap)) + "€)</td></tr>";
52 text += "<tr><td>" + tr("Price friendly") + "</td><td>" + stadium.priceFriendly + "€ (" + QString().setNum(cap/10) + " " + tr("attendance gives cca. ") + QString().setNum(stadium.priceFriendly.toInt()*(0.09*cap)) + "€)</td></tr>";
53 text += "<tr><td>" + tr("Price friendly cup") + "</td><td>" + stadium.priceFriendlyCup + "€ (" + QString().setNum(cap/10) + " " + tr("attendance gives cca. ") + QString().setNum(stadium.priceFriendlyCup.toInt()*(0.09*cap)) + "€)</td></tr>";
54 text += "</table><hr>";
55 text += tr("Increasing 1000 places on stadium (calculations)") + ":<br>";
56 if(stadium.parking.toInt() < ((cap+1000)/3)) {
57 text += tr("You need") + " " + QString().setNum((int)((float)(cap+1000)/3)) + " " + tr("Parking places") + "<br>";
59 if(stadium.wc.toInt() < ((cap+1000)*0.01)) {
60 text += tr("You need") + " " + QString().setNum((cap+1000)*0.01) + " " + tr("Toilets") + "<br>";
62 // but 60 for 21000 is still ok
63 if(stadium.bar.toInt() < ((cap+1000)*0.0044)) {
64 text += tr("You need") + " " + QString().setNum((cap+1000)*0.0044) + " " + tr("Buffets") + "<br>";
66 label = new QLabel(text);
67 mainLayout->addWidget(label);
72 * \brief Slot assigned to data change action.
74 void StadiumTab::dataChanged() {
79 * \brief Destroy current UI and draw it again.
81 void StadiumTab::rebuildUI() {
82 mainLayout->removeWidget(label);