mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kunitconversion: say hello to my delete button
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c244f74158
commit
c454d8fdc6
60 changed files with 2 additions and 5923 deletions
|
@ -363,7 +363,6 @@ add_subdirectory( kioslave )
|
|||
add_subdirectory( knotify )
|
||||
add_subdirectory( kparts )
|
||||
add_subdirectory( kpty )
|
||||
add_subdirectory( kunitconversion )
|
||||
add_subdirectory( kutils )
|
||||
add_subdirectory( licenses )
|
||||
add_subdirectory( mimetypes )
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
# KDE4_KNOTIFYCONFIG_LIBS - the knotify config library and all depending libraries
|
||||
# KDE4_KTEXTEDITOR_LIBS - the ktexteditor library and all depending libraries
|
||||
# KDE4_PLASMA_LIBS - the plasma library and all depending librairies
|
||||
# KDE4_KUNITCONVERSION_LIBS - the kunitconversion library and all depending libraries
|
||||
# KDE4_KDCRAW_LIBS - the kdcraw library and all depending libraries
|
||||
# KDE4_KEXIV2_LIBS - the kexiv2 library and all depending libraries
|
||||
# KDE4_KMEDIAPLAYER_LIBS - the kmediaplayer library and all depending libraries
|
||||
|
@ -300,7 +299,6 @@ set(_kde_libraries
|
|||
kprintutils
|
||||
kpty
|
||||
ktexteditor
|
||||
kunitconversion
|
||||
plasma
|
||||
solid
|
||||
threadweaver
|
||||
|
|
|
@ -150,6 +150,7 @@ install(
|
|||
KFontRequester
|
||||
KFontSizeAction
|
||||
KFontUtils
|
||||
KUnitConversion
|
||||
KGlobal
|
||||
KGlobalAccel
|
||||
KGlobalSettings
|
||||
|
@ -733,14 +734,3 @@ install(
|
|||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/KDE/Plasma
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
|
||||
install(
|
||||
FILES
|
||||
KUnitConversion/Converter
|
||||
KUnitConversion/Unit
|
||||
KUnitConversion/UnitCategory
|
||||
KUnitConversion/Value
|
||||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/KDE/KUnitConversion
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
|
1
includes/KUnitConversion
Normal file
1
includes/KUnitConversion
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../kunitconversion.h"
|
|
@ -1 +0,0 @@
|
|||
#include "../../kunitconversion/converter.h"
|
|
@ -1 +0,0 @@
|
|||
#include "../../kunitconversion/unit.h"
|
|
@ -1 +0,0 @@
|
|||
#include "../../kunitconversion/unitcategory.h"
|
|
@ -1 +0,0 @@
|
|||
#include "../../kunitconversion/value.h"
|
|
@ -1,105 +0,0 @@
|
|||
project(kunitconversion)
|
||||
|
||||
if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION)
|
||||
set(KUNITCONVERSION_NO_SOLID TRUE)
|
||||
set(KUNITCONVERSION_NO_KIO TRUE)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
config-kunitconversion.h.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config-kunitconversion.h
|
||||
)
|
||||
|
||||
set(kunitconversion_LIB_SRCS
|
||||
converter.cpp
|
||||
value.cpp
|
||||
unit.cpp
|
||||
unitcategory.cpp
|
||||
length.cpp
|
||||
area.cpp
|
||||
volume.cpp
|
||||
temperature.cpp
|
||||
velocity.cpp
|
||||
mass.cpp
|
||||
pressure.cpp
|
||||
energy.cpp
|
||||
currency.cpp
|
||||
power.cpp
|
||||
timeunit.cpp
|
||||
fuel_efficiency.cpp
|
||||
density.cpp
|
||||
acceleration.cpp
|
||||
force.cpp
|
||||
angle.cpp
|
||||
frequency.cpp
|
||||
)
|
||||
|
||||
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=930)
|
||||
|
||||
if(NOT KUNITCONVERSION_NO_KIO)
|
||||
include_directories(${KDE4_KIO_INCLUDES})
|
||||
set(KUNITCONVERSION_EXTRA_LIBS
|
||||
${KUNITCONVERSION_EXTRA_LIBS}
|
||||
${KDE4_KIO_LIBS}
|
||||
)
|
||||
else()
|
||||
set(KUNITCONVERSION_EXTRA_LIBS
|
||||
${KUNITCONVERSION_EXTRA_LIBS}
|
||||
${QT_QTNETWORK_LIBRARY}
|
||||
${QT_QTXML_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT KUNITCONVERSION_NO_SOLID)
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}/solid
|
||||
${CMAKE_SOURCE_DIR}/solid
|
||||
)
|
||||
set(KUNITCONVERSION_EXTRA_LIBS
|
||||
${KUNITCONVERSION_EXTRA_LIBS}
|
||||
${KDE4_SOLID_LIBS}
|
||||
)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}
|
||||
# for the export header
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${KDE4_KDECORE_INCLUDES}
|
||||
${KDE4_KDEUI_INCLUDES}
|
||||
)
|
||||
|
||||
add_library(kunitconversion ${LIBRARY_TYPE} ${kunitconversion_LIB_SRCS})
|
||||
|
||||
target_link_libraries(kunitconversion PUBLIC
|
||||
${KDE4_KDECORE_LIBS}
|
||||
${KUNITCONVERSION_EXTRA_LIBS}
|
||||
)
|
||||
|
||||
set_target_properties(kunitconversion PROPERTIES
|
||||
VERSION ${GENERIC_LIB_VERSION}
|
||||
SOVERSION ${GENERIC_LIB_SOVERSION}
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS kunitconversion
|
||||
EXPORT kdelibsLibraryTargets
|
||||
${INSTALL_TARGETS_DEFAULT_ARGS}
|
||||
)
|
||||
|
||||
generate_export_header(kunitconversion)
|
||||
|
||||
install(
|
||||
FILES
|
||||
converter.h
|
||||
value.h
|
||||
unit.h
|
||||
unitcategory.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/kunitconversion_export.h
|
||||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/kunitconversion
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
if(ENABLE_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
|
@ -1,2 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
$XGETTEXT *.cpp -o $podir/libkunitconversion.pot
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "acceleration.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Acceleration::Acceleration() : UnitCategory(AccelerationCategory)
|
||||
{
|
||||
setName(i18n("Acceleration"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (acceleration)", "%1 %2"));
|
||||
|
||||
setDefaultUnit(UP(MetresPerSecondSquared, 1,
|
||||
i18nc("acceleration unit symbol", "m/s²"),
|
||||
i18nc("unit description in lists", "meters per second squared"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"meter per second squared;meters per second squared;m/s²;m/s2;m/s^2"),
|
||||
ki18nc("amount in units (real)", "%1 meters per second squared"),
|
||||
ki18ncp("amount in units (integer)", "%1 meter per second squared",
|
||||
"%1 meters per second squared")
|
||||
));
|
||||
U(FeetPerSecondSquared, 0.3048,
|
||||
i18nc("acceleration unit symbol", "ft/s²"),
|
||||
i18nc("unit description in lists", "feet per second squared"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"foot per second squared;feet per second squared;ft/s²;ft/s2;ft/s^2"),
|
||||
ki18nc("amount in units (real)", "%1 feet per second squared"),
|
||||
ki18ncp("amount in units (integer)", "%1 foot per second squared",
|
||||
"%1 feet per second squared")
|
||||
);
|
||||
U(StandardGravity, 9.80665,
|
||||
i18nc("acceleration unit symbol", "g"),
|
||||
i18nc("unit description in lists", "standard gravity"),
|
||||
i18nc("unit synonyms for matching user input", "standard gravity;g"),
|
||||
ki18nc("amount in units (real)", "%1 times standard gravity"),
|
||||
ki18ncp("amount in units (integer)", "%1 standard gravity",
|
||||
"%1 times standard gravity")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
MetresPerSecondSquared << FeetPerSecondSquared);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef ACCELERATION_H
|
||||
#define ACCELERATION_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Acceleration : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Acceleration();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "angle.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
#include <math.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class RadiansConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return (value / (2 * M_PI)) * 360.0; };
|
||||
double fromDefault(double value) const { return (value / 360.0) * (2 * M_PI); };
|
||||
};
|
||||
|
||||
Angle::Angle() : UnitCategory(AngleCategory)
|
||||
{
|
||||
setName(i18n("Angle"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (angle)", "%1 %2"));
|
||||
|
||||
setDefaultUnit(UP(Degree, 1,
|
||||
i18nc("angle unit symbol", "°"),
|
||||
i18nc("unit description in lists", "degrees"),
|
||||
i18nc("unit synonyms for matching user input", "deg;degree;degrees;°"),
|
||||
ki18nc("amount in units (real)", "%1 degrees"),
|
||||
ki18ncp("amount in units (integer)", "%1 degree", "%1 degrees")
|
||||
));
|
||||
U(Radian, new RadiansConv(),
|
||||
i18nc("angle unit symbol", "rad"),
|
||||
i18nc("unit description in lists", "radians"),
|
||||
i18nc("unit synonyms for matching user input", "rad;radian;radians"),
|
||||
ki18nc("amount in units (real)", "%1 radians"),
|
||||
ki18ncp("amount in units (integer)", "%1 radian", "%1 radians")
|
||||
);
|
||||
U(Gradian, 360.0 / 400.0,
|
||||
i18nc("angle unit symbol", "grad"),
|
||||
i18nc("unit description in lists", "gradians"),
|
||||
i18nc("unit synonyms for matching user input", "grad;gradian;gradians;grade;gon"),
|
||||
ki18nc("amount in units (real)", "%1 gradians"),
|
||||
ki18ncp("amount in units (integer)", "%1 gradian", "%1 gradians")
|
||||
);
|
||||
U(ArcMinute, 1.0 / 60.0,
|
||||
i18nc("angle unit symbol", "'"),
|
||||
i18nc("unit description in lists", "arc minutes"),
|
||||
i18nc("unit synonyms for matching user input", "minute of arc;MOA;arcminute;minute;'"),
|
||||
ki18nc("amount in units (real)", "%1 arc minutes"),
|
||||
ki18ncp("amount in units (integer)", "%1 arc minute", "%1 arc minutes")
|
||||
);
|
||||
U(ArcSecond, 1.0 / 3600.0,
|
||||
i18nc("angle unit symbol", "\""),
|
||||
i18nc("unit description in lists", "arc seconds"),
|
||||
i18nc("unit synonyms for matching user input", "second of arc;arcsecond;second;\""),
|
||||
ki18nc("amount in units (real)", "%1 arc seconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 arc second", "%1 arc seconds")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() << Degree << Radian << ArcMinute << ArcSecond);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef ANGLE_H
|
||||
#define ANGLE_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Angle : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Angle();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,247 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "area.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Area::Area() : UnitCategory(AreaCategory)
|
||||
{
|
||||
setName(i18nc("Unit Category: two dimensional size of a surface", "Area"));
|
||||
// i18n: Used when converting to symbol string e.g. 2.34 m²
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (area)", "%1 %2"));
|
||||
|
||||
U(SquareYottameter, 1e+48,
|
||||
// i18n: Used when unit symbol is needed.
|
||||
i18nc("area unit symbol", "Ym²"),
|
||||
// i18n: unit as it will be shown to user wherever units are to
|
||||
// be explicitly selected (listbox, radio buttons, checkboxes...).
|
||||
// E.g. an application may give option "Unit of wind speed: [unit-list-box]"
|
||||
i18nc("unit description in lists", "square yottameters"),
|
||||
// i18n: Messages such as this one provide synonyms for each unit,
|
||||
// in order to guess the unit from the text that the user inputs.
|
||||
// Synonyms are semicolon-separated, and you can add as many as
|
||||
// you need (either equal to, more, or less than in the original).
|
||||
// Note that any gramatical inflections of unit names
|
||||
// (such as plural and cases) should also be listed.
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square yottameter;square yottameters;Ym²;Ym/-2;Ym^2;Ym2"),
|
||||
// i18n: This is used when a real-valued amount in units is given,
|
||||
// such as "0.37 miles".
|
||||
ki18nc("amount in units (real)", "%1 square yottameters"),
|
||||
// i18n: This is used when a integer-valued amount in units is given,
|
||||
// such as "1 mile" or "21 miles".
|
||||
ki18ncp("amount in units (integer)", "%1 square yottameter", "%1 square yottameters")
|
||||
);
|
||||
U(SquareZettameter, 1e+42,
|
||||
i18nc("area unit symbol", "Zm²"),
|
||||
i18nc("unit description in lists", "square zettameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square zettameter;square zettameters;Zm²;Zm/-2;Zm^2;Zm2"),
|
||||
ki18nc("amount in units (real)", "%1 square zettameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square zettameter", "%1 square zettameters")
|
||||
);
|
||||
U(SquareExameter, 1e+36,
|
||||
i18nc("area unit symbol", "Em²"),
|
||||
i18nc("unit description in lists", "square exameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square exameter;square exameters;Em²;Em/-2;Em^2;Em2"),
|
||||
ki18nc("amount in units (real)", "%1 square exameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square exameter", "%1 square exameters")
|
||||
);
|
||||
U(SquarePetameter, 1e+30,
|
||||
i18nc("area unit symbol", "Pm²"),
|
||||
i18nc("unit description in lists", "square petameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square petameter;square petameters;Pm²;Pm/-2;Pm^2;Pm2"),
|
||||
ki18nc("amount in units (real)", "%1 square petameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square petameter", "%1 square petameters")
|
||||
);
|
||||
U(SquareTerameter, 1e+24,
|
||||
i18nc("area unit symbol", "Tm²"),
|
||||
i18nc("unit description in lists", "square terameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square terameter;square terameters;Tm²;Tm/-2;Tm^2;Tm2"),
|
||||
ki18nc("amount in units (real)", "%1 square terameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square terameter", "%1 square terameters")
|
||||
);
|
||||
U(SquareGigameter, 1e+18,
|
||||
i18nc("area unit symbol", "Gm²"),
|
||||
i18nc("unit description in lists", "square gigameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square gigameter;square gigameters;Gm²;Gm/-2;Gm^2;Gm2"),
|
||||
ki18nc("amount in units (real)", "%1 square gigameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square gigameter", "%1 square gigameters")
|
||||
);
|
||||
U(SquareMegameter, 1e+12,
|
||||
i18nc("area unit symbol", "Mm²"),
|
||||
i18nc("unit description in lists", "square megameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square megameter;square megameters;Mm²;Mm/-2;Mm^2;Mm2"),
|
||||
ki18nc("amount in units (real)", "%1 square megameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square megameter", "%1 square megameters")
|
||||
);
|
||||
U(SquareKilometer, 1e+06,
|
||||
i18nc("area unit symbol", "km²"),
|
||||
i18nc("unit description in lists", "square kilometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square kilometer;square kilometers;km²;km/-2;km^2;km2"),
|
||||
ki18nc("amount in units (real)", "%1 square kilometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square kilometer", "%1 square kilometers")
|
||||
);
|
||||
U(SquareHectometer, 10000,
|
||||
i18nc("area unit symbol", "hm²"),
|
||||
i18nc("unit description in lists", "square hectometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square hectometer;square hectometers;hm²;hm/-2;hm^2;hm2;hectare;hectares"),
|
||||
ki18nc("amount in units (real)", "%1 square hectometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square hectometer", "%1 square hectometers")
|
||||
);
|
||||
U(SquareDecameter, 100,
|
||||
i18nc("area unit symbol", "dam²"),
|
||||
i18nc("unit description in lists", "square decameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square decameter;square decameters;dam²;dam/-2;dam^2;dam2"),
|
||||
ki18nc("amount in units (real)", "%1 square decameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square decameter", "%1 square decameters")
|
||||
);
|
||||
setDefaultUnit(UP(SquareMeter, 1,
|
||||
i18nc("area unit symbol", "m²"),
|
||||
i18nc("unit description in lists", "square meters"),
|
||||
i18nc("unit synonyms for matching user input", "square meter;square meters;m²;m/-2;m^2;m2"),
|
||||
ki18nc("amount in units (real)", "%1 square meters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square meter", "%1 square meters")
|
||||
));
|
||||
U(SquareDecimeter, 0.01,
|
||||
i18nc("area unit symbol", "dm²"),
|
||||
i18nc("unit description in lists", "square decimeters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square decimeter;square decimeters;dm²;dm/-2;dm^2;dm2"),
|
||||
ki18nc("amount in units (real)", "%1 square decimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square decimeter", "%1 square decimeters")
|
||||
);
|
||||
U(SquareCentimeter, 0.0001,
|
||||
i18nc("area unit symbol", "cm²"),
|
||||
i18nc("unit description in lists", "square centimeters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square centimeter;square centimeters;cm²;cm/-2;cm^2;cm2"),
|
||||
ki18nc("amount in units (real)", "%1 square centimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square centimeter", "%1 square centimeters")
|
||||
);
|
||||
U(SquareMillimeter, 1e-06,
|
||||
i18nc("area unit symbol", "mm²"),
|
||||
i18nc("unit description in lists", "square millimeters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square millimeter;square millimeters;mm²;mm/-2;mm^2;mm2"),
|
||||
ki18nc("amount in units (real)", "%1 square millimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square millimeter", "%1 square millimeters")
|
||||
);
|
||||
U(SquareMicrometer, 1e-12,
|
||||
i18nc("area unit symbol", "µm²"),
|
||||
i18nc("unit description in lists", "square micrometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square micrometer;square micrometers;µm²;um²;µm/-2;µm^2;µm2"),
|
||||
ki18nc("amount in units (real)", "%1 square micrometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square micrometer", "%1 square micrometers")
|
||||
);
|
||||
U(SquareNanometer, 1e-18,
|
||||
i18nc("area unit symbol", "nm²"),
|
||||
i18nc("unit description in lists", "square nanometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square nanometer;square nanometers;nm²;nm/-2;nm^2;nm2"),
|
||||
ki18nc("amount in units (real)", "%1 square nanometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square nanometer", "%1 square nanometers")
|
||||
);
|
||||
U(SquarePicometer, 1e-24,
|
||||
i18nc("area unit symbol", "pm²"),
|
||||
i18nc("unit description in lists", "square picometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square picometer;square picometers;pm²;pm/-2;pm^2;pm2"),
|
||||
ki18nc("amount in units (real)", "%1 square picometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square picometer", "%1 square picometers")
|
||||
);
|
||||
U(SquareFemtometer, 1e-30,
|
||||
i18nc("area unit symbol", "fm²"),
|
||||
i18nc("unit description in lists", "square femtometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square femtometer;square femtometers;fm²;fm/-2;fm^2;fm2"),
|
||||
ki18nc("amount in units (real)", "%1 square femtometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square femtometer", "%1 square femtometers")
|
||||
);
|
||||
U(SquareAttometer, 1e-36,
|
||||
i18nc("area unit symbol", "am²"),
|
||||
i18nc("unit description in lists", "square attometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square attometer;square attometers;am²;am/-2;am^2;am2"),
|
||||
ki18nc("amount in units (real)", "%1 square attometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square attometer", "%1 square attometers")
|
||||
);
|
||||
U(SquareZeptometer, 1e-42,
|
||||
i18nc("area unit symbol", "zm²"),
|
||||
i18nc("unit description in lists", "square zeptometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square zeptometer;square zeptometers;zm²;zm/-2;zm^2;zm2"),
|
||||
ki18nc("amount in units (real)", "%1 square zeptometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square zeptometer", "%1 square zeptometers")
|
||||
);
|
||||
U(SquareYoctometer, 1e-48,
|
||||
i18nc("area unit symbol", "ym²"),
|
||||
i18nc("unit description in lists", "square yoctometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square yoctometer;square yoctometers;ym²;ym/-2;ym^2;ym2"),
|
||||
ki18nc("amount in units (real)", "%1 square yoctometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square yoctometer", "%1 square yoctometers")
|
||||
);
|
||||
U(Acre, 4046.86,
|
||||
i18nc("area unit symbol", "acre"),
|
||||
i18nc("unit description in lists", "acres"),
|
||||
i18nc("unit synonyms for matching user input", "acre;acres"),
|
||||
ki18nc("amount in units (real)", "%1 acres"),
|
||||
ki18ncp("amount in units (integer)", "%1 acre", "%1 acres")
|
||||
);
|
||||
U(SquareFoot, 0.092903,
|
||||
i18nc("area unit symbol", "ft²"),
|
||||
i18nc("unit description in lists", "square feet"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square foot;square feet;ft²;square ft;sq foot;sq ft;sq feet;feet²"),
|
||||
ki18nc("amount in units (real)", "%1 square feet"),
|
||||
ki18ncp("amount in units (integer)", "%1 square foot", "%1 square feet")
|
||||
);
|
||||
U(SquareInch, 0.00064516,
|
||||
i18nc("area unit symbol", "in²"),
|
||||
i18nc("unit description in lists", "square inches"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square inch;square inches;in²;square inch;square in;sq inches;sq inch;sq in;inch²"),
|
||||
ki18nc("amount in units (real)", "%1 square inches"),
|
||||
ki18ncp("amount in units (integer)", "%1 square inch", "%1 square inches")
|
||||
);
|
||||
U(SquareMile, 2.58999e+06,
|
||||
i18nc("area unit symbol", "mi²"),
|
||||
i18nc("unit description in lists", "square miles"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"square mile;square miles;mi²;square mi;sq miles;sq mile;sq mi;mile²"),
|
||||
ki18nc("amount in units (real)", "%1 square miles"),
|
||||
ki18ncp("amount in units (integer)", "%1 square mile", "%1 square miles")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
SquareKilometer << SquareMeter << SquareHectometer << Acre << SquareFoot << SquareMile);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef AREA_H
|
||||
#define AREA_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Area : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Area();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,3 +0,0 @@
|
|||
#cmakedefine KUNITCONVERSION_NO_SOLID
|
||||
#cmakedefine KUNITCONVERSION_NO_KIO
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "converter.h"
|
||||
|
||||
#include <kglobal.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "unitcategory.h"
|
||||
#include "area.h"
|
||||
#include "length.h"
|
||||
#include "currency.h"
|
||||
#include "density.h"
|
||||
#include "energy.h"
|
||||
#include "fuel_efficiency.h"
|
||||
#include "mass.h"
|
||||
#include "power.h"
|
||||
#include "pressure.h"
|
||||
#include "temperature.h"
|
||||
#include "timeunit.h"
|
||||
#include "unit.h"
|
||||
#include "velocity.h"
|
||||
#include "volume.h"
|
||||
#include "acceleration.h"
|
||||
#include "force.h"
|
||||
#include "angle.h"
|
||||
#include "frequency.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
|
||||
class Invalid : public UnitCategory
|
||||
{
|
||||
public:
|
||||
Invalid() : UnitCategory(InvalidCategory)
|
||||
{
|
||||
const QString s;
|
||||
const KLocalizedString ls;
|
||||
setName(i18n("Invalid"));
|
||||
setDefaultUnit(UP(InvalidUnit, 1.0, s, s, s, ls, ls));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (default)", "%1 %2"));
|
||||
};
|
||||
};
|
||||
|
||||
class ConverterPrivate
|
||||
{
|
||||
public:
|
||||
QMap<int, UnitCategory *> categories;
|
||||
ConverterPrivate()
|
||||
{
|
||||
KGlobal::locale()->insertCatalog("libkunitconversion");
|
||||
|
||||
categories[InvalidCategory] = new Invalid;
|
||||
categories[LengthCategory] = new Length;
|
||||
categories[AreaCategory] = new Area();
|
||||
categories[VolumeCategory] = new Volume;
|
||||
categories[TemperatureCategory] = new Temperature;
|
||||
categories[VelocityCategory] = new Velocity;
|
||||
categories[MassCategory] = new Mass;
|
||||
categories[PressureCategory] = new Pressure;
|
||||
categories[EnergyCategory] = new Energy;
|
||||
categories[CurrencyCategory] = new Currency;
|
||||
categories[PowerCategory] = new Power;
|
||||
categories[TimeCategory] = new Time;
|
||||
categories[FuelEfficiencyCategory] = new FuelEfficiency;
|
||||
categories[DensityCategory] = new Density;
|
||||
categories[AccelerationCategory] = new Acceleration;
|
||||
categories[ForceCategory] = new Force;
|
||||
categories[AngleCategory] = new Angle;
|
||||
categories[FrequencyCategory] = new Frequency;
|
||||
};
|
||||
|
||||
~ConverterPrivate()
|
||||
{
|
||||
qDeleteAll(categories);
|
||||
};
|
||||
};
|
||||
|
||||
K_GLOBAL_STATIC(ConverterPrivate, static_d)
|
||||
|
||||
Converter::Converter(QObject* parent)
|
||||
: QObject(parent), d(static_cast<ConverterPrivate *>(static_d))
|
||||
{
|
||||
}
|
||||
|
||||
Converter::~Converter()
|
||||
{
|
||||
}
|
||||
|
||||
Value Converter::convert(const Value& value, const QString& toUnit) const
|
||||
{
|
||||
if (!value.unit().isNull()) {
|
||||
UnitCategory* category = value.unit()->category();
|
||||
if (category) {
|
||||
return category->convert(value, toUnit);
|
||||
}
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value Converter::convert(const Value& value, int toUnit) const
|
||||
{
|
||||
if (!value.unit().isNull()) {
|
||||
UnitCategory* category = value.unit()->category();
|
||||
if (category) {
|
||||
return category->convert(value, toUnit);
|
||||
}
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value Converter::convert(const Value& value, UnitPtr toUnit) const
|
||||
{
|
||||
if (!toUnit.isNull() && !value.unit().isNull() && value.unit()->isValid()) {
|
||||
UnitCategory* category = value.unit()->category();
|
||||
if (category) {
|
||||
return category->convert(value, toUnit);
|
||||
}
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
UnitCategory* Converter::categoryForUnit(const QString& unit) const
|
||||
{
|
||||
foreach (UnitCategory* u, categories()) {
|
||||
if (u->hasUnit(unit)) {
|
||||
return u;
|
||||
}
|
||||
}
|
||||
return d->categories[InvalidCategory];
|
||||
}
|
||||
|
||||
UnitPtr Converter::unit(const QString& unitString) const
|
||||
{
|
||||
foreach (UnitCategory* u, d->categories) {
|
||||
UnitPtr unitClass = u->unit(unitString);
|
||||
if (unitClass) {
|
||||
return unitClass;
|
||||
}
|
||||
}
|
||||
return unit(InvalidUnit);
|
||||
}
|
||||
|
||||
UnitPtr Converter::unit(int unitId) const
|
||||
{
|
||||
foreach (UnitCategory* u, d->categories) {
|
||||
UnitPtr unitClass = u->unit(unitId);
|
||||
if (unitClass) {
|
||||
return unitClass;
|
||||
}
|
||||
}
|
||||
return d->categories[InvalidCategory]->defaultUnit();
|
||||
}
|
||||
|
||||
UnitCategory* Converter::category(const QString& category) const
|
||||
{
|
||||
foreach (UnitCategory *u, d->categories) {
|
||||
if (u->name() == category)
|
||||
return u;
|
||||
}
|
||||
// not found
|
||||
return d->categories[InvalidCategory];
|
||||
}
|
||||
|
||||
UnitCategory* Converter::category(int categoryId) const
|
||||
{
|
||||
if (d->categories.contains(categoryId)) {
|
||||
return d->categories[categoryId];
|
||||
}
|
||||
// not found
|
||||
return d->categories[InvalidCategory];
|
||||
}
|
||||
|
||||
QList<UnitCategory*> Converter::categories() const
|
||||
{
|
||||
QList<UnitCategory*> categories = d->categories.values();
|
||||
categories.removeAt(0);
|
||||
return categories;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_converter.cpp"
|
|
@ -1,209 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KUNITCONVERSION_CONVERTER_H
|
||||
#define KUNITCONVERSION_CONVERTER_H
|
||||
|
||||
#include <kunitconversion/value.h>
|
||||
#include <kunitconversion/kunitconversion_export.h>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
enum CategoryId {
|
||||
InvalidCategory = -1, LengthCategory, AreaCategory, VolumeCategory, TemperatureCategory,
|
||||
VelocityCategory, MassCategory, PressureCategory, EnergyCategory, CurrencyCategory,
|
||||
PowerCategory, TimeCategory, FuelEfficiencyCategory, DensityCategory, AccelerationCategory,
|
||||
AngleCategory, FrequencyCategory, ForceCategory
|
||||
};
|
||||
enum UnitId {
|
||||
InvalidUnit = -1, NoUnit = 0, Percent = 1,
|
||||
// Area
|
||||
SquareYottameter = 1000, SquareZettameter, SquareExameter, SquarePetameter, SquareTerameter,
|
||||
SquareGigameter, SquareMegameter, SquareKilometer, SquareHectometer, SquareDecameter,
|
||||
SquareMeter, SquareDecimeter, SquareCentimeter, SquareMillimeter, SquareMicrometer,
|
||||
SquareNanometer, SquarePicometer, SquareFemtometer, SquareAttometer, SquareZeptometer,
|
||||
SquareYoctometer, Acre, SquareFoot, SquareInch, SquareMile,
|
||||
|
||||
// Length
|
||||
Yottameter = 2000, Zettameter, Exameter, Petameter, Terameter, Gigameter, Megameter,
|
||||
Kilometer, Hectometer, Decameter, Meter, Decimeter, Centimeter, Millimeter, Micrometer,
|
||||
Nanometer, Picometer, Femtometer, Attometer, Zeptometer, Yoctometer, Inch, Foot, Yard,
|
||||
Mile, NauticalMile, LightYear, Parsec, AstronomicalUnit, Thou, Angstrom,
|
||||
|
||||
// Volume
|
||||
CubicYottameter = 3000, CubicZettameter, CubicExameter, CubicPetameter, CubicTerameter,
|
||||
CubicGigameter, CubicMegameter, CubicKilometer, CubicHectometer, CubicDecameter, CubicMeter,
|
||||
CubicDecimeter, CubicCentimeter, CubicMillimeter, CubicMicrometer, CubicNanometer,
|
||||
CubicPicometer, CubicFemtometer, CubicAttometer, CubicZeptometer, CubicYoctometer,
|
||||
Yottaliter, Zettaliter, Exaliter, Petaliter, Teraliter, Gigaliter, Megaliter, Kiloliter,
|
||||
Hectoliter, Decaliter, Liter, Deciliter, Centiliter, Milliliter, Microliter, Nanoliter,
|
||||
Picoliter, Femtoliter, Attoliter, Zeptoliter, Yoctoliter, CubicFoot, CubicInch, CubicMile,
|
||||
FluidOunce, Cup, GallonUS, PintImperial,
|
||||
|
||||
// Mass
|
||||
Yottagram = 4000, Zettagram, Exagram, Petagram, Teragram, Gigagram, Megagram, Kilogram,
|
||||
Hectogram, Decagram, Gram, Decigram, Centigram, Milligram, Microgram, Nanogram, Picogram,
|
||||
Femtogram, Attogram, Zeptogram, Yoctogram, Ton, Carat, Pound, Ounce, TroyOunce, MassNewton,
|
||||
Kilonewton,
|
||||
|
||||
// Pressure
|
||||
Yottapascal = 5000, Zettapascal, Exapascal, Petapascal, Terapascal, Gigapascal, Megapascal,
|
||||
Kilopascal, Hectopascal, Decapascal, Pascal, Decipascal, Centipascal, Millipascal,
|
||||
Micropascal, Nanopascal, Picopascal, Femtopascal, Attopascal, Zeptopascal, Yoctopascal,
|
||||
Bar, Millibar, Decibar, Torr, TechnicalAtmosphere, Atmosphere, PoundForcePerSquareInch,
|
||||
InchesOfMercury, MillimetersOfMercury,
|
||||
|
||||
// Temperature
|
||||
Kelvin = 6000, Celsius, Fahrenheit, Rankine, Delisle, TemperatureNewton, Reaumur, Romer,
|
||||
|
||||
// Energy
|
||||
Yottajoule = 7000, Zettajoule, Exajoule, Petajoule, Terajoule, Gigajoule, Megajoule,
|
||||
Kilojoule, Hectojoule, Decajoule, Joule, Decijoule, Centijoule, Millijoule, Microjoule,
|
||||
Nanojoule, Picojoule, Femtojoule, Attojoule, Zeptojoule, Yoctojoule, GuidelineDailyAmount,
|
||||
Electronvolt, Rydberg, Kilocalorie, PhotonWavelength, KiloJoulePerMole, JoulePerMole,
|
||||
|
||||
// Currency
|
||||
Eur = 8000, Ats, Bef, Nlg, Fim, Frf, Dem, Iep, Itl, Luf, Pte, Esp, Grd, Sit, Cyp, Mtl, Skk,
|
||||
Usd, Jpy, Bgn, Czk, Dkk, Eek, Gbp, Huf, Ltl, Lvl, Pln, Ron, Sek, Chf, Nok, Hrk, Rub, Try,
|
||||
Aud, Brl, Cad, Cny, Hkd, Idr, Inr, Krw, Mxn, Myr, Nzd, Php, Sgd, Thb, Zar,
|
||||
|
||||
// Velocity
|
||||
MeterPerSecond = 9000, KilometerPerHour, MilePerHour, FootPerSecond, InchPerSecond, Knot,
|
||||
Mach, SpeedOfLight, Beaufort,
|
||||
|
||||
// Power
|
||||
Yottawatt = 10000, Zettawatt, Exawatt, Petawatt, Terawatt, Gigawatt, Megawatt, Kilowatt,
|
||||
Hectowatt, Decawatt, Watt, Deciwatt, Centiwatt, Milliwatt, Microwatt, Nanowatt, Picowatt,
|
||||
Femtowatt, Attowatt, Zeptowatt, Yoctowatt, Horsepower,
|
||||
|
||||
// Time
|
||||
Yottasecond = 11000, Zettasecond, Exasecond, Petasecond, Terasecond, Gigasecond, Megasecond,
|
||||
Kilosecond, Hectosecond, Decasecond, Second, Decisecond, Centisecond, Millisecond,
|
||||
Microsecond, Nanosecond, Picosecond, Femtosecond, Attosecond, Zeptosecond, Yoctosecond,
|
||||
Minute, Hour, Day, Week, JulianYear, LeapYear, Year,
|
||||
|
||||
// FuelEfficiency
|
||||
LitersPer100Kilometers = 12000, MilePerUsGallon, MilePerImperialGallon, KilometrePerLitre,
|
||||
|
||||
// Density
|
||||
YottakilogramsPerCubicMeter = 13000, ZettakilogramPerCubicMeter, ExakilogramPerCubicMeter,
|
||||
PetakilogramPerCubicMeter, TerakilogramPerCubicMeter, GigakilogramPerCubicMeter,
|
||||
MegakilogramPerCubicMeter, KilokilogramPerCubicMeter, HectokilogramsPerCubicMeter,
|
||||
DecakilogramsPerCubicMeter, KilogramsPerCubicMeter, DecikilogramsPerCubicMeter,
|
||||
CentikilogramsPerCubicMeter, MillikilogramsPerCubicMeter, MicrokilogramsPerCubicMeter,
|
||||
NanokilogramsPerCubicMeter, PicokilogramsPerCubicMeter, FemtokilogramsPerCubicMeter,
|
||||
AttokilogramsPerCubicMeter, ZeptokilogramsPerCubicMeter, YoctokilogramsPerCubicMeter,
|
||||
KilogramPerLiter, GramPerLiter, GramPerMilliliter,
|
||||
OuncePerCubicInch, OuncePerCubicFoot, OuncePerCubicYard,
|
||||
PoundPerCubicInch, PoundPerCubicFoot, PoundPerCubicYard,
|
||||
|
||||
// Acceleration
|
||||
MetresPerSecondSquared = 14000, FeetPerSecondSquared, StandardGravity,
|
||||
|
||||
// Force
|
||||
Yottanewton = 15000, Zettanewton, Exanewton, Petanewton, Teranewton, Giganewton, Meganewton,
|
||||
KilonewtonForce, Hectonewton, Decanewton, Newton, Decinewton, Centinewton, Millinewton, Micronewton,
|
||||
Nanonewton, Piconewton, Femtonewton, Attonewton, Zeptonewton, Yoctonewton, Dyne, Kilopond,
|
||||
PoundForce, Poundal,
|
||||
|
||||
// Angle
|
||||
Degree = 16000, Radian, Gradian, ArcMinute, ArcSecond,
|
||||
|
||||
// Frequency
|
||||
Yottahertz = 17000, Zettahertz, Exahertz, Petahertz, Terahertz, Gigahertz, Megahertz,
|
||||
Kilohertz, Hectohertz, Decahertz, Hertz, Decihertz, Centihertz, Millihertz, Microhertz,
|
||||
Nanohertz, Picohertz, Femtohertz, Attohertz, Zeptohertz, Yoctohertz, RPM
|
||||
};
|
||||
|
||||
class UnitCategory;
|
||||
|
||||
class ConverterPrivate;
|
||||
class KUNITCONVERSION_EXPORT Converter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Converter(QObject* parent = 0);
|
||||
~Converter();
|
||||
|
||||
/**
|
||||
* Convert value to another unit.
|
||||
*
|
||||
* @param value value to convert
|
||||
* @param toUnit unit to convert to. If empty default unit is used.
|
||||
* @return converted value
|
||||
**/
|
||||
Value convert(const Value& value, const QString& toUnit = QString()) const;
|
||||
Value convert(const Value& value, int toUnit) const;
|
||||
Value convert(const Value& value, UnitPtr toUnit) const;
|
||||
|
||||
/**
|
||||
* Find unit category for unit.
|
||||
*
|
||||
* @param unit unit to find category for.
|
||||
* @return unit category for unit
|
||||
**/
|
||||
UnitCategory* categoryForUnit(const QString& unit) const;
|
||||
|
||||
/**
|
||||
* Find unit for string unit.
|
||||
*
|
||||
* @param unitString unit string to find unit for.
|
||||
* @return unit for string unit
|
||||
**/
|
||||
UnitPtr unit(const QString& unitString) const;
|
||||
|
||||
/**
|
||||
* Find unit for unit enum.
|
||||
*
|
||||
* @param unit unit enum to find unit for.
|
||||
* @return unit for string unit
|
||||
**/
|
||||
UnitPtr unit(int unitId) const;
|
||||
|
||||
/**
|
||||
* Find unit category.
|
||||
*
|
||||
* @param category name of the category to find (length, area, mass, etc.).
|
||||
* @return unit category named category or invalid category.
|
||||
**/
|
||||
UnitCategory* category(const QString& category) const;
|
||||
|
||||
/**
|
||||
* Find unit category.
|
||||
*
|
||||
* @param categoryId id of the category to find (LengthCategory, AreaCategory, etc.).
|
||||
* @return unit category which id is categoryId or invalid category.
|
||||
**/
|
||||
UnitCategory* category(int categoryId) const;
|
||||
|
||||
/**
|
||||
* Returns a list of all unit categories.
|
||||
*
|
||||
* @return list of unit categories.
|
||||
**/
|
||||
QList<UnitCategory*> categories() const;
|
||||
|
||||
private:
|
||||
ConverterPrivate *d;
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -1,593 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "currency.h"
|
||||
|
||||
#include "config-kunitconversion.h"
|
||||
|
||||
#include "converter.h"
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtXml/qdom.h>
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#ifndef KUNITCONVERSION_NO_SOLID
|
||||
#include <solid/networking.h>
|
||||
#endif
|
||||
|
||||
#ifdef KUNITCONVERSION_NO_KIO
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
#endif
|
||||
|
||||
#include <kcurrencycode.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
static const char URL[] = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
|
||||
|
||||
Currency::Currency() : UnitCategory(CurrencyCategory)
|
||||
{
|
||||
setName(i18n("Currency"));
|
||||
setDescription(i18n("From ECB"));
|
||||
setUrl(KUrl("https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (currency)", "%1 %2"));
|
||||
|
||||
// Static rates
|
||||
setDefaultUnit(UP(Eur, 1,
|
||||
"EUR",
|
||||
KCurrencyCode::currencyCodeToName("EUR"),
|
||||
i18nc("EUR Euro - unit synonyms for matching user input", "euro;euros") +
|
||||
";EUR;" + QString::fromUtf8("€") + ';' + KCurrencyCode::currencyCodeToName("EUR"),
|
||||
ki18nc("amount in units (real)", "%1 euros"),
|
||||
ki18ncp("amount in units (integer)", "%1 euro", "%1 euros")
|
||||
));
|
||||
U(Ats, 0.0726728,
|
||||
"ATS",
|
||||
KCurrencyCode::currencyCodeToName("ATS"),
|
||||
i18nc("ATS Austrian Schilling - unit synonyms for matching user input",
|
||||
"schilling;schillings") + ";ATS;" + KGlobal::locale()->countryCodeToName("at") +';' +
|
||||
KCurrencyCode::currencyCodeToName("ATS"),
|
||||
ki18nc("amount in units (real)", "%1 schillings"),
|
||||
ki18ncp("amount in units (integer)", "%1 schilling", "%1 schillings")
|
||||
);
|
||||
U(Bef, 0.0247894,
|
||||
"BEF",
|
||||
KCurrencyCode::currencyCodeToName("BEF"),
|
||||
i18nc("BEF Belgian Franc - unit synonyms for matching user input", "franc;francs") +
|
||||
";BEF;" + KGlobal::locale()->countryCodeToName("be") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("BEF"),
|
||||
ki18nc("amount in units (real)", "%1 Belgian francs"),
|
||||
ki18ncp("amount in units (integer)", "%1 Belgian franc", "%1 Belgian francs")
|
||||
);
|
||||
U(Nlg, 0.45378,
|
||||
"NLG",
|
||||
KCurrencyCode::currencyCodeToName("NLG"),
|
||||
i18nc("NLG Netherlands Guilder - unit synonyms for matching user input", "guilder;guilders") +
|
||||
";NLG;" + KGlobal::locale()->countryCodeToName("nl") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("NLG"),
|
||||
ki18nc("amount in units (real)", "%1 guilders"),
|
||||
ki18ncp("amount in units (integer)", "%1 guilder", "%1 guilders")
|
||||
);
|
||||
U(Fim, 0.168188,
|
||||
"FIM",
|
||||
KCurrencyCode::currencyCodeToName("FIM"),
|
||||
i18nc("FIM Finnish Markka - unit synonyms for matching user input",
|
||||
"markka;markkas;markkaa") + ";FIM;" +
|
||||
KGlobal::locale()->countryCodeToName("fi") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("FIM"),
|
||||
ki18nc("amount in units (real)", "%1 markkas"),
|
||||
ki18ncp("amount in units (integer)", "%1 markka", "%1 markkas") // Alternative = markkaa
|
||||
);
|
||||
U(Frf, 0.152449,
|
||||
"FRF",
|
||||
KCurrencyCode::currencyCodeToName("FRF"),
|
||||
i18nc("FRF French Franc - unit synonyms for matching user input", "franc;francs") + ";FRF;" +
|
||||
KGlobal::locale()->countryCodeToName("fr") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("FRF"),
|
||||
ki18nc("amount in units (real)", "%1 French francs"),
|
||||
ki18ncp("amount in units (integer)", "%1 French franc", "%1 French francs")
|
||||
);
|
||||
U(Dem, 0.511292,
|
||||
"DEM",
|
||||
KCurrencyCode::currencyCodeToName("DEM"),
|
||||
i18nc("DEM German Mark - unit synonyms for matching user input", "mark;marks") + ";DEM;" +
|
||||
KGlobal::locale()->countryCodeToName("de") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("DEM"),
|
||||
ki18nc("amount in units (real)", "%1 marks"),
|
||||
ki18ncp("amount in units (integer)", "%1 mark", "%1 marks")
|
||||
);
|
||||
U(Iep, 1.26974,
|
||||
"IEP",
|
||||
KCurrencyCode::currencyCodeToName("IEP"),
|
||||
i18nc("IEP Irish Pound - unit synonyms for matching user input", "Irish pound;Irish pounds") +
|
||||
";IEP;" + KGlobal::locale()->countryCodeToName("ie") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("IEP"),
|
||||
ki18nc("amount in units (real)", "%1 Irish pounds"),
|
||||
ki18ncp("amount in units (integer)", "%1 Irish pound", "%1 Irish pounds")
|
||||
);
|
||||
U(Itl, 0.000516457,
|
||||
"ITL",
|
||||
KCurrencyCode::currencyCodeToName("ITL"),
|
||||
i18nc("ITL Italian Lira - unit synonyms for matching user input", "lira;liras") + ";ITL;" +
|
||||
KGlobal::locale()->countryCodeToName("it") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("ITL"),
|
||||
ki18nc("amount in units (real)", "%1 Italian lira"),
|
||||
ki18ncp("amount in units (integer)", "%1 Italian lira", "%1 Italian lira")
|
||||
);
|
||||
U(Luf, 0.0247894,
|
||||
"LUF",
|
||||
KCurrencyCode::currencyCodeToName("LUF"),
|
||||
i18nc("LUF Luxembourgish Franc - unit synonyms for matching user input", "franc;francs") +
|
||||
";LUF;" + KGlobal::locale()->countryCodeToName("lu") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("LUF"),
|
||||
ki18nc("amount in units (real)", "%1 Luxembourgish francs"),
|
||||
ki18ncp("amount in units (integer)", "%1 Luxembourgish franc", "%1 Luxembourgish francs")
|
||||
);
|
||||
U(Pte, 0.00498798,
|
||||
"PTE",
|
||||
KCurrencyCode::currencyCodeToName("PTE"),
|
||||
i18nc("PTE Portugeuse Escudo - unit synonyms for matching user input", "escudo;escudos") +
|
||||
";PTE;" + KGlobal::locale()->countryCodeToName("pt") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("PTE"),
|
||||
ki18nc("amount in units (real)", "%1 escudos"),
|
||||
ki18ncp("amount in units (integer)", "%1 escudo", "%1 escudos")
|
||||
);
|
||||
U(Esp, 0.00601012,
|
||||
"ESP",
|
||||
KCurrencyCode::currencyCodeToName("ESP"),
|
||||
i18nc("ESP Spanish Pesetas - unit synonyms for matching user input", "peseta;pesetas") +
|
||||
";ESP;" + KGlobal::locale()->countryCodeToName("es") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("ESP"),
|
||||
ki18nc("amount in units (real)", "%1 pesetas"),
|
||||
ki18ncp("amount in units (integer)", "%1 peseta", "%1 pesetas")
|
||||
);
|
||||
U(Grd, 0.0029347,
|
||||
"GRD",
|
||||
KCurrencyCode::currencyCodeToName("GRD"),
|
||||
i18nc("GRD Greek Drachma - unit synonyms for matching user input", "drachma;drachmas") +
|
||||
";GRD;" + KGlobal::locale()->countryCodeToName("gr") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("GRD"),
|
||||
ki18nc("amount in units (real)", "%1 drachmas"),
|
||||
ki18ncp("amount in units (integer)", "%1 drachma", "%1 drachmas")
|
||||
);
|
||||
U(Sit, 0.00417293,
|
||||
"SIT",
|
||||
KCurrencyCode::currencyCodeToName("SIT"),
|
||||
i18nc("SIT Slovenian Tolar - unit synonyms for matching user input", "tolar;tolars;tolarjev") + ";SIT;" +
|
||||
KGlobal::locale()->countryCodeToName("si") + ';' + KCurrencyCode::currencyCodeToName("SIT"),
|
||||
ki18nc("amount in units (real)", "%1 tolars"),
|
||||
ki18ncp("amount in units (integer)", "%1 tolar", "%1 tolars") //Alt: tolarjev/tolarja/tolarji
|
||||
);
|
||||
U(Cyp, 1.7086,
|
||||
"CYP",
|
||||
KCurrencyCode::currencyCodeToName("CYP"),
|
||||
i18nc("CYP Cypriot Pound - unit synonyms for matching user input",
|
||||
"Cypriot pound;Cypriot pounds") + ";CYP;" +
|
||||
KGlobal::locale()->countryCodeToName("cy") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("CYP"),
|
||||
ki18nc("amount in units (real)", "%1 Cypriot pounds"),
|
||||
ki18ncp("amount in units (integer)", "%1 Cypriot pound", "%1 Cypriot pounds")
|
||||
);
|
||||
U(Mtl, 2.32937,
|
||||
"MTL",
|
||||
KCurrencyCode::currencyCodeToName("MTL"),
|
||||
i18nc("MTL Maltese Lira - unit synonyms for matching user input", "Maltese lira") + ";MTL;" +
|
||||
KGlobal::locale()->countryCodeToName("mt") + ';' + KCurrencyCode::currencyCodeToName("MTL"),
|
||||
ki18nc("amount in units (real)", "%1 Maltese lira"),
|
||||
ki18ncp("amount in units (integer)", "%1 Maltese lira", "%1 Maltese lira")
|
||||
);
|
||||
U(Skk, 0.0331939,
|
||||
"SKK",
|
||||
KCurrencyCode::currencyCodeToName("SKK"),
|
||||
i18nc("SKK Slovak Koruna - unit synonyms for matching user input",
|
||||
"koruna;korunas;koruny;korun") + ";SKK;" +
|
||||
KGlobal::locale()->countryCodeToName("sk") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("SKK"),
|
||||
ki18nc("amount in units (real)", "%1 Slovak korunas"),
|
||||
ki18ncp("amount in units (integer)", "%1 Slovak koruna", "%1 Slovak korunas") // Alt: koruny, korun
|
||||
);
|
||||
|
||||
// From ECB
|
||||
U(Usd, 1e+99,
|
||||
"USD",
|
||||
KCurrencyCode::currencyCodeToName("USD"),
|
||||
i18nc("USD United States Dollars - unit synonyms for matching user input", "dollar;dollars") +
|
||||
";USD;$;" + KGlobal::locale()->countryCodeToName("us") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("USD"),
|
||||
ki18nc("amount in units (real)", "%1 United States dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 United States dollar", "%1 United States dollars")
|
||||
);
|
||||
U(Jpy, 1e+99,
|
||||
"JPY",
|
||||
KCurrencyCode::currencyCodeToName("JPY"),
|
||||
i18nc("JPY Japanese Yen - unit synonyms for matching user input", "yen") +
|
||||
";JPY;" + QString::fromUtf8("¥") + ';' +
|
||||
KGlobal::locale()->countryCodeToName("jp") + ';' + KCurrencyCode::currencyCodeToName("JPY"),
|
||||
ki18nc("amount in units (real)", "%1 yen"),
|
||||
ki18ncp("amount in units (integer)", "%1 yen", "%1 yen")
|
||||
);
|
||||
U(Bgn, 1e+99,
|
||||
"BGN",
|
||||
KCurrencyCode::currencyCodeToName("BGN"),
|
||||
i18nc("BGN Bulgarian Lev - unit synonyms for matching user input", "lev;leva") + ";BGN;" +
|
||||
KGlobal::locale()->countryCodeToName("bg") + ';' + KCurrencyCode::currencyCodeToName("BGN"),
|
||||
ki18nc("amount in units (real)", "%1 leva"),
|
||||
ki18ncp("amount in units (integer)", "%1 lev", "%1 leva")
|
||||
);
|
||||
U(Czk, 1e+99,
|
||||
"CZK",
|
||||
KCurrencyCode::currencyCodeToName("CZK"),
|
||||
i18nc("CZK Czech Koruna - unit synonyms for matching user input", "koruna;korunas") +
|
||||
";CZK;" + KGlobal::locale()->countryCodeToName("cz") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("CZK"),
|
||||
ki18nc("amount in units (real)", "%1 Czech korunas"),
|
||||
// Alt: koruny, korun
|
||||
ki18ncp("amount in units (integer)", "%1 Czech koruna", "%1 Czech korunas")
|
||||
);
|
||||
U(Dkk, 1e+99,
|
||||
"DKK",
|
||||
KCurrencyCode::currencyCodeToName("DKK"),
|
||||
i18nc("DKK Danish Krone - unit synonyms for matching user input",
|
||||
"Danish krone;Danish kroner") + ";DKK;" +
|
||||
KGlobal::locale()->countryCodeToName("dk") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("DKK"),
|
||||
ki18nc("amount in units (real)", "%1 Danish kroner"),
|
||||
ki18ncp("amount in units (integer)", "%1 Danish krone", "%1 Danish kroner")
|
||||
);
|
||||
U(Eek, 1e+99,
|
||||
"EEK",
|
||||
KCurrencyCode::currencyCodeToName("EEK"),
|
||||
i18nc("EEK Estonian Kroon - unit synonyms for matching user input", "kroon;kroons;krooni") +
|
||||
";EEK;" + KGlobal::locale()->countryCodeToName("ee") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("EEK"),
|
||||
ki18nc("amount in units (real)", "%1 kroons"),
|
||||
ki18ncp("amount in units (integer)", "%1 kroon", "%1 kroons") // Alt: krooni
|
||||
);
|
||||
U(Gbp, 1e+99,
|
||||
"GBP",
|
||||
KCurrencyCode::currencyCodeToName("GBP"),
|
||||
i18nc("GBP British Pound - unit synonyms for matching user input",
|
||||
"pound;pounds;pound sterling;pounds sterling") +
|
||||
";GBP;" + QString::fromUtf8("£") + ';' +
|
||||
KGlobal::locale()->countryCodeToName("gb") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("GBP"),
|
||||
ki18nc("amount in units (real)", "%1 pounds sterling"),
|
||||
ki18ncp("amount in units (integer)", "%1 pound sterling", "%1 pounds sterling")
|
||||
);
|
||||
U(Huf, 1e+99,
|
||||
"HUF",
|
||||
KCurrencyCode::currencyCodeToName("HUF"),
|
||||
i18nc("HUF hungarian Forint - unit synonyms for matching user input", "forint") + ";HUF;" +
|
||||
KGlobal::locale()->countryCodeToName("hu") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("HUF"),
|
||||
ki18nc("amount in units (real)", "%1 forint"),
|
||||
ki18ncp("amount in units (integer)", "%1 forint", "%1 forint")
|
||||
);
|
||||
U(Ltl, 1e+99,
|
||||
"LTL",
|
||||
KCurrencyCode::currencyCodeToName("LTL"),
|
||||
i18nc("LTL Lithuanian Litas - unit synonyms for matching user input", "litas;litai;litu") +
|
||||
";LTL;" + KGlobal::locale()->countryCodeToName("lt") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("LTL"),
|
||||
ki18nc("amount in units (real)", "%1 litas"),
|
||||
ki18ncp("amount in units (integer)", "%1 litas", "%1 litai") // Alt: litu
|
||||
);
|
||||
U(Lvl, 1e+99,
|
||||
"LVL",
|
||||
KCurrencyCode::currencyCodeToName("LVL"),
|
||||
i18nc("LVL Latvian Lats - unit synonyms for matching user input", "lats;lati") + ";LVL;" +
|
||||
KGlobal::locale()->countryCodeToName("lv") + ';' + KCurrencyCode::currencyCodeToName("LVL"),
|
||||
ki18nc("amount in units (real)", "%1 lati"),
|
||||
ki18ncp("amount in units (integer)", "%1 lats", "%1 lati")
|
||||
);
|
||||
U(Pln, 1e+99,
|
||||
"PLN",
|
||||
KCurrencyCode::currencyCodeToName("PLN"),
|
||||
i18nc("PLN Polish Zloty - unit synonyms for matching user input", "zloty;zlotys;zloties") +
|
||||
";PLN;" + KGlobal::locale()->countryCodeToName("pl") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("PLN"),
|
||||
ki18nc("amount in units (real)", "%1 zlotys"),
|
||||
ki18ncp("amount in units (integer)", "%1 zloty", "%1 zlotys") // Alt: zloty, zlote, zlotych
|
||||
);
|
||||
U(Ron, 1e+99,
|
||||
"RON",
|
||||
KCurrencyCode::currencyCodeToName("RON"),
|
||||
i18nc("RON Roumanian Leu - unit synonyms for matching user input", "leu;lei") + ";RON;" +
|
||||
KGlobal::locale()->countryCodeToName("ro") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("RON"),
|
||||
ki18nc("amount in units (real)", "%1 lei"),
|
||||
ki18ncp("amount in units (integer)", "%1 leu", "%1 lei")
|
||||
);
|
||||
U(Sek, 1e+99,
|
||||
"SEK",
|
||||
KCurrencyCode::currencyCodeToName("SEK"),
|
||||
i18nc("SEK Swedish Krona - unit synonyms for matching user input", "krona;kronor") + ";SEK;" +
|
||||
KGlobal::locale()->countryCodeToName("se") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("SEK"),
|
||||
ki18nc("amount in units (real)", "%1 kronor"),
|
||||
ki18ncp("amount in units (integer)", "%1 krona", "%1 kronor")
|
||||
);
|
||||
U(Chf, 1e+99,
|
||||
"CHF",
|
||||
KCurrencyCode::currencyCodeToName("CHF"),
|
||||
i18nc("CHF Swiss Francs - unit synonyms for matching user input", "franc;francs") + ";CHF;" +
|
||||
KGlobal::locale()->countryCodeToName("ch") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("CHF"),
|
||||
ki18nc("amount in units (real)", "%1 Swiss francs"),
|
||||
ki18ncp("amount in units (integer)", "%1 Swiss franc", "%1 Swiss francs")
|
||||
);
|
||||
U(Nok, 1e+99,
|
||||
"NOK",
|
||||
KCurrencyCode::currencyCodeToName("NOK"),
|
||||
i18nc("Norwegian Krone - unit synonyms for matching user input",
|
||||
"Norwegian krone;Norwegian kroner") + ";NOK;" +
|
||||
KGlobal::locale()->countryCodeToName("no") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("NOK"),
|
||||
ki18nc("amount in units (real)", "%1 Norwegian kroner"),
|
||||
ki18ncp("amount in units (integer)", "%1 Norwegian krone", "%1 Norwegian kroner")
|
||||
);
|
||||
U(Hrk, 1e+99,
|
||||
"HRK",
|
||||
KCurrencyCode::currencyCodeToName("HRK"),
|
||||
i18nc("HRK Croatian Kuna - unit synonyms for matching user input", "kuna;kune") + ";HRK;" +
|
||||
KGlobal::locale()->countryCodeToName("hr") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("HRK"),
|
||||
ki18nc("amount in units (real)", "%1 kune"),
|
||||
ki18ncp("amount in units (integer)", "%1 kuna", "%1 kune")
|
||||
);
|
||||
U(Rub, 1e+99,
|
||||
"RUB",
|
||||
KCurrencyCode::currencyCodeToName("RUB"),
|
||||
i18nc("RUB Russsian Ruble - unit synonyms for matching user input",
|
||||
"ruble;rubles;rouble;roubles") + ";RUB;" +
|
||||
KGlobal::locale()->countryCodeToName("ru") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("RUB"),
|
||||
ki18nc("amount in units (real)", "%1 rubles"),
|
||||
ki18ncp("amount in units (integer)", "%1 ruble", "%1 rubles") //Alt: rouble/roubles
|
||||
);
|
||||
U(Try, 1e+99,
|
||||
"TRY",
|
||||
KCurrencyCode::currencyCodeToName("TRY"),
|
||||
i18nc("TRY Turkish Lira - unit synonyms for matching user input", "lira") + ";TRY;" +
|
||||
KGlobal::locale()->countryCodeToName("tr") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("TRY"),
|
||||
ki18nc("amount in units (real)", "%1 Turkish lira"),
|
||||
ki18ncp("amount in units (integer)", "%1 Turkish lira", "%1 Turkish lira")
|
||||
);
|
||||
U(Aud, 1e+99,
|
||||
"AUD",
|
||||
KCurrencyCode::currencyCodeToName("AUD"),
|
||||
i18nc("AUD Australian Dollar - unit synonyms for matching user input",
|
||||
"Australian dollar;Australian dollars") + ";AUD;" +
|
||||
KGlobal::locale()->countryCodeToName("au") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("AUD"),
|
||||
ki18nc("amount in units (real)", "%1 Australian dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 Australian dollar", "%1 Australian dollars")
|
||||
);
|
||||
U(Brl, 1e+99,
|
||||
"BRL",
|
||||
KCurrencyCode::currencyCodeToName("BRL"),
|
||||
i18nc("BRL Brazillian Real - unit synonyms for matching user input", "real;reais") +
|
||||
";BRL;" + KGlobal::locale()->countryCodeToName("br") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("BRL"),
|
||||
ki18nc("amount in units (real)", "%1 reais"),
|
||||
ki18ncp("amount in units (integer)", "%1 real", "%1 reais")
|
||||
);
|
||||
U(Cad, 1e+99,
|
||||
"CAD",
|
||||
KCurrencyCode::currencyCodeToName("CAD"),
|
||||
i18nc("Canadian Dollar - unit synonyms for matching user input",
|
||||
"Canadian dollar;Canadian dollars") + ";CAD;" +
|
||||
KGlobal::locale()->countryCodeToName("ca") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("CAD"),
|
||||
ki18nc("amount in units (real)", "%1 Canadian dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 Canadian dollar", "%1 Canadian dollars")
|
||||
);
|
||||
U(Cny, 1e+99,
|
||||
"CNY",
|
||||
KCurrencyCode::currencyCodeToName("CNY"),
|
||||
i18nc("Chinese Yuan - unit synonyms for matching user input", "yuan") + ";CNY;" +
|
||||
KGlobal::locale()->countryCodeToName("cn") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("CNY"),
|
||||
ki18nc("amount in units (real)", "%1 yuan"),
|
||||
ki18ncp("amount in units (integer)", "%1 yuan", "%1 yuan")
|
||||
);
|
||||
U(Hkd, 1e+99,
|
||||
"HKD",
|
||||
KCurrencyCode::currencyCodeToName("HKD"),
|
||||
i18nc("Hong Kong Dollar - unit synonyms for matching user input",
|
||||
"Hong Kong dollar;Hong Kong dollars") + ";HKD;" +
|
||||
KGlobal::locale()->countryCodeToName("hk") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("HKD"),
|
||||
ki18nc("amount in units (real)", "%1 Hong Kong dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 Hong Kong dollar", "%1 Hong Kong dollars")
|
||||
);
|
||||
U(Idr, 1e+99,
|
||||
"IDR",
|
||||
KCurrencyCode::currencyCodeToName("IDR"),
|
||||
i18nc("IDR Indonesian Rupiah - unit synonyms for matching user input", "rupiah;rupiahs") +
|
||||
";IDR;" + KGlobal::locale()->countryCodeToName("id") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("IDR"),
|
||||
ki18nc("amount in units (real)", "%1 rupiahs"),
|
||||
ki18ncp("amount in units (integer)", "%1 rupiah", "%1 rupiahs") // Alt: rupiah
|
||||
);
|
||||
U(Inr, 1e+99,
|
||||
"INR",
|
||||
KCurrencyCode::currencyCodeToName("INR"),
|
||||
i18nc("INR Indian Rupee - unit synonyms for matching user input", "rupee;rupees") + ";INR;" +
|
||||
KGlobal::locale()->countryCodeToName("in") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("INR"),
|
||||
ki18nc("amount in units (real)", "%1 rupees"),
|
||||
ki18ncp("amount in units (integer)", "%1 rupee", "%1 rupees") // Alt: rupee
|
||||
);
|
||||
U(Krw, 1e+99,
|
||||
"KRW",
|
||||
KCurrencyCode::currencyCodeToName("KRW"),
|
||||
i18nc("KRW Korean Won - unit synonyms for matching user input", "won") + ";KRW;" +
|
||||
KGlobal::locale()->countryCodeToName("kr") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("KRW"),
|
||||
ki18nc("amount in units (real)", "%1 won"),
|
||||
ki18ncp("amount in units (integer)", "%1 won", "%1 won")
|
||||
);
|
||||
U(Mxn, 1e+99,
|
||||
"MXN",
|
||||
KCurrencyCode::currencyCodeToName("MXN"),
|
||||
i18nc("MXN Mexican Peso - unit synonyms for matching user input",
|
||||
"Mexican peso;Mexican pesos") + ";MXN;" +
|
||||
KGlobal::locale()->countryCodeToName("mx") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("MXN"),
|
||||
ki18nc("amount in units (real)", "%1 Mexican pesos"),
|
||||
ki18ncp("amount in units (integer)", "%1 Mexican peso", "%1 Mexican pesos")
|
||||
);
|
||||
U(Myr, 1e+99,
|
||||
"MYR",
|
||||
KCurrencyCode::currencyCodeToName("MYR"),
|
||||
i18nc("MYR Malasian Ringgit - unit synonyms for matching user input", "ringgit;ringgits") +
|
||||
";MYR;" + KGlobal::locale()->countryCodeToName("my") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("MYR"),
|
||||
ki18nc("amount in units (real)", "%1 ringgit"),
|
||||
ki18ncp("amount in units (integer)", "%1 ringgit", "%1 ringgit") // Alt: ringgits
|
||||
);
|
||||
U(Nzd, 1e+99,
|
||||
"NZD",
|
||||
KCurrencyCode::currencyCodeToName("NZD"),
|
||||
i18nc("NZD New Zealand Dollar - unit synonyms for matching user input",
|
||||
"New Zealand dollar;New Zealand dollars") + ";NZD;" +
|
||||
KGlobal::locale()->countryCodeToName("nz") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("NZD"),
|
||||
ki18nc("amount in units (real)", "%1 New Zealand dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 New Zealand dollar", "%1 New Zealand dollars")
|
||||
);
|
||||
U(Php, 1e+99,
|
||||
"PHP",
|
||||
KCurrencyCode::currencyCodeToName("PHP"),
|
||||
i18nc("PHP Philippine Peso - unit synonyms for matching user input",
|
||||
"Philippine peso;Philippine pesos") + ";PHP;" +
|
||||
KGlobal::locale()->countryCodeToName("ph") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("PHP"),
|
||||
ki18nc("amount in units (real)", "%1 Philippine pesos"),
|
||||
ki18ncp("amount in units (integer)", "%1 Philippine peso", "%1 Philippine pesos")
|
||||
);
|
||||
U(Sgd, 1e+99,
|
||||
"SGD",
|
||||
KCurrencyCode::currencyCodeToName("SGD"),
|
||||
i18nc("SGD Singapore Dollar - unit synonyms for matching user input",
|
||||
"Singapore dollar;Singapore dollars") + ";SGD;" +
|
||||
KGlobal::locale()->countryCodeToName("sg") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("SGD"),
|
||||
ki18nc("amount in units (real)", "%1 Singapore dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 Singapore dollar", "%1 Singapore dollars")
|
||||
);
|
||||
U(Thb, 1e+99,
|
||||
"THB",
|
||||
KCurrencyCode::currencyCodeToName("THB"),
|
||||
i18nc("THB Thai Baht - unit synonyms for matching user input", "baht") + ";THB;" +
|
||||
KGlobal::locale()->countryCodeToName("th") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("THB"),
|
||||
ki18nc("amount in units (real)", "%1 baht"),
|
||||
ki18ncp("amount in units (integer)", "%1 baht", "%1 baht")
|
||||
);
|
||||
U(Zar, 1e+99,
|
||||
"ZAR",
|
||||
KCurrencyCode::currencyCodeToName("ZAR"),
|
||||
i18nc("South African Rand - unit synonyms for matching user input", "rand") + ";ZAR;" +
|
||||
KGlobal::locale()->countryCodeToName("za") + ';' +
|
||||
KCurrencyCode::currencyCodeToName("ZAR"),
|
||||
ki18nc("amount in units (real)", "%1 rand"),
|
||||
ki18ncp("amount in units (integer)", "%1 rand", "%1 rand")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() << Eur << Usd << Jpy << Gbp << Cad);
|
||||
|
||||
m_cache = KStandardDirs::locateLocal("data", "libkunitconversion/currency.xml");
|
||||
m_update = true;
|
||||
}
|
||||
|
||||
Value Currency::convert(const Value& value, UnitPtr to)
|
||||
{
|
||||
static QMutex mutex;
|
||||
|
||||
QMutexLocker lock(&mutex);
|
||||
QFileInfo info(m_cache);
|
||||
if (!info.exists() || info.lastModified().secsTo(QDateTime::currentDateTime()) > 86400) {
|
||||
#ifndef KUNITCONVERSION_NO_SOLID
|
||||
Solid::Networking::Status status = Solid::Networking::status();
|
||||
if (status == Solid::Networking::Connected || status == Solid::Networking::Unknown ) {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
kDebug() << "Getting currency info from net:" << URL;
|
||||
// TODO: This crashes in runner. Threading issues??
|
||||
/*
|
||||
KIO::Job* job = KIO::file_copy(KUrl(URL), KUrl(m_cache), -1,
|
||||
KIO::Overwrite | KIO::HideProgressInfo);
|
||||
job->setUiDelegate(0);
|
||||
if (KIO::NetAccess::synchronousRun(job, 0)) {
|
||||
m_update = true;
|
||||
}
|
||||
*/
|
||||
kDebug() << "Removed previous cache:" << QFile::remove(m_cache);
|
||||
#ifndef KUNITCONVERSION_NO_KIO
|
||||
if (QProcess::execute("kioclient", QStringList() << "copy" << "--noninteractive" << URL << m_cache) == 0) {
|
||||
m_update = true;
|
||||
}
|
||||
#else
|
||||
QNetworkAccessManager manager;
|
||||
QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(URL)));
|
||||
QFile cacheFile(m_cache);
|
||||
cacheFile.open(QFile::WriteOnly);
|
||||
while (!reply->error() && !reply->atEnd()) {
|
||||
if (reply->bytesAvailable()>0
|
||||
|| reply->waitForReadyRead(500)) {
|
||||
cacheFile.write(reply->readAll());
|
||||
}
|
||||
}
|
||||
cacheFile.close();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
lock.unlock();
|
||||
|
||||
if (m_update) {
|
||||
QFile file(m_cache);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QDomDocument doc;
|
||||
if (doc.setContent(&file, false) ) {
|
||||
QDomNodeList list = doc.elementsByTagName("Cube");
|
||||
for (int i = 0; i < list.count(); ++i) {
|
||||
const QDomElement e = list.item(i).toElement();
|
||||
if (e.hasAttribute("currency")) {
|
||||
UnitPtr u = unit(e.attribute("currency"));
|
||||
if (u) {
|
||||
u->setMultiplier(1.0 / e.attribute("rate").toDouble());
|
||||
}
|
||||
}
|
||||
}
|
||||
m_update = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return UnitCategory::convert(value, to);
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef CURRENCY_H
|
||||
#define CURRENCY_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Currency : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Currency();
|
||||
virtual KUnitConversion::Value convert(const KUnitConversion::Value& value,
|
||||
KUnitConversion::UnitPtr to);
|
||||
|
||||
private:
|
||||
QString m_cache;
|
||||
bool m_update;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "density.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Density::Density() : UnitCategory(DensityCategory)
|
||||
{
|
||||
setName(i18n("Density"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (density)", "%1 %2"));
|
||||
|
||||
setDefaultUnit(UP(KilogramsPerCubicMeter, 1,
|
||||
i18nc("density unit symbol", "kg/m³"),
|
||||
i18nc("unit description in lists", "kilograms per cubic meter"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"kilogram per cubic meter;kilograms per cubic meter;kg/m³"),
|
||||
ki18nc("amount in units (real)", "%1 kilograms per cubic meter"),
|
||||
ki18ncp("amount in units (integer)",
|
||||
"%1 kilogram per cubic meter", "%1 kilograms per cubic meter")
|
||||
));
|
||||
|
||||
// source Google calculator
|
||||
U(KilogramPerLiter, 1000,
|
||||
i18nc("density unit symbol", "kg/l"),
|
||||
i18nc("unit description in lists", "kilograms per liter"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"kilogram per liter;kilograms per liter;kg/l"),
|
||||
ki18nc("amount in units (real)", "%1 kilograms per liter"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilogram per liter", "%1 kilograms per liter")
|
||||
);
|
||||
U(GramPerLiter, 1,
|
||||
i18nc("density unit symbol", "g/l"),
|
||||
i18nc("unit description in lists", "grams per liter"),
|
||||
i18nc("unit synonyms for matching user input", "gram per liter;grams per liter;g/l"),
|
||||
ki18nc("amount in units (real)", "%1 grams per liter"),
|
||||
ki18ncp("amount in units (integer)", "%1 gram per liter", "%1 grams per liter")
|
||||
);
|
||||
U(GramPerMilliliter, 1000,
|
||||
i18nc("density unit symbol", "g/ml"),
|
||||
i18nc("unit description in lists", "grams per milliliter"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"gram per milliliter;grams per milliliter;g/ml"),
|
||||
ki18nc("amount in units (real)", "%1 grams per milliliter"),
|
||||
ki18ncp("amount in units (integer)", "%1 gram per milliliter", "%1 grams per milliliter")
|
||||
);
|
||||
|
||||
// source : Google calculator
|
||||
U(OuncePerCubicInch, 1729.99404,
|
||||
i18nc("density unit symbol", "oz/in³"),
|
||||
i18nc("unit description in lists", "ounces per cubic inch"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"ounce per cubic inch;ounces per cubic inch;oz/in³"),
|
||||
ki18nc("amount in units (real)", "%1 ounces per cubic inch"),
|
||||
ki18ncp("amount in units (integer)", "%1 ounce per cubic inch", "%1 ounces per cubic inch")
|
||||
);
|
||||
U(OuncePerCubicFoot, 1.00115396,
|
||||
i18nc("density unit symbol", "oz/ft³"),
|
||||
i18nc("unit description in lists", "ounces per cubic foot"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"ounce per cubic foot;ounces per cubic foot;oz/ft³"),
|
||||
ki18nc("amount in units (real)", "%1 ounces per cubic foot"),
|
||||
ki18ncp("amount in units (integer)", "%1 ounce per cubic foot", "%1 ounces per cubic foot")
|
||||
);
|
||||
U(PoundPerCubicInch, 27679.9047,
|
||||
i18nc("density unit symbol", "lb/in³"),
|
||||
i18nc("unit description in lists", "pounds per cubic inch"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"pound per cubic inch;pounds per cubic inch;lb/in³"),
|
||||
ki18nc("amount in units (real)", "%1 pounds per cubic inch"),
|
||||
ki18ncp("amount in units (integer)", "%1 pound per cubic inch", "%1 pounds per cubic inch")
|
||||
);
|
||||
U(PoundPerCubicFoot, 16.0184634,
|
||||
i18nc("density unit symbol", "lb/ft³"),
|
||||
i18nc("unit description in lists", "pounds per cubic foot"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"pound per cubic foot;pounds per cubic foot;lb/ft³"),
|
||||
ki18nc("amount in units (real)", "%1 pounds per cubic foot"),
|
||||
ki18ncp("amount in units (integer)", "%1 pound per cubic foot", "%1 pounds per cubic foot")
|
||||
);
|
||||
U(PoundPerCubicYard, 0.593276421,
|
||||
i18nc("density unit symbol", "lb/yd³"),
|
||||
i18nc("unit description in lists", "pounds per cubic yard"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"pound per cubic yard;pounds per cubic yard;lb/yd³"),
|
||||
ki18nc("amount in units (real)", "%1 pounds per cubic yard"),
|
||||
ki18ncp("amount in units (integer)", "%1 pound per cubic yard", "%1 pounds per cubic yard")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
KilogramsPerCubicMeter << KilogramPerLiter << OuncePerCubicInch);
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* author Kashyap R Puranik
|
||||
* email kashthealien@gmail.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef DENSITY_H
|
||||
#define DENSITY_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Density : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Density();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,237 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "energy.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class PhotonWavelengthConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return (2.99792458e+08 * 6.62606896e-34) / (value * 1e-09); };
|
||||
double fromDefault(double value) const { return ((2.99792458e+08 * 6.62606896e-34) / value) / 1e-09; };
|
||||
};
|
||||
|
||||
Energy::Energy() : UnitCategory(EnergyCategory)
|
||||
{
|
||||
setName(i18n("Energy"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (energy)", "%1 %2"));
|
||||
|
||||
U(Yottajoule, 1e+24,
|
||||
i18nc("energy unit symbol", "YJ"),
|
||||
i18nc("unit description in lists", "yottajoules"),
|
||||
i18nc("unit synonyms for matching user input", "yottajoule;yottajoules;YJ"),
|
||||
ki18nc("amount in units (real)", "%1 yottajoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottajoule", "%1 yottajoules")
|
||||
);
|
||||
U(Zettajoule, 1e+21,
|
||||
i18nc("energy unit symbol", "ZJ"),
|
||||
i18nc("unit description in lists", "zettajoules"),
|
||||
i18nc("unit synonyms for matching user input", "zettajoule;zettajoules;ZJ"),
|
||||
ki18nc("amount in units (real)", "%1 zettajoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettajoule", "%1 zettajoules")
|
||||
);
|
||||
U(Exajoule, 1e+18,
|
||||
i18nc("energy unit symbol", "EJ"),
|
||||
i18nc("unit description in lists", "exajoules"),
|
||||
i18nc("unit synonyms for matching user input", "exajoule;exajoules;EJ"),
|
||||
ki18nc("amount in units (real)", "%1 exajoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 exajoule", "%1 exajoules")
|
||||
);
|
||||
U(Petajoule, 1e+15,
|
||||
i18nc("energy unit symbol", "PJ"),
|
||||
i18nc("unit description in lists", "petajoules"),
|
||||
i18nc("unit synonyms for matching user input", "petajoule;petajoules;PJ"),
|
||||
ki18nc("amount in units (real)", "%1 petajoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 petajoule", "%1 petajoules")
|
||||
);
|
||||
U(Terajoule, 1e+12,
|
||||
i18nc("energy unit symbol", "TJ"),
|
||||
i18nc("unit description in lists", "terajoules"),
|
||||
i18nc("unit synonyms for matching user input", "terajoule;terajoules;TJ"),
|
||||
ki18nc("amount in units (real)", "%1 terajoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 terajoule", "%1 terajoules")
|
||||
);
|
||||
U(Gigajoule, 1e+09,
|
||||
i18nc("energy unit symbol", "GJ"),
|
||||
i18nc("unit description in lists", "gigajoules"),
|
||||
i18nc("unit synonyms for matching user input", "gigajoule;gigajoules;GJ"),
|
||||
ki18nc("amount in units (real)", "%1 gigajoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigajoule", "%1 gigajoules")
|
||||
);
|
||||
U(Megajoule, 1e+06,
|
||||
i18nc("energy unit symbol", "MJ"),
|
||||
i18nc("unit description in lists", "megajoules"),
|
||||
i18nc("unit synonyms for matching user input", "megajoule;megajoules;MJ"),
|
||||
ki18nc("amount in units (real)", "%1 megajoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 megajoule", "%1 megajoules")
|
||||
);
|
||||
U(Kilojoule, 1000,
|
||||
i18nc("energy unit symbol", "kJ"),
|
||||
i18nc("unit description in lists", "kilojoules"),
|
||||
i18nc("unit synonyms for matching user input", "kilojoule;kilojoules;kJ"),
|
||||
ki18nc("amount in units (real)", "%1 kilojoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilojoule", "%1 kilojoules")
|
||||
);
|
||||
U(Hectojoule, 100,
|
||||
i18nc("energy unit symbol", "hJ"),
|
||||
i18nc("unit description in lists", "hectojoules"),
|
||||
i18nc("unit synonyms for matching user input", "hectojoule;hectojoules;hJ"),
|
||||
ki18nc("amount in units (real)", "%1 hectojoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectojoule", "%1 hectojoules")
|
||||
);
|
||||
U(Decajoule, 10,
|
||||
i18nc("energy unit symbol", "daJ"),
|
||||
i18nc("unit description in lists", "decajoules"),
|
||||
i18nc("unit synonyms for matching user input", "decajoule;decajoules;daJ"),
|
||||
ki18nc("amount in units (real)", "%1 decajoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 decajoule", "%1 decajoules")
|
||||
);
|
||||
setDefaultUnit(UP(Joule, 1,
|
||||
i18nc("energy unit symbol", "J"),
|
||||
i18nc("unit description in lists", "joules"),
|
||||
i18nc("unit synonyms for matching user input", "joule;joules;J"),
|
||||
ki18nc("amount in units (real)", "%1 joules"),
|
||||
ki18ncp("amount in units (integer)", "%1 joule", "%1 joules")
|
||||
));
|
||||
U(Decijoule, 0.1,
|
||||
i18nc("energy unit symbol", "dJ"),
|
||||
i18nc("unit description in lists", "decijoules"),
|
||||
i18nc("unit synonyms for matching user input", "decijoule;decijoules;dJ"),
|
||||
ki18nc("amount in units (real)", "%1 decijoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 decijoule", "%1 decijoules")
|
||||
);
|
||||
U(Centijoule, 0.01,
|
||||
i18nc("energy unit symbol", "cJ"),
|
||||
i18nc("unit description in lists", "centijoules"),
|
||||
i18nc("unit synonyms for matching user input", "centijoule;centijoules;cJ"),
|
||||
ki18nc("amount in units (real)", "%1 centijoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 centijoule", "%1 centijoules")
|
||||
);
|
||||
U(Millijoule, 0.001,
|
||||
i18nc("energy unit symbol", "mJ"),
|
||||
i18nc("unit description in lists", "millijoules"),
|
||||
i18nc("unit synonyms for matching user input", "millijoule;millijoules;mJ"),
|
||||
ki18nc("amount in units (real)", "%1 millijoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 millijoule", "%1 millijoules")
|
||||
);
|
||||
U(Microjoule, 1e-06,
|
||||
i18nc("energy unit symbol", "µJ"),
|
||||
i18nc("unit description in lists", "microjoules"),
|
||||
i18nc("unit synonyms for matching user input", "microjoule;microjoules;µJ;uJ"),
|
||||
ki18nc("amount in units (real)", "%1 microjoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 microjoule", "%1 microjoules")
|
||||
);
|
||||
U(Nanojoule, 1e-09,
|
||||
i18nc("energy unit symbol", "nJ"),
|
||||
i18nc("unit description in lists", "nanojoules"),
|
||||
i18nc("unit synonyms for matching user input", "nanojoule;nanojoules;nJ"),
|
||||
ki18nc("amount in units (real)", "%1 nanojoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanojoule", "%1 nanojoules")
|
||||
);
|
||||
U(Picojoule, 1e-12,
|
||||
i18nc("energy unit symbol", "pJ"),
|
||||
i18nc("unit description in lists", "picojoules"),
|
||||
i18nc("unit synonyms for matching user input", "picojoule;picojoules;pJ"),
|
||||
ki18nc("amount in units (real)", "%1 picojoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 picojoule", "%1 picojoules")
|
||||
);
|
||||
U(Femtojoule, 1e-15,
|
||||
i18nc("energy unit symbol", "fJ"),
|
||||
i18nc("unit description in lists", "femtojoules"),
|
||||
i18nc("unit synonyms for matching user input", "femtojoule;femtojoules;fJ"),
|
||||
ki18nc("amount in units (real)", "%1 femtojoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtojoule", "%1 femtojoules")
|
||||
);
|
||||
U(Attojoule, 1e-18,
|
||||
i18nc("energy unit symbol", "aJ"),
|
||||
i18nc("unit description in lists", "attojoules"),
|
||||
i18nc("unit synonyms for matching user input", "attojoule;attojoules;aJ"),
|
||||
ki18nc("amount in units (real)", "%1 attojoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 attojoule", "%1 attojoules")
|
||||
);
|
||||
U(Zeptojoule, 1e-21,
|
||||
i18nc("energy unit symbol", "zJ"),
|
||||
i18nc("unit description in lists", "zeptojoules"),
|
||||
i18nc("unit synonyms for matching user input", "zeptojoule;zeptojoules;zJ"),
|
||||
ki18nc("amount in units (real)", "%1 zeptojoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptojoule", "%1 zeptojoules")
|
||||
);
|
||||
U(Yoctojoule, 1e-24,
|
||||
i18nc("energy unit symbol", "yJ"),
|
||||
i18nc("unit description in lists", "yoctojoules"),
|
||||
i18nc("unit synonyms for matching user input", "yoctojoule;yoctojoules;yJ"),
|
||||
ki18nc("amount in units (real)", "%1 yoctojoules"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctojoule", "%1 yoctojoules")
|
||||
);
|
||||
U(GuidelineDailyAmount, 8.3736e+06,
|
||||
i18nc("energy unit symbol", "GDA"),
|
||||
i18nc("unit description in lists", "guideline daily amount"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"guideline daily amount;guideline daily amount;GDA"),
|
||||
ki18nc("amount in units (real)", "%1 guideline daily amount"),
|
||||
ki18ncp("amount in units (integer)", "%1 guideline daily amount", "%1 guideline daily amount")
|
||||
);
|
||||
U(Electronvolt, 1.60218e-19,
|
||||
i18nc("energy unit symbol", "eV"),
|
||||
i18nc("unit description in lists", "electronvolts"),
|
||||
i18nc("unit synonyms for matching user input", "electronvolt;electronvolts;eV"),
|
||||
ki18nc("amount in units (real)", "%1 electronvolts"),
|
||||
ki18ncp("amount in units (integer)", "%1 electronvolt", "%1 electronvolts")
|
||||
);
|
||||
U(JoulePerMole, 1.66054238581e-24,
|
||||
i18nc("energy unit symbol", "J/mol"),
|
||||
i18nc("unit description in lists", "joule per mole"),
|
||||
i18nc("unit synonyms for matching user input", "joule per mole;joulepermole;joulemol;jmol;j/mol"),
|
||||
ki18nc("amount in units (real)", "%1 joules per mole"),
|
||||
ki18ncp("amount in units (integer)", "%1 joule per mole", "%1 joules per mole")
|
||||
);
|
||||
U(KiloJoulePerMole, 1.66054238581e-21,
|
||||
i18nc("energy unit symbol", "kJ/mol"),
|
||||
i18nc("unit description in lists", "kilojoule per mole"),
|
||||
i18nc("unit synonyms for matching user input", "kilojoule per mole;kilojoulepermole;kilojoule per mole;kilojoulemol;kjmol;kj/mol"),
|
||||
ki18nc("amount in units (real)", "%1 kilojoules per mole"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilojoule per mole", "%1 kilojoules per mole")
|
||||
);
|
||||
U(Rydberg, 2.17987e-18,
|
||||
i18nc("energy unit symbol", "Ry"),
|
||||
i18nc("unit description in lists", "rydbergs"),
|
||||
i18nc("unit synonyms for matching user input", "rydberg;rydbergs;Ry"),
|
||||
ki18nc("amount in units (real)", "%1 rydbergs"),
|
||||
ki18ncp("amount in units (integer)", "%1 rydberg", "%1 rydbergs")
|
||||
);
|
||||
U(Kilocalorie, 4186.8,
|
||||
i18nc("energy unit symbol", "kcal"),
|
||||
i18nc("unit description in lists", "kilocalories"),
|
||||
i18nc("unit synonyms for matching user input", "kilocalorie;kilocalories;kcal"),
|
||||
ki18nc("amount in units (real)", "%1 kilocalories"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilocalorie", "%1 kilocalories")
|
||||
);
|
||||
U(PhotonWavelength, new PhotonWavelengthConv(),
|
||||
i18nc("energy unit symbol", "nm"),
|
||||
i18nc("unit description in lists", "photon wavelength in nanometers"),
|
||||
i18nc("unit synonyms for matching user input", "nm;photon wavelength"),
|
||||
ki18nc("amount in units (real)", "%1 nanometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanometer", "%1 nanometers")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
Joule << Kilojoule << Kilocalorie << GuidelineDailyAmount);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef ENERGY_H
|
||||
#define ENERGY_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Energy : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Energy();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,211 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "force.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Force::Force() : UnitCategory(ForceCategory)
|
||||
{
|
||||
setName(i18n("Force"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (force", "%1 %2"));
|
||||
|
||||
U(Yottanewton, 1e+24,
|
||||
i18nc("force unit symbol", "YN"),
|
||||
i18nc("unit description in lists", "yottanewtons"),
|
||||
i18nc("unit synonyms for matching user input", "yottanewton;yottanewtons;YN"),
|
||||
ki18nc("amount in units (real)", "%1 yottanewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottanewton", "%1 yottanewtons")
|
||||
);
|
||||
U(Zettanewton, 1e+21,
|
||||
i18nc("force unit symbol", "ZN"),
|
||||
i18nc("unit description in lists", "zettanewtons"),
|
||||
i18nc("unit synonyms for matching user input", "zettanewton;zettanewtons;ZN"),
|
||||
ki18nc("amount in units (real)", "%1 zettanewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettanewton", "%1 zettanewtons")
|
||||
);
|
||||
U(Exanewton, 1e+18,
|
||||
i18nc("force unit symbol", "EN"),
|
||||
i18nc("unit description in lists", "exanewtons"),
|
||||
i18nc("unit synonyms for matching user input", "exanewton;exanewtons;EN"),
|
||||
ki18nc("amount in units (real)", "%1 exanewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 exanewton", "%1 exanewtons")
|
||||
);
|
||||
U(Petanewton, 1e+15,
|
||||
i18nc("force unit symbol", "PN"),
|
||||
i18nc("unit description in lists", "petanewtons"),
|
||||
i18nc("unit synonyms for matching user input", "petanewton;petanewtons;PN"),
|
||||
ki18nc("amount in units (real)", "%1 petanewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 petanewton", "%1 petanewtons")
|
||||
);
|
||||
U(Teranewton, 1e+12,
|
||||
i18nc("force unit symbol", "TN"),
|
||||
i18nc("unit description in lists", "teranewtons"),
|
||||
i18nc("unit synonyms for matching user input", "teranewton;teranewtons;TN"),
|
||||
ki18nc("amount in units (real)", "%1 teranewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 teranewton", "%1 teranewtons")
|
||||
);
|
||||
U(Giganewton, 1e+09,
|
||||
i18nc("force unit symbol", "GN"),
|
||||
i18nc("unit description in lists", "giganewtons"),
|
||||
i18nc("unit synonyms for matching user input", "giganewton;giganewtons;GN"),
|
||||
ki18nc("amount in units (real)", "%1 giganewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 giganewton", "%1 giganewtons")
|
||||
);
|
||||
U(Meganewton, 1e+06,
|
||||
i18nc("force unit symbol", "MN"),
|
||||
i18nc("unit description in lists", "meganewtons"),
|
||||
i18nc("unit synonyms for matching user input", "meganewton;meganewtons;MN"),
|
||||
ki18nc("amount in units (real)", "%1 meganewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 meganewton", "%1 meganewtons")
|
||||
);
|
||||
U(KilonewtonForce, 1000,
|
||||
i18nc("force unit symbol", "kN"),
|
||||
i18nc("unit description in lists", "kilonewtons"),
|
||||
i18nc("unit synonyms for matching user input", "kilonewton;kilonewtons;kN"),
|
||||
ki18nc("amount in units (real)", "%1 kilonewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilonewton", "%1 kilonewtons")
|
||||
);
|
||||
U(Hectonewton, 100,
|
||||
i18nc("force unit symbol", "hN"),
|
||||
i18nc("unit description in lists", "hectonewtons"),
|
||||
i18nc("unit synonyms for matching user input", "hectonewton;hectonewtons;hN"),
|
||||
ki18nc("amount in units (real)", "%1 hectonewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectonewton", "%1 hectonewtons")
|
||||
);
|
||||
U(Decanewton, 10,
|
||||
i18nc("force unit symbol", "daN"),
|
||||
i18nc("unit description in lists", "decanewtons"),
|
||||
i18nc("unit synonyms for matching user input", "decanewton;decanewtons;daN"),
|
||||
ki18nc("amount in units (real)", "%1 decanewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 decanewton", "%1 decanewtons")
|
||||
);
|
||||
setDefaultUnit(UP(Newton, 1,
|
||||
i18nc("force unit symbol", "N"),
|
||||
i18nc("unit description in lists", "newtons"),
|
||||
i18nc("unit synonyms for matching user input", "newton;newtons;N"),
|
||||
ki18nc("amount in units (real)", "%1 newtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 newton", "%1 newtons")
|
||||
));
|
||||
U(Decinewton, 0.1,
|
||||
i18nc("force unit symbol", "dN"),
|
||||
i18nc("unit description in lists", "decinewtons"),
|
||||
i18nc("unit synonyms for matching user input", "decinewton;decinewtons;dN"),
|
||||
ki18nc("amount in units (real)", "%1 decinewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 decinewton", "%1 decinewtons")
|
||||
);
|
||||
U(Centinewton, 0.01,
|
||||
i18nc("force unit symbol", "cN"),
|
||||
i18nc("unit description in lists", "centinewtons"),
|
||||
i18nc("unit synonyms for matching user input", "centinewton;centinewtons;cN"),
|
||||
ki18nc("amount in units (real)", "%1 centinewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 centinewton", "%1 centinewtons")
|
||||
);
|
||||
U(Millinewton, 0.001,
|
||||
i18nc("force unit symbol", "mN"),
|
||||
i18nc("unit description in lists", "millinewtons"),
|
||||
i18nc("unit synonyms for matching user input", "millinewton;millinewtons;mN"),
|
||||
ki18nc("amount in units (real)", "%1 millinewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 millinewton", "%1 millinewtons")
|
||||
);
|
||||
U(Micronewton, 1e-06,
|
||||
i18nc("force unit symbol", "µN"),
|
||||
i18nc("unit description in lists", "micronewtons"),
|
||||
i18nc("unit synonyms for matching user input", "micronewton;micronewtons;µm;uN"),
|
||||
ki18nc("amount in units (real)", "%1 micronewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 micronewton", "%1 micronewtons")
|
||||
);
|
||||
U(Nanonewton, 1e-09,
|
||||
i18nc("force unit symbol", "nN"),
|
||||
i18nc("unit description in lists", "nanonewtons"),
|
||||
i18nc("unit synonyms for matching user input", "nanonewton;nanonewtons;nN"),
|
||||
ki18nc("amount in units (real)", "%1 nanonewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanonewton", "%1 nanonewtons")
|
||||
);
|
||||
U(Piconewton, 1e-12,
|
||||
i18nc("force unit symbol", "pN"),
|
||||
i18nc("unit description in lists", "piconewtons"),
|
||||
i18nc("unit synonyms for matching user input", "piconewton;piconewtons;pN"),
|
||||
ki18nc("amount in units (real)", "%1 piconewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 piconewton", "%1 piconewtons")
|
||||
);
|
||||
U(Femtonewton, 1e-15,
|
||||
i18nc("force unit symbol", "fN"),
|
||||
i18nc("unit description in lists", "femtonewtons"),
|
||||
i18nc("unit synonyms for matching user input", "femtonewton;femtonewtons;fN"),
|
||||
ki18nc("amount in units (real)", "%1 femtonewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtonewton", "%1 femtonewtons")
|
||||
);
|
||||
U(Attonewton, 1e-18,
|
||||
i18nc("force unit symbol", "aN"),
|
||||
i18nc("unit description in lists", "attonewtons"),
|
||||
i18nc("unit synonyms for matching user input", "attonewton;attonewtons;aN"),
|
||||
ki18nc("amount in units (real)", "%1 attonewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 attonewton", "%1 attonewtons")
|
||||
);
|
||||
U(Zeptonewton, 1e-21,
|
||||
i18nc("force unit symbol", "zN"),
|
||||
i18nc("unit description in lists", "zeptonewtons"),
|
||||
i18nc("unit synonyms for matching user input", "zeptonewton;zeptonewtons;zN"),
|
||||
ki18nc("amount in units (real)", "%1 zeptonewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptonewton", "%1 zeptonewtons")
|
||||
);
|
||||
U(Yoctonewton, 1e-24,
|
||||
i18nc("force unit symbol", "yN"),
|
||||
i18nc("unit description in lists", "yoctonewtons"),
|
||||
i18nc("unit synonyms for matching user input", "yoctonewton;yoctonewtons;yN"),
|
||||
ki18nc("amount in units (real)", "%1 yoctonewtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctonewton", "%1 yoctonewtons")
|
||||
);
|
||||
|
||||
// http://en.wikipedia.org/wiki/Force#Units_of_measurement
|
||||
U(Dyne, 0.0001,
|
||||
i18nc("force unit symbol", "dyn"),
|
||||
i18nc("unit description in lists", "dynes"),
|
||||
i18nc("unit synonyms for matching user input", "dyne;dynes;dyn"),
|
||||
ki18nc("amount in units (real)", "%1 dynes"),
|
||||
ki18ncp("amount in units (integer)", "%1 dyne", "%1 dynes")
|
||||
);
|
||||
U(Kilopond, 9.80665,
|
||||
i18nc("force unit symbol", "kp"),
|
||||
i18nc("unit description in lists", "kiloponds"),
|
||||
i18nc("unit synonyms for matching user input", "kilogram-force;kilopond;kiloponds;kp"),
|
||||
ki18nc("amount in units (real)", "%1 kiloponds"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilopond", "%1 kiloponds")
|
||||
);
|
||||
U(PoundForce, 4.448222,
|
||||
i18nc("force unit symbol", "lbf"),
|
||||
i18nc("unit description in lists", "pound-force"),
|
||||
i18nc("unit synonyms for matching user input", "pound-force;lbf"),
|
||||
ki18nc("amount in units (real)", "%1 pound-force"),
|
||||
ki18ncp("amount in units (integer)", "%1 pound-force", "%1 pound-force")
|
||||
);
|
||||
U(Poundal, 0.138255,
|
||||
i18nc("force unit symbol", "pdl"),
|
||||
i18nc("unit description in lists", "poundals"),
|
||||
i18nc("unit synonyms for matching user input", "poundal;poundals;pdl"),
|
||||
ki18nc("amount in units (real)", "%1 poundals"),
|
||||
ki18ncp("amount in units (integer)", "%1 poundal", "%1 poundals")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() << KilonewtonForce << Newton);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef FORCE_H
|
||||
#define FORCE_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Force : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Force();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "frequency.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Frequency::Frequency() : UnitCategory(FrequencyCategory)
|
||||
{
|
||||
setName(i18n("Frequency"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (frequency", "%1 %2"));
|
||||
|
||||
U(Yottahertz, 1e+24,
|
||||
i18nc("frequency unit symbol", "YHz"),
|
||||
i18nc("unit description in lists", "yottahertzs"),
|
||||
i18nc("unit synonyms for matching user input", "yottahertz;yottahertzs;YHz"),
|
||||
ki18nc("amount in units (real)", "%1 yottahertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottahertz", "%1 yottahertzs")
|
||||
);
|
||||
U(Zettahertz, 1e+21,
|
||||
i18nc("frequency unit symbol", "ZHz"),
|
||||
i18nc("unit description in lists", "zettahertzs"),
|
||||
i18nc("unit synonyms for matching user input", "zettahertz;zettahertzs;ZHz"),
|
||||
ki18nc("amount in units (real)", "%1 zettahertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettahertz", "%1 zettahertzs")
|
||||
);
|
||||
U(Exahertz, 1e+18,
|
||||
i18nc("frequency unit symbol", "EHz"),
|
||||
i18nc("unit description in lists", "exahertzs"),
|
||||
i18nc("unit synonyms for matching user input", "exahertz;exahertzs;EHz"),
|
||||
ki18nc("amount in units (real)", "%1 exahertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 exahertz", "%1 exahertzs")
|
||||
);
|
||||
U(Petahertz, 1e+15,
|
||||
i18nc("frequency unit symbol", "PHz"),
|
||||
i18nc("unit description in lists", "petahertzs"),
|
||||
i18nc("unit synonyms for matching user input", "petahertz;petahertzs;PHz"),
|
||||
ki18nc("amount in units (real)", "%1 petahertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 petahertz", "%1 petahertzs")
|
||||
);
|
||||
U(Terahertz, 1e+12,
|
||||
i18nc("frequency unit symbol", "THz"),
|
||||
i18nc("unit description in lists", "terahertzs"),
|
||||
i18nc("unit synonyms for matching user input", "terahertz;terahertzs;THz"),
|
||||
ki18nc("amount in units (real)", "%1 terahertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 terahertz", "%1 terahertzs")
|
||||
);
|
||||
U(Gigahertz, 1e+09,
|
||||
i18nc("frequency unit symbol", "GHz"),
|
||||
i18nc("unit description in lists", "gigahertzs"),
|
||||
i18nc("unit synonyms for matching user input", "gigahertz;gigahertzs;GHz"),
|
||||
ki18nc("amount in units (real)", "%1 gigahertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigahertz", "%1 gigahertzs")
|
||||
);
|
||||
U(Megahertz, 1e+06,
|
||||
i18nc("frequency unit symbol", "MHz"),
|
||||
i18nc("unit description in lists", "megahertzs"),
|
||||
i18nc("unit synonyms for matching user input", "megahertz;megahertzs;MHz"),
|
||||
ki18nc("amount in units (real)", "%1 megahertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 megahertz", "%1 megahertzs")
|
||||
);
|
||||
U(Kilohertz, 1000,
|
||||
i18nc("frequency unit symbol", "kHz"),
|
||||
i18nc("unit description in lists", "kilohertzs"),
|
||||
i18nc("unit synonyms for matching user input", "kilohertz;kilohertzs;kHz"),
|
||||
ki18nc("amount in units (real)", "%1 kilohertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilohertz", "%1 kilohertzs")
|
||||
);
|
||||
U(Hectohertz, 100,
|
||||
i18nc("frequency unit symbol", "hHz"),
|
||||
i18nc("unit description in lists", "hectohertzs"),
|
||||
i18nc("unit synonyms for matching user input", "hectohertz;hectohertzs;hHz"),
|
||||
ki18nc("amount in units (real)", "%1 hectohertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectohertz", "%1 hectohertzs")
|
||||
);
|
||||
U(Decahertz, 10,
|
||||
i18nc("frequency unit symbol", "daHz"),
|
||||
i18nc("unit description in lists", "decahertzs"),
|
||||
i18nc("unit synonyms for matching user input", "decahertz;decahertzs;daHz"),
|
||||
ki18nc("amount in units (real)", "%1 decahertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 decahertz", "%1 decahertzs")
|
||||
);
|
||||
setDefaultUnit(UP(Hertz, 1,
|
||||
i18nc("frequency unit symbol", "Hz"),
|
||||
i18nc("unit description in lists", "hertzs"),
|
||||
i18nc("unit synonyms for matching user input", "hertz;hertzs;Hz"),
|
||||
ki18nc("amount in units (real)", "%1 hertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 hertz", "%1 hertzs")
|
||||
));
|
||||
U(Decihertz, 0.1,
|
||||
i18nc("frequency unit symbol", "dHz"),
|
||||
i18nc("unit description in lists", "decihertzs"),
|
||||
i18nc("unit synonyms for matching user input", "decihertz;decihertzs;dHz"),
|
||||
ki18nc("amount in units (real)", "%1 decihertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 decihertz", "%1 decihertzs")
|
||||
);
|
||||
U(Centihertz, 0.01,
|
||||
i18nc("frequency unit symbol", "cHz"),
|
||||
i18nc("unit description in lists", "centihertzs"),
|
||||
i18nc("unit synonyms for matching user input", "centihertz;centihertzs;cHz"),
|
||||
ki18nc("amount in units (real)", "%1 centihertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 centihertz", "%1 centihertzs")
|
||||
);
|
||||
U(Millihertz, 0.001,
|
||||
i18nc("frequency unit symbol", "mHz"),
|
||||
i18nc("unit description in lists", "millihertzs"),
|
||||
i18nc("unit synonyms for matching user input", "millihertz;millihertzs;mHz"),
|
||||
ki18nc("amount in units (real)", "%1 millihertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 millihertz", "%1 millihertzs")
|
||||
);
|
||||
U(Microhertz, 1e-06,
|
||||
i18nc("frequency unit symbol", "µHz"),
|
||||
i18nc("unit description in lists", "microhertzs"),
|
||||
i18nc("unit synonyms for matching user input", "microhertz;microhertzs;µHz;uHz"),
|
||||
ki18nc("amount in units (real)", "%1 microhertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 microhertz", "%1 microhertzs")
|
||||
);
|
||||
U(Nanohertz, 1e-09,
|
||||
i18nc("frequency unit symbol", "nHz"),
|
||||
i18nc("unit description in lists", "nanohertzs"),
|
||||
i18nc("unit synonyms for matching user input", "nanohertz;nanohertzs;nHz"),
|
||||
ki18nc("amount in units (real)", "%1 nanohertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanohertz", "%1 nanohertzs")
|
||||
);
|
||||
U(Picohertz, 1e-12,
|
||||
i18nc("frequency unit symbol", "pHz"),
|
||||
i18nc("unit description in lists", "picohertzs"),
|
||||
i18nc("unit synonyms for matching user input", "picohertz;picohertzs;pHz"),
|
||||
ki18nc("amount in units (real)", "%1 picohertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 picohertz", "%1 picohertzs")
|
||||
);
|
||||
U(Femtohertz, 1e-15,
|
||||
i18nc("frequency unit symbol", "fHz"),
|
||||
i18nc("unit description in lists", "femtohertzs"),
|
||||
i18nc("unit synonyms for matching user input", "femtohertz;femtohertzs;fHz"),
|
||||
ki18nc("amount in units (real)", "%1 femtohertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtohertz", "%1 femtohertzs")
|
||||
);
|
||||
U(Attohertz, 1e-18,
|
||||
i18nc("frequency unit symbol", "aHz"),
|
||||
i18nc("unit description in lists", "attohertzs"),
|
||||
i18nc("unit synonyms for matching user input", "attohertz;attohertzs;aHz"),
|
||||
ki18nc("amount in units (real)", "%1 attohertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 attohertz", "%1 attohertzs")
|
||||
);
|
||||
U(Zeptohertz, 1e-21,
|
||||
i18nc("frequency unit symbol", "zHz"),
|
||||
i18nc("unit description in lists", "zeptohertzs"),
|
||||
i18nc("unit synonyms for matching user input", "zeptohertz;zeptohertzs;zHz"),
|
||||
ki18nc("amount in units (real)", "%1 zeptohertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptohertz", "%1 zeptohertzs")
|
||||
);
|
||||
U(Yoctohertz, 1e-24,
|
||||
i18nc("frequency unit symbol", "yHz"),
|
||||
i18nc("unit description in lists", "yoctohertzs"),
|
||||
i18nc("unit synonyms for matching user input", "yoctohertz;yoctohertzs;yHz"),
|
||||
ki18nc("amount in units (real)", "%1 yoctohertzs"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctohertz", "%1 yoctohertzs")
|
||||
);
|
||||
U(RPM, 1.0 / 60.0,
|
||||
i18nc("frequency unit symbol", "RPM"),
|
||||
i18nc("unit description in lists", "revolutions per minute"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"revolutions per minute;revolution per minute;RPM"),
|
||||
ki18nc("amount in units (real)", "%1 revolutions per minute"),
|
||||
ki18ncp("amount in units (integer)", "%1 revolution per minute", "%1 revolutions per minute")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
Kilohertz << Megahertz << Gigahertz << Hertz << RPM);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef FREQUENCY_H
|
||||
#define FREQUENCY_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Frequency : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Frequency();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "fuel_efficiency.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class kmpl : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return 100.0 / value; };
|
||||
double fromDefault(double value) const { return 100.0 / value; };
|
||||
};
|
||||
|
||||
class mpg : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return 235.2 / value; };
|
||||
double fromDefault(double value) const { return 235.2 / value; };
|
||||
};
|
||||
|
||||
class mpgi : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return 282.5 / value; };
|
||||
double fromDefault(double value) const { return 282.5 / value; };
|
||||
};
|
||||
|
||||
FuelEfficiency::FuelEfficiency() : UnitCategory(FuelEfficiencyCategory)
|
||||
{
|
||||
setName(i18n("Fuel Efficiency"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (fuel efficiency)", "%1 %2"));
|
||||
|
||||
setDefaultUnit(UP(LitersPer100Kilometers, 1,
|
||||
i18nc("fuelefficiency unit symbol", "l/100 km"),
|
||||
i18nc("unit description in lists", "liters per 100 kilometers"),
|
||||
i18nc("unit synonyms for matching user input", "liters per 100 kilometers;liters per 100 kilometers;l/100 km;L/100 km"),
|
||||
ki18nc("amount in units (real)", "%1 liters per 100 kilometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 liters per 100 kilometers", "%1 liters per 100 kilometers")
|
||||
));
|
||||
U(MilePerUsGallon, new mpg(),
|
||||
i18nc("fuelefficiency unit symbol", "mpg"),
|
||||
i18nc("unit description in lists", "miles per US gallon"),
|
||||
i18nc("unit synonyms for matching user input", "mile per US gallon;miles per US gallon;mpg"),
|
||||
ki18nc("amount in units (real)", "%1 miles per US gallon"),
|
||||
ki18ncp("amount in units (integer)", "%1 mile per US gallon", "%1 miles per US gallon")
|
||||
);
|
||||
U(MilePerImperialGallon, new mpgi(),
|
||||
i18nc("fuelefficiency unit symbol", "mpg (imperial)"),
|
||||
i18nc("unit description in lists", "miles per imperial gallon"),
|
||||
i18nc("unit synonyms for matching user input", "mile per imperial gallon;miles per imperial gallon;mpg (imperial)"),
|
||||
ki18nc("amount in units (real)", "%1 miles per imperial gallon"),
|
||||
ki18ncp("amount in units (integer)", "%1 mile per imperial gallon", "%1 miles per imperial gallon")
|
||||
);
|
||||
U(KilometrePerLitre, new kmpl(),
|
||||
i18nc("fuelefficiency unit symbol", "kmpl"),
|
||||
i18nc("unit description in lists", "kilometers per liter"),
|
||||
i18nc("unit synonyms for matching user input", "kilometer per liter;kilometers per liter;kmpl;km/l"),
|
||||
ki18nc("amount in units (real)", "%1 kilometers per liter"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilometer per liter", "%1 kilometers per liter")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
LitersPer100Kilometers << MilePerUsGallon << MilePerImperialGallon);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef FUELEFFICIENCY_H
|
||||
#define FUELEFFICIENCY_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class FuelEfficiency : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
FuelEfficiency();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,253 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "length.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Length::Length() : UnitCategory(LengthCategory)
|
||||
{
|
||||
setName(i18n("Length"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (length", "%1 %2"));
|
||||
|
||||
U(Yottameter, 1e+24,
|
||||
i18nc("length unit symbol", "Ym"),
|
||||
i18nc("unit description in lists", "yottameters"),
|
||||
i18nc("unit synonyms for matching user input", "yottameter;yottameters;Ym"),
|
||||
ki18nc("amount in units (real)", "%1 yottameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottameter", "%1 yottameters")
|
||||
);
|
||||
U(Zettameter, 1e+21,
|
||||
i18nc("length unit symbol", "Zm"),
|
||||
i18nc("unit description in lists", "zettameters"),
|
||||
i18nc("unit synonyms for matching user input", "zettameter;zettameters;Zm"),
|
||||
ki18nc("amount in units (real)", "%1 zettameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettameter", "%1 zettameters")
|
||||
);
|
||||
U(Exameter, 1e+18,
|
||||
i18nc("length unit symbol", "Em"),
|
||||
i18nc("unit description in lists", "exameters"),
|
||||
i18nc("unit synonyms for matching user input", "exameter;exameters;Em"),
|
||||
ki18nc("amount in units (real)", "%1 exameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 exameter", "%1 exameters")
|
||||
);
|
||||
U(Petameter, 1e+15,
|
||||
i18nc("length unit symbol", "Pm"),
|
||||
i18nc("unit description in lists", "petameters"),
|
||||
i18nc("unit synonyms for matching user input", "petameter;petameters;Pm"),
|
||||
ki18nc("amount in units (real)", "%1 petameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 petameter", "%1 petameters")
|
||||
);
|
||||
U(Terameter, 1e+12,
|
||||
i18nc("length unit symbol", "Tm"),
|
||||
i18nc("unit description in lists", "terameters"),
|
||||
i18nc("unit synonyms for matching user input", "terameter;terameters;Tm"),
|
||||
ki18nc("amount in units (real)", "%1 terameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 terameter", "%1 terameters")
|
||||
);
|
||||
U(Gigameter, 1e+09,
|
||||
i18nc("length unit symbol", "Gm"),
|
||||
i18nc("unit description in lists", "gigameters"),
|
||||
i18nc("unit synonyms for matching user input", "gigameter;gigameters;Gm"),
|
||||
ki18nc("amount in units (real)", "%1 gigameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigameter", "%1 gigameters")
|
||||
);
|
||||
U(Megameter, 1e+06,
|
||||
i18nc("length unit symbol", "Mm"),
|
||||
i18nc("unit description in lists", "megameters"),
|
||||
i18nc("unit synonyms for matching user input", "megameter;megameters;Mm"),
|
||||
ki18nc("amount in units (real)", "%1 megameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 megameter", "%1 megameters")
|
||||
);
|
||||
U(Kilometer, 1000,
|
||||
i18nc("length unit symbol", "km"),
|
||||
i18nc("unit description in lists", "kilometers"),
|
||||
i18nc("unit synonyms for matching user input", "kilometer;kilometers;km"),
|
||||
ki18nc("amount in units (real)", "%1 kilometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilometer", "%1 kilometers")
|
||||
);
|
||||
U(Hectometer, 100,
|
||||
i18nc("length unit symbol", "hm"),
|
||||
i18nc("unit description in lists", "hectometers"),
|
||||
i18nc("unit synonyms for matching user input", "hectometer;hectometers;hm"),
|
||||
ki18nc("amount in units (real)", "%1 hectometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectometer", "%1 hectometers")
|
||||
);
|
||||
U(Decameter, 10,
|
||||
i18nc("length unit symbol", "dam"),
|
||||
i18nc("unit description in lists", "decameters"),
|
||||
i18nc("unit synonyms for matching user input", "decameter;decameters;dam"),
|
||||
ki18nc("amount in units (real)", "%1 decameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 decameter", "%1 decameters")
|
||||
);
|
||||
setDefaultUnit(UP(Meter, 1,
|
||||
i18nc("length unit symbol", "m"),
|
||||
i18nc("unit description in lists", "meters"),
|
||||
i18nc("unit synonyms for matching user input", "meter;meters;m"),
|
||||
ki18nc("amount in units (real)", "%1 meters"),
|
||||
ki18ncp("amount in units (integer)", "%1 meter", "%1 meters")
|
||||
));
|
||||
U(Decimeter, 0.1,
|
||||
i18nc("length unit symbol", "dm"),
|
||||
i18nc("unit description in lists", "decimeters"),
|
||||
i18nc("unit synonyms for matching user input", "decimeter;decimeters;dm"),
|
||||
ki18nc("amount in units (real)", "%1 decimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 decimeter", "%1 decimeters")
|
||||
);
|
||||
U(Centimeter, 0.01,
|
||||
i18nc("length unit symbol", "cm"),
|
||||
i18nc("unit description in lists", "centimeters"),
|
||||
i18nc("unit synonyms for matching user input", "centimeter;centimeters;cm"),
|
||||
ki18nc("amount in units (real)", "%1 centimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 centimeter", "%1 centimeters")
|
||||
);
|
||||
U(Millimeter, 0.001,
|
||||
i18nc("length unit symbol", "mm"),
|
||||
i18nc("unit description in lists", "millimeters"),
|
||||
i18nc("unit synonyms for matching user input", "millimeter;millimeters;mm"),
|
||||
ki18nc("amount in units (real)", "%1 millimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 millimeter", "%1 millimeters")
|
||||
);
|
||||
U(Micrometer, 1e-06,
|
||||
i18nc("length unit symbol", "µm"),
|
||||
i18nc("unit description in lists", "micrometers"),
|
||||
i18nc("unit synonyms for matching user input", "micrometer;micrometers;µm;um"),
|
||||
ki18nc("amount in units (real)", "%1 micrometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 micrometer", "%1 micrometers")
|
||||
);
|
||||
U(Nanometer, 1e-09,
|
||||
i18nc("length unit symbol", "nm"),
|
||||
i18nc("unit description in lists", "nanometers"),
|
||||
i18nc("unit synonyms for matching user input", "nanometer;nanometers;nm"),
|
||||
ki18nc("amount in units (real)", "%1 nanometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanometer", "%1 nanometers")
|
||||
);
|
||||
U(Angstrom, 1e-10,
|
||||
i18nc("length unit symbol", "Å"),
|
||||
i18nc("unit description in lists", "Ångström"),
|
||||
i18nc("unit synonyms for matching user input", "Ångström;Ångstrom;Angström;Angstrom;Ångströms;Ångstroms;Angströms;Angstroms;Å"),
|
||||
ki18nc("amount in units (real)", "%1 Ångströms"),
|
||||
ki18ncp("amount in units (integer)", "%1 Ångström", "%1 Ångströms")
|
||||
);
|
||||
U(Picometer, 1e-12,
|
||||
i18nc("length unit symbol", "pm"),
|
||||
i18nc("unit description in lists", "picometers"),
|
||||
i18nc("unit synonyms for matching user input", "picometer;picometers;pm"),
|
||||
ki18nc("amount in units (real)", "%1 picometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 picometer", "%1 picometers")
|
||||
);
|
||||
U(Femtometer, 1e-15,
|
||||
i18nc("length unit symbol", "fm"),
|
||||
i18nc("unit description in lists", "femtometers"),
|
||||
i18nc("unit synonyms for matching user input", "femtometer;femtometers;fm"),
|
||||
ki18nc("amount in units (real)", "%1 femtometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtometer", "%1 femtometers")
|
||||
);
|
||||
U(Attometer, 1e-18,
|
||||
i18nc("length unit symbol", "am"),
|
||||
i18nc("unit description in lists", "attometers"),
|
||||
i18nc("unit synonyms for matching user input", "attometer;attometers;am"),
|
||||
ki18nc("amount in units (real)", "%1 attometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 attometer", "%1 attometers")
|
||||
);
|
||||
U(Zeptometer, 1e-21,
|
||||
i18nc("length unit symbol", "zm"),
|
||||
i18nc("unit description in lists", "zeptometers"),
|
||||
i18nc("unit synonyms for matching user input", "zeptometer;zeptometers;zm"),
|
||||
ki18nc("amount in units (real)", "%1 zeptometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptometer", "%1 zeptometers")
|
||||
);
|
||||
U(Yoctometer, 1e-24,
|
||||
i18nc("length unit symbol", "ym"),
|
||||
i18nc("unit description in lists", "yoctometers"),
|
||||
i18nc("unit synonyms for matching user input", "yoctometer;yoctometers;ym"),
|
||||
ki18nc("amount in units (real)", "%1 yoctometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctometer", "%1 yoctometers")
|
||||
);
|
||||
U(Inch, 0.0254,
|
||||
i18nc("length unit symbol", "in"),
|
||||
i18nc("unit description in lists", "inches"),
|
||||
i18nc("unit synonyms for matching user input", "inch;inches;in;\""),
|
||||
ki18nc("amount in units (real)", "%1 inches"),
|
||||
ki18ncp("amount in units (integer)", "%1 inch", "%1 inches")
|
||||
);
|
||||
U(Thou, 0.0000254,
|
||||
i18nc("length unit symbol", "thou"),
|
||||
i18nc("unit description in lists", "thousandths of an inch"),
|
||||
i18nc("unit synonyms for matching user input", "thou;mil;point;thousandth of an inch;thousandths of an inch"),
|
||||
ki18nc("amount in units (real)", "%1 thousandths of an inch"),
|
||||
ki18ncp("amount in units (integer)", "%1 thousandth of an inch", "%1 thousandths of an inch")
|
||||
);
|
||||
U(Foot, 0.3048,
|
||||
i18nc("length unit symbol", "ft"),
|
||||
i18nc("unit description in lists", "feet"),
|
||||
i18nc("unit synonyms for matching user input", "foot;feet;ft"),
|
||||
ki18nc("amount in units (real)", "%1 feet"),
|
||||
ki18ncp("amount in units (integer)", "%1 foot", "%1 feet")
|
||||
);
|
||||
U(Yard, 0.9144,
|
||||
i18nc("length unit symbol", "yd"),
|
||||
i18nc("unit description in lists", "yards"),
|
||||
i18nc("unit synonyms for matching user input", "yard;yards;yd"),
|
||||
ki18nc("amount in units (real)", "%1 yards"),
|
||||
ki18ncp("amount in units (integer)", "%1 yard", "%1 yards")
|
||||
);
|
||||
U(Mile, 1609.34,
|
||||
i18nc("length unit symbol", "mi"),
|
||||
i18nc("unit description in lists", "miles"),
|
||||
i18nc("unit synonyms for matching user input", "mile;miles;mi"),
|
||||
ki18nc("amount in units (real)", "%1 miles"),
|
||||
ki18ncp("amount in units (integer)", "%1 mile", "%1 miles")
|
||||
);
|
||||
U(NauticalMile, 1852,
|
||||
i18nc("length unit symbol", "nmi"),
|
||||
i18nc("unit description in lists", "nautical miles"),
|
||||
i18nc("unit synonyms for matching user input", "nautical mile;nautical miles;nmi"),
|
||||
ki18nc("amount in units (real)", "%1 nautical miles"),
|
||||
ki18ncp("amount in units (integer)", "%1 nautical mile", "%1 nautical miles")
|
||||
);
|
||||
U(LightYear, 9.46073e+15,
|
||||
i18nc("length unit symbol", "ly"),
|
||||
i18nc("unit description in lists", "light-years"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"light-year;light-years;ly;lightyear;lightyears"),
|
||||
ki18nc("amount in units (real)", "%1 light-years"),
|
||||
ki18ncp("amount in units (integer)", "%1 light-year", "%1 light-years")
|
||||
);
|
||||
U(Parsec, 3.08568e+16,
|
||||
i18nc("length unit symbol", "pc"),
|
||||
i18nc("unit description in lists", "parsecs"),
|
||||
i18nc("unit synonyms for matching user input", "parsec;parsecs;pc"),
|
||||
ki18nc("amount in units (real)", "%1 parsecs"),
|
||||
ki18ncp("amount in units (integer)", "%1 parsec", "%1 parsecs")
|
||||
);
|
||||
U(AstronomicalUnit, 1.49598e+11,
|
||||
i18nc("length unit symbol", "au"),
|
||||
i18nc("unit description in lists", "astronomical units"),
|
||||
i18nc("unit synonyms for matching user input", "astronomical unit;astronomical units;au"),
|
||||
ki18nc("amount in units (real)", "%1 astronomical units"),
|
||||
ki18ncp("amount in units (integer)", "%1 astronomical unit", "%1 astronomical units")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
Kilometer << Meter << Centimeter << Millimeter << Mile << Yard << Foot << Inch);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef LENGTH_H
|
||||
#define LENGTH_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Length : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Length();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,235 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009 Petri Damstén <damu@iki.fi>
|
||||
* Copyright (C) 2008 Kristof Bal <kristof.bal@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "mass.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Mass::Mass() : UnitCategory(MassCategory)
|
||||
{
|
||||
setName(i18n("Mass"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (mass)", "%1 %2"));
|
||||
|
||||
U(Yottagram, 1e+24,
|
||||
i18nc("mass unit symbol", "Yg"),
|
||||
i18nc("unit description in lists", "yottagrams"),
|
||||
i18nc("unit synonyms for matching user input", "yottagram;yottagrams;Yg"),
|
||||
ki18nc("amount in units (real)", "%1 yottagrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottagram", "%1 yottagrams")
|
||||
);
|
||||
U(Zettagram, 1e+21,
|
||||
i18nc("mass unit symbol", "Zg"),
|
||||
i18nc("unit description in lists", "zettagrams"),
|
||||
i18nc("unit synonyms for matching user input", "zettagram;zettagrams;Zg"),
|
||||
ki18nc("amount in units (real)", "%1 zettagrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettagram", "%1 zettagrams")
|
||||
);
|
||||
U(Exagram, 1e+18,
|
||||
i18nc("mass unit symbol", "Eg"),
|
||||
i18nc("unit description in lists", "exagrams"),
|
||||
i18nc("unit synonyms for matching user input", "exagram;exagrams;Eg"),
|
||||
ki18nc("amount in units (real)", "%1 exagrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 exagram", "%1 exagrams")
|
||||
);
|
||||
U(Petagram, 1e+15,
|
||||
i18nc("mass unit symbol", "Pg"),
|
||||
i18nc("unit description in lists", "petagrams"),
|
||||
i18nc("unit synonyms for matching user input", "petagram;petagrams;Pg"),
|
||||
ki18nc("amount in units (real)", "%1 petagrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 petagram", "%1 petagrams")
|
||||
);
|
||||
U(Teragram, 1e+12,
|
||||
i18nc("mass unit symbol", "Tg"),
|
||||
i18nc("unit description in lists", "teragrams"),
|
||||
i18nc("unit synonyms for matching user input", "teragram;teragrams;Tg"),
|
||||
ki18nc("amount in units (real)", "%1 teragrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 teragram", "%1 teragrams")
|
||||
);
|
||||
U(Gigagram, 1e+09,
|
||||
i18nc("mass unit symbol", "Gg"),
|
||||
i18nc("unit description in lists", "gigagrams"),
|
||||
i18nc("unit synonyms for matching user input", "gigagram;gigagrams;Gg"),
|
||||
ki18nc("amount in units (real)", "%1 gigagrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigagram", "%1 gigagrams")
|
||||
);
|
||||
U(Megagram, 1e+06,
|
||||
i18nc("mass unit symbol", "Mg"),
|
||||
i18nc("unit description in lists", "megagrams"),
|
||||
i18nc("unit synonyms for matching user input", "megagram;megagrams;Mg"),
|
||||
ki18nc("amount in units (real)", "%1 megagrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 megagram", "%1 megagrams")
|
||||
);
|
||||
setDefaultUnit(UP(Kilogram, 1000,
|
||||
i18nc("mass unit symbol", "kg"),
|
||||
i18nc("unit description in lists", "kilograms"),
|
||||
i18nc("unit synonyms for matching user input", "kilogram;kilograms;kg"),
|
||||
ki18nc("amount in units (real)", "%1 kilograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilogram", "%1 kilograms")
|
||||
));
|
||||
U(Hectogram, 100,
|
||||
i18nc("mass unit symbol", "hg"),
|
||||
i18nc("unit description in lists", "hectograms"),
|
||||
i18nc("unit synonyms for matching user input", "hectogram;hectograms;hg"),
|
||||
ki18nc("amount in units (real)", "%1 hectograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectogram", "%1 hectograms")
|
||||
);
|
||||
U(Decagram, 10,
|
||||
i18nc("mass unit symbol", "dag"),
|
||||
i18nc("unit description in lists", "decagrams"),
|
||||
i18nc("unit synonyms for matching user input", "decagram;decagrams;dag"),
|
||||
ki18nc("amount in units (real)", "%1 decagrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 decagram", "%1 decagrams")
|
||||
);
|
||||
U(Gram, 1,
|
||||
i18nc("mass unit symbol", "g"),
|
||||
i18nc("unit description in lists", "grams"),
|
||||
i18nc("unit synonyms for matching user input", "gram;grams;g"),
|
||||
ki18nc("amount in units (real)", "%1 grams"),
|
||||
ki18ncp("amount in units (integer)", "%1 gram", "%1 grams")
|
||||
);
|
||||
U(Decigram, 0.1,
|
||||
i18nc("mass unit symbol", "dg"),
|
||||
i18nc("unit description in lists", "decigrams"),
|
||||
i18nc("unit synonyms for matching user input", "decigram;decigrams;dg"),
|
||||
ki18nc("amount in units (real)", "%1 decigrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 decigram", "%1 decigrams")
|
||||
);
|
||||
U(Centigram, 0.01,
|
||||
i18nc("mass unit symbol", "cg"),
|
||||
i18nc("unit description in lists", "centigrams"),
|
||||
i18nc("unit synonyms for matching user input", "centigram;centigrams;cg"),
|
||||
ki18nc("amount in units (real)", "%1 centigrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 centigram", "%1 centigrams")
|
||||
);
|
||||
U(Milligram, 0.001,
|
||||
i18nc("mass unit symbol", "mg"),
|
||||
i18nc("unit description in lists", "milligrams"),
|
||||
i18nc("unit synonyms for matching user input", "milligram;milligrams;mg"),
|
||||
ki18nc("amount in units (real)", "%1 milligrams"),
|
||||
ki18ncp("amount in units (integer)", "%1 milligram", "%1 milligrams")
|
||||
);
|
||||
U(Microgram, 1e-06,
|
||||
i18nc("mass unit symbol", "µg"),
|
||||
i18nc("unit description in lists", "micrograms"),
|
||||
i18nc("unit synonyms for matching user input", "microgram;micrograms;µg;ug"),
|
||||
ki18nc("amount in units (real)", "%1 micrograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 microgram", "%1 micrograms")
|
||||
);
|
||||
U(Nanogram, 1e-09,
|
||||
i18nc("mass unit symbol", "ng"),
|
||||
i18nc("unit description in lists", "nanograms"),
|
||||
i18nc("unit synonyms for matching user input", "nanogram;nanograms;ng"),
|
||||
ki18nc("amount in units (real)", "%1 nanograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanogram", "%1 nanograms")
|
||||
);
|
||||
U(Picogram, 1e-12,
|
||||
i18nc("mass unit symbol", "pg"),
|
||||
i18nc("unit description in lists", "picograms"),
|
||||
i18nc("unit synonyms for matching user input", "picogram;picograms;pg"),
|
||||
ki18nc("amount in units (real)", "%1 picograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 picogram", "%1 picograms")
|
||||
);
|
||||
U(Femtogram, 1e-15,
|
||||
i18nc("mass unit symbol", "fg"),
|
||||
i18nc("unit description in lists", "femtograms"),
|
||||
i18nc("unit synonyms for matching user input", "femtogram;femtograms;fg"),
|
||||
ki18nc("amount in units (real)", "%1 femtograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtogram", "%1 femtograms")
|
||||
);
|
||||
U(Attogram, 1e-18,
|
||||
i18nc("mass unit symbol", "ag"),
|
||||
i18nc("unit description in lists", "attograms"),
|
||||
i18nc("unit synonyms for matching user input", "attogram;attograms;ag"),
|
||||
ki18nc("amount in units (real)", "%1 attograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 attogram", "%1 attograms")
|
||||
);
|
||||
U(Zeptogram, 1e-21,
|
||||
i18nc("mass unit symbol", "zg"),
|
||||
i18nc("unit description in lists", "zeptograms"),
|
||||
i18nc("unit synonyms for matching user input", "zeptogram;zeptograms;zg"),
|
||||
ki18nc("amount in units (real)", "%1 zeptograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptogram", "%1 zeptograms")
|
||||
);
|
||||
U(Yoctogram, 1e-24,
|
||||
i18nc("mass unit symbol", "yg"),
|
||||
i18nc("unit description in lists", "yoctograms"),
|
||||
i18nc("unit synonyms for matching user input", "yoctogram;yoctograms;yg"),
|
||||
ki18nc("amount in units (real)", "%1 yoctograms"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctogram", "%1 yoctograms")
|
||||
);
|
||||
U(Ton, 1e+06,
|
||||
i18nc("mass unit symbol", "t"),
|
||||
i18nc("unit description in lists", "tons"),
|
||||
i18nc("unit synonyms for matching user input", "ton;tons;t;tonne"),
|
||||
ki18nc("amount in units (real)", "%1 tons"),
|
||||
ki18ncp("amount in units (integer)", "%1 ton", "%1 tons")
|
||||
);
|
||||
//I guess it's useful...
|
||||
U(Carat, 0.2,
|
||||
i18nc("mass unit symbol", "CD"),
|
||||
i18nc("unit description in lists", "carats"),
|
||||
i18nc("unit synonyms for matching user input", "carat;carats;CD"),
|
||||
ki18nc("amount in units (real)", "%1 carats"),
|
||||
ki18ncp("amount in units (integer)", "%1 carat", "%1 carats")
|
||||
);
|
||||
//http://en.wikipedia.org/wiki/Pound_(mass)#International_pound
|
||||
U(Pound, 453.592,
|
||||
i18nc("mass unit symbol", "lb"),
|
||||
i18nc("unit description in lists", "pounds"),
|
||||
i18nc("unit synonyms for matching user input", "pound;pounds;lb"),
|
||||
ki18nc("amount in units (real)", "%1 pounds"),
|
||||
ki18ncp("amount in units (integer)", "%1 pound", "%1 pounds")
|
||||
);
|
||||
//International avoirdupois ounce
|
||||
U(Ounce, 28.3495,
|
||||
i18nc("mass unit symbol", "oz"),
|
||||
i18nc("unit description in lists", "ounces"),
|
||||
i18nc("unit synonyms for matching user input", "ounce;ounces;oz"),
|
||||
ki18nc("amount in units (real)", "%1 ounces"),
|
||||
ki18ncp("amount in units (integer)", "%1 ounce", "%1 ounces")
|
||||
);
|
||||
U(TroyOunce, 31.1035,
|
||||
i18nc("mass unit symbol", "t oz"),
|
||||
i18nc("unit description in lists", "troy ounces"),
|
||||
i18nc("unit synonyms for matching user input", "troy ounce;troy ounces;t oz"),
|
||||
ki18nc("amount in units (real)", "%1 troy ounces"),
|
||||
ki18ncp("amount in units (integer)", "%1 troy ounce", "%1 troy ounces")
|
||||
);
|
||||
U(MassNewton, 101.937,
|
||||
i18nc("mass unit symbol", "N"),
|
||||
i18nc("unit description in lists", "newtons"),
|
||||
i18nc("unit synonyms for matching user input", "newton;newtons;N"),
|
||||
ki18nc("amount in units (real)", "%1 newtons"),
|
||||
ki18ncp("amount in units (integer)", "%1 newton", "%1 newtons")
|
||||
);
|
||||
//used a lot in industry (aircraft engines for example)
|
||||
U(Kilonewton, 101937,
|
||||
i18nc("mass unit symbol", "kN"),
|
||||
i18nc("unit description in lists", "kilonewton"),
|
||||
i18nc("unit synonyms for matching user input", "kilonewton;kilonewton;kN"),
|
||||
ki18nc("amount in units (real)", "%1 kilonewton"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilonewton", "%1 kilonewton")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
Kilogram << Gram << Microgram << Ton << Pound << Ounce);
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009 Petri Damstén <damu@iki.fi>
|
||||
* Copyright (C) 2008 Kristof Bal <kristof.bal@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef MASS_H
|
||||
#define MASS_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Mass : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Mass();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,187 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "power.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Power::Power() : UnitCategory(PowerCategory)
|
||||
{
|
||||
setName(i18n("Power"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (power)", "%1 %2"));
|
||||
|
||||
U(Yottawatt, 1e+24,
|
||||
i18nc("power unit symbol", "YW"),
|
||||
i18nc("unit description in lists", "yottawatts"),
|
||||
i18nc("unit synonyms for matching user input", "yottawatt;yottawatts;YW"),
|
||||
ki18nc("amount in units (real)", "%1 yottawatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottawatt", "%1 yottawatts")
|
||||
);
|
||||
U(Zettawatt, 1e+21,
|
||||
i18nc("power unit symbol", "ZW"),
|
||||
i18nc("unit description in lists", "zettawatts"),
|
||||
i18nc("unit synonyms for matching user input", "zettawatt;zettawatts;ZW"),
|
||||
ki18nc("amount in units (real)", "%1 zettawatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettawatt", "%1 zettawatts")
|
||||
);
|
||||
U(Exawatt, 1e+18,
|
||||
i18nc("power unit symbol", "EW"),
|
||||
i18nc("unit description in lists", "exawatts"),
|
||||
i18nc("unit synonyms for matching user input", "exawatt;exawatts;EW"),
|
||||
ki18nc("amount in units (real)", "%1 exawatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 exawatt", "%1 exawatts")
|
||||
);
|
||||
U(Petawatt, 1e+15,
|
||||
i18nc("power unit symbol", "PW"),
|
||||
i18nc("unit description in lists", "petawatts"),
|
||||
i18nc("unit synonyms for matching user input", "petawatt;petawatts;PW"),
|
||||
ki18nc("amount in units (real)", "%1 petawatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 petawatt", "%1 petawatts")
|
||||
);
|
||||
U(Terawatt, 1e+12,
|
||||
i18nc("power unit symbol", "TW"),
|
||||
i18nc("unit description in lists", "terawatts"),
|
||||
i18nc("unit synonyms for matching user input", "terawatt;terawatts;TW"),
|
||||
ki18nc("amount in units (real)", "%1 terawatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 terawatt", "%1 terawatts")
|
||||
);
|
||||
U(Gigawatt, 1e+09,
|
||||
i18nc("power unit symbol", "GW"),
|
||||
i18nc("unit description in lists", "gigawatts"),
|
||||
i18nc("unit synonyms for matching user input", "gigawatt;gigawatts;GW"),
|
||||
ki18nc("amount in units (real)", "%1 gigawatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigawatt", "%1 gigawatts")
|
||||
);
|
||||
U(Megawatt, 1e+06,
|
||||
i18nc("power unit symbol", "MW"),
|
||||
i18nc("unit description in lists", "megawatts"),
|
||||
i18nc("unit synonyms for matching user input", "megawatt;megawatts;MW"),
|
||||
ki18nc("amount in units (real)", "%1 megawatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 megawatt", "%1 megawatts")
|
||||
);
|
||||
U(Kilowatt, 1000,
|
||||
i18nc("power unit symbol", "kW"),
|
||||
i18nc("unit description in lists", "kilowatts"),
|
||||
i18nc("unit synonyms for matching user input", "kilowatt;kilowatts;kW"),
|
||||
ki18nc("amount in units (real)", "%1 kilowatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilowatt", "%1 kilowatts")
|
||||
);
|
||||
U(Hectowatt, 100,
|
||||
i18nc("power unit symbol", "hW"),
|
||||
i18nc("unit description in lists", "hectowatts"),
|
||||
i18nc("unit synonyms for matching user input", "hectowatt;hectowatts;hW"),
|
||||
ki18nc("amount in units (real)", "%1 hectowatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectowatt", "%1 hectowatts")
|
||||
);
|
||||
U(Decawatt, 10,
|
||||
i18nc("power unit symbol", "daW"),
|
||||
i18nc("unit description in lists", "decawatts"),
|
||||
i18nc("unit synonyms for matching user input", "decawatt;decawatts;daW"),
|
||||
ki18nc("amount in units (real)", "%1 decawatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 decawatt", "%1 decawatts")
|
||||
);
|
||||
setDefaultUnit(UP(Watt, 1,
|
||||
i18nc("power unit symbol", "W"),
|
||||
i18nc("unit description in lists", "watts"),
|
||||
i18nc("unit synonyms for matching user input", "watt;watts;W"),
|
||||
ki18nc("amount in units (real)", "%1 watts"),
|
||||
ki18ncp("amount in units (integer)", "%1 watt", "%1 watts")
|
||||
));
|
||||
U(Deciwatt, 0.1,
|
||||
i18nc("power unit symbol", "dW"),
|
||||
i18nc("unit description in lists", "deciwatts"),
|
||||
i18nc("unit synonyms for matching user input", "deciwatt;deciwatts;dW"),
|
||||
ki18nc("amount in units (real)", "%1 deciwatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 deciwatt", "%1 deciwatts")
|
||||
);
|
||||
U(Centiwatt, 0.01,
|
||||
i18nc("power unit symbol", "cW"),
|
||||
i18nc("unit description in lists", "centiwatts"),
|
||||
i18nc("unit synonyms for matching user input", "centiwatt;centiwatts;cW"),
|
||||
ki18nc("amount in units (real)", "%1 centiwatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 centiwatt", "%1 centiwatts")
|
||||
);
|
||||
U(Milliwatt, 0.001,
|
||||
i18nc("power unit symbol", "mW"),
|
||||
i18nc("unit description in lists", "milliwatts"),
|
||||
i18nc("unit synonyms for matching user input", "milliwatt;milliwatts;mW"),
|
||||
ki18nc("amount in units (real)", "%1 milliwatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 milliwatt", "%1 milliwatts")
|
||||
);
|
||||
U(Microwatt, 1e-06,
|
||||
i18nc("power unit symbol", "µW"),
|
||||
i18nc("unit description in lists", "microwatts"),
|
||||
i18nc("unit synonyms for matching user input", "microwatt;microwatts;µW;uW"),
|
||||
ki18nc("amount in units (real)", "%1 microwatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 microwatt", "%1 microwatts")
|
||||
);
|
||||
U(Nanowatt, 1e-09,
|
||||
i18nc("power unit symbol", "nW"),
|
||||
i18nc("unit description in lists", "nanowatts"),
|
||||
i18nc("unit synonyms for matching user input", "nanowatt;nanowatts;nW"),
|
||||
ki18nc("amount in units (real)", "%1 nanowatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanowatt", "%1 nanowatts")
|
||||
);
|
||||
U(Picowatt, 1e-12,
|
||||
i18nc("power unit symbol", "pW"),
|
||||
i18nc("unit description in lists", "picowatts"),
|
||||
i18nc("unit synonyms for matching user input", "picowatt;picowatts;pW"),
|
||||
ki18nc("amount in units (real)", "%1 picowatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 picowatt", "%1 picowatts")
|
||||
);
|
||||
U(Femtowatt, 1e-15,
|
||||
i18nc("power unit symbol", "fW"),
|
||||
i18nc("unit description in lists", "femtowatts"),
|
||||
i18nc("unit synonyms for matching user input", "femtowatt;femtowatts;fW"),
|
||||
ki18nc("amount in units (real)", "%1 femtowatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtowatt", "%1 femtowatts")
|
||||
);
|
||||
U(Attowatt, 1e-18,
|
||||
i18nc("power unit symbol", "aW"),
|
||||
i18nc("unit description in lists", "attowatts"),
|
||||
i18nc("unit synonyms for matching user input", "attowatt;attowatts;aW"),
|
||||
ki18nc("amount in units (real)", "%1 attowatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 attowatt", "%1 attowatts")
|
||||
);
|
||||
U(Zeptowatt, 1e-21,
|
||||
i18nc("power unit symbol", "zW"),
|
||||
i18nc("unit description in lists", "zeptowatts"),
|
||||
i18nc("unit synonyms for matching user input", "zeptowatt;zeptowatts;zW"),
|
||||
ki18nc("amount in units (real)", "%1 zeptowatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptowatt", "%1 zeptowatts")
|
||||
);
|
||||
U(Yoctowatt, 1e-24,
|
||||
i18nc("power unit symbol", "yW"),
|
||||
i18nc("unit description in lists", "yoctowatts"),
|
||||
i18nc("unit synonyms for matching user input", "yoctowatt;yoctowatts;yW"),
|
||||
ki18nc("amount in units (real)", "%1 yoctowatts"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctowatt", "%1 yoctowatts")
|
||||
);
|
||||
U(Horsepower, 735.499,
|
||||
i18nc("power unit symbol", "hp"),
|
||||
i18nc("unit description in lists", "horsepowers"),
|
||||
i18nc("unit synonyms for matching user input", "horsepower;horsepowers;hp"),
|
||||
ki18nc("amount in units (real)", "%1 horsepowers"),
|
||||
ki18ncp("amount in units (integer)", "%1 horsepower", "%1 horsepowers")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() << Kilowatt << Watt << Horsepower);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef POWER_H
|
||||
#define POWER_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Power : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Power();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,251 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "pressure.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Pressure::Pressure() : UnitCategory(PressureCategory)
|
||||
{
|
||||
setName(i18n("Pressure"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (pressure)", "%1 %2"));
|
||||
|
||||
U(Yottapascal, 1e+24,
|
||||
i18nc("pressure unit symbol", "YPa"),
|
||||
i18nc("unit description in lists", "yottapascals"),
|
||||
i18nc("unit synonyms for matching user input", "yottapascal;yottapascals;YPa"),
|
||||
ki18nc("amount in units (real)", "%1 yottapascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottapascal", "%1 yottapascals")
|
||||
);
|
||||
U(Zettapascal, 1e+21,
|
||||
i18nc("pressure unit symbol", "ZPa"),
|
||||
i18nc("unit description in lists", "zettapascals"),
|
||||
i18nc("unit synonyms for matching user input", "zettapascal;zettapascals;ZPa"),
|
||||
ki18nc("amount in units (real)", "%1 zettapascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettapascal", "%1 zettapascals")
|
||||
);
|
||||
U(Exapascal, 1e+18,
|
||||
i18nc("pressure unit symbol", "EPa"),
|
||||
i18nc("unit description in lists", "exapascals"),
|
||||
i18nc("unit synonyms for matching user input", "exapascal;exapascals;EPa"),
|
||||
ki18nc("amount in units (real)", "%1 exapascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 exapascal", "%1 exapascals")
|
||||
);
|
||||
U(Petapascal, 1e+15,
|
||||
i18nc("pressure unit symbol", "PPa"),
|
||||
i18nc("unit description in lists", "petapascals"),
|
||||
i18nc("unit synonyms for matching user input", "petapascal;petapascals;PPa"),
|
||||
ki18nc("amount in units (real)", "%1 petapascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 petapascal", "%1 petapascals")
|
||||
);
|
||||
U(Terapascal, 1e+12,
|
||||
i18nc("pressure unit symbol", "TPa"),
|
||||
i18nc("unit description in lists", "terapascals"),
|
||||
i18nc("unit synonyms for matching user input", "terapascal;terapascals;TPa"),
|
||||
ki18nc("amount in units (real)", "%1 terapascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 terapascal", "%1 terapascals")
|
||||
);
|
||||
U(Gigapascal, 1e+09,
|
||||
i18nc("pressure unit symbol", "GPa"),
|
||||
i18nc("unit description in lists", "gigapascals"),
|
||||
i18nc("unit synonyms for matching user input", "gigapascal;gigapascals;GPa"),
|
||||
ki18nc("amount in units (real)", "%1 gigapascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigapascal", "%1 gigapascals")
|
||||
);
|
||||
U(Megapascal, 1e+06,
|
||||
i18nc("pressure unit symbol", "MPa"),
|
||||
i18nc("unit description in lists", "megapascals"),
|
||||
i18nc("unit synonyms for matching user input", "megapascal;megapascals;MPa"),
|
||||
ki18nc("amount in units (real)", "%1 megapascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 megapascal", "%1 megapascals")
|
||||
);
|
||||
U(Kilopascal, 1000,
|
||||
i18nc("pressure unit symbol", "kPa"),
|
||||
i18nc("unit description in lists", "kilopascals"),
|
||||
i18nc("unit synonyms for matching user input", "kilopascal;kilopascals;kPa"),
|
||||
ki18nc("amount in units (real)", "%1 kilopascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilopascal", "%1 kilopascals")
|
||||
);
|
||||
U(Hectopascal, 100,
|
||||
i18nc("pressure unit symbol", "hPa"),
|
||||
i18nc("unit description in lists", "hectopascals"),
|
||||
i18nc("unit synonyms for matching user input", "hectopascal;hectopascals;hPa"),
|
||||
ki18nc("amount in units (real)", "%1 hectopascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectopascal", "%1 hectopascals")
|
||||
);
|
||||
U(Decapascal, 10,
|
||||
i18nc("pressure unit symbol", "daPa"),
|
||||
i18nc("unit description in lists", "decapascals"),
|
||||
i18nc("unit synonyms for matching user input", "decapascal;decapascals;daPa"),
|
||||
ki18nc("amount in units (real)", "%1 decapascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 decapascal", "%1 decapascals")
|
||||
);
|
||||
setDefaultUnit(UP(Pascal, 1,
|
||||
i18nc("pressure unit symbol", "Pa"),
|
||||
i18nc("unit description in lists", "pascals"),
|
||||
i18nc("unit synonyms for matching user input", "pascal;pascals;Pa"),
|
||||
ki18nc("amount in units (real)", "%1 pascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 pascal", "%1 pascals")
|
||||
));
|
||||
U(Decipascal, 0.1,
|
||||
i18nc("pressure unit symbol", "dPa"),
|
||||
i18nc("unit description in lists", "decipascals"),
|
||||
i18nc("unit synonyms for matching user input", "decipascal;decipascals;dPa"),
|
||||
ki18nc("amount in units (real)", "%1 decipascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 decipascal", "%1 decipascals")
|
||||
);
|
||||
U(Centipascal, 0.01,
|
||||
i18nc("pressure unit symbol", "cPa"),
|
||||
i18nc("unit description in lists", "centipascals"),
|
||||
i18nc("unit synonyms for matching user input", "centipascal;centipascals;cPa"),
|
||||
ki18nc("amount in units (real)", "%1 centipascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 centipascal", "%1 centipascals")
|
||||
);
|
||||
U(Millipascal, 0.001,
|
||||
i18nc("pressure unit symbol", "mPa"),
|
||||
i18nc("unit description in lists", "millipascals"),
|
||||
i18nc("unit synonyms for matching user input", "millipascal;millipascals;mPa"),
|
||||
ki18nc("amount in units (real)", "%1 millipascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 millipascal", "%1 millipascals")
|
||||
);
|
||||
U(Micropascal, 1e-06,
|
||||
i18nc("pressure unit symbol", "µPa"),
|
||||
i18nc("unit description in lists", "micropascals"),
|
||||
i18nc("unit synonyms for matching user input", "micropascal;micropascals;µPa;uPa"),
|
||||
ki18nc("amount in units (real)", "%1 micropascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 micropascal", "%1 micropascals")
|
||||
);
|
||||
U(Nanopascal, 1e-09,
|
||||
i18nc("pressure unit symbol", "nPa"),
|
||||
i18nc("unit description in lists", "nanopascals"),
|
||||
i18nc("unit synonyms for matching user input", "nanopascal;nanopascals;nPa"),
|
||||
ki18nc("amount in units (real)", "%1 nanopascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanopascal", "%1 nanopascals")
|
||||
);
|
||||
U(Picopascal, 1e-12,
|
||||
i18nc("pressure unit symbol", "pPa"),
|
||||
i18nc("unit description in lists", "picopascals"),
|
||||
i18nc("unit synonyms for matching user input", "picopascal;picopascals;pPa"),
|
||||
ki18nc("amount in units (real)", "%1 picopascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 picopascal", "%1 picopascals")
|
||||
);
|
||||
U(Femtopascal, 1e-15,
|
||||
i18nc("pressure unit symbol", "fPa"),
|
||||
i18nc("unit description in lists", "femtopascals"),
|
||||
i18nc("unit synonyms for matching user input", "femtopascal;femtopascals;fPa"),
|
||||
ki18nc("amount in units (real)", "%1 femtopascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtopascal", "%1 femtopascals")
|
||||
);
|
||||
U(Attopascal, 1e-18,
|
||||
i18nc("pressure unit symbol", "aPa"),
|
||||
i18nc("unit description in lists", "attopascals"),
|
||||
i18nc("unit synonyms for matching user input", "attopascal;attopascals;aPa"),
|
||||
ki18nc("amount in units (real)", "%1 attopascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 attopascal", "%1 attopascals")
|
||||
);
|
||||
U(Zeptopascal, 1e-21,
|
||||
i18nc("pressure unit symbol", "zPa"),
|
||||
i18nc("unit description in lists", "zeptopascals"),
|
||||
i18nc("unit synonyms for matching user input", "zeptopascal;zeptopascals;zPa"),
|
||||
ki18nc("amount in units (real)", "%1 zeptopascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptopascal", "%1 zeptopascals")
|
||||
);
|
||||
U(Yoctopascal, 1e-24,
|
||||
i18nc("pressure unit symbol", "yPa"),
|
||||
i18nc("unit description in lists", "yoctopascals"),
|
||||
i18nc("unit synonyms for matching user input", "yoctopascal;yoctopascals;yPa"),
|
||||
ki18nc("amount in units (real)", "%1 yoctopascals"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctopascal", "%1 yoctopascals")
|
||||
);
|
||||
U(Bar, 100000,
|
||||
i18nc("pressure unit symbol", "bar"),
|
||||
i18nc("unit description in lists", "bars"),
|
||||
i18nc("unit synonyms for matching user input", "bar;bars;bar"),
|
||||
ki18nc("amount in units (real)", "%1 bars"),
|
||||
ki18ncp("amount in units (integer)", "%1 bar", "%1 bars")
|
||||
);
|
||||
U(Millibar, 100,
|
||||
i18nc("pressure unit symbol", "mbar"),
|
||||
i18nc("unit description in lists", "millibars"),
|
||||
i18nc("unit synonyms for matching user input", "millibar;millibars;mbar;mb"),
|
||||
ki18nc("amount in units (real)", "%1 millibars"),
|
||||
ki18ncp("amount in units (integer)", "%1 millibar", "%1 millibars")
|
||||
);
|
||||
U(Decibar, 10000,
|
||||
i18nc("pressure unit symbol", "dbar"),
|
||||
i18nc("unit description in lists", "decibars"),
|
||||
i18nc("unit synonyms for matching user input", "decibar;decibars;dbar"),
|
||||
ki18nc("amount in units (real)", "%1 decibars"),
|
||||
ki18ncp("amount in units (integer)", "%1 decibar", "%1 decibars")
|
||||
);
|
||||
U(Torr, 133.322,
|
||||
i18nc("pressure unit symbol", "Torr"),
|
||||
i18nc("unit description in lists", "Torr"),
|
||||
i18nc("unit synonyms for matching user input", "Torr"),
|
||||
ki18nc("amount in units (real)", "%1 torr"),
|
||||
ki18ncp("amount in units (integer)", "%1 torr", "%1 torr")
|
||||
);
|
||||
U(TechnicalAtmosphere, 98066.5,
|
||||
i18nc("pressure unit symbol", "at"),
|
||||
i18nc("unit description in lists", "technical atmospheres"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"technical atmosphere;technical atmospheres;at"),
|
||||
ki18nc("amount in units (real)", "%1 technical atmospheres"),
|
||||
ki18ncp("amount in units (integer)", "%1 technical atmosphere", "%1 technical atmospheres")
|
||||
);
|
||||
U(Atmosphere, 101325,
|
||||
i18nc("pressure unit symbol", "atm"),
|
||||
i18nc("unit description in lists", "atmospheres"),
|
||||
i18nc("unit synonyms for matching user input", "atmosphere;atmospheres;atm"),
|
||||
ki18nc("amount in units (real)", "%1 atmospheres"),
|
||||
ki18ncp("amount in units (integer)", "%1 atmosphere", "%1 atmospheres")
|
||||
);
|
||||
U(PoundForcePerSquareInch, 6894.76,
|
||||
i18nc("pressure unit symbol", "psi"),
|
||||
i18nc("unit description in lists", "pound-force per square inch"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"pound-force per square inch;pound-force per square inches;psi"),
|
||||
ki18nc("amount in units (real)", "%1 pound-force per square inches"),
|
||||
ki18ncp("amount in units (integer)",
|
||||
"%1 pound-force per square inch", "%1 pound-force per square inch")
|
||||
);
|
||||
// http://en.wikipedia.org/wiki/InHg
|
||||
U(InchesOfMercury, 3386.39,
|
||||
i18nc("pressure unit symbol", "inHg"),
|
||||
i18nc("unit description in lists", "inches of mercury"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"inch of mercury;inches of mercury;inHg;in\""),
|
||||
ki18nc("amount in units (real)", "%1 inches of mercury"),
|
||||
ki18ncp("amount in units (integer)", "%1 inches of mercury", "%1 inches of mercury")
|
||||
);
|
||||
// http://en.wikipedia.org/wiki/MmHg#mmHg
|
||||
U(MillimetersOfMercury, 133.322,
|
||||
i18nc("pressure unit symbol", "mmHg"),
|
||||
i18nc("unit description in lists", "millimeters of mercury"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"millimeter of mercury;millimeters of mercury;mmHg"),
|
||||
ki18nc("amount in units (real)", "%1 millimeters of mercury"),
|
||||
ki18ncp("amount in units (integer)", "%1 millimeters of mercury", "%1 millimeters of mercury")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
Hectopascal << Pascal << Bar << Atmosphere << InchesOfMercury);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef PRESSURE_H
|
||||
#define PRESSURE_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Pressure : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Pressure();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,126 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "temperature.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class CelsiusConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return value + 273.15; };
|
||||
double fromDefault(double value) const { return value - 273.15; };
|
||||
};
|
||||
|
||||
class FahrenheitConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return (value + 459.67) * 5.0 / 9.0; };
|
||||
double fromDefault(double value) const { return (value * 9.0 / 5.0) - 459.67; };
|
||||
};
|
||||
|
||||
class DelisleConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return 373.15 - (value * 2.0 / 3.0); };
|
||||
double fromDefault(double value) const { return (373.15 - value) * 3.0 / 2.0; };
|
||||
};
|
||||
|
||||
class NewtonConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return (value * 100.0 / 33.0) + 273.15; };
|
||||
double fromDefault(double value) const { return (value - 273.15) * 33.0 / 100.0; };
|
||||
};
|
||||
|
||||
class ReaumurConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return (value * 5.0 / 4.0) + 273.15; };
|
||||
double fromDefault(double value) const { return (value - 273.15) * 4.0 / 5.0; };
|
||||
};
|
||||
|
||||
class RomerConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return (value - 7.5) * 40.0 / 21.0 + 273.15; };
|
||||
double fromDefault(double value) const { return (value - 273.15) * 21.0 / 40.0 + 7.5; };
|
||||
};
|
||||
|
||||
|
||||
Temperature::Temperature() : UnitCategory(TemperatureCategory)
|
||||
{
|
||||
setName(i18n("Temperature"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (temperature)", "%1 %2"));
|
||||
|
||||
setDefaultUnit(UP(Kelvin, 1,
|
||||
i18nc("temperature unit symbol", "K"),
|
||||
i18nc("unit description in lists", "kelvins"),
|
||||
i18nc("unit synonyms for matching user input", "kelvin;kelvins;K"),
|
||||
ki18nc("amount in units (real)", "%1 kelvins"),
|
||||
ki18ncp("amount in units (integer)", "%1 kelvin", "%1 kelvins")
|
||||
));
|
||||
U(Celsius, new CelsiusConv(),
|
||||
i18nc("temperature unit symbol", "°C"),
|
||||
i18nc("unit description in lists", "Celsius"),
|
||||
i18nc("unit synonyms for matching user input", "Celsius;°C;C"),
|
||||
ki18nc("amount in units (real)", "%1 degrees Celsius"),
|
||||
ki18ncp("amount in units (integer)", "%1 degree Celsius", "%1 degrees Celsius")
|
||||
);
|
||||
U(Fahrenheit, new FahrenheitConv(),
|
||||
i18nc("temperature unit symbol", "°F"),
|
||||
i18nc("unit description in lists", "Fahrenheit"),
|
||||
i18nc("unit synonyms for matching user input", "Fahrenheit;°F;F"),
|
||||
ki18nc("amount in units (real)", "%1 degrees Fahrenheit"),
|
||||
ki18ncp("amount in units (integer)", "%1 degree Fahrenheit", "%1 degrees Fahrenheit")
|
||||
);
|
||||
U(Rankine, 0.555556,
|
||||
i18nc("temperature unit symbol", "R"),
|
||||
i18nc("unit description in lists", "Rankine"),
|
||||
i18nc("unit synonyms for matching user input", "Rankine;°R;R;Ra"),
|
||||
ki18nc("amount in units (real)", "%1 Rankine"),
|
||||
ki18ncp("amount in units (integer)", "%1 Rankine", "%1 Rankine")
|
||||
);
|
||||
U(Delisle, new DelisleConv(),
|
||||
i18nc("temperature unit symbol", "°De"),
|
||||
i18nc("unit description in lists", "Delisle"),
|
||||
i18nc("unit synonyms for matching user input", "Delisle;°De;De"),
|
||||
ki18nc("amount in units (real)", "%1 degrees Delisle"),
|
||||
ki18ncp("amount in units (integer)", "%1 degree Delisle", "%1 degrees Delisle")
|
||||
);
|
||||
U(TemperatureNewton, new NewtonConv(),
|
||||
i18nc("temperature unit symbol", "°N"),
|
||||
i18nc("unit description in lists", "Newton"),
|
||||
i18nc("unit synonyms for matching user input", "Newton;°N;N"),
|
||||
ki18nc("amount in units (real)", "%1 degrees Newton"),
|
||||
ki18ncp("amount in units (integer)", "%1 degree Newton", "%1 degrees Newton")
|
||||
);
|
||||
U(Reaumur, new ReaumurConv(),
|
||||
i18nc("temperature unit symbol", "°Ré"),
|
||||
i18nc("unit description in lists", "Réaumur"),
|
||||
i18nc("unit synonyms for matching user input", "Réaumur;°Ré;Ré;Reaumur;°Re;Re"),
|
||||
ki18nc("amount in units (real)", "%1 degrees Réaumur"),
|
||||
ki18ncp("amount in units (integer)", "%1 degree Réaumur", "%1 degrees Réaumur")
|
||||
);
|
||||
U(Romer, new RomerConv(),
|
||||
i18nc("temperature unit symbol", "°Rø"),
|
||||
i18nc("unit description in lists", "Rømer"),
|
||||
i18nc("unit synonyms for matching user input", "Rømer;°Rø;Rø;Romer;°Ro;Ro"),
|
||||
ki18nc("amount in units (real)", "%1 degrees Rømer"),
|
||||
ki18ncp("amount in units (integer)", "%1 degree Rømer", "%1 degrees Rømer")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() << Kelvin << Celsius << Fahrenheit);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef TEMPERATURE_H
|
||||
#define TEMPERATURE_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Temperature : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Temperature();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,19 +0,0 @@
|
|||
include_directories(${KDE4_KDECORE_INCLUDES} ${KDE4_KDEUI_INCLUDES})
|
||||
|
||||
macro(KUNITCONVERSION_UNIT_TESTS)
|
||||
foreach(_testname ${ARGN})
|
||||
kde4_add_test(kunitconversion-${_testname} ${_testname}.cpp)
|
||||
target_link_libraries(kunitconversion-${_testname}
|
||||
${KDE4_KDECORE_LIBS}
|
||||
${KDE4_KUNITCONVERSION_LIBS}
|
||||
${QT_QTTEST_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
)
|
||||
endforeach(_testname)
|
||||
endmacro(KUNITCONVERSION_UNIT_TESTS)
|
||||
|
||||
KUNITCONVERSION_UNIT_TESTS(
|
||||
valuetest
|
||||
categorytest
|
||||
convertertest
|
||||
)
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "categorytest.h"
|
||||
#include <../unitcategory.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
void CategoryTest::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void CategoryTest::testInfo()
|
||||
{
|
||||
UnitCategory* cg = c.category(AreaCategory);
|
||||
QCOMPARE(cg->name(), QString("Area"));
|
||||
QCOMPARE(cg->description(), QString(""));
|
||||
QCOMPARE(cg->url(), KUrl());
|
||||
QCOMPARE(cg->id(), (int)AreaCategory);
|
||||
}
|
||||
|
||||
void CategoryTest::testUnits()
|
||||
{
|
||||
UnitCategory* cg = c.category(MassCategory);
|
||||
QCOMPARE(cg->defaultUnit()->symbol(), QString("kg"));
|
||||
QCOMPARE(cg->hasUnit(QString("g")), true);
|
||||
QCOMPARE(cg->unit(QString("g"))->symbol(), QString("g"));
|
||||
QCOMPARE(cg->unit(Kilogram)->symbol(), QString("kg"));
|
||||
QVERIFY(cg->units().size() > 0);
|
||||
QVERIFY(cg->allUnits().size() > 0);
|
||||
}
|
||||
|
||||
void CategoryTest::testConvert()
|
||||
{
|
||||
UnitCategory* cg = c.category(LengthCategory);
|
||||
Value v = cg->convert(Value(3.14, Kilometer), "m");
|
||||
QCOMPARE(v.number(), 3140.0);
|
||||
v = cg->convert(v, "cm");
|
||||
QCOMPARE(v.number(), 314000.0);
|
||||
v = cg->convert(v, cg->defaultUnit());
|
||||
QCOMPARE(v.number(), 3140.0);
|
||||
}
|
||||
|
||||
void CategoryTest::testInvalid()
|
||||
{
|
||||
UnitCategory* cg = c.category(99999);
|
||||
QCOMPARE(cg->name(), QString("Invalid"));
|
||||
cg = c.category("don't exist");
|
||||
QCOMPARE(cg->name(), QString("Invalid"));
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN(CategoryTest, NoGUI)
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef CATEGORYTEST_H
|
||||
#define CATEGORYTEST_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <qtest_kde.h>
|
||||
#include <../converter.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class CategoryTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testInfo();
|
||||
void testUnits();
|
||||
void testConvert();
|
||||
void testInvalid();
|
||||
|
||||
private:
|
||||
Converter c;
|
||||
};
|
||||
|
||||
#endif // CATEGORYTEST_H
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "convertertest.h"
|
||||
#include <../unitcategory.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
void ConverterTest::initTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void ConverterTest::testCategory()
|
||||
{
|
||||
QCOMPARE(c.categoryForUnit("km")->id(), (int)LengthCategory);
|
||||
QCOMPARE(c.category(QString("Length"))->id(), (int)LengthCategory);
|
||||
QCOMPARE(c.category(LengthCategory)->name(), QString("Length"));
|
||||
QVERIFY(c.categories().size() > 0);
|
||||
}
|
||||
|
||||
void ConverterTest::testUnits()
|
||||
{
|
||||
QCOMPARE(c.unit(QString("km"))->symbol(), QString("km"));
|
||||
QCOMPARE(c.unit(Kilogram)->symbol(), QString("kg"));
|
||||
}
|
||||
|
||||
void ConverterTest::testConvert()
|
||||
{
|
||||
Value v = c.convert(Value(3.14, Kilometer), "m");
|
||||
QCOMPARE(v.number(), 3140.0);
|
||||
v = c.convert(v, "cm");
|
||||
QCOMPARE(v.number(), 314000.0);
|
||||
v = c.convert(v, c.category(LengthCategory)->defaultUnit());
|
||||
QCOMPARE(v.number(), 3140.0);
|
||||
}
|
||||
|
||||
void ConverterTest::testInvalid()
|
||||
{
|
||||
QCOMPARE(c.categoryForUnit("does not exist")->id(), (int)InvalidCategory);
|
||||
QCOMPARE(c.unit("does not exist")->symbol(), QString(""));
|
||||
QCOMPARE(c.category("does not exist")->name(), QString("Invalid"));
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN(ConverterTest, NoGUI)
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef CONVERTERTEST_H
|
||||
#define CONVERTERTEST_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <qtest_kde.h>
|
||||
#include <../converter.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class ConverterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testCategory();
|
||||
void testUnits();
|
||||
void testConvert();
|
||||
void testInvalid();
|
||||
|
||||
private:
|
||||
Converter c;
|
||||
};
|
||||
|
||||
#endif // CONVERTERTEST_H
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "valuetest.h"
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
void ValueTest::initTestCase()
|
||||
{
|
||||
v1 = Value(3.1415, Kilometer);
|
||||
v2 = Value(6.1415, "m");
|
||||
v3 = Value(9.1415, v1.unit());
|
||||
}
|
||||
|
||||
void ValueTest::testStrings()
|
||||
{
|
||||
QCOMPARE(v1.unit()->symbol(), QString("km"));
|
||||
QCOMPARE(v2.toSymbolString(), QString("6.1415 m"));
|
||||
QCOMPARE(v3.toString(), QString("9.1415 kilometers"));
|
||||
}
|
||||
|
||||
void ValueTest::testRound()
|
||||
{
|
||||
v1.round(2);
|
||||
QCOMPARE(v1.number(), 3.14);
|
||||
}
|
||||
|
||||
void ValueTest::testConvert()
|
||||
{
|
||||
v1 = v1.convertTo(Meter);
|
||||
QCOMPARE(v1.number(), 3140.0);
|
||||
v1 = v1.convertTo("cm");
|
||||
QCOMPARE(v1.number(), 314000.0);
|
||||
v1 = v1.convertTo(v2.unit());
|
||||
QCOMPARE(v1.number(), 3140.0);
|
||||
}
|
||||
|
||||
void ValueTest::testInvalid()
|
||||
{
|
||||
v1 = v1.convertTo(99999);
|
||||
QCOMPARE(v1.number(), 0.0);
|
||||
QCOMPARE(v1.toSymbolString(), QString(""));
|
||||
v2 = v2.convertTo("don't exist");
|
||||
QCOMPARE(v2.number(), 0.0);
|
||||
QCOMPARE(v2.toSymbolString(), QString(""));
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN(ValueTest, NoGUI)
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef VALUE_TEST_H
|
||||
#define VALUE_TEST_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <qtest_kde.h>
|
||||
#include <../converter.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class ValueTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void testStrings();
|
||||
void testRound();
|
||||
void testConvert();
|
||||
void testInvalid();
|
||||
|
||||
private:
|
||||
Value v1;
|
||||
Value v2;
|
||||
Value v3;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,230 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "timeunit.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Time::Time() : UnitCategory(TimeCategory)
|
||||
{
|
||||
setName(i18n("Time"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (time)", "%1 %2"));
|
||||
|
||||
U(Yottasecond, 1e+24,
|
||||
i18nc("time unit symbol", "Ys"),
|
||||
i18nc("unit description in lists", "yottaseconds"),
|
||||
i18nc("unit synonyms for matching user input", "yottasecond;yottaseconds;Ys"),
|
||||
ki18nc("amount in units (real)", "%1 yottaseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottasecond", "%1 yottaseconds")
|
||||
);
|
||||
U(Zettasecond, 1e+21,
|
||||
i18nc("time unit symbol", "Zs"),
|
||||
i18nc("unit description in lists", "zettaseconds"),
|
||||
i18nc("unit synonyms for matching user input", "zettasecond;zettaseconds;Zs"),
|
||||
ki18nc("amount in units (real)", "%1 zettaseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettasecond", "%1 zettaseconds")
|
||||
);
|
||||
U(Exasecond, 1e+18,
|
||||
i18nc("time unit symbol", "Es"),
|
||||
i18nc("unit description in lists", "exaseconds"),
|
||||
i18nc("unit synonyms for matching user input", "exasecond;exaseconds;Es"),
|
||||
ki18nc("amount in units (real)", "%1 exaseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 exasecond", "%1 exaseconds")
|
||||
);
|
||||
U(Petasecond, 1e+15,
|
||||
i18nc("time unit symbol", "Ps"),
|
||||
i18nc("unit description in lists", "petaseconds"),
|
||||
i18nc("unit synonyms for matching user input", "petasecond;petaseconds;Ps"),
|
||||
ki18nc("amount in units (real)", "%1 petaseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 petasecond", "%1 petaseconds")
|
||||
);
|
||||
U(Terasecond, 1e+12,
|
||||
i18nc("time unit symbol", "Ts"),
|
||||
i18nc("unit description in lists", "teraseconds"),
|
||||
i18nc("unit synonyms for matching user input", "terasecond;teraseconds;Ts"),
|
||||
ki18nc("amount in units (real)", "%1 teraseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 terasecond", "%1 teraseconds")
|
||||
);
|
||||
U(Gigasecond, 1e+09,
|
||||
i18nc("time unit symbol", "Gs"),
|
||||
i18nc("unit description in lists", "gigaseconds"),
|
||||
i18nc("unit synonyms for matching user input", "gigasecond;gigaseconds;Gs"),
|
||||
ki18nc("amount in units (real)", "%1 gigaseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigasecond", "%1 gigaseconds")
|
||||
);
|
||||
U(Megasecond, 1e+06,
|
||||
i18nc("time unit symbol", "Ms"),
|
||||
i18nc("unit description in lists", "megaseconds"),
|
||||
i18nc("unit synonyms for matching user input", "megasecond;megaseconds;Ms"),
|
||||
ki18nc("amount in units (real)", "%1 megaseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 megasecond", "%1 megaseconds")
|
||||
);
|
||||
U(Kilosecond, 1000,
|
||||
i18nc("time unit symbol", "ks"),
|
||||
i18nc("unit description in lists", "kiloseconds"),
|
||||
i18nc("unit synonyms for matching user input", "kilosecond;kiloseconds;ks"),
|
||||
ki18nc("amount in units (real)", "%1 kiloseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilosecond", "%1 kiloseconds")
|
||||
);
|
||||
U(Hectosecond, 100,
|
||||
i18nc("time unit symbol", "hs"),
|
||||
i18nc("unit description in lists", "hectoseconds"),
|
||||
i18nc("unit synonyms for matching user input", "hectosecond;hectoseconds;hs"),
|
||||
ki18nc("amount in units (real)", "%1 hectoseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectosecond", "%1 hectoseconds")
|
||||
);
|
||||
U(Decasecond, 10,
|
||||
i18nc("time unit symbol", "das"),
|
||||
i18nc("unit description in lists", "decaseconds"),
|
||||
i18nc("unit synonyms for matching user input", "decasecond;decaseconds;das"),
|
||||
ki18nc("amount in units (real)", "%1 decaseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 decasecond", "%1 decaseconds")
|
||||
);
|
||||
setDefaultUnit(UP(Second, 1,
|
||||
i18nc("time unit symbol", "s"),
|
||||
i18nc("unit description in lists", "seconds"),
|
||||
i18nc("unit synonyms for matching user input", "second;seconds;s"),
|
||||
ki18nc("amount in units (real)", "%1 seconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 second", "%1 seconds")
|
||||
));
|
||||
U(Decisecond, 0.1,
|
||||
i18nc("time unit symbol", "ds"),
|
||||
i18nc("unit description in lists", "deciseconds"),
|
||||
i18nc("unit synonyms for matching user input", "decisecond;deciseconds;ds"),
|
||||
ki18nc("amount in units (real)", "%1 deciseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 decisecond", "%1 deciseconds")
|
||||
);
|
||||
U(Centisecond, 0.01,
|
||||
i18nc("time unit symbol", "cs"),
|
||||
i18nc("unit description in lists", "centiseconds"),
|
||||
i18nc("unit synonyms for matching user input", "centisecond;centiseconds;cs"),
|
||||
ki18nc("amount in units (real)", "%1 centiseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 centisecond", "%1 centiseconds")
|
||||
);
|
||||
U(Millisecond, 0.001,
|
||||
i18nc("time unit symbol", "ms"),
|
||||
i18nc("unit description in lists", "milliseconds"),
|
||||
i18nc("unit synonyms for matching user input", "millisecond;milliseconds;ms"),
|
||||
ki18nc("amount in units (real)", "%1 milliseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 millisecond", "%1 milliseconds")
|
||||
);
|
||||
U(Microsecond, 1e-06,
|
||||
i18nc("time unit symbol", "µs"),
|
||||
i18nc("unit description in lists", "microseconds"),
|
||||
i18nc("unit synonyms for matching user input", "microsecond;microseconds;µs;us"),
|
||||
ki18nc("amount in units (real)", "%1 microseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 microsecond", "%1 microseconds")
|
||||
);
|
||||
U(Nanosecond, 1e-09,
|
||||
i18nc("time unit symbol", "ns"),
|
||||
i18nc("unit description in lists", "nanoseconds"),
|
||||
i18nc("unit synonyms for matching user input", "nanosecond;nanoseconds;ns"),
|
||||
ki18nc("amount in units (real)", "%1 nanoseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanosecond", "%1 nanoseconds")
|
||||
);
|
||||
U(Picosecond, 1e-12,
|
||||
i18nc("time unit symbol", "ps"),
|
||||
i18nc("unit description in lists", "picoseconds"),
|
||||
i18nc("unit synonyms for matching user input", "picosecond;picoseconds;ps"),
|
||||
ki18nc("amount in units (real)", "%1 picoseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 picosecond", "%1 picoseconds")
|
||||
);
|
||||
U(Femtosecond, 1e-15,
|
||||
i18nc("time unit symbol", "fs"),
|
||||
i18nc("unit description in lists", "femtoseconds"),
|
||||
i18nc("unit synonyms for matching user input", "femtosecond;femtoseconds;fs"),
|
||||
ki18nc("amount in units (real)", "%1 femtoseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtosecond", "%1 femtoseconds")
|
||||
);
|
||||
U(Attosecond, 1e-18,
|
||||
i18nc("time unit symbol", "as"),
|
||||
i18nc("unit description in lists", "attoseconds"),
|
||||
i18nc("unit synonyms for matching user input", "attosecond;attoseconds;as"),
|
||||
ki18nc("amount in units (real)", "%1 attoseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 attosecond", "%1 attoseconds")
|
||||
);
|
||||
U(Zeptosecond, 1e-21,
|
||||
i18nc("time unit symbol", "zs"),
|
||||
i18nc("unit description in lists", "zeptoseconds"),
|
||||
i18nc("unit synonyms for matching user input", "zeptosecond;zeptoseconds;zs"),
|
||||
ki18nc("amount in units (real)", "%1 zeptoseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptosecond", "%1 zeptoseconds")
|
||||
);
|
||||
U(Yoctosecond, 1e-24,
|
||||
i18nc("time unit symbol", "ys"),
|
||||
i18nc("unit description in lists", "yoctoseconds"),
|
||||
i18nc("unit synonyms for matching user input", "yoctosecond;yoctoseconds;ys"),
|
||||
ki18nc("amount in units (real)", "%1 yoctoseconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctosecond", "%1 yoctoseconds")
|
||||
);
|
||||
U(Minute, 60,
|
||||
i18nc("time unit symbol", "min"),
|
||||
i18nc("unit description in lists", "minutes"),
|
||||
i18nc("unit synonyms for matching user input", "minute;minutes;min"),
|
||||
ki18nc("amount in units (real)", "%1 minutes"),
|
||||
ki18ncp("amount in units (integer)", "%1 minute", "%1 minutes")
|
||||
);
|
||||
U(Hour, 3600,
|
||||
i18nc("time unit symbol", "h"),
|
||||
i18nc("unit description in lists", "hours"),
|
||||
i18nc("unit synonyms for matching user input", "hour;hours;h"),
|
||||
ki18nc("amount in units (real)", "%1 hours"),
|
||||
ki18ncp("amount in units (integer)", "%1 hour", "%1 hours")
|
||||
);
|
||||
U(Day, 86400,
|
||||
i18nc("time unit symbol", "d"),
|
||||
i18nc("unit description in lists", "days"),
|
||||
i18nc("unit synonyms for matching user input", "day;days;d"),
|
||||
ki18nc("amount in units (real)", "%1 days"),
|
||||
ki18ncp("amount in units (integer)", "%1 day", "%1 days")
|
||||
);
|
||||
U(Week, 604800,
|
||||
i18nc("time unit symbol", "w"),
|
||||
i18nc("unit description in lists", "weeks"),
|
||||
i18nc("unit synonyms for matching user input", "week;weeks"),
|
||||
ki18nc("amount in units (real)", "%1 weeks"),
|
||||
ki18ncp("amount in units (integer)", "%1 week", "%1 weeks")
|
||||
);
|
||||
U(JulianYear, 3.15576e+07,
|
||||
i18nc("time unit symbol", "a"),
|
||||
i18nc("unit description in lists", "Julian years"),
|
||||
i18nc("unit synonyms for matching user input", "Julian year;Julian years;a"),
|
||||
ki18nc("amount in units (real)", "%1 Julian years"),
|
||||
ki18ncp("amount in units (integer)", "%1 Julian year", "%1 Julian years")
|
||||
);
|
||||
U(LeapYear, 3.16224e+07,
|
||||
i18nc("time unit symbol", "lpy"),
|
||||
i18nc("unit description in lists", "leap years"),
|
||||
i18nc("unit synonyms for matching user input", "leap year;leap years"),
|
||||
ki18nc("amount in units (real)", "%1 leap years"),
|
||||
ki18ncp("amount in units (integer)", "%1 leap year", "%1 leap years")
|
||||
);
|
||||
//Let's say we call that a normal year
|
||||
U(Year, 3.1536e+07,
|
||||
i18nc("time unit symbol", "y"),
|
||||
i18nc("unit description in lists", "year"),
|
||||
i18nc("unit synonyms for matching user input", "year;years;y"),
|
||||
ki18nc("amount in units (real)", "%1 year"),
|
||||
ki18ncp("amount in units (integer)", "%1 year", "%1 years")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() << Second << Minute << Day << Week << Year);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef TIME_H
|
||||
#define TIME_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Time : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Time();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,169 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "unit.h"
|
||||
|
||||
#include <klocalizedstring.h>
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
|
||||
Complex::Complex()
|
||||
{
|
||||
}
|
||||
|
||||
Complex::~Complex()
|
||||
{
|
||||
}
|
||||
|
||||
class Unit::Private
|
||||
{
|
||||
public:
|
||||
Private(UnitCategory* category, const Complex* complex = 0)
|
||||
: multiplier(1.0)
|
||||
, complex(complex)
|
||||
, category(category)
|
||||
{
|
||||
};
|
||||
|
||||
~Private()
|
||||
{
|
||||
};
|
||||
|
||||
QString symbol;
|
||||
QString description;
|
||||
double multiplier;
|
||||
KLocalizedString real;
|
||||
KLocalizedString integer;
|
||||
const Complex* complex;
|
||||
UnitCategory* category;
|
||||
int id;
|
||||
};
|
||||
|
||||
Unit::Unit(UnitCategory* category, int id, double multiplier, const QString& symbol,
|
||||
const QString& description, const QString& match,
|
||||
const KLocalizedString& real, const KLocalizedString& integer)
|
||||
: d(new Unit::Private(category))
|
||||
{
|
||||
if (category) {
|
||||
category->addUnitMapValues(UnitPtr(this), match);
|
||||
category->addIdMapValue(UnitPtr(this), id);
|
||||
}
|
||||
d->multiplier = multiplier;
|
||||
d->real = real;
|
||||
d->integer = integer;
|
||||
d->symbol = symbol;
|
||||
d->description = description;
|
||||
d->id = id;
|
||||
}
|
||||
|
||||
Unit::Unit(UnitCategory* category, int id, const Complex* complex, const QString& symbol,
|
||||
const QString& description, const QString& match,
|
||||
const KLocalizedString& real, const KLocalizedString& integer)
|
||||
: d(new Unit::Private(category, complex))
|
||||
{
|
||||
if (category) {
|
||||
category->addUnitMapValues(UnitPtr(this), match);
|
||||
category->addIdMapValue(UnitPtr(this), id);
|
||||
}
|
||||
d->real = real;
|
||||
d->integer = integer;
|
||||
d->symbol = symbol;
|
||||
d->description = description;
|
||||
d->id = id;
|
||||
}
|
||||
|
||||
Unit::~Unit()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
UnitCategory* Unit::category() const
|
||||
{
|
||||
return d->category;
|
||||
}
|
||||
|
||||
QString Unit::description() const
|
||||
{
|
||||
return d->description;
|
||||
}
|
||||
|
||||
QString Unit::symbol() const
|
||||
{
|
||||
return d->symbol;
|
||||
}
|
||||
|
||||
double Unit::multiplier() const
|
||||
{
|
||||
return d->multiplier;
|
||||
}
|
||||
|
||||
void Unit::setMultiplier(double multiplier)
|
||||
{
|
||||
d->multiplier = multiplier;
|
||||
}
|
||||
|
||||
double Unit::toDefault(double value) const
|
||||
{
|
||||
if (d->complex) {
|
||||
return d->complex->toDefault(value);
|
||||
} else {
|
||||
return value * d->multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
double Unit::fromDefault(double value) const
|
||||
{
|
||||
if (d->complex) {
|
||||
return d->complex->fromDefault(value);
|
||||
} else {
|
||||
return value / d->multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
QString Unit::toString(double value, int fieldWidth, char format, int precision,
|
||||
const QChar& fillChar) const
|
||||
{
|
||||
if ((int)value == value && precision < 1) {
|
||||
return d->integer.subs((int)value).toString();
|
||||
}
|
||||
return d->real.subs(value, fieldWidth, format, precision, fillChar).toString();
|
||||
}
|
||||
|
||||
QString Unit::toSymbolString(double value, int fieldWidth, char format, int precision,
|
||||
const QChar& fillChar) const
|
||||
{
|
||||
return category()->symbolStringFormat().subs(value, fieldWidth, format, precision, fillChar)
|
||||
.subs(d->symbol).toString();
|
||||
}
|
||||
|
||||
bool Unit::isValid() const
|
||||
{
|
||||
return !d->symbol.isEmpty();
|
||||
}
|
||||
|
||||
int Unit::id() const
|
||||
{
|
||||
return d->id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KUNITCONVERSION_UNIT_H
|
||||
#define KUNITCONVERSION_UNIT_H
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <ksharedptr.h>
|
||||
#include "kunitconversion_export.h"
|
||||
|
||||
class KLocalizedString;
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
|
||||
class UnitCategory;
|
||||
|
||||
class KUNITCONVERSION_EXPORT Complex
|
||||
{
|
||||
public:
|
||||
Complex();
|
||||
virtual ~Complex();
|
||||
virtual double toDefault(double) const = 0;
|
||||
virtual double fromDefault(double) const = 0;
|
||||
};
|
||||
|
||||
class KUNITCONVERSION_EXPORT Unit : public QSharedData
|
||||
{
|
||||
public:
|
||||
Unit(UnitCategory* category, int id, double multiplier, const QString& symbol,
|
||||
const QString& description, const QString& match,
|
||||
const KLocalizedString& real, const KLocalizedString& integer);
|
||||
Unit(UnitCategory* category, int id, const Complex* complex, const QString& symbol,
|
||||
const QString& description, const QString& match,
|
||||
const KLocalizedString& real, const KLocalizedString& integer);
|
||||
virtual ~Unit();
|
||||
|
||||
/**
|
||||
* @return translated name for unit.
|
||||
**/
|
||||
QString description() const;
|
||||
|
||||
/**
|
||||
* @return symbol for the unit.
|
||||
**/
|
||||
QString symbol() const;
|
||||
|
||||
/**
|
||||
* @param value number value
|
||||
* @param fieldWidth width of the formatted field, padded by spaces.
|
||||
* Positive value aligns right, negative aligns left
|
||||
* @param format type of floating point formating, like in QString::arg
|
||||
* @param precision number of digits after the decimal separator
|
||||
* @param fillChar the character used to fill up the empty places when
|
||||
* field width is greater than argument width
|
||||
* @return value + unit string
|
||||
**/
|
||||
QString toString(double value, int fieldWidth = 0, char format = 'g', int precision = -1,
|
||||
const QChar& fillChar = QLatin1Char(' ')) const;
|
||||
|
||||
/**
|
||||
* @param value number value
|
||||
* @param fieldWidth width of the formatted field, padded by spaces.
|
||||
* Positive value aligns right, negative aligns left
|
||||
* @param format type of floating point formating, like in QString::arg
|
||||
* @param precision number of digits after the decimal separator
|
||||
* @param fillChar the character used to fill up the empty places when
|
||||
* field width is greater than argument width
|
||||
* @return value + unit string
|
||||
**/
|
||||
QString toSymbolString(double value, int fieldWidth = 0, char format = 'g',
|
||||
int precision = -1, const QChar& fillChar = QLatin1Char(' ')) const;
|
||||
|
||||
/**
|
||||
* @return unit multiplier.
|
||||
**/
|
||||
double multiplier() const;
|
||||
|
||||
/**
|
||||
* Set unit multiplier.
|
||||
**/
|
||||
void setMultiplier(double multiplier);
|
||||
|
||||
/**
|
||||
* @return unit category.
|
||||
**/
|
||||
UnitCategory* category() const;
|
||||
|
||||
/**
|
||||
* @return if unit is valid.
|
||||
**/
|
||||
bool isValid() const;
|
||||
|
||||
/**
|
||||
* @return unit id.
|
||||
**/
|
||||
int id() const;
|
||||
|
||||
protected:
|
||||
double toDefault(double value) const;
|
||||
double fromDefault(double value) const;
|
||||
|
||||
private:
|
||||
friend class UnitCategory;
|
||||
class Private;
|
||||
Private* const d;
|
||||
};
|
||||
|
||||
typedef KSharedPtr<Unit> UnitPtr;
|
||||
|
||||
#define UP(id, m, s, d, sy, r, i) \
|
||||
(KUnitConversion::UnitPtr(new KUnitConversion::Unit(this, id, m, s, d, sy, r, i)))
|
||||
#define U(id, m, s, d, sy, r, i) (new KUnitConversion::Unit(this, id, m, s, d, sy, r, i))
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -1,196 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "unitcategory.h"
|
||||
#include <klocalizedstring.h>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
|
||||
class UnitCategory::Private
|
||||
{
|
||||
public:
|
||||
Private() :
|
||||
defaultUnit(0)
|
||||
{
|
||||
};
|
||||
|
||||
~Private()
|
||||
{
|
||||
};
|
||||
QString name;
|
||||
UnitPtr defaultUnit;
|
||||
QMap<QString, UnitPtr> unitMap;
|
||||
QMap<int, UnitPtr> idMap;
|
||||
QList<UnitPtr> units;
|
||||
QList<UnitPtr> mostCommonUnits;
|
||||
QString description;
|
||||
KUrl url;
|
||||
KLocalizedString symbolStringFormat;
|
||||
int id;
|
||||
};
|
||||
|
||||
UnitCategory::UnitCategory(int id)
|
||||
: d(new UnitCategory::Private)
|
||||
{
|
||||
d->id = id;
|
||||
}
|
||||
|
||||
UnitCategory::~UnitCategory()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void UnitCategory::setSymbolStringFormat(const KLocalizedString& symbolStringFormat)
|
||||
{
|
||||
d->symbolStringFormat = symbolStringFormat;
|
||||
}
|
||||
|
||||
KLocalizedString UnitCategory::symbolStringFormat() const
|
||||
{
|
||||
return d->symbolStringFormat;
|
||||
}
|
||||
|
||||
QList<UnitPtr> UnitCategory::units() const
|
||||
{
|
||||
return d->units;
|
||||
}
|
||||
|
||||
QList<UnitPtr> UnitCategory::mostCommonUnits() const
|
||||
{
|
||||
return d->mostCommonUnits;
|
||||
}
|
||||
|
||||
void UnitCategory::setMostCommonUnits(const QList<int>& units)
|
||||
{
|
||||
d->mostCommonUnits.clear();
|
||||
foreach (int u, units) {
|
||||
d->mostCommonUnits.append(unit(u));
|
||||
}
|
||||
}
|
||||
|
||||
QStringList UnitCategory::allUnits() const
|
||||
{
|
||||
return d->unitMap.keys();
|
||||
}
|
||||
|
||||
bool UnitCategory::hasUnit(const QString &unit) const
|
||||
{
|
||||
return d->unitMap.contains(unit);
|
||||
}
|
||||
|
||||
Value UnitCategory::convert(const Value& value, const QString& toUnit)
|
||||
{
|
||||
if ((toUnit.isEmpty() || d->unitMap.contains(toUnit)) && value.unit()->isValid()) {
|
||||
UnitPtr to = toUnit.isEmpty() ? defaultUnit() : d->unitMap[toUnit];
|
||||
return convert(value, to);
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value UnitCategory::convert(const Value& value, int toUnit)
|
||||
{
|
||||
if (d->idMap.contains(toUnit) && value.unit()->isValid()) {
|
||||
return convert(value, d->idMap[toUnit]);
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value UnitCategory::convert(const Value& value, UnitPtr toUnit)
|
||||
{
|
||||
if (toUnit) {
|
||||
double v = toUnit->fromDefault(value.unit()->toDefault(value.number()));
|
||||
return Value(v, toUnit);
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
void UnitCategory::addUnitMapValues(UnitPtr unit, const QString& names)
|
||||
{
|
||||
const QStringList list = names.split(';');
|
||||
foreach (const QString& name, list) {
|
||||
d->unitMap[name] = unit;
|
||||
}
|
||||
}
|
||||
|
||||
void UnitCategory::addIdMapValue(UnitPtr unit, int id)
|
||||
{
|
||||
d->idMap[id] = unit;
|
||||
d->units.append(unit);
|
||||
}
|
||||
|
||||
UnitPtr UnitCategory::unit(const QString& s) const
|
||||
{
|
||||
return d->unitMap.value(s);
|
||||
}
|
||||
|
||||
UnitPtr UnitCategory::unit(int unitId) const
|
||||
{
|
||||
if (d->idMap.contains(unitId)) {
|
||||
return d->idMap[unitId];
|
||||
}
|
||||
return UnitPtr();
|
||||
}
|
||||
|
||||
QString UnitCategory::name() const
|
||||
{
|
||||
return d->name;
|
||||
}
|
||||
|
||||
void UnitCategory::setName(const QString& name)
|
||||
{
|
||||
d->name = name;
|
||||
}
|
||||
|
||||
void UnitCategory::setDefaultUnit(UnitPtr defaultUnit)
|
||||
{
|
||||
d->defaultUnit = defaultUnit;
|
||||
}
|
||||
|
||||
UnitPtr UnitCategory::defaultUnit() const
|
||||
{
|
||||
return d->defaultUnit;
|
||||
}
|
||||
|
||||
QString UnitCategory::description() const
|
||||
{
|
||||
return d->description;
|
||||
}
|
||||
|
||||
void UnitCategory::setDescription(const QString& description)
|
||||
{
|
||||
d->description = description;
|
||||
}
|
||||
|
||||
KUrl UnitCategory::url() const
|
||||
{
|
||||
return d->url;
|
||||
}
|
||||
|
||||
void UnitCategory::setUrl(const KUrl& url)
|
||||
{
|
||||
d->url = url;
|
||||
}
|
||||
|
||||
int UnitCategory::id() const
|
||||
{
|
||||
return d->id;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KUNITCONVERSION_UNITCATEGORY_H
|
||||
#define KUNITCONVERSION_UNITCATEGORY_H
|
||||
|
||||
#include "value.h"
|
||||
#include "unit.h"
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <kurl.h>
|
||||
#include "kunitconversion_export.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
|
||||
class KUNITCONVERSION_EXPORT UnitCategory
|
||||
{
|
||||
public:
|
||||
UnitCategory(int id);
|
||||
virtual ~UnitCategory();
|
||||
|
||||
/**
|
||||
* Returns name for the unit category.
|
||||
*
|
||||
* @return Translated name for category.
|
||||
**/
|
||||
QString name() const;
|
||||
|
||||
/**
|
||||
* @return unit category description
|
||||
**/
|
||||
QString description() const;
|
||||
|
||||
/**
|
||||
* @return unit category url for description
|
||||
**/
|
||||
KUrl url() const;
|
||||
|
||||
/**
|
||||
* Returns default unit.
|
||||
*
|
||||
* @return default unit.
|
||||
**/
|
||||
UnitPtr defaultUnit() const;
|
||||
|
||||
/**
|
||||
* Check if unit category has a unit.
|
||||
*
|
||||
* @return True if unit is found
|
||||
**/
|
||||
bool hasUnit(const QString &unit) const;
|
||||
|
||||
/**
|
||||
* Return unit for string.
|
||||
*
|
||||
* @return Pointer to unit class.
|
||||
**/
|
||||
UnitPtr unit(const QString& s) const;
|
||||
|
||||
/**
|
||||
* Return unit for unit enum.
|
||||
*
|
||||
* @return Pointer to unit class.
|
||||
**/
|
||||
UnitPtr unit(int unitId) const;
|
||||
|
||||
/**
|
||||
* Return units in this category.
|
||||
*
|
||||
* @return list of units.
|
||||
**/
|
||||
QList<UnitPtr> units() const;
|
||||
|
||||
/**
|
||||
* Return most common units in this category.
|
||||
*
|
||||
* @return list of units.
|
||||
**/
|
||||
QList<UnitPtr> mostCommonUnits() const;
|
||||
|
||||
/**
|
||||
* Return all unit names, short names and unit synonyms in this category.
|
||||
*
|
||||
* @return list of units.
|
||||
**/
|
||||
QStringList allUnits() const;
|
||||
|
||||
/**
|
||||
* Convert value to another unit.
|
||||
*
|
||||
* @param value value to convert
|
||||
* @param toUnit unit to convert to. If empty default unit is used.
|
||||
* @return converted value
|
||||
**/
|
||||
Value convert(const Value& value, const QString& toUnit = QString());
|
||||
Value convert(const Value& value, int toUnit);
|
||||
virtual Value convert(const Value& value, UnitPtr toUnit);
|
||||
|
||||
/**
|
||||
* @return category id.
|
||||
**/
|
||||
int id() const;
|
||||
|
||||
protected:
|
||||
void setName(const QString& name);
|
||||
void setDefaultUnit(UnitPtr defaultUnit);
|
||||
void addUnitName(const QString& name);
|
||||
void addUnitMapValues(UnitPtr unit, const QString& names);
|
||||
void addIdMapValue(UnitPtr unit, int id);
|
||||
void setDescription(const QString& desc);
|
||||
void setUrl(const KUrl& url);
|
||||
void setSymbolStringFormat(const KLocalizedString& symbolStringFormat);
|
||||
void setMostCommonUnits(const QList<int>& units);
|
||||
KLocalizedString symbolStringFormat() const;
|
||||
|
||||
private:
|
||||
friend class Unit;
|
||||
class Private;
|
||||
Private* const d;
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "value.h"
|
||||
#include "converter.h"
|
||||
#include <qmath.h>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
|
||||
class Value::Private
|
||||
{
|
||||
public:
|
||||
Private(double n = 0.0, int u = InvalidUnit)
|
||||
: number(n)
|
||||
{
|
||||
unit = converter.unit(u);
|
||||
}
|
||||
|
||||
Private(double n, UnitPtr u)
|
||||
: number(n)
|
||||
, unit(u)
|
||||
{
|
||||
}
|
||||
|
||||
Private(double n, const QString& u)
|
||||
: number(n)
|
||||
{
|
||||
unit = converter.unit(u);
|
||||
}
|
||||
|
||||
~Private()
|
||||
{
|
||||
}
|
||||
|
||||
double number;
|
||||
UnitPtr unit;
|
||||
Converter converter;
|
||||
};
|
||||
|
||||
Value::Value()
|
||||
: d(new Value::Private())
|
||||
{
|
||||
}
|
||||
|
||||
Value::Value(double n, UnitPtr u)
|
||||
: d(new Value::Private(n, u))
|
||||
{
|
||||
}
|
||||
|
||||
Value::Value(double n, const QString& u)
|
||||
: d(new Value::Private(n, u))
|
||||
{
|
||||
}
|
||||
|
||||
Value::Value(double n, int u)
|
||||
: d(new Value::Private(n, u))
|
||||
{
|
||||
}
|
||||
|
||||
Value::Value(const QVariant& n, const QString& u)
|
||||
: d(new Value::Private(n.toDouble(), u))
|
||||
{
|
||||
}
|
||||
|
||||
Value::~Value()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool Value::isValid() const
|
||||
{
|
||||
return (d->unit && d->unit->isValid());
|
||||
}
|
||||
|
||||
QString Value::toString(int fieldWidth, char format, int precision, const QChar& fillChar) const
|
||||
{
|
||||
if (isValid()) {
|
||||
return d->unit->toString(d->number, fieldWidth, format, precision, fillChar);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString Value::toSymbolString(int fieldWidth, char format, int precision,
|
||||
const QChar& fillChar) const
|
||||
{
|
||||
if (isValid()) {
|
||||
return d->unit->toSymbolString(d->number, fieldWidth, format, precision, fillChar);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
Value& Value::round(uint decimals)
|
||||
{
|
||||
uint div = qPow(10, decimals);
|
||||
double add = 0.5 / (double)div;
|
||||
|
||||
d->number = (int)((d->number + add) * div) / (double)div;
|
||||
return *this;
|
||||
}
|
||||
|
||||
double Value::number() const
|
||||
{
|
||||
return d->number;
|
||||
}
|
||||
|
||||
UnitPtr Value::unit() const
|
||||
{
|
||||
if (!d->unit) {
|
||||
d->unit = d->converter.unit(InvalidUnit);
|
||||
}
|
||||
return d->unit;
|
||||
}
|
||||
|
||||
Value& Value::operator=(const Value& value)
|
||||
{
|
||||
d->number = value.d->number;
|
||||
d->unit = value.d->unit;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value Value::convertTo(UnitPtr unit) const
|
||||
{
|
||||
return d->converter.convert(*this, unit);
|
||||
}
|
||||
|
||||
Value Value::convertTo(int unit) const
|
||||
{
|
||||
return d->converter.convert(*this, unit);
|
||||
}
|
||||
|
||||
Value Value::convertTo(const QString& unit) const
|
||||
{
|
||||
return d->converter.convert(*this, unit);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KUNITCONVERSION_VALUE_H
|
||||
#define KUNITCONVERSION_VALUE_H
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include "unit.h"
|
||||
#include "kunitconversion_export.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
|
||||
class KUNITCONVERSION_EXPORT Value
|
||||
{
|
||||
public:
|
||||
Value();
|
||||
Value(double n, UnitPtr u);
|
||||
Value(double n, const QString& u);
|
||||
Value(double n, int u);
|
||||
Value(const QVariant& n, const QString& u);
|
||||
~Value();
|
||||
|
||||
/**
|
||||
* Check if value is valid.
|
||||
*
|
||||
* @return True if value is valid
|
||||
**/
|
||||
bool isValid() const;
|
||||
|
||||
/**
|
||||
* Convert value to a string
|
||||
* @param fieldWidth width of the formatted field, padded by spaces.
|
||||
* Positive value aligns right, negative aligns left
|
||||
* @param format type of floating point formating, like in QString::arg
|
||||
* @param precision number of digits after the decimal separator
|
||||
* @param fillChar the character used to fill up the empty places when
|
||||
* field width is greater than argument width
|
||||
* @return value as a string
|
||||
**/
|
||||
QString toString(int fieldWidth = 0, char format = 'g', int precision = -1,
|
||||
const QChar& fillChar = QLatin1Char(' ')) const;
|
||||
|
||||
/**
|
||||
* Convert value to a string with symbol
|
||||
* @param fieldWidth width of the formatted field, padded by spaces.
|
||||
* Positive value aligns right, negative aligns left
|
||||
* @param format type of floating point formating, like in QString::arg
|
||||
* @param precision number of digits after the decimal separator
|
||||
* @param fillChar the character used to fill up the empty places when
|
||||
* field width is greater than argument width
|
||||
* @return value as a string
|
||||
**/
|
||||
QString toSymbolString(int fieldWidth = 0, char format = 'g', int precision = -1,
|
||||
const QChar& fillChar = QLatin1Char(' ')) const;
|
||||
|
||||
/**
|
||||
* Number part of the value
|
||||
**/
|
||||
double number() const;
|
||||
|
||||
/**
|
||||
* rounds value to decimal count
|
||||
* @param decimals decimal count.
|
||||
**/
|
||||
Value& round(uint decimals);
|
||||
|
||||
/**
|
||||
* Unit part of the value
|
||||
**/
|
||||
UnitPtr unit() const;
|
||||
|
||||
/**
|
||||
* convert to another unit
|
||||
**/
|
||||
Value convertTo(UnitPtr unit) const;
|
||||
|
||||
/**
|
||||
* convert to another unit
|
||||
**/
|
||||
Value convertTo(int unit) const;
|
||||
|
||||
/**
|
||||
* convert to another unit
|
||||
**/
|
||||
Value convertTo(const QString& unit) const;
|
||||
|
||||
Value& operator=(const Value&);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* const d;
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "velocity.h"
|
||||
#include "converter.h"
|
||||
#include <math.h>
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class BeaufortConv : public Complex
|
||||
{
|
||||
double toDefault(double value) const { return 0.836 * pow(value, 3.0 / 2.0); };
|
||||
double fromDefault(double value) const { return pow(value / 0.836, 2.0 / 3.0); };
|
||||
};
|
||||
|
||||
Velocity::Velocity() : UnitCategory(VelocityCategory)
|
||||
{
|
||||
setName(i18n("Speed"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (velocity)", "%1 %2"));
|
||||
|
||||
setDefaultUnit(UP(MeterPerSecond, 1,
|
||||
i18nc("velocity unit symbol", "m/s"),
|
||||
i18nc("unit description in lists", "meters per second"),
|
||||
i18nc("unit synonyms for matching user input", "meter per second;meters per second;m/s;ms"),
|
||||
ki18nc("amount in units (real)", "%1 meters per second"),
|
||||
ki18ncp("amount in units (integer)", "%1 meter per second", "%1 meters per second")
|
||||
));
|
||||
U(KilometerPerHour, 0.277778,
|
||||
i18nc("velocity unit symbol", "km/h"),
|
||||
i18nc("unit description in lists", "kilometers per hour"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"kilometer per hour;kilometers per hour;km/h;kmh"),
|
||||
ki18nc("amount in units (real)", "%1 kilometers per hour"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilometer per hour", "%1 kilometers per hour")
|
||||
);
|
||||
U(MilePerHour, 0.44704,
|
||||
i18nc("velocity unit symbol", "mph"),
|
||||
i18nc("unit description in lists", "miles per hour"),
|
||||
i18nc("unit synonyms for matching user input", "mile per hour;miles per hour;mph"),
|
||||
ki18nc("amount in units (real)", "%1 miles per hour"),
|
||||
ki18ncp("amount in units (integer)", "%1 mile per hour", "%1 miles per hour")
|
||||
);
|
||||
U(FootPerSecond, 0.3048,
|
||||
i18nc("velocity unit symbol", "ft/s"),
|
||||
i18nc("unit description in lists", "feet per second"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"foot per second;feet per second;ft/s;ft/sec;fps"),
|
||||
ki18nc("amount in units (real)", "%1 feet per second"),
|
||||
ki18ncp("amount in units (integer)", "%1 foot per second", "%1 feet per second")
|
||||
);
|
||||
U(InchPerSecond, 0.0254,
|
||||
i18nc("velocity unit symbol", "in/s"),
|
||||
i18nc("unit description in lists", "inches per second"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"inch per second;inches per second;in/s;in/sec;ips"),
|
||||
ki18nc("amount in units (real)", "%1 inches per second"),
|
||||
ki18ncp("amount in units (integer)", "%1 inch per second", "%1 inches per second")
|
||||
);
|
||||
U(Knot, 0.514444,
|
||||
i18nc("velocity unit symbol", "kt"),
|
||||
i18nc("unit description in lists", "knots"),
|
||||
i18nc("unit synonyms for matching user input", "knot;knots;kt;nautical miles per hour"),
|
||||
ki18nc("amount in units (real)", "%1 knots"),
|
||||
ki18ncp("amount in units (integer)", "%1 knot", "%1 knots")
|
||||
);
|
||||
// http://en.wikipedia.org/wiki/Speed_of_sound
|
||||
U(Mach, 343,
|
||||
i18nc("velocity unit symbol", "Ma"),
|
||||
i18nc("unit description in lists", "Mach"),
|
||||
i18nc("unit synonyms for matching user input", "mach;machs;Ma;speed of sound"),
|
||||
ki18nc("amount in units (real)", "Mach %1"),
|
||||
ki18ncp("amount in units (integer)", "Mach %1", "Mach %1")
|
||||
);
|
||||
U(SpeedOfLight, 2.99792458e+08,
|
||||
i18nc("velocity unit symbol", "c"),
|
||||
i18nc("unit description in lists", "speed of light"),
|
||||
i18nc("unit synonyms for matching user input", "speed of light;c"),
|
||||
ki18nc("amount in units (real)", "%1 speed of light"),
|
||||
ki18ncp("amount in units (integer)", "%1 speed of light", "%1 speed of light")
|
||||
);
|
||||
// http://en.wikipedia.org/wiki/Beaufort_scale
|
||||
U(Beaufort, new BeaufortConv(),
|
||||
i18nc("velocity unit symbol", "bft"),
|
||||
i18nc("unit description in lists", "Beaufort"),
|
||||
i18nc("unit synonyms for matching user input", "Beaufort;Bft"),
|
||||
ki18nc("amount in units (real)", "%1 on the Beaufort scale"),
|
||||
ki18ncp("amount in units (integer)", "%1 on the Beaufort scale", "%1 on the Beaufort scale")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
MeterPerSecond << KilometerPerHour << MilePerHour << Knot << Mach);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef VELOCITY_H
|
||||
#define VELOCITY_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Velocity : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Velocity();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,404 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "volume.h"
|
||||
#include "converter.h"
|
||||
#include <klocale.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
Volume::Volume() : UnitCategory(VolumeCategory)
|
||||
{
|
||||
setName(i18n("Volume"));
|
||||
setSymbolStringFormat(ki18nc("%1 value, %2 unit symbol (volume)", "%1 %2"));
|
||||
|
||||
U(CubicYottameter, 1e+72,
|
||||
i18nc("volume unit symbol", "Ym³"),
|
||||
i18nc("unit description in lists", "cubic yottameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic yottameter;cubic yottameters;Ym³;Ym/-3;Ym^3;Ym3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic yottameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic yottameter", "%1 cubic yottameters")
|
||||
);
|
||||
U(CubicZettameter, 1e+63,
|
||||
i18nc("volume unit symbol", "Zm³"),
|
||||
i18nc("unit description in lists", "cubic zettameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic zettameter;cubic zettameters;Zm³;Zm/-3;Zm^3;Zm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic zettameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic zettameter", "%1 cubic zettameters")
|
||||
);
|
||||
U(CubicExameter, 1e+54,
|
||||
i18nc("volume unit symbol", "Em³"),
|
||||
i18nc("unit description in lists", "cubic exameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic exameter;cubic exameters;Em³;Em/-3;Em^3;Em3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic exameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic exameter", "%1 cubic exameters")
|
||||
);
|
||||
U(CubicPetameter, 1e+45,
|
||||
i18nc("volume unit symbol", "Pm³"),
|
||||
i18nc("unit description in lists", "cubic petameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic petameter;cubic petameters;Pm³;Pm/-3;Pm^3;Pm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic petameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic petameter", "%1 cubic petameters")
|
||||
);
|
||||
U(CubicTerameter, 1e+36,
|
||||
i18nc("volume unit symbol", "Tm³"),
|
||||
i18nc("unit description in lists", "cubic terameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic terameter;cubic terameters;Tm³;Tm/-3;Tm^3;Tm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic terameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic terameter", "%1 cubic terameters")
|
||||
);
|
||||
U(CubicGigameter, 1e+27,
|
||||
i18nc("volume unit symbol", "Gm³"),
|
||||
i18nc("unit description in lists", "cubic gigameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic gigameter;cubic gigameters;Gm³;Gm/-3;Gm^3;Gm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic gigameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic gigameter", "%1 cubic gigameters")
|
||||
);
|
||||
U(CubicMegameter, 1e+18,
|
||||
i18nc("volume unit symbol", "Mm³"),
|
||||
i18nc("unit description in lists", "cubic megameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic megameter;cubic megameters;Mm³;Mm/-3;Mm^3;Mm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic megameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic megameter", "%1 cubic megameters")
|
||||
);
|
||||
U(CubicKilometer, 1e+09,
|
||||
i18nc("volume unit symbol", "km³"),
|
||||
i18nc("unit description in lists", "cubic kilometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic kilometer;cubic kilometers;km³;km/-3;km^3;km3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic kilometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic kilometer", "%1 cubic kilometers")
|
||||
);
|
||||
U(CubicHectometer, 1e+06,
|
||||
i18nc("volume unit symbol", "hm³"),
|
||||
i18nc("unit description in lists", "cubic hectometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic hectometer;cubic hectometers;hm³;hm/-3;hm^3;hm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic hectometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic hectometer", "%1 cubic hectometers")
|
||||
);
|
||||
U(CubicDecameter, 1000,
|
||||
i18nc("volume unit symbol", "dam³"),
|
||||
i18nc("unit description in lists", "cubic decameters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic decameter;cubic decameters;dam³;dam/-3;dam^3;dam3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic decameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic decameter", "%1 cubic decameters")
|
||||
);
|
||||
U(CubicMeter, 1,
|
||||
i18nc("volume unit symbol", "m³"),
|
||||
i18nc("unit description in lists", "cubic meters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic meter;cubic meters;m³;m/-3;m^3;m3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic meters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic meter", "%1 cubic meters")
|
||||
);
|
||||
U(CubicDecimeter, 0.001,
|
||||
i18nc("volume unit symbol", "dm³"),
|
||||
i18nc("unit description in lists", "cubic decimeters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic decimeter;cubic decimeters;dm³;dm/-3;dm^3;dm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic decimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic decimeter", "%1 cubic decimeters")
|
||||
);
|
||||
U(CubicCentimeter, 1e-06,
|
||||
i18nc("volume unit symbol", "cm³"),
|
||||
i18nc("unit description in lists", "cubic centimeters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic centimeter;cubic centimeters;cm³;cm/-3;cm^3;cm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic centimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic centimeter", "%1 cubic centimeters")
|
||||
);
|
||||
U(CubicMillimeter, 1e-09,
|
||||
i18nc("volume unit symbol", "mm³"),
|
||||
i18nc("unit description in lists", "cubic millimeters"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic millimeter;cubic millimeters;mm³;mm/-3;mm^3;mm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic millimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic millimeter", "%1 cubic millimeters")
|
||||
);
|
||||
U(CubicMicrometer, 1e-18,
|
||||
i18nc("volume unit symbol", "µm³"),
|
||||
i18nc("unit description in lists", "cubic micrometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic micrometer;cubic micrometers;µm³;um³;µm/-3;µm^3;µm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic micrometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic micrometer", "%1 cubic micrometers")
|
||||
);
|
||||
U(CubicNanometer, 1e-27,
|
||||
i18nc("volume unit symbol", "nm³"),
|
||||
i18nc("unit description in lists", "cubic nanometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic nanometer;cubic nanometers;nm³;nm/-3;nm^3;nm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic nanometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic nanometer", "%1 cubic nanometers")
|
||||
);
|
||||
U(CubicPicometer, 1e-36,
|
||||
i18nc("volume unit symbol", "pm³"),
|
||||
i18nc("unit description in lists", "cubic picometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic picometer;cubic picometers;pm³;pm/-3;pm^3;pm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic picometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic picometer", "%1 cubic picometers")
|
||||
);
|
||||
U(CubicFemtometer, 1e-45,
|
||||
i18nc("volume unit symbol", "fm³"),
|
||||
i18nc("unit description in lists", "cubic femtometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic femtometer;cubic femtometers;fm³;fm/-3;fm^3;fm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic femtometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic femtometer", "%1 cubic femtometers")
|
||||
);
|
||||
U(CubicAttometer, 1e-54,
|
||||
i18nc("volume unit symbol", "am³"),
|
||||
i18nc("unit description in lists", "cubic attometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic attometer;cubic attometers;am³;am/-3;am^3;am3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic attometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic attometer", "%1 cubic attometers")
|
||||
);
|
||||
U(CubicZeptometer, 1e-63,
|
||||
i18nc("volume unit symbol", "zm³"),
|
||||
i18nc("unit description in lists", "cubic zeptometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic zeptometer;cubic zeptometers;zm³;zm/-3;zm^3;zm3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic zeptometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic zeptometer", "%1 cubic zeptometers")
|
||||
);
|
||||
U(CubicYoctometer, 1e-72,
|
||||
i18nc("volume unit symbol", "ym³"),
|
||||
i18nc("unit description in lists", "cubic yoctometers"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic yoctometer;cubic yoctometers;ym³;ym/-3;ym^3;ym3"),
|
||||
ki18nc("amount in units (real)", "%1 cubic yoctometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic yoctometer", "%1 cubic yoctometers")
|
||||
);
|
||||
U(Yottaliter, 1e+21,
|
||||
i18nc("volume unit symbol", "Yl"),
|
||||
i18nc("unit description in lists", "yottaliters"),
|
||||
i18nc("unit synonyms for matching user input", "yottaliter;yottaliters;Yl"),
|
||||
ki18nc("amount in units (real)", "%1 yottaliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottaliter", "%1 yottaliters")
|
||||
);
|
||||
U(Zettaliter, 1e+18,
|
||||
i18nc("volume unit symbol", "Zl"),
|
||||
i18nc("unit description in lists", "zettaliters"),
|
||||
i18nc("unit synonyms for matching user input", "zettaliter;zettaliters;Zl"),
|
||||
ki18nc("amount in units (real)", "%1 zettaliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettaliter", "%1 zettaliters")
|
||||
);
|
||||
U(Exaliter, 1e+15,
|
||||
i18nc("volume unit symbol", "El"),
|
||||
i18nc("unit description in lists", "exaliters"),
|
||||
i18nc("unit synonyms for matching user input", "exaliter;exaliters;El"),
|
||||
ki18nc("amount in units (real)", "%1 exaliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 exaliter", "%1 exaliters")
|
||||
);
|
||||
U(Petaliter, 1e+12,
|
||||
i18nc("volume unit symbol", "Pl"),
|
||||
i18nc("unit description in lists", "petaliters"),
|
||||
i18nc("unit synonyms for matching user input", "petaliter;petaliters;Pl"),
|
||||
ki18nc("amount in units (real)", "%1 petaliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 petaliter", "%1 petaliters")
|
||||
);
|
||||
U(Teraliter, 1e+09,
|
||||
i18nc("volume unit symbol", "Tl"),
|
||||
i18nc("unit description in lists", "teraliters"),
|
||||
i18nc("unit synonyms for matching user input", "teraliter;teraliters;Tl"),
|
||||
ki18nc("amount in units (real)", "%1 teraliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 teraliter", "%1 teraliters")
|
||||
);
|
||||
U(Gigaliter, 1e+06,
|
||||
i18nc("volume unit symbol", "Gl"),
|
||||
i18nc("unit description in lists", "gigaliters"),
|
||||
i18nc("unit synonyms for matching user input", "gigaliter;gigaliters;Gl"),
|
||||
ki18nc("amount in units (real)", "%1 gigaliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigaliter", "%1 gigaliters")
|
||||
);
|
||||
U(Megaliter, 1000,
|
||||
i18nc("volume unit symbol", "Ml"),
|
||||
i18nc("unit description in lists", "megaliters"),
|
||||
i18nc("unit synonyms for matching user input", "megaliter;megaliters;Ml"),
|
||||
ki18nc("amount in units (real)", "%1 megaliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 megaliter", "%1 megaliters")
|
||||
);
|
||||
setDefaultUnit(UP(Kiloliter, 1,
|
||||
i18nc("volume unit symbol", "kl"),
|
||||
i18nc("unit description in lists", "kiloliters"),
|
||||
i18nc("unit synonyms for matching user input", "kiloliter;kiloliters;kl"),
|
||||
ki18nc("amount in units (real)", "%1 kiloliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 kiloliter", "%1 kiloliters")
|
||||
));
|
||||
U(Hectoliter, 0.1,
|
||||
i18nc("volume unit symbol", "hl"),
|
||||
i18nc("unit description in lists", "hectoliters"),
|
||||
i18nc("unit synonyms for matching user input", "hectoliter;hectoliters;hl"),
|
||||
ki18nc("amount in units (real)", "%1 hectoliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectoliter", "%1 hectoliters")
|
||||
);
|
||||
U(Decaliter, 0.01,
|
||||
i18nc("volume unit symbol", "dal"),
|
||||
i18nc("unit description in lists", "decaliters"),
|
||||
i18nc("unit synonyms for matching user input", "decaliter;decaliters;dal"),
|
||||
ki18nc("amount in units (real)", "%1 decaliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 decaliter", "%1 decaliters")
|
||||
);
|
||||
U(Liter, 0.001,
|
||||
i18nc("volume unit symbol", "l"),
|
||||
i18nc("unit description in lists", "liters"),
|
||||
i18nc("unit synonyms for matching user input", "liter;liters;l"),
|
||||
ki18nc("amount in units (real)", "%1 liters"),
|
||||
ki18ncp("amount in units (integer)", "%1 liter", "%1 liters")
|
||||
);
|
||||
U(Deciliter, 0.0001,
|
||||
i18nc("volume unit symbol", "dl"),
|
||||
i18nc("unit description in lists", "deciliters"),
|
||||
i18nc("unit synonyms for matching user input", "deciliter;deciliters;dl"),
|
||||
ki18nc("amount in units (real)", "%1 deciliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 deciliter", "%1 deciliters")
|
||||
);
|
||||
U(Centiliter, 1e-05,
|
||||
i18nc("volume unit symbol", "cl"),
|
||||
i18nc("unit description in lists", "centiliters"),
|
||||
i18nc("unit synonyms for matching user input", "centiliter;centiliters;cl"),
|
||||
ki18nc("amount in units (real)", "%1 centiliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 centiliter", "%1 centiliters")
|
||||
);
|
||||
U(Milliliter, 1e-06,
|
||||
i18nc("volume unit symbol", "ml"),
|
||||
i18nc("unit description in lists", "milliliters"),
|
||||
i18nc("unit synonyms for matching user input", "milliliter;milliliters;ml"),
|
||||
ki18nc("amount in units (real)", "%1 milliliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 milliliter", "%1 milliliters")
|
||||
);
|
||||
U(Microliter, 1e-09,
|
||||
i18nc("volume unit symbol", "µl"),
|
||||
i18nc("unit description in lists", "microliters"),
|
||||
i18nc("unit synonyms for matching user input", "microliter;microliters;µl;ul"),
|
||||
ki18nc("amount in units (real)", "%1 microliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 microliter", "%1 microliters")
|
||||
);
|
||||
U(Nanoliter, 1e-12,
|
||||
i18nc("volume unit symbol", "nl"),
|
||||
i18nc("unit description in lists", "nanoliters"),
|
||||
i18nc("unit synonyms for matching user input", "nanoliter;nanoliters;nl"),
|
||||
ki18nc("amount in units (real)", "%1 nanoliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanoliter", "%1 nanoliters")
|
||||
);
|
||||
U(Picoliter, 1e-15,
|
||||
i18nc("volume unit symbol", "pl"),
|
||||
i18nc("unit description in lists", "picoliters"),
|
||||
i18nc("unit synonyms for matching user input", "picoliter;picoliters;pl"),
|
||||
ki18nc("amount in units (real)", "%1 picoliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 picoliter", "%1 picoliters")
|
||||
);
|
||||
U(Femtoliter, 1e-18,
|
||||
i18nc("volume unit symbol", "fl"),
|
||||
i18nc("unit description in lists", "femtoliters"),
|
||||
i18nc("unit synonyms for matching user input", "femtoliter;femtoliters;fl"),
|
||||
ki18nc("amount in units (real)", "%1 femtoliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtoliter", "%1 femtoliters")
|
||||
);
|
||||
U(Attoliter, 1e-21,
|
||||
i18nc("volume unit symbol", "al"),
|
||||
i18nc("unit description in lists", "attoliters"),
|
||||
i18nc("unit synonyms for matching user input", "attoliter;attoliters;al"),
|
||||
ki18nc("amount in units (real)", "%1 attoliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 attoliter", "%1 attoliters")
|
||||
);
|
||||
U(Zeptoliter, 1e-24,
|
||||
i18nc("volume unit symbol", "zl"),
|
||||
i18nc("unit description in lists", "zeptoliters"),
|
||||
i18nc("unit synonyms for matching user input", "zeptoliter;zeptoliters;zl"),
|
||||
ki18nc("amount in units (real)", "%1 zeptoliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptoliter", "%1 zeptoliters")
|
||||
);
|
||||
U(Yoctoliter, 1e-27,
|
||||
i18nc("volume unit symbol", "yl"),
|
||||
i18nc("unit description in lists", "yoctoliters"),
|
||||
i18nc("unit synonyms for matching user input", "yoctoliter;yoctoliters;yl"),
|
||||
ki18nc("amount in units (real)", "%1 yoctoliters"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctoliter", "%1 yoctoliters")
|
||||
);
|
||||
U(CubicFoot, 0.0283168,
|
||||
i18nc("volume unit symbol", "ft³"),
|
||||
i18nc("unit description in lists", "cubic feet"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic foot;cubic feet;ft³;cubic ft;cu foot;cu ft;cu feet;feet³"),
|
||||
ki18nc("amount in units (real)", "%1 cubic feet"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic foot", "%1 cubic feet")
|
||||
);
|
||||
U(CubicInch, 1.63871e-05,
|
||||
i18nc("volume unit symbol", "in³"),
|
||||
i18nc("unit description in lists", "cubic inches"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic inch;cubic inches;in³;cubic inch;cubic in;cu inches;cu inch;cu in;inch³"),
|
||||
ki18nc("amount in units (real)", "%1 cubic inches"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic inch", "%1 cubic inches")
|
||||
);
|
||||
U(CubicMile, 4.16818e+09,
|
||||
i18nc("volume unit symbol", "mi³"),
|
||||
i18nc("unit description in lists", "cubic miles"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"cubic mile;cubic miles;mi³;cubic mile;cubic mi;cu miles;cu mile;cu mi;mile³"),
|
||||
ki18nc("amount in units (real)", "%1 cubic miles"),
|
||||
ki18ncp("amount in units (integer)", "%1 cubic mile", "%1 cubic miles")
|
||||
);
|
||||
U(FluidOunce, 2.95735e-05,
|
||||
i18nc("volume unit symbol", "fl.oz."),
|
||||
i18nc("unit description in lists", "fluid ounces"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"fluid ounce;fluid ounces;fl.oz.;oz.fl.;oz. fl.;fl. oz.;fl oz;fluid ounce"),
|
||||
ki18nc("amount in units (real)", "%1 fluid ounces"),
|
||||
ki18ncp("amount in units (integer)", "%1 fluid ounce", "%1 fluid ounces")
|
||||
);
|
||||
U(Cup, 0.000236588,
|
||||
i18nc("volume unit symbol", "cp"),
|
||||
i18nc("unit description in lists", "cups"),
|
||||
i18nc("unit synonyms for matching user input", "cup;cups;cp"),
|
||||
ki18nc("amount in units (real)", "%1 cups"),
|
||||
ki18ncp("amount in units (integer)", "%1 cup", "%1 cups")
|
||||
);
|
||||
U(GallonUS, 0.00378541,
|
||||
i18nc("volume unit symbol", "gal"),
|
||||
i18nc("unit description in lists", "gallons (U.S. liquid)"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"gallon (U.S. liquid);gallons (U.S. liquid);gal;gallon;gallons"),
|
||||
ki18nc("amount in units (real)", "%1 gallons (U.S. liquid)"),
|
||||
ki18ncp("amount in units (integer)", "%1 gallon (U.S. liquid)", "%1 gallons (U.S. liquid)")
|
||||
);
|
||||
U(PintImperial, 0.000568261,
|
||||
i18nc("volume unit symbol", "pt"),
|
||||
i18nc("unit description in lists", "pints (imperial)"),
|
||||
i18nc("unit synonyms for matching user input",
|
||||
"pint (imperial);pints (imperial);pt;pint;pints;p"),
|
||||
ki18nc("amount in units (real)", "%1 pints (imperial)"),
|
||||
ki18ncp("amount in units (integer)", "%1 pint (imperial)", "%1 pints (imperial)")
|
||||
);
|
||||
|
||||
setMostCommonUnits(QList<int>() <<
|
||||
Deciliter << Liter << GallonUS << FluidOunce << CubicMeter << Cup << PintImperial);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef VOLUME_H
|
||||
#define VOLUME_H
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
class Volume : public KUnitConversion::UnitCategory
|
||||
{
|
||||
public:
|
||||
Volume();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue