Added new graphs
[harbour-pedalo.git] / src / journeymodel.h
1 #ifndef JOURNEYMODEL_H
2 #define JOURNEYMODEL_H
3
4 #include <QAbstractListModel>
5 #include <QStringList>
6 #include <QFile>
7
8 #include "journey.h"
9
10 class JourneyModel : public QAbstractListModel
11 {
12 Q_OBJECT
13 public:
14 enum JourneyRoles {
15 StartRole = Qt::UserRole + 1,
16 DurationRole,
17 OvertookRole,
18 OvertakenByRole
19 };
20
21 QHash<int, QByteArray> roleNames() const;
22
23 JourneyModel(QObject *parent = 0);
24
25 void addJourney(const Journey &journey);
26 Q_INVOKABLE void addJourney(QDateTime start, quint32 duration, quint32 overtook, quint32 overtakenby);
27 Q_INVOKABLE void editJourney(quint32 index, QDateTime start, quint32 duration, quint32 overtook, quint32 overtakenby);
28 Q_INVOKABLE void deleteJourney(quint32 index);
29
30 int rowCount(const QModelIndex & parent = QModelIndex()) const;
31
32 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
33
34 void clear();
35
36 void exportToFile(QFile & file);
37 void importFromFile(QFile & file);
38
39 Q_INVOKABLE static QDate epochToDate(quint64 epoch);
40 Q_INVOKABLE static QTime epochToTime(quint64 epoch);
41 Q_INVOKABLE static QDateTime epochToDateTime(quint64 epoch);
42
43 QList<Journey> const & getData() const;
44
45 void sort(int column, Qt::SortOrder order);
46 signals:
47 // General signals
48 void journeysChanged();
49
50 private:
51 QHash<int, QByteArray> roles;
52 QList<Journey> journeys;
53 };
54
55 #endif // JOURNEYMODEL_H