diff --git a/src/StravaUploadDialog.cpp b/src/StravaUploadDialog.cpp index 79f6e8be8..fbdbf2ca2 100644 --- a/src/StravaUploadDialog.cpp +++ b/src/StravaUploadDialog.cpp @@ -399,7 +399,7 @@ StravaUploadDialog::requestUpload() params.addQueryItem("token", token); params.addQueryItem("type", "tcx"); - params.addQueryItem("data", reader.toByteArray(mainWindow, ride->ride())); + params.addQueryItem("data", reader.toByteArray(mainWindow, ride->ride(), altitudeChk->isChecked(), powerChk->isChecked(), heartrateChk->isChecked(), cadenceChk->isChecked())); data = params.encodedQuery(); QUrl url = QUrl(STRAVA_URL2 + "/upload"); diff --git a/src/TcxRideFile.cpp b/src/TcxRideFile.cpp index ad505d8eb..fcff82518 100644 --- a/src/TcxRideFile.cpp +++ b/src/TcxRideFile.cpp @@ -51,7 +51,7 @@ RideFile *TcxFileReader::openRideFile(QFile &file, QStringList &errors, QListareDataPresent()->alt && point->alt != 0.0) { + if (withAlt && ride->areDataPresent()->alt && point->alt != 0.0) { QDomElement alt = doc.createElement("AltitudeMeters"); text = doc.createTextNode(QString("%1").arg(point->alt)); alt.appendChild(text); @@ -203,25 +204,27 @@ TcxFileReader::toByteArray(MainWindow *mainWindow, const RideFile *ride) const trackpoint.appendChild(dist); } - // HeartRate hack for Garmin Training Center - // It needs an hr datapoint for every trackpoint or else the - // hr graph in TC won't display. Schema defines the datapoint - // as a positive int (> 0) + if (withHr) { + // HeartRate hack for Garmin Training Center + // It needs an hr datapoint for every trackpoint or else the + // hr graph in TC won't display. Schema defines the datapoint + // as a positive int (> 0) - int tHr = 1; - if (ride->areDataPresent()->hr && point->hr >0.00) { - tHr = (int)point->hr; + int tHr = 1; + if (ride->areDataPresent()->hr && point->hr >0.00) { + tHr = (int)point->hr; + } + QDomElement hr = doc.createElement("HeartRateBpm"); + hr.setAttribute("xsi:type", "HeartRateInBeatsPerMinute_t"); + QDomElement value = doc.createElement("Value"); + text = doc.createTextNode(QString("%1").arg(tHr)); + value.appendChild(text); + hr.appendChild(value); + trackpoint.appendChild(hr); } - QDomElement hr = doc.createElement("HeartRateBpm"); - hr.setAttribute("xsi:type", "HeartRateInBeatsPerMinute_t"); - QDomElement value = doc.createElement("Value"); - text = doc.createTextNode(QString("%1").arg(tHr)); - value.appendChild(text); - hr.appendChild(value); - trackpoint.appendChild(hr); // cad - if (ride->areDataPresent()->cad && point->cad < 255) { //xsd maxInclusive value="254" + if (withCad && ride->areDataPresent()->cad && point->cad < 255) { //xsd maxInclusive value="254" QDomElement cad = doc.createElement("Cadence"); text = doc.createTextNode(QString("%1").arg((int)(point->cad))); cad.appendChild(text); @@ -243,7 +246,7 @@ TcxFileReader::toByteArray(MainWindow *mainWindow, const RideFile *ride) const tpx.appendChild(spd); } // pwr - if (ride->areDataPresent()->watts) { + if (withWatts && ride->areDataPresent()->watts) { QDomElement pwr = doc.createElement("Watts"); text = doc.createTextNode(QString("%1").arg((int)point->watts)); pwr.appendChild(text); @@ -396,7 +399,7 @@ TcxFileReader::toByteArray(MainWindow *mainWindow, const RideFile *ride) const bool TcxFileReader::writeRideFile(MainWindow *mainWindow, const RideFile *ride, QFile &file) const { - QByteArray xml = toByteArray(mainWindow, ride); + QByteArray xml = toByteArray(mainWindow, ride, true, true, true, true); if (!file.open(QIODevice::WriteOnly)) return(false); if (file.write(xml) != xml.size()) return(false); diff --git a/src/TcxRideFile.h b/src/TcxRideFile.h index 20c6ff961..71467a17e 100644 --- a/src/TcxRideFile.h +++ b/src/TcxRideFile.h @@ -25,7 +25,7 @@ struct TcxFileReader : public RideFileReader { virtual RideFile *openRideFile(QFile &file, QStringList &errors, QList* = 0) const; - QByteArray toByteArray(MainWindow *mainWindow, const RideFile *ride) const; + QByteArray toByteArray(MainWindow *mainWindow, const RideFile *ride, bool withAlt, bool withWatts, bool withHr, bool withCad) const; bool writeRideFile(MainWindow *mainWindow, const RideFile *ride, QFile &file) const; bool hasWrite() const { return true; } };