97f027b989e8943d51fb6894ce25a637b0fbdc9a
[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 StadiumTab::StadiumTab(QWidget *parent) : QWidget(parent) {
10         mainLayout = new QVBoxLayout;
11         setLayout(mainLayout);
12         init();
13 }
14
15 StadiumTab::~StadiumTab() {
16         delete label;
17         delete mainLayout;
18 }
19
20 void StadiumTab::init() {
21         int cap = stadium.cap_n.toInt() + stadium.cap_e.toInt() + stadium.cap_w.toInt() + stadium.cap_s.toInt();
22         QString text;
23         text = "<table cellspacing=\"3\">";
24         text += "<tr><td>" + tr("Stadium") + "</td><td><span style=\"color:red;\">" + stadium.name + "</span></td></tr>";
25         text += "<tr><td>" + tr("Field condition") + "</td><td>" + stadium.field_status + "%</td></tr>";
26         text += "<tr><td></td><td></td></tr>";
27         text += "<tr><td>" + tr("Fan base") + "</td><td>" + stadium.fans + "</td></tr>";
28         text += "<tr><td>" + tr("satisfaction") + "</td><td>" + stadium.fanSatis + "%</td></tr>";
29         text += "<tr><td>" + tr("Capacity") + "</td><td><span style=\"color:red;\">" + QString().setNum(cap) + "</span></td></tr>";
30         text += "<tr><td></td><td></td></tr>";
31         text += "<tr><td>" + tr("Parking") + "</td><td>" + stadium.parking + "</td><td>(" + tr("minimal") + " " + QString().setNum((int)((float)cap/3)) + ")";
32         if(stadium.park_fu) text += " <span style=\"color:red;\">" + tr("unhappy!!") + "</span>";
33         text += "</td></tr>";
34         text += "<tr><td>" + tr("Toilets") + "</td><td>" + stadium.wc + "</td><td>(" + tr("minimal") + " " + QString().setNum(cap*0.01) + ")";
35         if(stadium.wc_fu) text += " <span style=\"color:red;\">" + tr("unhappy!!") + "</span>";
36         text += "</td></tr>";
37         text += "<tr><td>" + tr("Buffets") + "</td><td>" + stadium.bar + "</td><td>(" + tr("minimal") + " " + QString().setNum((int)(cap*0.0044)) + ")";
38         if(stadium.bar_fu) text += " <span style=\"color:red;\">" + tr("unhappy!!") + "</span>";
39         text += "</td></tr></table><hr>";
40         text += "<table cellspacing=\"3\">";
41         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>";
42         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>";
43         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>";
44         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>";
45         text += "</table><hr>";
46         text += tr("Increasing 1000 places on stadium (calculations)") + ":<br>";
47         if(stadium.parking.toInt() < ((cap+1000)/3)) {
48                 text += tr("You need") + "  " + QString().setNum((int)((float)(cap+1000)/3)) + "  " + tr("Parking places") + "<br>";
49         }
50         if(stadium.wc.toInt() < ((cap+1000)*0.01)) {
51                 text += tr("You need") + "  " + QString().setNum((cap+1000)*0.01) + "  " + tr("Toilets") + "<br>";
52         }
53         if(stadium.bar.toInt() < ((cap+1000)*0.0044)) {
54                 text += tr("You need") + "  " + QString().setNum((cap+1000)*0.0044) + "  " + tr("Buffets") + "<br>";
55         }
56         label = new QLabel(text);
57         mainLayout->addWidget(label);
58         mainLayout->update();
59 }
60
61 void StadiumTab::dataChanged() {
62         rebuildUI();
63 }
64
65 void StadiumTab::rebuildUI() {
66         mainLayout->removeWidget(label);
67         delete label;
68         mainLayout->update();
69         init();
70 }