- changed checkbox name to "Sound Notifications"
[buliscores] / src / src / match.cpp
1 #include "match.h"
2
3 Match::Match(QString hometeam, QString awayteam, QDateTime date, QObject *parent) :
4     QObject(parent)
5 {
6     m_date = date;
7     m_lastevent = QDateTime::currentDateTime();
8
9     m_homeTeam = hometeam;
10     m_awayTeam = awayteam;
11     m_homeScore = -1;
12     m_awayScore = -1;
13
14     m_homeEmblem = getEmblemByName(hometeam);
15     m_awayEmblem = getEmblemByName(awayteam);
16 }
17
18
19 // TODO write team class that allows more attributes
20 // and aliases for team names
21 QIcon Match::getEmblemByName(QString team)
22 {
23     QIcon i;
24
25     if (team == "Hannover 96") {
26         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Hannover.png");
27     } else if (team == "FC St. Pauli") {
28         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/St.Pauli.png");
29     } else if (team == "Hamburger SV") {
30         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Hamburg.png");
31     } else if (team == "1. FC Kaiserslautern") {
32         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Kaiserslautern.png");
33     } else if (team == "1. FSV Mainz 05") {
34         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Mainz.png");
35     } else if (team == "1899 Hoffenheim") {
36         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Hoffenheim.png");
37     } else if (team == "Borussia M'gladbach") {
38         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Moenchengladbach.png");
39     } else if (team == "VfL Wolfsburg") {
40         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Wolfsburg.png");
41     } else if (team == "SC Freiburg") {
42         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Freiburg.png");
43     } else if (team == "1. FC Köln") {
44         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Koeln.png");
45     } else if (team == "1. FC Nürnberg") {
46         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Nuernberg.png");
47     } else if (team == "FC Schalke 04") {
48         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Schalke.png");
49     } else if (team == "VfB Stuttgart") {
50         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Stuttgart.png");
51     } else if (team == "Eintracht Frankfurt") {
52         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Frankfurt.png");
53     } else if (team == "Bayer Leverkusen") {
54         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Leverkusen.png");
55     } else if (team == "Werder Bremen") {
56         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Bremen.png");
57     } else if (team == "Borussia Dortmund") {
58         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Dortmund.png");
59     } else if (team == "Bayern München") {
60         i = QIcon(":/1.Bundesliga/images/teams/Bundesliga1/Bayern.png");
61
62         // 2. Bundesliga
63
64     } else if (team == "Arminia Bielefeld") {
65         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Bielefeld.png");
66     } else if (team == "SpVgg Greuther Fürth") {
67         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/GreutherFuerth.png");
68     } else if (team == "FSV Frankfurt") {
69         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Frankfurt.png");
70     } else if (team == "Hertha BSC") {
71         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/HerthaBerlin.png");
72     } else if (team == "Karlsruher SC") {
73         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Karlsruhe.png");
74     } else if (team == "Energie Cottbus") {
75         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Cottbus.png");
76     } else if (team == "Alemannia Aachen") {
77         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Aachen.png");
78     } else if (team == "Rot-Weiß Oberhausen") {
79         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Oberhausen.png");
80     } else if (team == "Fortuna Düsseldorf") {
81         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Duesseldorf.png");
82     } else if (team == "1. FC Union Berlin") {
83         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/UnionBerlin.png");
84     } else if (team == "Erzgebirge Aue") {
85         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Aue.png");
86     } else if (team == "SC Paderborn 07") {
87         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Paderborn.png");
88     } else if (team == "FC Ingolstadt 04") {
89         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Ingolstadt.png");
90     } else if (team == "1860 München") {
91         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Muenchen.png");
92     } else if (team == "VfL Bochum") {
93         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Bochum.png");
94     } else if (team == "VfL Osnabrück") {
95         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Osnabrueck.png");
96     } else if (team == "FC Augsburg") {
97         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Augsburg.png");
98     } else if (team == "MSV Duisburg") {
99         i = QIcon(":/2.Bundesliga/images/teams/Bundesliga2/Duisburg.png");
100
101         // tipp3Liga
102
103     } else if (team == "Sturm Graz") {
104         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/Graz.png");
105     } else if (team == "Austria Wien") {
106         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/AustriaWien.png");
107     } else if (team == "SV Mattersburg") {
108         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/Mattersburg.png");
109     } else if (team == "RB Salzburg") {
110         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/Salzburg.png");
111     } else if (team == "LASK Linz") {
112         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/Linz.png");
113     } else if (team == "Rapid Wien") {
114         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/RapidWien.png");
115     } else if (team == "SV Ried") {
116         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/Ried.png");
117     } else if (team == "Kapfenberger SV") {
118         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/Kapfenberg.png");
119     } else if (team == "Wacker Innsbruck") {
120         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/Innsbruck.png");
121     } else if (team == "SC Wiener Neustadt") {
122         i = QIcon(":/tipp3Liga/images/teams/tipp3Liga/WienerNeustadt.gif");
123     } else {
124
125
126         i = QIcon();
127     }
128
129     return i;
130 }
131
132 void Match::setScore(int home, int away, bool notifyWatchers)
133 {
134     bool changed = false;
135     int oldhomescore = m_homeScore;
136     int oldawayscore = m_awayScore;
137
138     if (m_homeScore != home) {
139         m_homeScore = home;
140         changed = true;
141     }
142
143     if (m_awayScore != away) {
144         m_awayScore = away;
145         changed = true;
146     }
147
148     if (changed) {
149         m_lastevent = QDateTime::currentDateTime();
150         if(notifyWatchers) {
151             emit scoreChanged(oldhomescore, oldawayscore,
152                               home, away);
153         }
154     }
155 }
156
157 void Match::setState(MatchState state, bool notifyWatchers) {
158     if (m_state != state) {
159         m_state = state;
160         m_lastevent = QDateTime::currentDateTime();
161         if (notifyWatchers) {
162             emit stateChanged(state);
163         }
164     }
165 }