4b76cf70b5613429abd3ce3bd300bbbe78a35634
[evehomescreen] / src / eveskilltraining.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 EVESKILLTRAINING_H
5 #define EVESKILLTRAINING_H
6
7 #include <QObject>
8 #include <QDateTime>
9 #include <QString>
10 #include <QXmlStreamReader>
11 #include <QNetworkAccessManager>
12 #include <QtDebug>
13
14 class EveCharacter;
15 class EveModel;
16
17 class TrainingEntry {
18 public:
19     QDateTime startTime;
20     QDateTime endTime;
21     int typeId;
22     int startSkillpoints;
23     int destSkillpoints;
24     int level;
25 };
26
27 QDebug operator<<(QDebug, const TrainingEntry &);
28
29 class EveSkillTraining : public QObject
30 {
31     Q_OBJECT
32 public:
33     explicit EveSkillTraining(QObject *parent = 0);
34     bool fromXml(QXmlStreamReader &xml);
35     void setCharacter(EveCharacter *character) { m_character = character; }
36     void setAccount(EveModel *aModel) { m_account = aModel; }
37     bool isTraining() { return !m_trainingQueue.isEmpty(); }
38     const TrainingEntry &firstTraining() const { return m_trainingQueue.first(); }
39     const TrainingEntry &lastTraining() const { return m_trainingQueue.last(); }
40 signals:
41     void finished();
42
43 public slots:
44     void fetchInfo();
45     void infoReady();
46 public:
47     bool training;
48     QDateTime cachedUntil;
49     QDateTime currentTime;
50 private:
51     EveCharacter *m_character;
52     EveModel *m_account;
53     QNetworkAccessManager m_mgr;
54     QNetworkReply *m_reply;
55     QList<TrainingEntry> m_trainingQueue;
56 };
57
58
59
60 #endif // EVESKILLTRAINING_H