• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KUnitConversion

  • sources
  • kde-4.14
  • kdelibs
  • kunitconversion
fuel_efficiency.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Petri Damstén <damu@iki.fi>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "fuel_efficiency.h"
21 #include "converter.h"
22 #include <klocale.h>
23 
24 using namespace KUnitConversion;
25 
26 class kmpl : public Complex
27 {
28  double toDefault(double value) const { return 100.0 / value; };
29  double fromDefault(double value) const { return 100.0 / value; };
30 };
31 
32 class mpg : public Complex
33 {
34  double toDefault(double value) const { return 235.2 / value; };
35  double fromDefault(double value) const { return 235.2 / value; };
36 };
37 
38 class mpgi : public Complex
39 {
40  double toDefault(double value) const { return 282.5 / value; };
41  double fromDefault(double value) const { return 282.5 / value; };
42 };
43 
44 FuelEfficiency::FuelEfficiency() : UnitCategory(FuelEfficiencyCategory)
45 {
46  setName(i18n("Fuel Efficiency"));
47  setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (fuel efficiency)", "%1 %2"));
48 
49  setDefaultUnit(UP(LitersPer100Kilometers, 1,
50  i18nc("fuelefficiency unit symbol", "l/100 km"),
51  i18nc("unit description in lists", "liters per 100 kilometers"),
52  i18nc("unit synonyms for matching user input", "liters per 100 kilometers;liters per 100 kilometers;l/100 km;L/100 km"),
53  ki18nc("amount in units (real)", "%1 liters per 100 kilometers"),
54  ki18ncp("amount in units (integer)", "%1 liters per 100 kilometers", "%1 liters per 100 kilometers")
55  ));
56  U(MilePerUsGallon, new mpg(),
57  i18nc("fuelefficiency unit symbol", "mpg"),
58  i18nc("unit description in lists", "miles per US gallon"),
59  i18nc("unit synonyms for matching user input", "mile per US gallon;miles per US gallon;mpg"),
60  ki18nc("amount in units (real)", "%1 miles per US gallon"),
61  ki18ncp("amount in units (integer)", "%1 mile per US gallon", "%1 miles per US gallon")
62  );
63  U(MilePerImperialGallon, new mpgi(),
64  i18nc("fuelefficiency unit symbol", "mpg (imperial)"),
65  i18nc("unit description in lists", "miles per imperial gallon"),
66  i18nc("unit synonyms for matching user input", "mile per imperial gallon;miles per imperial gallon;mpg (imperial)"),
67  ki18nc("amount in units (real)", "%1 miles per imperial gallon"),
68  ki18ncp("amount in units (integer)", "%1 mile per imperial gallon", "%1 miles per imperial gallon")
69  );
70  U(KilometrePerLitre, new kmpl(),
71  i18nc("fuelefficiency unit symbol", "kmpl"),
72  i18nc("unit description in lists", "kilometers per liter"),
73  i18nc("unit synonyms for matching user input", "kilometer per liter;kilometers per liter;kmpl;km/l"),
74  ki18nc("amount in units (real)", "%1 kilometers per liter"),
75  ki18ncp("amount in units (integer)", "%1 kilometer per liter", "%1 kilometers per liter")
76  );
77 
78  setMostCommonUnits(QList<int>() <<
79  LitersPer100Kilometers << MilePerUsGallon << MilePerImperialGallon);
80 }
KUnitConversion::UnitCategory::setMostCommonUnits
void setMostCommonUnits(const QList< int > &units)
Definition: unitcategory.cpp:80
FuelEfficiency::FuelEfficiency
FuelEfficiency()
Definition: fuel_efficiency.cpp:44
KUnitConversion::UnitCategory::setName
void setName(const QString &name)
Definition: unitcategory.cpp:156
KUnitConversion::Complex
Definition: unit.h:34
KUnitConversion::LitersPer100Kilometers
Definition: converter.h:103
KUnitConversion::FuelEfficiencyCategory
Definition: converter.h:32
KUnitConversion::MilePerImperialGallon
Definition: converter.h:103
UP
#define UP(id, m, s, d, sy, r, i)
Definition: unit.h:127
converter.h
QList
KUnitConversion::UnitCategory::setDefaultUnit
void setDefaultUnit(UnitPtr defaultUnit)
Definition: unitcategory.cpp:161
KUnitConversion::UnitCategory
Definition: unitcategory.h:33
KUnitConversion::KilometrePerLitre
Definition: converter.h:103
KUnitConversion::UnitCategory::setSymbolStringFormat
void setSymbolStringFormat(const KLocalizedString &symbolStringFormat)
Definition: unitcategory.cpp:60
U
#define U(id, m, s, d, sy, r, i)
Definition: unit.h:129
fuel_efficiency.h
KUnitConversion::MilePerUsGallon
Definition: converter.h:103
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KUnitConversion

Skip menu "KUnitConversion"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal