KUnitConversion
fuel_efficiency.cpp
Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2009 Petri Damstén <damu@iki.fi> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include "fuel_efficiency.h" 00021 #include "converter.h" 00022 #include <klocale.h> 00023 00024 using namespace KUnitConversion; 00025 00026 class kmpl : public Complex 00027 { 00028 double toDefault(double value) const { return 100.0 / value; }; 00029 double fromDefault(double value) const { return 100.0 / value; }; 00030 }; 00031 00032 class mpg : public Complex 00033 { 00034 double toDefault(double value) const { return 235.2 / value; }; 00035 double fromDefault(double value) const { return 235.2 / value; }; 00036 }; 00037 00038 class mpgi : public Complex 00039 { 00040 double toDefault(double value) const { return 282.5 / value; }; 00041 double fromDefault(double value) const { return 282.5 / value; }; 00042 }; 00043 00044 FuelEfficiency::FuelEfficiency() : UnitCategory(FuelEfficiencyCategory) 00045 { 00046 setName(i18n("Fuel Efficiency")); 00047 setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (fuel efficiency)", "%1 %2")); 00048 00049 setDefaultUnit(UP(LitersPer100Kilometers, 1, 00050 i18nc("fuelefficiency unit symbol", "l/100 km"), 00051 i18nc("unit description in lists", "liters per 100 kilometers"), 00052 i18nc("unit synonyms for matching user input", "liters per 100 kilometers;liters per 100 kilometers;l/100 km;L/100 km"), 00053 ki18nc("amount in units (real)", "%1 liters per 100 kilometers"), 00054 ki18ncp("amount in units (integer)", "%1 liters per 100 kilometers", "%1 liters per 100 kilometers") 00055 )); 00056 U(MilePerUsGallon, new mpg(), 00057 i18nc("fuelefficiency unit symbol", "mpg"), 00058 i18nc("unit description in lists", "miles per US gallon"), 00059 i18nc("unit synonyms for matching user input", "mile per US gallon;miles per US gallon;mpg"), 00060 ki18nc("amount in units (real)", "%1 miles per US gallon"), 00061 ki18ncp("amount in units (integer)", "%1 mile per US gallon", "%1 miles per US gallon") 00062 ); 00063 U(MilePerImperialGallon, new mpgi(), 00064 i18nc("fuelefficiency unit symbol", "mpg (imperial)"), 00065 i18nc("unit description in lists", "miles per imperial gallon"), 00066 i18nc("unit synonyms for matching user input", "mile per imperial gallon;miles per imperial gallon;mpg (imperial)"), 00067 ki18nc("amount in units (real)", "%1 miles per imperial gallon"), 00068 ki18ncp("amount in units (integer)", "%1 mile per imperial gallon", "%1 miles per imperial gallon") 00069 ); 00070 U(KilometrePerLitre, new kmpl(), 00071 i18nc("fuelefficiency unit symbol", "kmpl"), 00072 i18nc("unit description in lists", "kilometers per liter"), 00073 i18nc("unit synonyms for matching user input", "kilometer per liter;kilometers per liter;kmpl;km/l"), 00074 ki18nc("amount in units (real)", "%1 kilometers per liter"), 00075 ki18ncp("amount in units (integer)", "%1 kilometer per liter", "%1 kilometers per liter") 00076 ); 00077 00078 setMostCommonUnits(QList<int>() << 00079 LitersPer100Kilometers << MilePerUsGallon << MilePerImperialGallon); 00080 }
KDE 4.6 API Reference