KUnitConversion
energy.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 "energy.h" 00021 #include "converter.h" 00022 #include <klocale.h> 00023 00024 using namespace KUnitConversion; 00025 00026 class PhotonWavelengthConv : public Complex 00027 { 00028 double toDefault(double value) const { return (2.99792458e+08 * 6.62606896e-34) / (value * 1e-09); }; 00029 double fromDefault(double value) const { return ((2.99792458e+08 * 6.62606896e-34) / value) / 1e-09; }; 00030 }; 00031 00032 Energy::Energy() : UnitCategory(EnergyCategory) 00033 { 00034 setName(i18n("Energy")); 00035 setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (energy)", "%1 %2")); 00036 00037 U(Yottajoule, 1e+24, 00038 i18nc("energy unit symbol", "YJ"), 00039 i18nc("unit description in lists", "yottajoules"), 00040 i18nc("unit synonyms for matching user input", "yottajoule;yottajoules;YJ"), 00041 ki18nc("amount in units (real)", "%1 yottajoules"), 00042 ki18ncp("amount in units (integer)", "%1 yottajoule", "%1 yottajoules") 00043 ); 00044 U(Zettajoule, 1e+21, 00045 i18nc("energy unit symbol", "ZJ"), 00046 i18nc("unit description in lists", "zettajoules"), 00047 i18nc("unit synonyms for matching user input", "zettajoule;zettajoules;ZJ"), 00048 ki18nc("amount in units (real)", "%1 zettajoules"), 00049 ki18ncp("amount in units (integer)", "%1 zettajoule", "%1 zettajoules") 00050 ); 00051 U(Exajoule, 1e+18, 00052 i18nc("energy unit symbol", "EJ"), 00053 i18nc("unit description in lists", "exajoules"), 00054 i18nc("unit synonyms for matching user input", "exajoule;exajoules;EJ"), 00055 ki18nc("amount in units (real)", "%1 exajoules"), 00056 ki18ncp("amount in units (integer)", "%1 exajoule", "%1 exajoules") 00057 ); 00058 U(Petajoule, 1e+15, 00059 i18nc("energy unit symbol", "PJ"), 00060 i18nc("unit description in lists", "petajoules"), 00061 i18nc("unit synonyms for matching user input", "petajoule;petajoules;PJ"), 00062 ki18nc("amount in units (real)", "%1 petajoules"), 00063 ki18ncp("amount in units (integer)", "%1 petajoule", "%1 petajoules") 00064 ); 00065 U(Terajoule, 1e+12, 00066 i18nc("energy unit symbol", "TJ"), 00067 i18nc("unit description in lists", "terajoules"), 00068 i18nc("unit synonyms for matching user input", "terajoule;terajoules;TJ"), 00069 ki18nc("amount in units (real)", "%1 terajoules"), 00070 ki18ncp("amount in units (integer)", "%1 terajoule", "%1 terajoules") 00071 ); 00072 U(Gigajoule, 1e+09, 00073 i18nc("energy unit symbol", "GJ"), 00074 i18nc("unit description in lists", "gigajoules"), 00075 i18nc("unit synonyms for matching user input", "gigajoule;gigajoules;GJ"), 00076 ki18nc("amount in units (real)", "%1 gigajoules"), 00077 ki18ncp("amount in units (integer)", "%1 gigajoule", "%1 gigajoules") 00078 ); 00079 U(Megajoule, 1e+06, 00080 i18nc("energy unit symbol", "MJ"), 00081 i18nc("unit description in lists", "megajoules"), 00082 i18nc("unit synonyms for matching user input", "megajoule;megajoules;MJ"), 00083 ki18nc("amount in units (real)", "%1 megajoules"), 00084 ki18ncp("amount in units (integer)", "%1 megajoule", "%1 megajoules") 00085 ); 00086 U(Kilojoule, 1000, 00087 i18nc("energy unit symbol", "kJ"), 00088 i18nc("unit description in lists", "kilojoules"), 00089 i18nc("unit synonyms for matching user input", "kilojoule;kilojoules;kJ"), 00090 ki18nc("amount in units (real)", "%1 kilojoules"), 00091 ki18ncp("amount in units (integer)", "%1 kilojoule", "%1 kilojoules") 00092 ); 00093 U(Hectojoule, 100, 00094 i18nc("energy unit symbol", "hJ"), 00095 i18nc("unit description in lists", "hectojoules"), 00096 i18nc("unit synonyms for matching user input", "hectojoule;hectojoules;hJ"), 00097 ki18nc("amount in units (real)", "%1 hectojoules"), 00098 ki18ncp("amount in units (integer)", "%1 hectojoule", "%1 hectojoules") 00099 ); 00100 U(Decajoule, 10, 00101 i18nc("energy unit symbol", "daJ"), 00102 i18nc("unit description in lists", "decajoules"), 00103 i18nc("unit synonyms for matching user input", "decajoule;decajoules;daJ"), 00104 ki18nc("amount in units (real)", "%1 decajoules"), 00105 ki18ncp("amount in units (integer)", "%1 decajoule", "%1 decajoules") 00106 ); 00107 setDefaultUnit(UP(Joule, 1, 00108 i18nc("energy unit symbol", "J"), 00109 i18nc("unit description in lists", "joules"), 00110 i18nc("unit synonyms for matching user input", "joule;joules;J"), 00111 ki18nc("amount in units (real)", "%1 joules"), 00112 ki18ncp("amount in units (integer)", "%1 joule", "%1 joules") 00113 )); 00114 U(Decijoule, 0.1, 00115 i18nc("energy unit symbol", "dJ"), 00116 i18nc("unit description in lists", "decijoules"), 00117 i18nc("unit synonyms for matching user input", "decijoule;decijoules;dJ"), 00118 ki18nc("amount in units (real)", "%1 decijoules"), 00119 ki18ncp("amount in units (integer)", "%1 decijoule", "%1 decijoules") 00120 ); 00121 U(Centijoule, 0.01, 00122 i18nc("energy unit symbol", "cJ"), 00123 i18nc("unit description in lists", "centijoules"), 00124 i18nc("unit synonyms for matching user input", "centijoule;centijoules;cJ"), 00125 ki18nc("amount in units (real)", "%1 centijoules"), 00126 ki18ncp("amount in units (integer)", "%1 centijoule", "%1 centijoules") 00127 ); 00128 U(Millijoule, 0.001, 00129 i18nc("energy unit symbol", "mJ"), 00130 i18nc("unit description in lists", "millijoules"), 00131 i18nc("unit synonyms for matching user input", "millijoule;millijoules;mJ"), 00132 ki18nc("amount in units (real)", "%1 millijoules"), 00133 ki18ncp("amount in units (integer)", "%1 millijoule", "%1 millijoules") 00134 ); 00135 U(Microjoule, 1e-06, 00136 i18nc("energy unit symbol", "µJ"), 00137 i18nc("unit description in lists", "microjoules"), 00138 i18nc("unit synonyms for matching user input", "microjoule;microjoules;µJ;uJ"), 00139 ki18nc("amount in units (real)", "%1 microjoules"), 00140 ki18ncp("amount in units (integer)", "%1 microjoule", "%1 microjoules") 00141 ); 00142 U(Nanojoule, 1e-09, 00143 i18nc("energy unit symbol", "nJ"), 00144 i18nc("unit description in lists", "nanojoules"), 00145 i18nc("unit synonyms for matching user input", "nanojoule;nanojoules;nJ"), 00146 ki18nc("amount in units (real)", "%1 nanojoules"), 00147 ki18ncp("amount in units (integer)", "%1 nanojoule", "%1 nanojoules") 00148 ); 00149 U(Picojoule, 1e-12, 00150 i18nc("energy unit symbol", "pJ"), 00151 i18nc("unit description in lists", "picojoules"), 00152 i18nc("unit synonyms for matching user input", "picojoule;picojoules;pJ"), 00153 ki18nc("amount in units (real)", "%1 picojoules"), 00154 ki18ncp("amount in units (integer)", "%1 picojoule", "%1 picojoules") 00155 ); 00156 U(Femtojoule, 1e-15, 00157 i18nc("energy unit symbol", "fJ"), 00158 i18nc("unit description in lists", "femtojoules"), 00159 i18nc("unit synonyms for matching user input", "femtojoule;femtojoules;fJ"), 00160 ki18nc("amount in units (real)", "%1 femtojoules"), 00161 ki18ncp("amount in units (integer)", "%1 femtojoule", "%1 femtojoules") 00162 ); 00163 U(Attojoule, 1e-18, 00164 i18nc("energy unit symbol", "aJ"), 00165 i18nc("unit description in lists", "attojoules"), 00166 i18nc("unit synonyms for matching user input", "attojoule;attojoules;aJ"), 00167 ki18nc("amount in units (real)", "%1 attojoules"), 00168 ki18ncp("amount in units (integer)", "%1 attojoule", "%1 attojoules") 00169 ); 00170 U(Zeptojoule, 1e-21, 00171 i18nc("energy unit symbol", "zJ"), 00172 i18nc("unit description in lists", "zeptojoules"), 00173 i18nc("unit synonyms for matching user input", "zeptojoule;zeptojoules;zJ"), 00174 ki18nc("amount in units (real)", "%1 zeptojoules"), 00175 ki18ncp("amount in units (integer)", "%1 zeptojoule", "%1 zeptojoules") 00176 ); 00177 U(Yoctojoule, 1e-24, 00178 i18nc("energy unit symbol", "yJ"), 00179 i18nc("unit description in lists", "yoctojoules"), 00180 i18nc("unit synonyms for matching user input", "yoctojoule;yoctojoules;yJ"), 00181 ki18nc("amount in units (real)", "%1 yoctojoules"), 00182 ki18ncp("amount in units (integer)", "%1 yoctojoule", "%1 yoctojoules") 00183 ); 00184 U(GuidelineDailyAmount, 8.3736e+06, 00185 i18nc("energy unit symbol", "GDA"), 00186 i18nc("unit description in lists", "guideline daily amount"), 00187 i18nc("unit synonyms for matching user input", 00188 "guideline daily amount;guideline daily amount;GDA"), 00189 ki18nc("amount in units (real)", "%1 guideline daily amount"), 00190 ki18ncp("amount in units (integer)", "%1 guideline daily amount", "%1 guideline daily amount") 00191 ); 00192 U(Electronvolt, 1.60218e-19, 00193 i18nc("energy unit symbol", "eV"), 00194 i18nc("unit description in lists", "electronvolts"), 00195 i18nc("unit synonyms for matching user input", "electronvolt;electronvolts;eV"), 00196 ki18nc("amount in units (real)", "%1 electronvolts"), 00197 ki18ncp("amount in units (integer)", "%1 electronvolt", "%1 electronvolts") 00198 ); 00199 U(Rydberg, 2.17987e-18, 00200 i18nc("energy unit symbol", "Ry"), 00201 i18nc("unit description in lists", "rydbergs"), 00202 i18nc("unit synonyms for matching user input", "rydberg;rydbergs;Ry"), 00203 ki18nc("amount in units (real)", "%1 rydbergs"), 00204 ki18ncp("amount in units (integer)", "%1 rydberg", "%1 rydbergs") 00205 ); 00206 U(Kilocalorie, 4186.8, 00207 i18nc("energy unit symbol", "kcal"), 00208 i18nc("unit description in lists", "kilocalories"), 00209 i18nc("unit synonyms for matching user input", "kilocalorie;kilocalories;kcal"), 00210 ki18nc("amount in units (real)", "%1 kilocalories"), 00211 ki18ncp("amount in units (integer)", "%1 kilocalorie", "%1 kilocalories") 00212 ); 00213 U(PhotonWavelength, new PhotonWavelengthConv(), 00214 i18nc("energy unit symbol", "nm"), 00215 i18nc("unit description in lists", "photon wavelength in nanometers"), 00216 i18nc("unit synonyms for matching user input", "nm;photon wavelength"), 00217 ki18nc("amount in units (real)", "%1 nanometers"), 00218 ki18ncp("amount in units (integer)", "%1 nanometer", "%1 nanometers") 00219 ); 00220 00221 setMostCommonUnits(QList<int>() << 00222 Joule << Kilojoule << Kilocalorie << GuidelineDailyAmount); 00223 }
KDE 4.6 API Reference