remove XmlRideFile and "Export to XML"

These were part of an earlier attempt at a GC-specific ride file
format.  They aren't in use now, and they'll be replaced by the new
one when it's done.
This commit is contained in:
Sean Rhea
2009-10-31 15:12:48 -04:00
parent 5dc82a6c93
commit 868e3d4b6b
6 changed files with 0 additions and 296 deletions

View File

@@ -23,89 +23,6 @@
#include <QtXml/QtXml>
#include <assert.h>
static void
markInterval(QDomDocument &doc, QDomNode &xride, QDomNode &xintervals,
double &startSecs, double prevSecs,
int &thisInterval, RideFilePoint *sample)
{
if (xintervals.isNull()) {
xintervals = doc.createElement("intervals");
xride.appendChild(xintervals);
}
QDomElement xint = doc.createElement("interval").toElement();
xintervals.appendChild(xint);
xint.setAttribute("name", thisInterval);
xint.setAttribute("from_secs", QString("%1").arg(startSecs, 0, 'f', 2));
xint.setAttribute("thru_secs", QString("%1").arg(prevSecs, 0, 'f', 2));
startSecs = sample->secs;
thisInterval = sample->interval;
}
static void
append_text(QDomDocument &doc, QDomNode &parent,
const QString &child_name, const QString &child_value)
{
QDomNode child = parent.appendChild(doc.createElement(child_name));
child.appendChild(doc.createTextNode(child_value));
}
bool
RideFile::writeAsXml(QFile &file, QString &err) const
{
(void) err;
QDomDocument doc("GoldenCheetah-1.0");
QDomNode xride = doc.appendChild(doc.createElement("ride"));
QDomNode xheader = xride.appendChild(doc.createElement("header"));
append_text(doc, xheader, "start_time", startTime_.toString("yyyy/MM/dd hh:mm:ss"));
append_text(doc, xheader, "device_type", deviceType_);
append_text(doc, xheader, "rec_int_secs", QString("%1").arg(recIntSecs_, 0, 'f', 3));
QDomNode xintervals;
bool hasNm = false;
double startSecs = 0.0, prevSecs = 0.0;
int thisInterval = 0;
QListIterator<RideFilePoint*> i(dataPoints_);
RideFilePoint *sample = NULL;
while (i.hasNext()) {
sample = i.next();
if (sample->nm > 0.0)
hasNm = true;
assert(sample->secs >= 0.0);
if (sample->interval != thisInterval) {
markInterval(doc, xride, xintervals, startSecs,
prevSecs, thisInterval, sample);
}
prevSecs = sample->secs;
}
if (sample) {
markInterval(doc, xride, xintervals, startSecs,
prevSecs, thisInterval, sample);
}
QDomNode xsamples = doc.createElement("samples");
xride.appendChild(xsamples);
i.toFront();
while (i.hasNext()) {
RideFilePoint *sample = i.next();
QDomElement xsamp = doc.createElement("sample").toElement();
xsamples.appendChild(xsamp);
xsamp.setAttribute("secs", QString("%1").arg(sample->secs, 0, 'f', 2));
xsamp.setAttribute("cad", QString("%1").arg(sample->cad, 0, 'f', 0));
xsamp.setAttribute("hr", QString("%1").arg(sample->hr, 0, 'f', 0));
xsamp.setAttribute("km", QString("%1").arg(sample->km, 0, 'f', 3));
xsamp.setAttribute("kph", QString("%1").arg(sample->kph, 0, 'f', 1));
xsamp.setAttribute("alt", QString("%1").arg(sample->alt, 0, 'f', 1));
xsamp.setAttribute("watts", sample->watts);
if (hasNm) {
double nm = (sample->watts > 0.0) ? sample->nm : 0.0;
xsamp.setAttribute("nm", QString("%1").arg(nm, 0,'f', 1));
}
}
file.open(QFile::WriteOnly);
QTextStream ts(&file);
doc.save(ts, 4);
file.close();
return true;
}
void RideFile::writeAsCsv(QFile &file, bool bIsMetric) const
{