summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseniy-Movshev <dodoradio@outlook.com>2023-05-26 01:35:39 +0100
committerArseniy-Movshev <dodoradio@outlook.com>2023-05-26 23:34:53 +0100
commitdf9b49d6123b83f0ce8239693bc1064de1a4e828 (patch)
tree4aab68851f326df632600f4489ec39ef458d266d
parentf279ddedcac3e9b77ab742c57a37bbdcbabe7a82 (diff)
steps: add more useful data fetch method
Diffstat (limited to '')
-rw-r--r--qmlplugin/stepsDataLoader.cpp8
-rw-r--r--qmlplugin/stepsDataLoader.h1
2 files changed, 7 insertions, 2 deletions
diff --git a/qmlplugin/stepsDataLoader.cpp b/qmlplugin/stepsDataLoader.cpp
index 1180f0b..9d99c79 100644
--- a/qmlplugin/stepsDataLoader.cpp
+++ b/qmlplugin/stepsDataLoader.cpp
@@ -20,9 +20,13 @@ StepsDataLoader::StepsDataLoader() : QObject()
{
}
-int StepsDataLoader::getTodayData() { // This is obvious garbage. This should really be abstracted and cached, so that every page doesn't have to reload the file from scratch.
+int StepsDataLoader::getTodayData() {
+ return getDataForDate(QDate::currentDate());
+}
+
+int StepsDataLoader::getDataForDate(QDate date) { // This is obvious garbage. This should really be abstracted and cached, so that every page doesn't have to reload the file from scratch.
// The intention is to also add graph functionality at some point. The graph will be simplifying the data before loading it in - it would be worth caching the simplified data when it comes to that as well.
- QFile file(fileNameForDate(QDate::currentDate(), "stepCounter"));
+ QFile file(fileNameForDate(date, "stepCounter"));
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
qDebug() << "failed to open file";
return 0;
diff --git a/qmlplugin/stepsDataLoader.h b/qmlplugin/stepsDataLoader.h
index 7be8bfc..4937ee9 100644
--- a/qmlplugin/stepsDataLoader.h
+++ b/qmlplugin/stepsDataLoader.h
@@ -19,6 +19,7 @@ class StepsDataLoader : public QObject
public:
explicit StepsDataLoader();
+ Q_INVOKABLE int getDataForDate(QDate date);
Q_INVOKABLE int getTodayData();
};
QString fileNameForDate(QDate date, QString prefix);