diff --git a/src/Athlete.cpp b/src/Athlete.cpp index 98c40e244..6bd582a0c 100644 --- a/src/Athlete.cpp +++ b/src/Athlete.cpp @@ -47,6 +47,7 @@ Athlete::Athlete(Context *context, const QDir &home) this->context = context; context->athlete = this; cyclist = home.dirName(); + isclean = false; // metric / non-metric QVariant unit = appsettings->cvalue(cyclist, GC_UNIT); diff --git a/src/Athlete.h b/src/Athlete.h index 4ac6d575b..60db62994 100644 --- a/src/Athlete.h +++ b/src/Athlete.h @@ -60,6 +60,7 @@ class Athlete : public QObject Zones *zones_; HrZones *hrzones_; void setCriticalPower(int cp); + bool isclean; QSqlDatabase db; MetricAggregator *metricDB; RideMetadata *rideMetadata_; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 9e1f6b214..6ba066376 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -146,7 +146,7 @@ QList mainwindows; // keep track of all the MainWindows we have op QDesktopWidget *desktop = NULL; MainWindow::MainWindow(const QDir &home) : - session(0), isclean(false), init(false), isfiltered(false), groupByMapper(NULL) + session(0), init(false), isfiltered(false), groupByMapper(NULL) { setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/MainWindow.h b/src/MainWindow.h index 0abeb90af..68efa6796 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -147,7 +147,6 @@ class MainWindow : public QMainWindow // state data SpecialFields specialFields; int session; - bool isclean; bool init; // we built children (i.e. didn't quit at upgrade) // global filters diff --git a/src/MetricAggregator.cpp b/src/MetricAggregator.cpp index 97c5b12dd..1f3ecffee 100644 --- a/src/MetricAggregator.cpp +++ b/src/MetricAggregator.cpp @@ -72,7 +72,7 @@ void MetricAggregator::refreshMetrics() void MetricAggregator::refreshMetrics(QDateTime forceAfterThisDate) { // only if we have established a connection to the database - if (dbaccess == NULL || context->mainWindow->isclean==true) return; + if (dbaccess == NULL || context->athlete->isclean==true) return; // first check db structure is still up to date // this is because metadata.xml may add new fields @@ -215,7 +215,7 @@ void MetricAggregator::refreshMetrics(QDateTime forceAfterThisDate) context->athlete->lucene->optimise(); #endif #endif - context->mainWindow->isclean = true; + context->athlete->isclean = true; // stop logging out << "SIGNAL DATA CHANGED: " << QDateTime::currentDateTime().toString() + "\r\n"; @@ -240,7 +240,7 @@ void MetricAggregator::addRide(RideItem*ride) } void MetricAggregator::update() { - context->mainWindow->isclean = false; + context->athlete->isclean = false; refreshMetrics(); } @@ -346,7 +346,7 @@ MetricAggregator::getAllMetricsFor(DateRange dr) QList MetricAggregator::getAllMetricsFor(QDateTime start, QDateTime end) { - if (context->mainWindow->isclean == false) refreshMetrics(); // get them up-to-date + if (context->athlete->isclean == false) refreshMetrics(); // get them up-to-date QList empty; @@ -367,7 +367,7 @@ MetricAggregator::getAllMetricsFor(QDateTime start, QDateTime end) SummaryMetrics MetricAggregator::getAllMetricsFor(QString filename) { - if (context->mainWindow->isclean == false) refreshMetrics(); // get them up-to-date + if (context->athlete->isclean == false) refreshMetrics(); // get them up-to-date SummaryMetrics results; QColor color; // ignored for now... @@ -408,7 +408,7 @@ MetricAggregator::getAllMeasuresFor(QDateTime start, QDateTime end) SummaryMetrics MetricAggregator::getRideMetrics(QString filename) { - if (context->mainWindow->isclean == false) refreshMetrics(); // get them up-to-date + if (context->athlete->isclean == false) refreshMetrics(); // get them up-to-date SummaryMetrics empty; diff --git a/src/RideImportWizard.cpp b/src/RideImportWizard.cpp index c0258a852..0bae52b68 100644 --- a/src/RideImportWizard.cpp +++ b/src/RideImportWizard.cpp @@ -700,7 +700,7 @@ RideImportWizard::abortClicked() if (label == tr("Abort")) { hide(); - context->mainWindow->isclean = false; + context->athlete->isclean = false; context->athlete->metricDB->refreshMetrics(); aborted=true; // terminated. I'll be back. return; @@ -709,7 +709,7 @@ RideImportWizard::abortClicked() if (label == tr("Finish")) { // phew. our work is done. -- lets force an update stats... hide(); - context->mainWindow->isclean = false; + context->athlete->isclean = false; context->athlete->metricDB->refreshMetrics(); done(0); return; diff --git a/src/WithingsDownload.cpp b/src/WithingsDownload.cpp index 36d30b06f..4e0f62c77 100644 --- a/src/WithingsDownload.cpp +++ b/src/WithingsDownload.cpp @@ -93,7 +93,7 @@ WithingsDownload::downloadFinished(QNetworkReply *reply) QMessageBox::information(context->mainWindow, tr("Withings Data Download"), status); if (!olderDate.isNull()) { - context->mainWindow->isclean = false; + context->athlete->isclean = false; context->athlete->metricDB->refreshMetrics(olderDate); } return;