RideCache::RideCache(Context *context) : context(context) { progress_ = 100; exiting = false; // get the new zone configuration fingerprint fingerprint = static_cast<unsigned long>(context->athlete->zones()->getFingerprint()) + static_cast<unsigned long>(context->athlete->paceZones()->getFingerprint()) + static_cast<unsigned long>(context->athlete->hrZones()->getFingerprint()) + static_cast<unsigned long>(context->athlete->routes->getFingerprint()); // set the list // populate ride list RideItem *last = NULL; QStringListIterator i(RideFileFactory::instance().listRideFiles(context->athlete->home->activities())); while (i.hasNext()) { QString name = i.next(); QDateTime dt; if (RideFile::parseRideFileName(name, &dt)) { last = new RideItem(context->athlete->home->activities().canonicalPath(), name, dt, context); connect(last, SIGNAL(rideDataChanged()), this, SLOT(itemChanged())); connect(last, SIGNAL(rideMetadataChanged()), this, SLOT(itemChanged())); rides_ << last; } } // load the store - will unstale once cache restored load(); // now sort it qSort(rides_.begin(), rides_.end(), rideCacheLessThan); // set model once we have the basics model_ = new RideCacheModel(context, this); // now refresh just in case. refresh(); // do we have any stale items ? connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); // future watching connect(&watcher, SIGNAL(finished()), this, SLOT(garbageCollect())); connect(&watcher, SIGNAL(finished()), this, SLOT(save())); connect(&watcher, SIGNAL(finished()), context, SLOT(notifyRefreshEnd())); connect(&watcher, SIGNAL(started()), context, SLOT(notifyRefreshStart())); connect(&watcher, SIGNAL(progressValueChanged(int)), this, SLOT(progressing(int))); }
void RideItem::notifyRideMetadataChanged() { emit rideMetadataChanged(); }