added intermedia code that selects the corrent icons for the Kicker
[buliscores] / src / match.cpp
1 #include "match.h"
2
3 Match::Match(QString hometeam, QString awayteam, QObject *parent) :
4     QObject(parent)
5 {
6     m_hometeam = hometeam;
7     m_awayteam = awayteam;
8
9     m_awayEmblem = getEmblemByName(awayteam);
10     m_homeEmblem = getEmblemByName(hometeam);
11 }
12
13
14 // TODO write team class that allows more attributes
15 // and aliases for team names
16 QIcon Match::getEmblemByName(QString team)
17 {
18     QIcon i;
19
20     if (team == "Hannover 96") {
21         i = QIcon(":/Icons/Hannover.png");
22     } else if (team == "FC St. Pauli") {
23         i = QIcon(":/Icons/St.Pauli.png");
24     } else if (team == "Hamburger SV") {
25         i = QIcon(":/Icons/Hamburg.png");
26     } else if (team == "1. FC Kaiserslautern") {
27         i = QIcon(":/Icons/Kaiserslautern.png");
28     } else if (team == "1. FSV Mainz 05") {
29         i = QIcon(":/Icons/Mainz.png");
30     } else if (team == "1899 Hoffenheim") {
31         i = QIcon(":/Icons/Hoffenheim.png");
32     } else if (team == "Borussia M'gladbach") {
33         i = QIcon(":/Icons/Mönchengladbach.png");
34     } else if (team == "VfL Wolfsburg") {
35         i = QIcon(":/Icons/Wolfsburg.png");
36     } else if (team == "SC Freiburg") {
37         i = QIcon(":/Icons/Freiburg.png");
38     } else if (team == "1. FC Köln") {
39         i = QIcon(":/Icons/Köln.png");
40     } else if (team == "1. FC Nürnberg") {
41         i = QIcon(":/Icons/Nürnberg.png");
42     } else if (team == "FC Schalke 04") {
43         i = QIcon(":/Icons/Schalke.png");
44     } else if (team == "VfB Stuttgart") {
45         i = QIcon(":/Icons/Stuttgart.png");
46     } else if (team == "Eintracht Frankfurt") {
47         i = QIcon(":/Icons/Frankfurt.png");
48     } else if (team == "Bayer Leverkusen") {
49         i = QIcon(":/Icons/Leverkusen.png");
50     } else if (team == "Werder Bremen") {
51         i = QIcon(":/Icons/Bremen.png");
52     } else if (team == "Borussia Dortmund") {
53         i = QIcon(":/Icons/Dortmund.png");
54     } else if (team == "Bayern München") {
55         i = QIcon(":/Icons/Bayern.png");
56     } else {
57         i = QIcon();
58     }
59
60
61     return i;
62 }
63
64 void Match::setScore(int home, int away)
65 {
66     bool changed;
67
68     if (m_homescore != home) {
69         m_homescore = home;
70         changed = true;
71     }
72
73     if (m_awayscore != away) {
74         m_awayscore = away;
75         changed = true;
76     }
77
78     if (changed) {
79         emit scoreChanged(home, away);
80     }
81 }