3f246b9bd0fa873567228eab6aab150aed831247
[buliscores] / src / backendkicker.h
1 #ifndef BACKENDKICKER_H
2 #define BACKENDKICKER_H
3
4 #include <QObject>
5 #include <QTimer>
6 #include <QNetworkAccessManager>
7 #include <QNetworkReply>
8
9 #include "matchdaybackend.h"
10
11 class BackendKicker : public MatchDayBackend
12 {
13     Q_OBJECT
14
15     // TODO clear matchlist on match day change!
16 public:
17     explicit BackendKicker(QObject *parent = 0);
18
19     Match*        getMatch(QString hometeam, QString awayteam, QDateTime date);
20     QList<Match*> matchList();
21
22     bool          selectLeague(QString league);
23     void          setAutomaticUpdate(bool);
24
25 signals:
26     void updateFinished(int);
27     void updateStarted(void);
28
29 public slots:
30     void update();
31
32 private:
33     QList<Match*> m_matchlist;
34     QString       m_URL;
35     QDateTime     m_lastUpdate;
36     QTimer        m_updateTimer;
37     QNetworkAccessManager* m_netaccmgr;
38     bool          m_initialUpdateDone;
39
40     static const int INTERVAL_FAST;
41
42     void parsePage (QString htmlstr);
43     void parseScore(Match* match, QString scorehtml);
44     int secsToNextGame(void);
45
46 private slots:
47     void dlndFinished(QNetworkReply *reply);
48
49
50 };
51
52 #endif // BACKENDKICKER_H