add device types

This commit is contained in:
Sean C. Rhea
2008-05-27 03:53:22 +00:00
parent 61161a7b5d
commit ec38e8ca1d
5 changed files with 13 additions and 3 deletions

View File

@@ -188,6 +188,7 @@ pt_read_raw(FILE *in, int compat, void *context,
RideFile *RawFileReader::openRideFile(QFile &file, QStringList &errors) const
{
RideFile *rideFile = new RideFile;
rideFile->setDeviceType("PowerTap");
if (!file.open(QIODevice::ReadOnly)) {
delete rideFile;
return NULL;

View File

@@ -50,6 +50,9 @@ RideFile::writeAsXml(QFile &file, QString &err)
QDomElement xstart = xroot.createElement("start").toElement();
xride.appendChild(xstart);
xstart.setAttribute("date", startTime_.toString("yyyy/MM/dd hh:mm:ss"));
QDomElement xdevtype = xroot.createElement("device_type").toElement();
xride.appendChild(xdevtype);
xdevtype.setAttribute("name", deviceType_);
QDomElement xrecint = xroot.createElement("sampling_period").toElement();
xride.appendChild(xrecint);
xrecint.setAttribute("secs", QString("%1").arg(recIntSecs_, 0, 'f', 3));

View File

@@ -59,12 +59,14 @@ class RideFile
QDateTime startTime_; // time of day that the ride started
double recIntSecs_; // recording interval in seconds
QList<RideFilePoint*> dataPoints_;
QString deviceType_;
public:
RideFile() : recIntSecs_(0.0) {}
RideFile() : recIntSecs_(0.0), deviceType_("unknown") {}
RideFile(const QDateTime &startTime, double recIntSecs) :
startTime_(startTime), recIntSecs_(recIntSecs) {}
startTime_(startTime), recIntSecs_(recIntSecs),
deviceType_("unknown") {}
virtual ~RideFile() {
QListIterator<RideFilePoint*> i(dataPoints_);
@@ -75,9 +77,12 @@ class RideFile
const QDateTime &startTime() const { return startTime_; }
double recIntSecs() const { return recIntSecs_; }
const QList<RideFilePoint*> dataPoints() const { return dataPoints_; }
const QString &deviceType() const { return deviceType_; }
void setStartTime(const QDateTime &value) { startTime_ = value; }
void setRecIntSecs(double value) { recIntSecs_ = value; }
void setDeviceType(const QString &value) { deviceType_ = value; }
void appendPoint(double secs, double cad, double hr, double km,
double kph, double nm, double watts, int interval) {
dataPoints_.append(new RideFilePoint(secs, cad, hr, km, kph,

View File

@@ -182,7 +182,7 @@ RideItem::htmlSummary()
}
summary = ("<p><center><h2>"
+ dateTime.toString("dddd MMMM d, yyyy, h:mm AP")
+ "</h2><p><h2>Summary</h2>");
+ "</h2><h3>Device Type: " + ride->deviceType() + "</h3>");
if (zones) {
zone_range = zones->whichRange(dateTime.date());

View File

@@ -30,6 +30,7 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errors) const
if (!readSrmFile(file, srmData, errors))
return NULL;
RideFile *rideFile = new RideFile(srmData.startTime, srmData.recint);
rideFile->setDeviceType("SRM");
QListIterator<SrmDataPoint*> i(srmData.dataPoints);
while (i.hasNext()) {
SrmDataPoint *p = i.next();