From 47ed16926ac86295000a51fe1360a0ff9e21d84a Mon Sep 17 00:00:00 2001 From: Arseniy-Movshev Date: Sat, 11 Mar 2023 00:45:44 +0000 Subject: Step counter: reset every 24 hours, and load offsets from the log file when initialising. - This is quite crude - Firstly, we assume that the last record in the file is chronologically the last. This needs more consideration. - we do check if we're on a fresh boot, but we just give up completely if it's not a fresh boot, which may work, but needs testing to figure out how it actually works in practice --- logger.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'logger.cpp') diff --git a/logger.cpp b/logger.cpp index 74b3d59..641987f 100644 --- a/logger.cpp +++ b/logger.cpp @@ -63,3 +63,22 @@ void writeReadingToFile(QString data, QString filename) { out << data; file.close(); } + +QString getLineFromFile(int lineNumber, QString filename) { + QFile file(filename); + if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { + qDebug() << "failed to open file"; + return "0 : 0"; + } + QTextStream inStream(&file); + QString line; + int i; + while(!inStream.atEnd() & (i < lineNumber | i < 0)) + { + line = inStream.readLine(); + qDebug() << line; + i++; + } + file.close(); + return line; +} -- cgit v1.2.3-54-g00ecf