Move isclean from MainWindow to Athlete

.. rather unfortunate use of English as it leads
   to athlete->isclean == false :)
This commit is contained in:
Mark Liversedge
2013-07-12 18:15:14 +01:00
parent 6e1be4a541
commit 65182f70c1
7 changed files with 12 additions and 11 deletions

View File

@@ -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);

View File

@@ -60,6 +60,7 @@ class Athlete : public QObject
Zones *zones_;
HrZones *hrzones_;
void setCriticalPower(int cp);
bool isclean;
QSqlDatabase db;
MetricAggregator *metricDB;
RideMetadata *rideMetadata_;

View File

@@ -146,7 +146,7 @@ QList<MainWindow *> 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);

View File

@@ -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

View File

@@ -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<SummaryMetrics>
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<SummaryMetrics> 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;

View File

@@ -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;

View File

@@ -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;