Skip to content

Commit

Permalink
Merge pull request #2340 from Joern-R/RIW
Browse files Browse the repository at this point in the history
RideImport
  • Loading branch information
Joern-R committed Feb 16, 2017
2 parents 9c8a41d + 62730c7 commit bd62548
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Core/RideCache.cpp
Expand Up @@ -843,6 +843,17 @@ RideCache::getRide(QString filename)
return NULL; return NULL;
} }


RideItem *
RideCache::getRide(QDateTime dateTime)
{
foreach(RideItem *item, rides())
if (item->dateTime == dateTime)
return item;
return NULL;
}



QHash<QString,int> QHash<QString,int>
RideCache::getRankedValues(QString field) RideCache::getRankedValues(QString field)
{ {
Expand Down
1 change: 1 addition & 0 deletions src/Core/RideCache.h
Expand Up @@ -57,6 +57,7 @@ class RideCache : public QObject
// query the cache // query the cache
int count() const { return rides_.count(); } int count() const { return rides_.count(); }
RideItem *getRide(QString filename); RideItem *getRide(QString filename);
RideItem *getRide(QDateTime dateTime);
QList<QDateTime> getAllDates(); QList<QDateTime> getAllDates();
QStringList getAllFilenames(); QStringList getAllFilenames();


Expand Down
6 changes: 6 additions & 0 deletions src/Gui/RideImportWizard.cpp
Expand Up @@ -23,6 +23,7 @@
#include "RideItem.h" #include "RideItem.h"
#include "RideFile.h" #include "RideFile.h"
#include "RideImportWizard.h" #include "RideImportWizard.h"
#include "RideCache.h"


#include "RideAutoImportConfig.h" #include "RideAutoImportConfig.h"
#include "HelpWhatsThis.h" #include "HelpWhatsThis.h"
Expand Down Expand Up @@ -968,6 +969,11 @@ RideImportWizard::abortClicked()
// check if a ride at this point of time already exists in /activities - if yes, skip import // check if a ride at this point of time already exists in /activities - if yes, skip import
if (QFileInfo(finalActivitiesFulltarget).exists()) { tableWidget->item(i,5)->setText(tr("Error - Activity file exists")); continue; } if (QFileInfo(finalActivitiesFulltarget).exists()) { tableWidget->item(i,5)->setText(tr("Error - Activity file exists")); continue; }


// in addition, also check the RideCache for a Ride with the same point in Time in UTC, which also indicates
// that there was already a ride imported - reason is that RideCache start time is in UTC, while the file Name is in "localTime"
// which causes problems when importing the same file (for files which do not have time/date in the file name),
// while the computer has been set to a different time zone
if (context->athlete->rideCache->getRide(ridedatetime.toUTC())) { tableWidget->item(i,5)->setText(tr("Error - Activity file with same start date/time exists")); continue; };


// SAVE STEP 4 - copy the source file to "/imports" directory (if it's not taken from there as source) // SAVE STEP 4 - copy the source file to "/imports" directory (if it's not taken from there as source)
// add the date/time of the target to the source file name (for identification) // add the date/time of the target to the source file name (for identification)
Expand Down

0 comments on commit bd62548

Please sign in to comment.