Store current journey details in persistent settings
[harbour-pedalo.git] / src / status.cpp
1 #include <QDateTime>
2
3 #include "status.h"
4
5 Status::Status(QObject *parent) : QObject(parent),
6 cycling(false),
7 startTime(0u)
8 {
9
10 }
11
12 bool Status::getCycling() const {
13 return cycling;
14 }
15
16 quint64 Status::getStartTime() const {
17 return startTime;
18 }
19
20 quint64 Status::getDuration() const {
21 return (QDateTime::currentMSecsSinceEpoch() - startTime) / 1000;
22 }
23
24 void Status::setCycling(bool value) {
25 cycling = value;
26 emit cyclingChanged(cycling);
27 }
28
29 void Status::setStartTime(quint64 value) {
30 startTime = value;
31 emit startTimeChanged(startTime);
32 }
33
34 void Status::startJourney() {
35 setCycling(true);
36 setStartTime(QDateTime::currentMSecsSinceEpoch());
37 }