diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-03-11 00:45:44 +0000 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-03-11 09:16:47 +0000 |
commit | 47ed16926ac86295000a51fe1360a0ff9e21d84a (patch) | |
tree | 12ce59d143cf01c83695c3e48cf76fb5b04103b2 /logger.cpp | |
parent | 222f776d9f9d1f362038d26f835c96918a7af5fe (diff) |
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
Diffstat (limited to 'logger.cpp')
-rw-r--r-- | logger.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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; +} |