Changlod update, homescreen loader dependency updated
[evehomescreen] / src / evemodel.h
1 // Copyright (C) 2010 Jaakko Kyro <jkyro@korjaussarja.net>
2 // This file is licenced under GPL, see COPYING
3 // for full licence information
4 #ifndef EVEMODEL_H
5 #define EVEMODEL_H
6
7 #include "eveaccount.h"
8 #include <QObject>
9 #include <QString>
10 #include <QNetworkAccessManager>
11 #include <QNetworkReply>
12 class EveModel : public QObject
13 {
14     Q_OBJECT
15 public:
16     explicit EveModel(QObject *parent = 0);
17     void setApiKey(QString aKey) { m_apiKey = aKey; }
18     QString apiKey() const { return m_apiKey; }
19
20     void setUserId(int aId) { m_userId = aId; }
21     int userId() const { return m_userId; }
22     QList<EveCharacter> &characters() { return m_characters; }
23
24     EveCharacter *selectedCharacter();
25     void setSelected( int index ) { m_selectedIndex = index; }
26     int selectedIndex() { return m_selectedIndex; }
27 signals:
28     void accountsReady();
29
30 public slots:
31     void fetchAccounts();
32     bool loadSettings();
33     void saveSettings();
34
35 private slots:
36     void replyReady();
37     void networkError(QNetworkReply::NetworkError);
38 private:
39     QString m_apiKey;
40     int m_userId;
41     QNetworkAccessManager mgr;
42     QNetworkReply *m_reply;
43     QList<EveCharacter> m_characters;
44     int m_selectedIndex;
45 };
46
47 #endif // EVEMODEL_H