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

KUnitConversion

  • kunitconversion
converter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-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 #ifndef KUNITCONVERSION_CONVERTER_H
21 #define KUNITCONVERSION_CONVERTER_H
22 
23 #include <kunitconversion/value.h>
24 #include <kunitconversion/kunitconversion_export.h>
25 #include <QtCore/QVariant>
26 
27 namespace KUnitConversion
28 {
29 enum CategoryId {
30  InvalidCategory = -1, LengthCategory, AreaCategory, VolumeCategory, TemperatureCategory,
31  VelocityCategory, MassCategory, PressureCategory, EnergyCategory, CurrencyCategory,
32  PowerCategory, TimeCategory, FuelEfficiencyCategory, DensityCategory, AccelerationCategory,
33  AngleCategory, FrequencyCategory, ForceCategory
34 };
35 enum UnitId {
36  InvalidUnit = -1, NoUnit = 0, Percent = 1,
37  // Area
38  SquareYottameter = 1000, SquareZettameter, SquareExameter, SquarePetameter, SquareTerameter,
39  SquareGigameter, SquareMegameter, SquareKilometer, SquareHectometer, SquareDecameter,
40  SquareMeter, SquareDecimeter, SquareCentimeter, SquareMillimeter, SquareMicrometer,
41  SquareNanometer, SquarePicometer, SquareFemtometer, SquareAttometer, SquareZeptometer,
42  SquareYoctometer, Acre, SquareFoot, SquareInch, SquareMile,
43 
44  // Length
45  Yottameter = 2000, Zettameter, Exameter, Petameter, Terameter, Gigameter, Megameter,
46  Kilometer, Hectometer, Decameter, Meter, Decimeter, Centimeter, Millimeter, Micrometer,
47  Nanometer, Picometer, Femtometer, Attometer, Zeptometer, Yoctometer, Inch, Foot, Yard,
48  Mile, NauticalMile, LightYear, Parsec, AstronomicalUnit, Thou, Angstrom,
49 
50  // Volume
51  CubicYottameter = 3000, CubicZettameter, CubicExameter, CubicPetameter, CubicTerameter,
52  CubicGigameter, CubicMegameter, CubicKilometer, CubicHectometer, CubicDecameter, CubicMeter,
53  CubicDecimeter, CubicCentimeter, CubicMillimeter, CubicMicrometer, CubicNanometer,
54  CubicPicometer, CubicFemtometer, CubicAttometer, CubicZeptometer, CubicYoctometer,
55  Yottaliter, Zettaliter, Exaliter, Petaliter, Teraliter, Gigaliter, Megaliter, Kiloliter,
56  Hectoliter, Decaliter, Liter, Deciliter, Centiliter, Milliliter, Microliter, Nanoliter,
57  Picoliter, Femtoliter, Attoliter, Zeptoliter, Yoctoliter, CubicFoot, CubicInch, CubicMile,
58  FluidOunce, Cup, GallonUS, PintImperial,
59 
60  // Mass
61  Yottagram = 4000, Zettagram, Exagram, Petagram, Teragram, Gigagram, Megagram, Kilogram,
62  Hectogram, Decagram, Gram, Decigram, Centigram, Milligram, Microgram, Nanogram, Picogram,
63  Femtogram, Attogram, Zeptogram, Yoctogram, Ton, Carat, Pound, Ounce, TroyOunce, MassNewton,
64  Kilonewton,
65 
66  // Pressure
67  Yottapascal = 5000, Zettapascal, Exapascal, Petapascal, Terapascal, Gigapascal, Megapascal,
68  Kilopascal, Hectopascal, Decapascal, Pascal, Decipascal, Centipascal, Millipascal,
69  Micropascal, Nanopascal, Picopascal, Femtopascal, Attopascal, Zeptopascal, Yoctopascal,
70  Bar, Millibar, Decibar, Torr, TechnicalAtmosphere, Atmosphere, PoundForcePerSquareInch,
71  InchesOfMercury, MillimetersOfMercury,
72 
73  // Temperature
74  Kelvin = 6000, Celsius, Fahrenheit, Rankine, Delisle, TemperatureNewton, Reaumur, Romer,
75 
76  // Energy
77  Yottajoule = 7000, Zettajoule, Exajoule, Petajoule, Terajoule, Gigajoule, Megajoule,
78  Kilojoule, Hectojoule, Decajoule, Joule, Decijoule, Centijoule, Millijoule, Microjoule,
79  Nanojoule, Picojoule, Femtojoule, Attojoule, Zeptojoule, Yoctojoule, GuidelineDailyAmount,
80  Electronvolt, Rydberg, Kilocalorie, PhotonWavelength, KiloJoulePerMole, JoulePerMole,
81 
82  // Currency
83  Eur = 8000, Ats, Bef, Nlg, Fim, Frf, Dem, Iep, Itl, Luf, Pte, Esp, Grd, Sit, Cyp, Mtl, Skk,
84  Usd, Jpy, Bgn, Czk, Dkk, Eek, Gbp, Huf, Ltl, Lvl, Pln, Ron, Sek, Chf, Nok, Hrk, Rub, Try,
85  Aud, Brl, Cad, Cny, Hkd, Idr, Inr, Krw, Mxn, Myr, Nzd, Php, Sgd, Thb, Zar,
86 
87  // Velocity
88  MeterPerSecond = 9000, KilometerPerHour, MilePerHour, FootPerSecond, InchPerSecond, Knot,
89  Mach, SpeedOfLight, Beaufort,
90 
91  // Power
92  Yottawatt = 10000, Zettawatt, Exawatt, Petawatt, Terawatt, Gigawatt, Megawatt, Kilowatt,
93  Hectowatt, Decawatt, Watt, Deciwatt, Centiwatt, Milliwatt, Microwatt, Nanowatt, Picowatt,
94  Femtowatt, Attowatt, Zeptowatt, Yoctowatt, Horsepower,
95 
96  // Time
97  Yottasecond = 11000, Zettasecond, Exasecond, Petasecond, Terasecond, Gigasecond, Megasecond,
98  Kilosecond, Hectosecond, Decasecond, Second, Decisecond, Centisecond, Millisecond,
99  Microsecond, Nanosecond, Picosecond, Femtosecond, Attosecond, Zeptosecond, Yoctosecond,
100  Minute, Hour, Day, Week, JulianYear, LeapYear, Year,
101 
102  // FuelEfficiency
103  LitersPer100Kilometers = 12000, MilePerUsGallon, MilePerImperialGallon, KilometrePerLitre,
104 
105  // Density
106  YottakilogramsPerCubicMeter = 13000, ZettakilogramPerCubicMeter, ExakilogramPerCubicMeter,
107  PetakilogramPerCubicMeter, TerakilogramPerCubicMeter, GigakilogramPerCubicMeter,
108  MegakilogramPerCubicMeter, KilokilogramPerCubicMeter, HectokilogramsPerCubicMeter,
109  DecakilogramsPerCubicMeter, KilogramsPerCubicMeter, DecikilogramsPerCubicMeter,
110  CentikilogramsPerCubicMeter, MillikilogramsPerCubicMeter, MicrokilogramsPerCubicMeter,
111  NanokilogramsPerCubicMeter, PicokilogramsPerCubicMeter, FemtokilogramsPerCubicMeter,
112  AttokilogramsPerCubicMeter, ZeptokilogramsPerCubicMeter, YoctokilogramsPerCubicMeter,
113  KilogramPerLiter, GramPerLiter, GramPerMilliliter,
114  OuncePerCubicInch, OuncePerCubicFoot, OuncePerCubicYard,
115  PoundPerCubicInch, PoundPerCubicFoot, PoundPerCubicYard,
116 
117  // Acceleration
118  MetresPerSecondSquared = 14000, FeetPerSecondSquared, StandardGravity,
119 
120  // Force
121  Yottanewton = 15000, Zettanewton, Exanewton, Petanewton, Teranewton, Giganewton, Meganewton,
122  KilonewtonForce, Hectonewton, Decanewton, Newton, Decinewton, Centinewton, Millinewton, Micronewton,
123  Nanonewton, Piconewton, Femtonewton, Attonewton, Zeptonewton, Yoctonewton, Dyne, Kilopond,
124  PoundForce, Poundal,
125 
126  // Angle
127  Degree = 16000, Radian, Gradian, ArcMinute, ArcSecond,
128 
129  // Frequency
130  Yottahertz = 17000, Zettahertz, Exahertz, Petahertz, Terahertz, Gigahertz, Megahertz,
131  Kilohertz, Hectohertz, Decahertz, Hertz, Decihertz, Centihertz, Millihertz, Microhertz,
132  Nanohertz, Picohertz, Femtohertz, Attohertz, Zeptohertz, Yoctohertz, RPM
133 };
134 
135 class UnitCategory;
136 
137 class ConverterPrivate;
138 class KUNITCONVERSION_EXPORT Converter : public QObject
139 {
140  Q_OBJECT
141 public:
142  explicit Converter(QObject* parent = 0);
143  ~Converter();
144 
152  Value convert(const Value& value, const QString& toUnit = QString()) const;
153  Value convert(const Value& value, int toUnit) const;
154  Value convert(const Value& value, UnitPtr toUnit) const;
155 
162  UnitCategory* categoryForUnit(const QString& unit) const;
163 
170  UnitPtr unit(const QString& unitString) const;
171 
178  UnitPtr unit(int unitId) const;
179 
186  UnitCategory* category(const QString& category) const;
187 
194  UnitCategory* category(int categoryId) const;
195 
201  QList<UnitCategory*> categories() const;
202 
203 private:
204  ConverterPrivate *d;
205 };
206 
207 } // KUnitConversion namespace
208 
209 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Fri Jul 12 2013 08:51:25 by doxygen 1.8.3.1 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-4.10.5 API Reference

Skip menu "kdelibs-4.10.5 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
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