Asynchronous updating for remote info in SettingsDlg
[irwi] / src / remote.h
1 #ifndef REMOTE_H
2 #define REMOTE_H
3
4 #include <QObject>
5 #include <QString>
6 #include <QSettings>
7
8 #include "rating.h"
9
10 class QNetworkReply;
11 class QNetworkAccessManager;
12
13 class Remote : public QObject
14 {
15     Q_OBJECT
16
17 public:
18     Remote();
19     Remote(const QString &name, const QString &mfg = "",
20             int rating = 0, int voteCount = 0);
21     Remote(const Remote &);
22     Remote &operator=(const Remote &);
23     bool operator==(const Remote &other) const;
24     ~Remote();
25
26     //getters
27     QString name()  const { return m_name; }
28     QString mfg()   const { return m_mfg; }
29     int rating()    const { return m_rating; }
30     int voteCount() const { return m_voteCount; }
31
32 public slots:
33     void saveToFile();
34     void updateInfo();
35     void sendRating(Rating::Rating);
36
37 private slots:
38     void remoteDownloadFinished(QNetworkReply *reply);
39     void infoRequestFinished(QNetworkReply *reply);
40
41 signals:
42     void infoUpdated();
43     void saveFinished();
44
45 private:
46     QString m_name;
47     QString m_mfg;
48     int m_rating;
49     int m_voteCount;
50
51     QNetworkAccessManager *m_infoNAM;
52     QNetworkAccessManager *m_remoteNAM;
53     QNetworkAccessManager *m_ratingNAM;
54 };
55
56 #endif
57