- don't play sounds on initial update
[buliscores] / src / match.cpp
index 9850d7f..64a5f90 100644 (file)
@@ -4,6 +4,7 @@ Match::Match(QString hometeam, QString awayteam, QDateTime date, QObject *parent
     QObject(parent)
 {
     m_date = date;
+    m_lastevent = QDateTime::currentDateTime();
 
     m_homeTeam = hometeam;
     m_awayTeam = awayteam;
@@ -64,7 +65,7 @@ QIcon Match::getEmblemByName(QString team)
     return i;
 }
 
-void Match::setScore(int home, int away)
+void Match::setScore(int home, int away, bool notifyWatchers)
 {
     bool changed = false;
     int oldhomescore = m_homeScore;
@@ -81,14 +82,20 @@ void Match::setScore(int home, int away)
     }
 
     if (changed) {
-        emit scoreChanged(oldhomescore, oldawayscore,
-                          home, away);
+        m_lastevent = QDateTime::currentDateTime();
+        if(notifyWatchers) {
+            emit scoreChanged(oldhomescore, oldawayscore,
+                              home, away);
+        }
     }
 }
 
-void Match::setState(MatchState state) {
+void Match::setState(MatchState state, bool notifyWatchers) {
     if (m_state != state) {
         m_state = state;
-        emit stateChanged(state);
+        m_lastevent = QDateTime::currentDateTime();
+        if (notifyWatchers) {
+            emit stateChanged(state);
+        }
     }
 }