Corrently add, edit and list journey details
[harbour-pedalo.git] / src / status.cpp
diff --git a/src/status.cpp b/src/status.cpp
new file mode 100644 (file)
index 0000000..2aa9f7a
--- /dev/null
@@ -0,0 +1,37 @@
+#include <QDateTime>
+
+#include "status.h"
+
+Status::Status(QObject *parent) : QObject(parent),
+  cycling(false),
+  startTime(0u)
+{
+
+}
+
+bool Status::getCycling() const {
+    return cycling;
+}
+
+quint64 Status::getStartTime() const {
+    return startTime;
+}
+
+quint64 Status::getDuration() const {
+    return (QDateTime::currentMSecsSinceEpoch() - startTime) / 1000;
+}
+
+void Status::setCycling(bool value) {
+    cycling = value;
+    emit cyclingChanged(cycling);
+}
+
+void Status::setStartTime(quint64 value) {
+    startTime = value;
+    emit startTimeChanged(startTime);
+}
+
+void Status::startJourney() {
+    setCycling(true);
+    setStartTime(QDateTime::currentMSecsSinceEpoch());
+}