Some forgotten comment...
[aspt.git] / stadiumtab.cc
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 *******************************************************************/
6
7 #include "stadiumtab.h"
8
9 /**
10  * \brief Stadium Tab constructor.
11  */
12 StadiumTab::StadiumTab(QWidget *parent) : QWidget(parent) {
13         mainLayout = new QVBoxLayout;
14         setLayout(mainLayout);
15         init();
16 }
17
18 /**
19  * \brief Stadium Tab destructor.
20  */
21 StadiumTab::~StadiumTab() {
22         delete label;
23         delete mainLayout;
24 }
25
26 /**
27  * \brief Print info about stadium from parsed data.
28  */
29 void StadiumTab::init() {
30         int cap = stadium.cap_n.toInt() + stadium.cap_e.toInt() + stadium.cap_w.toInt() + stadium.cap_s.toInt();
31         QString text;
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>";
42         text += "</td></tr>";
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>";
45         text += "</td></tr>";
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 + "&euro; (" + QString().setNum(cap) + " " + tr("attendance gives cca. ") + QString().setNum(stadium.priceLeague.toInt()*(0.9*cap)) + "&euro;)</td></tr>";
51         text += "<tr><td>" + tr("Price cup") + "</td><td>" + stadium.priceCup + "&euro; (" + QString().setNum(cap) + " " + tr("attendance gives cca. ") + QString().setNum(stadium.priceCup.toInt()*(0.9*cap)) + "&euro;)</td></tr>";
52         text += "<tr><td>" + tr("Price friendly") + "</td><td>" + stadium.priceFriendly + "&euro; (" + QString().setNum(cap/10) + " " + tr("attendance gives cca. ") + QString().setNum(stadium.priceFriendly.toInt()*(0.09*cap)) + "&euro;)</td></tr>";
53         text += "<tr><td>" + tr("Price friendly cup") + "</td><td>" + stadium.priceFriendlyCup + "&euro; (" + QString().setNum(cap/10) + " " + tr("attendance gives cca. ") + QString().setNum(stadium.priceFriendlyCup.toInt()*(0.09*cap)) + "&euro;)</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>";
58         }
59         if(stadium.wc.toInt() < ((cap+1000)*0.01)) {
60                 text += tr("You need") + "  " + QString().setNum((cap+1000)*0.01) + "  " + tr("Toilets") + "<br>";
61         }
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>";
65         }
66         label = new QLabel(text);
67         mainLayout->addWidget(label);
68         mainLayout->update();
69 }
70
71 /**
72  * \brief Slot assigned to data change action.
73  */
74 void StadiumTab::dataChanged() {
75         rebuildUI();
76 }
77
78 /**
79  * \brief Destroy current UI and draw it again.
80  */
81 void StadiumTab::rebuildUI() {
82         mainLayout->removeWidget(label);
83         delete label;
84         mainLayout->update();
85         init();
86 }