mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Damien's patch to support CS600 Polar files.
This commit is contained in:
@@ -67,7 +67,7 @@ bool
|
||||
is_ride_filename(const QString filename)
|
||||
{
|
||||
QRegExp re("^([0-9][0-9][0-9][0-9])_([0-9][0-9])_([0-9][0-9])"
|
||||
"_([0-9][0-9])_([0-9][0-9])_([0-9][0-9])\\.(raw|srm|csv|tcx)$");
|
||||
"_([0-9][0-9])_([0-9][0-9])_([0-9][0-9])\\.(raw|srm|csv|tcx|hrm)$");
|
||||
return (re.exactMatch(filename));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,7 @@
|
||||
#define _GC_PT_D2XX_h 1
|
||||
|
||||
#include "Device.h"
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include "../ftdi/FTD2XX.H"
|
||||
#else
|
||||
#include <D2XX/ftd2xx.h>
|
||||
#endif
|
||||
#include <D2XX/ftd2xx.h>
|
||||
|
||||
class D2XX : public Device
|
||||
{
|
||||
|
||||
@@ -559,6 +559,8 @@ MainWindow::MainWindow(const QDir &home) :
|
||||
SLOT (importCSV()), tr ("Ctrl+S"));
|
||||
rideMenu->addAction(tr("&Import from TCX..."), this,
|
||||
SLOT (importTCX()));
|
||||
rideMenu->addAction(tr("&Import from Polar..."), this,
|
||||
SLOT (importPolar()));
|
||||
rideMenu->addAction(tr("Find &best intervals..."), this,
|
||||
SLOT(findBestIntervals()), tr ("Ctrl+B"));
|
||||
rideMenu->addAction(tr("Split &ride..."), this,
|
||||
@@ -963,6 +965,63 @@ MainWindow::importTCX()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::importPolar()
|
||||
{
|
||||
QVariant lastDirVar = settings.value(GC_SETTINGS_LAST_IMPORT_PATH);
|
||||
QString lastDir = (lastDirVar != QVariant())
|
||||
? lastDirVar.toString() : QDir::homePath();
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(
|
||||
this, tr("Import Polar"), lastDir,
|
||||
tr("Polar Format (*.hrm)"));
|
||||
if (!fileNames.isEmpty()) {
|
||||
lastDir = QFileInfo(fileNames.front()).absolutePath();
|
||||
settings.setValue(GC_SETTINGS_LAST_IMPORT_PATH, lastDir);
|
||||
}
|
||||
QStringList fileNamesCopy = fileNames;
|
||||
QStringListIterator i(fileNames);
|
||||
while (i.hasNext()) {
|
||||
QString fileName = i.next();
|
||||
QFile file(fileName);
|
||||
QStringList errors;
|
||||
|
||||
boost::scoped_ptr<RideFile> ride(
|
||||
RideFileFactory::instance().openRideFile(file, errors));
|
||||
|
||||
if (!ride || !errors.empty()) {
|
||||
QString all = (ride
|
||||
? tr("Non-fatal problem(s) opening %1:")
|
||||
: tr("Fatal problem(s) opening %1:")).arg(fileName);
|
||||
QStringListIterator i(errors);
|
||||
while (i.hasNext())
|
||||
all += "\n" + i.next();
|
||||
if (ride)
|
||||
QMessageBox::warning(this, tr("Open Warning"), all);
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Open Error"), all);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QChar zero = QLatin1Char('0');
|
||||
QString name = QString("%1_%2_%3_%4_%5_%6.hrm")
|
||||
.arg(ride->startTime().date().year(), 4, 10, zero)
|
||||
.arg(ride->startTime().date().month(), 2, 10, zero)
|
||||
.arg(ride->startTime().date().day(), 2, 10, zero)
|
||||
.arg(ride->startTime().time().hour(), 2, 10, zero)
|
||||
.arg(ride->startTime().time().minute(), 2, 10, zero)
|
||||
.arg(ride->startTime().time().second(), 2, 10, zero);
|
||||
|
||||
if (!file.copy(home.absolutePath() + "/" + name)) {
|
||||
QMessageBox::critical(this, tr("Copy Error"),
|
||||
tr("Couldn't copy %1").arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
addRide(name);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::findBestIntervals()
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@ class MainWindow : public QMainWindow
|
||||
void importCSV();
|
||||
void importSRM();
|
||||
void importTCX();
|
||||
void importPolar();
|
||||
void findBestIntervals();
|
||||
void splitRide();
|
||||
void deleteRide();
|
||||
|
||||
@@ -33,6 +33,7 @@ HEADERS += \
|
||||
DownloadRideDialog.h \
|
||||
MainWindow.h \
|
||||
PfPvPlot.h \
|
||||
PolarRideFile.h \
|
||||
PowerHist.h \
|
||||
RawRideFile.h \
|
||||
RideFile.h \
|
||||
@@ -72,6 +73,7 @@ SOURCES += \
|
||||
DownloadRideDialog.cpp \
|
||||
MainWindow.cpp \
|
||||
PfPvPlot.cpp \
|
||||
PolarRideFile.cpp \
|
||||
PowerHist.cpp \
|
||||
RawRideFile.cpp \
|
||||
RideFile.cpp \
|
||||
|
||||
Reference in New Issue
Block a user