ccb4ffc17c0bb8fca55d6459a21c1948a4f85486
4 #include <QAbstractListModel>
10 class JourneyModel
: public QAbstractListModel
15 StartRole
= Qt::UserRole
+ 1,
21 QHash
<int, QByteArray
> roleNames() const;
23 JourneyModel(QObject
*parent
= 0);
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
);
30 int rowCount(const QModelIndex
& parent
= QModelIndex()) const;
32 QVariant
data(const QModelIndex
& index
, int role
= Qt::DisplayRole
) const;
36 void exportToFile(QFile
& file
);
37 void importFromFile(QFile
& file
);
39 Q_INVOKABLE
static QDate
epochToDate(quint64 epoch
);
40 Q_INVOKABLE
static QTime
epochToTime(quint64 epoch
);
41 Q_INVOKABLE
static QDateTime
epochToDateTime(quint64 epoch
);
43 QList
<Journey
> const & getData() const;
45 void sort(int column
, Qt::SortOrder order
);
48 void journeysChanged();
51 QHash
<int, QByteArray
> roles
;
52 QList
<Journey
> journeys
;
55 #endif // JOURNEYMODEL_H