From: eshe Date: Wed, 4 Aug 2010 10:49:24 +0000 (+0100) Subject: Couple of new fields added to text element. Small fix to web page. X-Git-Url: http://git.maemo.org/git/?p=jspeed;a=commitdiff_plain;h=896cef4efae239e6ece29a288812425ec9e366e5 Couple of new fields added to text element. Small fix to web page. --- diff --git a/src/location.cpp b/src/location.cpp index d8ef14c..56071f5 100644 --- a/src/location.cpp +++ b/src/location.cpp @@ -21,8 +21,10 @@ namespace { - static const double KM_MULTIPLIER = 1.0; - static const double MILE_MULTIPLIER = 0.621371192; + static double const KM_MULTIPLIER = 1.0; + static double const MILE_MULTIPLIER = 0.621371192; + static double const METER_MULTIPLIER = 1.0; + static double const FEET_MULTIPLIER = 3.2808399; } Location::Unit Location::unit_ = Location::KM; @@ -125,6 +127,16 @@ double Location::getUnitMultiplier() return KM_MULTIPLIER; } +double Location::getMeterMultiplier() +{ + if(unit_ == MILE) + { + return FEET_MULTIPLIER; + } + + return METER_MULTIPLIER; +} + void Location::onChanged(LocationGPSDevice *device, gpointer data) { if(device && device->fix && @@ -145,7 +157,7 @@ void Location::onChanged(LocationGPSDevice *device, gpointer data) if(device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET) { - fix.altitude = device->fix->altitude; + fix.altitude = device->fix->altitude * getMeterMultiplier(); fix.epv = device->fix->epv; } diff --git a/src/location.h b/src/location.h index a431cf8..92f6c46 100644 --- a/src/location.h +++ b/src/location.h @@ -66,6 +66,7 @@ public: static void setUnit(Unit unit); static Unit getUnit(); static double getUnitMultiplier(); + static double getMeterMultiplier(); signals: void locationChanged(Location::Fix const& fix); diff --git a/src/odometer.cpp b/src/odometer.cpp index 740c3cc..9c73be7 100644 --- a/src/odometer.cpp +++ b/src/odometer.cpp @@ -35,8 +35,6 @@ namespace QString const MILE_SPEEDUNIT = "mph"; QString const METER_UNIT = "m"; QString const FEET_UNIT = "feet"; - double const FEET_MULTIPLIER = 3.2808399; - double const METER_MULTIPLIER = 1.0; static const int FIX_TIMEOUT = 4000; double const DEFAULT_SPEED_TRESHOLD = 8.0; double const MIN_SPEED_TRESHOLD = 0.8; @@ -295,14 +293,7 @@ double Odometer::getUnitMultiplier() double Odometer::getMeterMultiplier() { - if(Location::getUnit() == Location::KM) - { - return METER_MULTIPLIER; - } - else - { - return FEET_MULTIPLIER; - } + return Location::getMeterMultiplier(); } QString Odometer::getMeterUnit() diff --git a/src/textelement.cpp b/src/textelement.cpp index 4f4fab7..d42b423 100644 --- a/src/textelement.cpp +++ b/src/textelement.cpp @@ -54,11 +54,12 @@ namespace "MAXSPEED", "AVGSPEED", "UNIT", "SPEEDUNIT", "TIME", "DATE", "POIDISTANCE", "ANGLE", "LATITUDE", - "LONGITUDE"}; + "LONGITUDE", "ALTITUDE", "DISTANCEUNIT"}; } TextElement::TextElement(Reader* reader): GraphicsElement(reader), -data_(""), format_(""), align_("left"), timeFormat_("hh:mm"), dateFormat_("dd.MM.yyyy"), fontSize_(16), bold_(false), italic_(false), +data_(""), format_(""), align_("left"), timeFormat_("hh:mm"), +dateFormat_("dd.MM.yyyy"), fontSize_(16), bold_(false), italic_(false), uppercase_(false), letterSpacing_(0) { element_ = new QGraphicsTextItem(); @@ -286,6 +287,12 @@ void TextElement::replaceSpecialFields(QString& value) case LONGITUDE: replaceValue(value, f, handleEmpty(o->getLatestFix().longitude)); break; + case ALTITUDE: + replaceValue(value, f, handleEmpty(o->getLatestFix().altitude)); + break; + case DISTANCEUNIT: + replaceValue(value, f, o->getMeterUnit()); + break; default: qDebug() << "Unknown field: " << f; } diff --git a/src/textelement.h b/src/textelement.h index 2a3f519..95fb221 100644 --- a/src/textelement.h +++ b/src/textelement.h @@ -31,7 +31,7 @@ class TextElement : public GraphicsElement { public: enum Attribute {XPOS, YPOS, ZPOS, VISIBLEWHEN, DATA, FORMAT, WIDTH, ALIGN, COLOR, SIZE, FONT, BOLD, ITALIC, UPPERCASE, LETTERSPACING, TIMEFORMAT, DATEFORMAT, ATTRIBUTE_COUNT}; - enum Field {TRIP, TOTAL, SPEED, MAXSPEED, AVGSPEED, UNIT, SPEEDUNIT, TIME, DATE, POIDISTANCE, ANGLE, LATITUDE, LONGITUDE, FIELD_COUNT}; + enum Field {TRIP, TOTAL, SPEED, MAXSPEED, AVGSPEED, UNIT, SPEEDUNIT, TIME, DATE, POIDISTANCE, ANGLE, LATITUDE, LONGITUDE, ALTITUDE, DISTANCEUNIT, FIELD_COUNT}; TextElement(Reader* reader); virtual bool setAttribute(QString const& name, QString const& value); virtual void addToScene(GraphicsScene* scene); diff --git a/www/documentation.html b/www/documentation.html index 98f1d65..8dc7626 100644 --- a/www/documentation.html +++ b/www/documentation.html @@ -50,7 +50,7 @@

Themes

-

Theme files are located in /home/user/.speed/themes/. For more information about how to make your own theme, take a look at the theme howto.

+

Theme files are located in /home/user/.jspeed/themes/. For more information about how to make your own theme, take a look at the theme howto.