Import Upstream version 5.92.0
This commit is contained in:
commit
227c62979d
|
@ -0,0 +1,2 @@
|
|||
#clang-tidy
|
||||
171e615a7383c8c7a1035ac4d89db198297a4f13
|
|
@ -0,0 +1,28 @@
|
|||
# Ignore the following files
|
||||
*~
|
||||
*.[oa]
|
||||
*.diff
|
||||
*.kate-swp
|
||||
*.kdev4
|
||||
.kdev_include_paths
|
||||
*.kdevelop.pcs
|
||||
*.moc
|
||||
*.moc.cpp
|
||||
*.orig
|
||||
*.user
|
||||
.*.swp
|
||||
.swp.*
|
||||
Doxyfile
|
||||
Makefile
|
||||
avail
|
||||
random_seed
|
||||
/build*/
|
||||
CMakeLists.txt.user*
|
||||
*.unc-backup*
|
||||
.cmake/
|
||||
/.clang-format
|
||||
/compile_commands.json
|
||||
.clangd
|
||||
.idea
|
||||
/cmake-build*
|
||||
.cache
|
|
@ -0,0 +1,9 @@
|
|||
# SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
include:
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/android-qt6.yml
|
|
@ -0,0 +1,9 @@
|
|||
Dependencies:
|
||||
- 'on': ['@all']
|
||||
'require':
|
||||
'frameworks/extra-cmake-modules': '@same'
|
||||
'frameworks/ki18n' : '@same'
|
||||
'frameworks/kconfig' : '@same'
|
||||
|
||||
Options:
|
||||
test-before-installing: True
|
|
@ -0,0 +1,76 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(KF_VERSION "5.92.0") # handled by release scripts
|
||||
set(KF_DEP_VERSION "5.92.0") # handled by release scripts
|
||||
project(KUnitConversion VERSION ${KF_VERSION})
|
||||
|
||||
include(FeatureSummary)
|
||||
find_package(ECM 5.92.0 NO_MODULE)
|
||||
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
||||
|
||||
include(KDEInstallDirs)
|
||||
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
|
||||
include(KDECMakeSettings)
|
||||
include(ECMGenerateExportHeader)
|
||||
include(ECMSetupVersion)
|
||||
include(ECMGenerateHeaders)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
|
||||
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
||||
|
||||
set(REQUIRED_QT_VERSION 5.15.2)
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Network)
|
||||
|
||||
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5UnitConversion")
|
||||
|
||||
ecm_setup_version(PROJECT VARIABLE_PREFIX KUNITCONVERSION
|
||||
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kunitconversion_version.h"
|
||||
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5UnitConversionConfigVersion.cmake"
|
||||
SOVERSION 5)
|
||||
|
||||
# QCH
|
||||
include(ECMAddQch)
|
||||
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF)
|
||||
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")
|
||||
if (BUILD_QCH)
|
||||
ecm_install_qch_export(
|
||||
TARGETS KF5UnitConversion_QCH
|
||||
FILE KF5UnitConversionQchTargets.cmake
|
||||
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5UnitConversionQchTargets.cmake\")")
|
||||
endif()
|
||||
|
||||
# I18n
|
||||
find_package(KF5I18n ${KF_DEP_VERSION} REQUIRED)
|
||||
add_definitions(-DTRANSLATION_DOMAIN=\"kunitconversion5\")
|
||||
ki18n_install(po)
|
||||
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f02)
|
||||
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055900)
|
||||
|
||||
add_subdirectory(src)
|
||||
if (BUILD_TESTING)
|
||||
add_subdirectory(autotests)
|
||||
endif()
|
||||
# create a Config.cmake and a ConfigVersion.cmake file and install them
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/KF5UnitConversionConfig.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/KF5UnitConversionConfig.cmake"
|
||||
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
)
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/KF5UnitConversionConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/KF5UnitConversionConfigVersion.cmake"
|
||||
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
install(EXPORT KF5UnitConversionTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5UnitConversionTargets.cmake NAMESPACE KF5:: )
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/kunitconversion_version.h
|
||||
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KUnitConversion COMPONENT Devel
|
||||
)
|
||||
|
||||
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
|
@ -0,0 +1,8 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(Qt@QT_MAJOR_VERSION@Core @REQUIRED_QT_VERSION@)
|
||||
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/KF5UnitConversionTargets.cmake")
|
||||
@PACKAGE_INCLUDE_QCHTARGETS@
|
|
@ -0,0 +1,121 @@
|
|||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
|
@ -0,0 +1,446 @@
|
|||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is numbered 2 because
|
||||
it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share
|
||||
and change it. By contrast, the GNU General Public Licenses are intended to
|
||||
guarantee your freedom to share and change free software--to make sure the
|
||||
software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some specially
|
||||
designated Free Software Foundation software, and to any other libraries whose
|
||||
authors decide to use it. You can use it for your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for this service if you
|
||||
wish), that you receive source code or can get it if you want it, that you
|
||||
can change the software or use pieces of it in new free programs; and that
|
||||
you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to
|
||||
deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of
|
||||
the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis or for
|
||||
a fee, you must give the recipients all the rights that we gave you. You must
|
||||
make sure that they, too, receive or can get the source code. If you link
|
||||
a program with the library, you must provide complete object files to the
|
||||
recipients so that they can relink them with the library, after making changes
|
||||
to the library and recompiling it. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright the library,
|
||||
and (2) offer you this license which gives you legal permission to copy, distribute
|
||||
and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain that everyone
|
||||
understands that there is no warranty for this free library. If the library
|
||||
is modified by someone else and passed on, we want its recipients to know
|
||||
that what they have is not the original version, so that any problems introduced
|
||||
by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We
|
||||
wish to avoid the danger that companies distributing free software will individually
|
||||
obtain patent licenses, thus in effect transforming the program into proprietary
|
||||
software. To prevent this, we have made it clear that any patent must be licensed
|
||||
for everyone's free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary GNU
|
||||
General Public License, which was designed for utility programs. This license,
|
||||
the GNU Library General Public License, applies to certain designated libraries.
|
||||
This license is quite different from the ordinary one; be sure to read it
|
||||
in full, and don't assume that anything in it is the same as in the ordinary
|
||||
license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that they
|
||||
blur the distinction we usually make between modifying or adding to a program
|
||||
and simply using it. Linking a program with a library, without changing the
|
||||
library, is in some sense simply using the library, and is analogous to running
|
||||
a utility program or application program. However, in a textual and legal
|
||||
sense, the linked executable is a combined work, a derivative of the original
|
||||
library, and the ordinary General Public License treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General Public License
|
||||
for libraries did not effectively promote software sharing, because most developers
|
||||
did not use the libraries. We concluded that weaker conditions might promote
|
||||
sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the users
|
||||
of those programs of all benefit from the free status of the libraries themselves.
|
||||
This Library General Public License is intended to permit developers of non-free
|
||||
programs to use free libraries, while preserving your freedom as a user of
|
||||
such programs to change the free libraries that are incorporated in them.
|
||||
(We have not seen how to achieve this as regards changes in header files,
|
||||
but we have achieved it as regards changes in the actual functions of the
|
||||
Library.) The hope is that this will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow. Pay close attention to the difference between a "work based on the
|
||||
library" and a "work that uses the library". The former contains code derived
|
||||
from the library, while the latter only works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary General
|
||||
Public License rather than by this special one.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which contains a
|
||||
notice placed by the copyright holder or other authorized party saying it
|
||||
may be distributed under the terms of this Library General Public License
|
||||
(also called "this License"). Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data prepared
|
||||
so as to be conveniently linked with application programs (which use some
|
||||
of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work which has
|
||||
been distributed under these terms. A "work based on the Library" means either
|
||||
the Library or any derivative work under copyright law: that is to say, a
|
||||
work containing the Library or a portion of it, either verbatim or with modifications
|
||||
and/or translated straightforwardly into another language. (Hereinafter, translation
|
||||
is included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for making modifications
|
||||
to it. For a library, complete source code means all the source code for all
|
||||
modules it contains, plus any associated interface definition files, plus
|
||||
the scripts used to control compilation and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running a program
|
||||
using the Library is not restricted, and output from such a program is covered
|
||||
only if its contents constitute a work based on the Library (independent of
|
||||
the use of the Library in a tool for writing it). Whether that is true depends
|
||||
on what the Library does and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's complete source
|
||||
code as you receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice and disclaimer
|
||||
of warranty; keep intact all the notices that refer to this License and to
|
||||
the absence of any warranty; and distribute a copy of this License along with
|
||||
the Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion of it,
|
||||
thus forming a work based on the Library, and copy and distribute such modifications
|
||||
or work under the terms of Section 1 above, provided that you also meet all
|
||||
of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no charge to all
|
||||
third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a table of
|
||||
data to be supplied by an application program that uses the facility, other
|
||||
than as an argument passed when the facility is invoked, then you must make
|
||||
a good faith effort to ensure that, in the event an application does not supply
|
||||
such function or table, the facility still operates, and performs whatever
|
||||
part of its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has a purpose
|
||||
that is entirely well-defined independent of the application. Therefore, Subsection
|
||||
2d requires that any application-supplied function or table used by this function
|
||||
must be optional: if the application does not supply it, the square root function
|
||||
must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Library, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them as
|
||||
separate works. But when you distribute the same sections as part of a whole
|
||||
which is a work based on the Library, the distribution of the whole must be
|
||||
on the terms of this License, whose permissions for other licensees extend
|
||||
to the entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your
|
||||
rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works based
|
||||
on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library with
|
||||
the Library (or with a work based on the Library) on a volume of a storage
|
||||
or distribution medium does not bring the other work under the scope of this
|
||||
License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public License
|
||||
instead of this License to a given copy of the Library. To do this, you must
|
||||
alter all the notices that refer to this License, so that they refer to the
|
||||
ordinary GNU General Public License, version 2, instead of to this License.
|
||||
(If a newer version than version 2 of the ordinary GNU General Public License
|
||||
has appeared, then you can specify that version instead if you wish.) Do not
|
||||
make any other change in these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for that copy,
|
||||
so the ordinary GNU General Public License applies to all subsequent copies
|
||||
and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of the Library
|
||||
into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or derivative of
|
||||
it, under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you accompany it with the complete corresponding
|
||||
machine-readable source code, which must be distributed under the terms of
|
||||
Sections 1 and 2 above on a medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy from a designated
|
||||
place, then offering equivalent access to copy the source code from the same
|
||||
place satisfies the requirement to distribute the source code, even though
|
||||
third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the Library, but
|
||||
is designed to work with the Library by being compiled or linked with it,
|
||||
is called a "work that uses the Library". Such a work, in isolation, is not
|
||||
a derivative work of the Library, and therefore falls outside the scope of
|
||||
this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library creates an
|
||||
executable that is a derivative of the Library (because it contains portions
|
||||
of the Library), rather than a "work that uses the library". The executable
|
||||
is therefore covered by this License. Section 6 states terms for distribution
|
||||
of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file that
|
||||
is part of the Library, the object code for the work may be a derivative work
|
||||
of the Library even though the source code is not. Whether this is true is
|
||||
especially significant if the work can be linked without the Library, or if
|
||||
the work is itself a library. The threshold for this to be true is not precisely
|
||||
defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data structure layouts
|
||||
and accessors, and small macros and small inline functions (ten lines or less
|
||||
in length), then the use of the object file is unrestricted, regardless of
|
||||
whether it is legally a derivative work. (Executables containing this object
|
||||
code plus portions of the Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may distribute
|
||||
the object code for the work under the terms of Section 6. Any executables
|
||||
containing that work also fall under Section 6, whether or not they are linked
|
||||
directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or link a "work
|
||||
that uses the Library" with the Library to produce a work containing portions
|
||||
of the Library, and distribute that work under terms of your choice, provided
|
||||
that the terms permit modification of the work for the customer's own use
|
||||
and reverse engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the Library
|
||||
is used in it and that the Library and its use are covered by this License.
|
||||
You must supply a copy of this License. If the work during execution displays
|
||||
copyright notices, you must include the copyright notice for the Library among
|
||||
them, as well as a reference directing the user to the copy of this License.
|
||||
Also, you must do one of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding machine-readable source
|
||||
code for the Library including whatever changes were used in the work (which
|
||||
must be distributed under Sections 1 and 2 above); and, if the work is an
|
||||
executable linked with the Library, with the complete machine-readable "work
|
||||
that uses the Library", as object code and/or source code, so that the user
|
||||
can modify the Library and then relink to produce a modified executable containing
|
||||
the modified Library. (It is understood that the user who changes the contents
|
||||
of definitions files in the Library will not necessarily be able to recompile
|
||||
the application to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at least three years,
|
||||
to give the same user the materials specified in Subsection 6a, above, for
|
||||
a charge no more than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy from a designated
|
||||
place, offer equivalent access to copy the above specified materials from
|
||||
the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these materials or
|
||||
that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the Library" must
|
||||
include any data and utility programs needed for reproducing the executable
|
||||
from it. However, as a special exception, the source code distributed need
|
||||
not include anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the operating
|
||||
system on which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license restrictions of
|
||||
other proprietary libraries that do not normally accompany the operating system.
|
||||
Such a contradiction means you cannot use both them and the Library together
|
||||
in an executable that you distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the Library side-by-side
|
||||
in a single library together with other library facilities not covered by
|
||||
this License, and distribute such a combined library, provided that the separate
|
||||
distribution of the work based on the Library and of the other library facilities
|
||||
is otherwise permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the
|
||||
Library, uncombined with any other library facilities. This must be distributed
|
||||
under the terms of the Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact that part of
|
||||
it is a work based on the Library, and explaining where to find the accompanying
|
||||
uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute the Library
|
||||
except as expressly provided under this License. Any attempt otherwise to
|
||||
copy, modify, sublicense, link with, or distribute the Library is void, and
|
||||
will automatically terminate your rights under this License. However, parties
|
||||
who have received copies, or rights, from you under this License will not
|
||||
have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not signed
|
||||
it. However, nothing else grants you permission to modify or distribute the
|
||||
Library or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the Library
|
||||
(or any work based on the Library), you indicate your acceptance of this License
|
||||
to do so, and all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the Library),
|
||||
the recipient automatically receives a license from the original licensor
|
||||
to copy, distribute, link with or modify the Library subject to these terms
|
||||
and conditions. You may not impose any further restrictions on the recipients'
|
||||
exercise of the rights granted herein. You are not responsible for enforcing
|
||||
compliance by third parties to this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent infringement
|
||||
or for any other reason (not limited to patent issues), conditions are imposed
|
||||
on you (whether by court order, agreement or otherwise) that contradict the
|
||||
conditions of this License, they do not excuse you from the conditions of
|
||||
this License. If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations, then as
|
||||
a consequence you may not distribute the Library at all. For example, if a
|
||||
patent license would not permit royalty-free redistribution of the Library
|
||||
by all those who receive copies directly or indirectly through you, then the
|
||||
only way you could satisfy both it and this License would be to refrain entirely
|
||||
from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents
|
||||
or other property right claims or to contest validity of any such claims;
|
||||
this section has the sole purpose of protecting the integrity of the free
|
||||
software distribution system which is implemented by public license practices.
|
||||
Many people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Library under this License may add an explicit geographical
|
||||
distribution limitation excluding those countries, so that distribution is
|
||||
permitted only in or among countries not thus excluded. In such case, this
|
||||
License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new versions of
|
||||
the Library General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to address
|
||||
new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that version
|
||||
or of any later version published by the Free Software Foundation. If the
|
||||
Library does not specify a license version number, you may choose any version
|
||||
ever published by the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free programs
|
||||
whose distribution conditions are incompatible with these, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free Software
|
||||
Foundation, write to the Free Software Foundation; we sometimes make exceptions
|
||||
for this. Our decision will be guided by the two goals of preserving the free
|
||||
status of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
|
||||
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
|
||||
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
|
||||
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
|
||||
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
|
||||
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest possible
|
||||
use to the public, we recommend making it free software that everyone can
|
||||
redistribute and change. You can do so by permitting redistribution under
|
||||
these terms (or, alternatively, under the terms of the ordinary General Public
|
||||
License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is safest
|
||||
to attach them to the start of each source file to most effectively convey
|
||||
the exclusion of warranty; and each file should have at least the "copyright"
|
||||
line and a pointer to where the full notice is found.
|
||||
|
||||
one line to give the library's name and an idea of what it does.
|
||||
|
||||
Copyright (C) year name of author
|
||||
|
||||
This library 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 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
This library 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 Library General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school,
|
||||
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
|
||||
is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in
|
||||
|
||||
the library `Frob' (a library for tweaking knobs) written
|
||||
|
||||
by James Random Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1990
|
||||
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
|
@ -0,0 +1,45 @@
|
|||
# KUnitConversion
|
||||
|
||||
Converting physical units
|
||||
|
||||
## Introduction
|
||||
|
||||
KUnitConversion provides functions to convert values in different physical
|
||||
units. It supports converting different prefixes (e.g. kilo, mega, giga) as
|
||||
well as converting between different unit systems (e.g. liters, gallons). The
|
||||
following areas are supported:
|
||||
|
||||
* Acceleration
|
||||
* Angle
|
||||
* Area
|
||||
* Binary Data
|
||||
* Currency
|
||||
* Density
|
||||
* Electrical Current
|
||||
* Electrical Resistance
|
||||
* Energy
|
||||
* Force
|
||||
* Frequency
|
||||
* Fuel Efficiency
|
||||
* Length
|
||||
* Mass
|
||||
* Permeability
|
||||
* Power
|
||||
* Pressure
|
||||
* Temperature
|
||||
* Thermal Conductivity
|
||||
* Thermal Flux
|
||||
* Thermal Generation
|
||||
* Time
|
||||
* Velocity
|
||||
* Volume
|
||||
* Voltage
|
||||
|
||||
## Usage
|
||||
|
||||
To convert 100 GBP into EUR, you can write:
|
||||
|
||||
using namespace KUnitConversion;
|
||||
Value pounds(100, Gbp);
|
||||
Value eur = pounds.convertTo(Eur);
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
include(ECMAddTests)
|
||||
|
||||
find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test)
|
||||
|
||||
ecm_add_tests(
|
||||
valuetest.cpp
|
||||
categorytest.cpp
|
||||
convertertest.cpp
|
||||
LINK_LIBRARIES KF5::UnitConversion KF5::I18n Qt${QT_MAJOR_VERSION}::Test
|
||||
)
|
||||
|
||||
qt_add_resources(CURRENCY_TEST_RESOURCES currencytableinittest/data.qrc)
|
||||
ecm_add_test(
|
||||
currencytableinittest.cpp
|
||||
${CURRENCY_TEST_RESOURCES}
|
||||
TEST_NAME currencytableinittest
|
||||
LINK_LIBRARIES KF5::UnitConversion KF5::I18n Qt${QT_MAJOR_VERSION}::Test
|
||||
)
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "categorytest.h"
|
||||
#include <QStandardPaths>
|
||||
#include <chrono>
|
||||
#include <currency_p.h>
|
||||
#include <kunitconversion/unitcategory.h>
|
||||
#include <unitcategory_p.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
void CategoryTest::initTestCase()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
}
|
||||
|
||||
void CategoryTest::testInfo()
|
||||
{
|
||||
UnitCategory cg = c.category(AreaCategory);
|
||||
QCOMPARE(cg.name(), QStringLiteral("Area"));
|
||||
QCOMPARE(cg.description(), QStringLiteral("Area"));
|
||||
QCOMPARE(cg.id(), AreaCategory);
|
||||
}
|
||||
|
||||
void CategoryTest::testUnits()
|
||||
{
|
||||
UnitCategory cg = c.category(MassCategory);
|
||||
QCOMPARE(cg.defaultUnit().symbol(), QStringLiteral("kg"));
|
||||
QCOMPARE(cg.hasUnit(QStringLiteral("g")), true);
|
||||
QCOMPARE(cg.unit(QStringLiteral("g")).symbol(), QStringLiteral("g"));
|
||||
QCOMPARE(cg.unit(Kilogram).symbol(), QStringLiteral("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), QStringLiteral("m"));
|
||||
QCOMPARE(v.number(), 3140.0);
|
||||
v = cg.convert(v, QStringLiteral("cm"));
|
||||
QCOMPARE(v.number(), 314000.0);
|
||||
v = cg.convert(v, cg.defaultUnit());
|
||||
QCOMPARE(v.number(), 3140.0);
|
||||
}
|
||||
|
||||
void CategoryTest::testInvalid()
|
||||
{
|
||||
UnitCategory cg = c.category(CategoryId(99999));
|
||||
QCOMPARE(cg.name(), QString());
|
||||
cg = c.category(QStringLiteral("don't exist"));
|
||||
QCOMPARE(cg.name(), QString());
|
||||
}
|
||||
|
||||
void CategoryTest::testCurrencyTableUpdate()
|
||||
{
|
||||
// Remove currency cache to force a download
|
||||
const QString cache = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/libkunitconversion/currency.xml");
|
||||
QFile::remove(cache);
|
||||
QVERIFY(Currency::lastConversionTableUpdate().isNull());
|
||||
|
||||
UnitCategory category = c.category(CurrencyCategory);
|
||||
QCOMPARE(category.hasOnlineConversionTable(), true);
|
||||
{
|
||||
category.syncConversionTable(std::chrono::seconds::zero()); // no skip period = force update
|
||||
QVERIFY(!Currency::lastConversionTableUpdate().isNull());
|
||||
QDateTime lastUpdate = Currency::lastConversionTableUpdate();
|
||||
QVERIFY(lastUpdate.secsTo(QDateTime::currentDateTime()) < std::chrono::seconds(1h).count());
|
||||
|
||||
category.syncConversionTable(1h);
|
||||
QVERIFY(!Currency::lastConversionTableUpdate().isNull());
|
||||
QDateTime newUpdate = Currency::lastConversionTableUpdate();
|
||||
QCOMPARE(newUpdate, lastUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(CategoryTest)
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef CATEGORYTEST_H
|
||||
#define CATEGORYTEST_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
#include <kunitconversion/converter.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class CategoryTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testInfo();
|
||||
void testUnits();
|
||||
void testConvert();
|
||||
void testInvalid();
|
||||
void testCurrencyTableUpdate();
|
||||
|
||||
private:
|
||||
Converter c;
|
||||
};
|
||||
|
||||
#endif // CATEGORYTEST_H
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "convertertest.h"
|
||||
#include <QStandardPaths>
|
||||
#include <QThread>
|
||||
#include <QVector>
|
||||
#include <currency_p.h>
|
||||
#include <kunitconversion/unitcategory.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
void ConverterTest::initTestCase()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
|
||||
// Remove currency cache to force a download
|
||||
const QString cache = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/libkunitconversion/currency.xml");
|
||||
QFile::remove(cache);
|
||||
}
|
||||
|
||||
void ConverterTest::testCategory()
|
||||
{
|
||||
Converter c;
|
||||
QCOMPARE(c.categoryForUnit(QStringLiteral("km")).id(), LengthCategory);
|
||||
QCOMPARE(c.category(QStringLiteral("Length")).id(), LengthCategory);
|
||||
QCOMPARE(c.category(LengthCategory).name(), QStringLiteral("Length"));
|
||||
QVERIFY(c.categories().size() > 0);
|
||||
}
|
||||
|
||||
void ConverterTest::testUnits()
|
||||
{
|
||||
Converter c;
|
||||
QCOMPARE(c.unit(QStringLiteral("km")).symbol(), QStringLiteral("km"));
|
||||
QCOMPARE(c.unit(Kilogram).symbol(), QStringLiteral("kg"));
|
||||
}
|
||||
|
||||
void ConverterTest::testConvert()
|
||||
{
|
||||
Converter c;
|
||||
Value v = c.convert(Value(3.14, Kilometer), QStringLiteral("m"));
|
||||
QCOMPARE(v.number(), 3140.0);
|
||||
v = c.convert(v, QStringLiteral("cm"));
|
||||
QCOMPARE(v.number(), 314000.0);
|
||||
v = c.convert(v, c.category(LengthCategory).defaultUnit());
|
||||
QCOMPARE(v.number(), 3140.0);
|
||||
|
||||
v = Value(8.0, LitersPer100Kilometers);
|
||||
v = c.convert(v, QStringLiteral("mpg"));
|
||||
QCOMPARE(v.number(), 29.401875);
|
||||
v = c.convert(v, QStringLiteral("mpg (imperial)"));
|
||||
QCOMPARE(v.number(), 35.310125);
|
||||
v = c.convert(v, QStringLiteral("kmpl"));
|
||||
QCOMPARE(v.number(), 12.5);
|
||||
v = c.convert(v, QStringLiteral("l/100 km"));
|
||||
QCOMPARE(v.number(), 8.0);
|
||||
|
||||
v = Value(33.0, MilePerUsGallon);
|
||||
v = c.convert(v, QStringLiteral("mpg (imperial)"));
|
||||
QCOMPARE(v.number(), 39.63128627);
|
||||
v = c.convert(v, QStringLiteral("kmpl"));
|
||||
QCOMPARE(v.number(), 14.0297174925);
|
||||
v = c.convert(v, QStringLiteral("l/100 km"));
|
||||
QCOMPARE(v.number(), 7.12772727273);
|
||||
v = c.convert(v, QStringLiteral("mpg"));
|
||||
QCOMPARE(v.number(), 33.0);
|
||||
}
|
||||
|
||||
void ConverterTest::testInvalid()
|
||||
{
|
||||
Converter c;
|
||||
QCOMPARE(c.categoryForUnit(QStringLiteral("does not exist")).id(), InvalidCategory);
|
||||
QCOMPARE(c.unit(QStringLiteral("does not exist")).symbol(), QString());
|
||||
QCOMPARE(c.category(QStringLiteral("does not exist")).name(), QString());
|
||||
}
|
||||
|
||||
class CurrencyTestThread : public QThread
|
||||
{
|
||||
public:
|
||||
CurrencyTestThread(Converter &c)
|
||||
: m_c(c)
|
||||
{
|
||||
}
|
||||
void run() override
|
||||
{
|
||||
Value input = Value(1000, Eur);
|
||||
Value v = m_c.convert(input, QStringLiteral("$"));
|
||||
number = v.number();
|
||||
}
|
||||
int number;
|
||||
Converter &m_c;
|
||||
};
|
||||
|
||||
void ConverterTest::testCurrency()
|
||||
{
|
||||
Converter c;
|
||||
// 2 threads is enough for tsan to notice races, let's not hammer the website with more concurrent requests
|
||||
const int numThreads = 2;
|
||||
QVector<CurrencyTestThread *> threads;
|
||||
threads.resize(numThreads);
|
||||
for (int i = 0; i < numThreads; ++i) {
|
||||
threads[i] = new CurrencyTestThread(c);
|
||||
}
|
||||
for (int i = 0; i < numThreads; ++i) {
|
||||
threads[i]->start();
|
||||
}
|
||||
for (int i = 0; i < numThreads; ++i) {
|
||||
threads[i]->wait();
|
||||
QVERIFY(threads.at(i)->number > 100);
|
||||
}
|
||||
qDeleteAll(threads);
|
||||
}
|
||||
|
||||
void ConverterTest::testCurrencyConversionTableUpdate()
|
||||
{
|
||||
const QString cache = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/libkunitconversion/currency.xml");
|
||||
|
||||
// Missing conversion table must lead to update of table
|
||||
// note that this is the same code path as for last modified updates
|
||||
QFile::remove(cache);
|
||||
QVERIFY(Currency::lastConversionTableUpdate().isNull());
|
||||
Converter c;
|
||||
Value input = Value(1000, Eur);
|
||||
Value v = c.convert(input, QStringLiteral("$"));
|
||||
QVERIFY(!Currency::lastConversionTableUpdate().isNull());
|
||||
}
|
||||
|
||||
QTEST_MAIN(ConverterTest)
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef CONVERTERTEST_H
|
||||
#define CONVERTERTEST_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
#include <kunitconversion/converter.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class ConverterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testCategory();
|
||||
void testUnits();
|
||||
void testConvert();
|
||||
void testInvalid();
|
||||
void testCurrency();
|
||||
/**
|
||||
* Checks that conversion tables are updated after timeout
|
||||
*
|
||||
* Regression test for https://bugs.kde.org/show_bug.cgi?id=441337
|
||||
*/
|
||||
void testCurrencyConversionTableUpdate();
|
||||
};
|
||||
|
||||
#endif // CONVERTERTEST_H
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Andreas Cord-Landwehr <cordlandwehr@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "currencytableinittest.h"
|
||||
#include <QStandardPaths>
|
||||
#include <cmath>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
void CurrencyTableInitTest::testCategoryInit()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
const QString cache = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/libkunitconversion/currency.xml");
|
||||
|
||||
QVERIFY(QFile::exists(QLatin1String(":/currency.xml")));
|
||||
if (QFile::exists(cache)) {
|
||||
QFile::remove(cache);
|
||||
}
|
||||
// note: copy of file updates the file's modified timestamp and thus file is seen as recently downloaded file
|
||||
QVERIFY(QFile::copy(QLatin1String(":/currency.xml"), cache));
|
||||
|
||||
Converter c;
|
||||
Value input = Value(1000, Eur);
|
||||
Value v = c.convert(input, QStringLiteral("$"));
|
||||
qDebug() << "converted value to:" << v.number();
|
||||
QVERIFY(v.isValid());
|
||||
QVERIFY(!std::isnan(v.number()));
|
||||
}
|
||||
|
||||
QTEST_MAIN(CurrencyTableInitTest)
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Andreas Cord-Landwehr <cordlandwehr@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef CURRENCYTABLEINIT_TEST_H
|
||||
#define CURRENCYTABLEINIT_TEST_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
#include <kunitconversion/converter.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class CurrencyTableInitTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Check that the currency converter is correctly initialized when currency.xml is recent and available
|
||||
*/
|
||||
void testCategoryInit();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
|
||||
<gesmes:subject>Reference rates</gesmes:subject>
|
||||
<gesmes:Sender>
|
||||
<gesmes:name>European Central Bank</gesmes:name>
|
||||
</gesmes:Sender>
|
||||
<Cube>
|
||||
<Cube time='2021-08-24'>
|
||||
<Cube currency='USD' rate='1.1740'/>
|
||||
<Cube currency='JPY' rate='128.74'/>
|
||||
<Cube currency='BGN' rate='1.9558'/>
|
||||
<Cube currency='CZK' rate='25.533'/>
|
||||
<Cube currency='DKK' rate='7.4370'/>
|
||||
<Cube currency='GBP' rate='0.85578'/>
|
||||
<Cube currency='HUF' rate='349.69'/>
|
||||
<Cube currency='PLN' rate='4.5792'/>
|
||||
<Cube currency='RON' rate='4.9280'/>
|
||||
<Cube currency='SEK' rate='10.2090'/>
|
||||
<Cube currency='CHF' rate='1.0711'/>
|
||||
<Cube currency='ISK' rate='150.00'/>
|
||||
<Cube currency='NOK' rate='10.4003'/>
|
||||
<Cube currency='HRK' rate='7.4938'/>
|
||||
<Cube currency='RUB' rate='86.7484'/>
|
||||
<Cube currency='TRY' rate='9.8836'/>
|
||||
<Cube currency='AUD' rate='1.6203'/>
|
||||
<Cube currency='BRL' rate='6.2681'/>
|
||||
<Cube currency='CAD' rate='1.4822'/>
|
||||
<Cube currency='CNY' rate='7.6042'/>
|
||||
<Cube currency='HKD' rate='9.1448'/>
|
||||
<Cube currency='IDR' rate='16897.00'/>
|
||||
<Cube currency='ILS' rate='3.7789'/>
|
||||
<Cube currency='INR' rate='87.0625'/>
|
||||
<Cube currency='KRW' rate='1369.00'/>
|
||||
<Cube currency='MXN' rate='23.8606'/>
|
||||
<Cube currency='MYR' rate='4.9525'/>
|
||||
<Cube currency='NZD' rate='1.6893'/>
|
||||
<Cube currency='PHP' rate='58.783'/>
|
||||
<Cube currency='SGD' rate='1.5918'/>
|
||||
<Cube currency='THB' rate='38.595'/>
|
||||
<Cube currency='ZAR' rate='17.6902'/>
|
||||
</Cube>
|
||||
</Cube>
|
||||
</gesmes:Envelope>
|
|
@ -0,0 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>currency.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "valuetest.h"
|
||||
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
void ValueTest::initTestCase()
|
||||
{
|
||||
qputenv("KF5UNITCONVERT_NO_DOWNLOAD", "1");
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
QLocale::setDefault(QLocale::c());
|
||||
|
||||
v1 = Value(3.1415, Kilometer);
|
||||
v2 = Value(6.1415, QStringLiteral("m"));
|
||||
v3 = Value(9.1415, v1.unit());
|
||||
}
|
||||
|
||||
void ValueTest::testStrings()
|
||||
{
|
||||
QCOMPARE(v1.unit().symbol(), QStringLiteral("km"));
|
||||
QCOMPARE(v2.toSymbolString(), QStringLiteral("6.1415 m"));
|
||||
QCOMPARE(v3.toString(), QStringLiteral("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(QStringLiteral("cm"));
|
||||
QCOMPARE(v1.number(), 314000.0);
|
||||
v1 = v1.convertTo(v2.unit());
|
||||
QCOMPARE(v1.number(), 3140.0);
|
||||
}
|
||||
|
||||
void ValueTest::testInvalid()
|
||||
{
|
||||
v1 = v1.convertTo(UnitId(99999));
|
||||
QCOMPARE(v1.number(), 0.0);
|
||||
QCOMPARE(v1.toSymbolString(), QLatin1String(""));
|
||||
v2 = v2.convertTo(QStringLiteral("don't exist"));
|
||||
QCOMPARE(v2.number(), 0.0);
|
||||
QCOMPARE(v2.toSymbolString(), QLatin1String(""));
|
||||
}
|
||||
|
||||
void ValueTest::testCurrencyNotDownloaded()
|
||||
{
|
||||
// ensure that no local conversion table is available
|
||||
const QString cache = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/libkunitconversion/currency.xml");
|
||||
if (QFile::exists(cache)) {
|
||||
QFile::remove(cache);
|
||||
}
|
||||
|
||||
auto pounds = Value(100, Gbp);
|
||||
auto eur = pounds.convertTo(Eur);
|
||||
QVERIFY(!eur.isValid());
|
||||
}
|
||||
|
||||
QTEST_MAIN(ValueTest)
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef VALUE_TEST_H
|
||||
#define VALUE_TEST_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
#include <kunitconversion/converter.h>
|
||||
|
||||
using namespace KUnitConversion;
|
||||
|
||||
class ValueTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testStrings();
|
||||
void testRound();
|
||||
void testConvert();
|
||||
void testInvalid();
|
||||
void testCurrencyNotDownloaded();
|
||||
|
||||
private:
|
||||
Value v1;
|
||||
Value v2;
|
||||
Value v3;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,21 @@
|
|||
maintainer: jlayt
|
||||
description: Support for unit conversion
|
||||
tier: 2
|
||||
type: functional
|
||||
platforms:
|
||||
- name: Linux
|
||||
- name: FreeBSD
|
||||
- name: Windows
|
||||
- name: macOS
|
||||
- name: Android
|
||||
portingAid: false
|
||||
deprecated: false
|
||||
release: true
|
||||
libraries:
|
||||
- qmake: KUnitConversion
|
||||
cmake: "KF5::UnitConversion"
|
||||
cmakename: KF5UnitConversion
|
||||
|
||||
public_lib: true
|
||||
group: Frameworks
|
||||
subgroup: Tier 2
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,124 @@
|
|||
add_library(KF5UnitConversion)
|
||||
add_library(KF5::UnitConversion ALIAS KF5UnitConversion)
|
||||
|
||||
ecm_qt_declare_logging_category(KF5UnitConversion
|
||||
HEADER kunitconversion_debug.h
|
||||
IDENTIFIER LOG_KUNITCONVERSION
|
||||
CATEGORY_NAME kf.kunitconversion
|
||||
DESCRIPTION "kunitconversion"
|
||||
EXPORT KUNITCONVERSION
|
||||
)
|
||||
|
||||
target_sources(KF5UnitConversion PRIVATE
|
||||
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
|
||||
thermal_conductivity.cpp
|
||||
thermal_flux.cpp
|
||||
thermal_generation.cpp
|
||||
voltage.cpp
|
||||
electrical_current.cpp
|
||||
electrical_resistance.cpp
|
||||
permeability.cpp
|
||||
binary_data.cpp
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
# As stated in http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx M_PI only gets defined
|
||||
# when using MSVC if _USE_MATH_DEFINES is defined (this is needed for angle.cpp)
|
||||
target_compile_definitions(KF5UnitConversion PRIVATE _USE_MATH_DEFINES)
|
||||
endif()
|
||||
ecm_generate_export_header(KF5UnitConversion
|
||||
BASE_NAME KUnitConversion
|
||||
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/kunitconversion/kunitconversion_export.h
|
||||
GROUP_BASE_NAME KF
|
||||
VERSION ${KF_VERSION}
|
||||
DEPRECATED_BASE_VERSION 0
|
||||
DEPRECATION_VERSIONS 5.91
|
||||
EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT}
|
||||
)
|
||||
|
||||
set(kunitconversion_BUILD_INCLUDE_DIRS ${KUnitConversion_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(KF5UnitConversion PUBLIC "$<BUILD_INTERFACE:${kunitconversion_BUILD_INCLUDE_DIRS}>")
|
||||
target_include_directories(KF5UnitConversion INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF}/KUnitConversion>")
|
||||
|
||||
target_link_libraries(KF5UnitConversion PUBLIC Qt${QT_MAJOR_VERSION}::Core
|
||||
PRIVATE Qt${QT_MAJOR_VERSION}::Network
|
||||
KF5::I18n
|
||||
)
|
||||
|
||||
set_target_properties(KF5UnitConversion PROPERTIES VERSION ${KUNITCONVERSION_VERSION}
|
||||
SOVERSION ${KUNITCONVERSION_SOVERSION}
|
||||
EXPORT_NAME UnitConversion
|
||||
)
|
||||
|
||||
ecm_generate_headers(KUnitConversion_CamelCase_HEADERS
|
||||
HEADER_NAMES
|
||||
Converter
|
||||
Value
|
||||
Unit
|
||||
UnitCategory
|
||||
|
||||
PREFIX KUnitConversion
|
||||
REQUIRED_HEADERS KUnitConversion_HEADERS
|
||||
)
|
||||
install(FILES ${KUnitConversion_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KUnitConversion/KUnitConversion COMPONENT Devel)
|
||||
|
||||
install(TARGETS KF5UnitConversion EXPORT KF5UnitConversionTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/kunitconversion/kunitconversion_export.h
|
||||
${KUnitConversion_HEADERS}
|
||||
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KUnitConversion/kunitconversion COMPONENT Devel
|
||||
)
|
||||
|
||||
ecm_qt_install_logging_categories(
|
||||
EXPORT KUNITCONVERSION
|
||||
FILE kunitconversion.categories
|
||||
DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
|
||||
)
|
||||
|
||||
if(BUILD_QCH)
|
||||
ecm_add_qch(
|
||||
KF5UnitConversion_QCH
|
||||
NAME KUnitConversion
|
||||
BASE_NAME KF5UnitConversion
|
||||
VERSION ${KF_VERSION}
|
||||
ORG_DOMAIN org.kde
|
||||
SOURCES # using only public headers, to cover only public API
|
||||
${KUnitConversion_HEADERS}
|
||||
MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md"
|
||||
LINK_QCHS
|
||||
Qt5Core_QCH
|
||||
INCLUDE_DIRS
|
||||
${kunitconversion_BUILD_INCLUDE_DIRS}
|
||||
BLANK_MACROS
|
||||
KUNITCONVERSION_EXPORT
|
||||
KUNITCONVERSION_DEPRECATED
|
||||
KUNITCONVERSION_DEPRECATED_EXPORT
|
||||
TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR}
|
||||
QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR}
|
||||
COMPONENT Devel
|
||||
)
|
||||
endif()
|
||||
|
||||
include(ECMGeneratePriFile)
|
||||
ecm_generate_pri_file(BASE_NAME KUnitConversion LIB_NAME KF5UnitConversion DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF}/KUnitConversion)
|
||||
install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR})
|
|
@ -0,0 +1,2 @@
|
|||
#! /usr/bin/env bash
|
||||
$XGETTEXT *.cpp -o $podir/kunitconversion5.pot
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2010 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "acceleration_p.h"
|
||||
#include "unit_p.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
UnitCategory Acceleration::makeCategory()
|
||||
{
|
||||
auto c = UnitCategoryPrivate::makeCategory(AccelerationCategory, i18n("Acceleration"), i18n("Acceleration"));
|
||||
auto d = UnitCategoryPrivate::get(c);
|
||||
KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (acceleration)", "%1 %2");
|
||||
|
||||
d->addDefaultUnit(UnitPrivate::makeUnit(AccelerationCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
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")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(AccelerationCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
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")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AccelerationCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 times standard gravity"),
|
||||
ki18ncp("amount in units (integer)", "%1 standard gravity", "%1 times standard gravity")));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
} // KUnitConversion namespace
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2010 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef ACCELERATION_P_H
|
||||
#define ACCELERATION_P_H
|
||||
|
||||
#include "unitcategory_p.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
namespace Acceleration
|
||||
{
|
||||
UnitCategory makeCategory();
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2010 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "angle_p.h"
|
||||
#include "unit_p.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
class RadiansUnitPrivate : public UnitPrivate
|
||||
{
|
||||
public:
|
||||
RadiansUnitPrivate(CategoryId categoryId,
|
||||
UnitId id,
|
||||
qreal multiplier,
|
||||
const QString &symbol,
|
||||
const QString &description,
|
||||
const QString &matchString,
|
||||
const KLocalizedString &symbolString,
|
||||
const KLocalizedString &realString,
|
||||
const KLocalizedString &integerString)
|
||||
: UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
|
||||
{
|
||||
}
|
||||
|
||||
qreal toDefault(qreal value) const override
|
||||
{
|
||||
return (value / (2 * M_PI)) * 360.0;
|
||||
}
|
||||
qreal fromDefault(qreal value) const override
|
||||
{
|
||||
return (value / 360.0) * (2 * M_PI);
|
||||
}
|
||||
};
|
||||
|
||||
UnitCategory Angle::makeCategory()
|
||||
{
|
||||
auto c = UnitCategoryPrivate::makeCategory(AngleCategory, i18n("Angle"), i18n("Angle"));
|
||||
auto d = UnitCategoryPrivate::get(c);
|
||||
KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (angle)", "%1 %2");
|
||||
|
||||
d->addDefaultUnit(UnitPrivate::makeUnit(AngleCategory,
|
||||
Degree,
|
||||
1,
|
||||
i18nc("angle unit symbol", "°"),
|
||||
i18nc("unit description in lists", "degrees"),
|
||||
i18nc("unit synonyms for matching user input", "deg;degree;degrees;°"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 degrees"),
|
||||
ki18ncp("amount in units (integer)", "%1 degree", "%1 degrees")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(new RadiansUnitPrivate(AngleCategory,
|
||||
Radian,
|
||||
1.0,
|
||||
i18nc("angle unit symbol", "rad"),
|
||||
i18nc("unit description in lists", "radians"),
|
||||
i18nc("unit synonyms for matching user input", "rad;radian;radians"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 radians"),
|
||||
ki18ncp("amount in units (integer)", "%1 radian", "%1 radians"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AngleCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 gradians"),
|
||||
ki18ncp("amount in units (integer)", "%1 gradian", "%1 gradians")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(AngleCategory,
|
||||
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;'"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 arc minutes"),
|
||||
ki18ncp("amount in units (integer)", "%1 arc minute", "%1 arc minutes")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(AngleCategory,
|
||||
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;\""),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 arc seconds"),
|
||||
ki18ncp("amount in units (integer)", "%1 arc second", "%1 arc seconds")));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
} // KUnitConversion namespace
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2010 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef ANGLE_P_H
|
||||
#define ANGLE_P_H
|
||||
|
||||
#include "unitcategory_p.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
namespace Angle
|
||||
{
|
||||
UnitCategory makeCategory();
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,292 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "area_p.h"
|
||||
#include "unit_p.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
|
||||
UnitCategory Area::makeCategory()
|
||||
{
|
||||
auto c = UnitCategoryPrivate::makeCategory(AreaCategory,
|
||||
i18nc("Unit Category: two dimensional size of a surface", "Area"),
|
||||
i18nc("Unit Category: two dimensional size of a surface", "Area"));
|
||||
auto d = UnitCategoryPrivate::get(c);
|
||||
// i18n: Used when converting to symbol string e.g. 2.34 m²
|
||||
KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (area)", "%1 %2");
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
// 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")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square zettameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square zettameter", "%1 square zettameters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square exameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square exameter", "%1 square exameters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square petameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square petameter", "%1 square petameters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square terameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square terameter", "%1 square terameters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square gigameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square gigameter", "%1 square gigameters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square megameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square megameter", "%1 square megameters")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square kilometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square kilometer", "%1 square kilometers")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square hectometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square hectometer", "%1 square hectometers")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square decameters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square decameter", "%1 square decameters")));
|
||||
|
||||
d->addDefaultUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square meters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square meter", "%1 square meters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square decimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square decimeter", "%1 square decimeters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square centimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square centimeter", "%1 square centimeters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square millimeters"),
|
||||
ki18ncp("amount in units (integer)", "%1 square millimeter", "%1 square millimeters")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square micrometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square micrometer", "%1 square micrometers")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square nanometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square nanometer", "%1 square nanometers")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square picometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square picometer", "%1 square picometers")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square femtometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square femtometer", "%1 square femtometers")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square attometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square attometer", "%1 square attometers")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square zeptometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square zeptometer", "%1 square zeptometers")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square yoctometers"),
|
||||
ki18ncp("amount in units (integer)", "%1 square yoctometer", "%1 square yoctometers")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
Acre,
|
||||
4046.86,
|
||||
i18nc("area unit symbol", "acre"),
|
||||
i18nc("unit description in lists", "acres"),
|
||||
i18nc("unit synonyms for matching user input", "acre;acres"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 acres"),
|
||||
ki18ncp("amount in units (integer)", "%1 acre", "%1 acres")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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²"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square feet"),
|
||||
ki18ncp("amount in units (integer)", "%1 square foot", "%1 square feet")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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²"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square inches"),
|
||||
ki18ncp("amount in units (integer)", "%1 square inch", "%1 square inches")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(AreaCategory,
|
||||
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²"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 square miles"),
|
||||
ki18ncp("amount in units (integer)", "%1 square mile", "%1 square miles")));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
} // KUnitConversion namespace
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2007-2009 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef AREA_P_H
|
||||
#define AREA_P_H
|
||||
|
||||
#include "unitcategory_p.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
namespace Area
|
||||
{
|
||||
UnitCategory makeCategory();
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,391 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2019 Jonathan Rubenstein <jrubcop@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "binary_data_p.h"
|
||||
#include "unit_p.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
class BinaryPowerOfTwoUnitPrivate : public UnitPrivate
|
||||
{
|
||||
public:
|
||||
BinaryPowerOfTwoUnitPrivate(CategoryId categoryId,
|
||||
UnitId id,
|
||||
qreal multiplier,
|
||||
const QString &symbol,
|
||||
const QString &description,
|
||||
const QString &matchString,
|
||||
const KLocalizedString &symbolString,
|
||||
const KLocalizedString &realString,
|
||||
const KLocalizedString &integerString)
|
||||
: UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString)
|
||||
{
|
||||
}
|
||||
|
||||
qreal toDefault(qreal value) const override
|
||||
{
|
||||
return value * pow(2.0, m_multiplier);
|
||||
}
|
||||
qreal fromDefault(qreal value) const override
|
||||
{
|
||||
return value / pow(2.0, m_multiplier);
|
||||
}
|
||||
};
|
||||
|
||||
UnitCategory BinaryData::makeCategory()
|
||||
{
|
||||
auto c = UnitCategoryPrivate::makeCategory(BinaryDataCategory, i18n("Binary Data"), i18n("Binary Data Size"));
|
||||
auto d = UnitCategoryPrivate::get(c);
|
||||
KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (binary data)", "%1 %2");
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Yobibyte,
|
||||
83,
|
||||
i18nc("binary data unit symbol", "YiB"),
|
||||
i18nc("unit description in lists", "yobibytes"),
|
||||
i18nc("unit synonyms for matching user input", "YiB;yobibyte;yobibytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 yobibytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 yobibyte", "%1 yobibytes"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Yobibit,
|
||||
80,
|
||||
i18nc("binary data unit symbol", "Yib"),
|
||||
i18nc("unit description in lists", "yobibits"),
|
||||
i18nc("unit synonyms for matching user input", "Yib;yobibit;yobibits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 yobibits"),
|
||||
ki18ncp("amount in units (integer)", "%1 yobibit", "%1 yobibits"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Yottabyte,
|
||||
8e+24,
|
||||
i18nc("binary data unit symbol", "YB"),
|
||||
i18nc("unit description in lists", "yottabytes"),
|
||||
i18nc("unit synonyms for matching user input", "YB;yottabyte;yottabytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 yottabytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottabyte", "%1 yottabytes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Yottabit,
|
||||
1e+24,
|
||||
i18nc("binary data unit symbol", "Yb"),
|
||||
i18nc("unit description in lists", "yottabits"),
|
||||
i18nc("unit synonyms for matching user input", "Yb;yottabit;yottabits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 yottabits"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottabit", "%1 yottabits")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Zebibyte,
|
||||
73,
|
||||
i18nc("binary data unit symbol", "ZiB"),
|
||||
i18nc("unit description in lists", "zebibytes"),
|
||||
i18nc("unit synonyms for matching user input", "ZiB;zebibyte;zebibytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 zebibytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 zebibyte", "%1 zebibytes"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Zebibit,
|
||||
70,
|
||||
i18nc("binary data unit symbol", "Zib"),
|
||||
i18nc("unit description in lists", "zebibits"),
|
||||
i18nc("unit synonyms for matching user input", "Zib;zebibit;zebibits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 zebibits"),
|
||||
ki18ncp("amount in units (integer)", "%1 zebibit", "%1 zebibits"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Zettabyte,
|
||||
8e+21,
|
||||
i18nc("binary data unit symbol", "ZB"),
|
||||
i18nc("unit description in lists", "zettabytes"),
|
||||
i18nc("unit synonyms for matching user input", "ZB;zettabyte;zettabytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 zettabytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettabyte", "%1 zettabytes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Zettabit,
|
||||
1e+21,
|
||||
i18nc("binary data unit symbol", "Zb"),
|
||||
i18nc("unit description in lists", "zettabits"),
|
||||
i18nc("unit synonyms for matching user input", "Zb;zettabit;zettabits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 zettabits"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettabit", "%1 zettabits")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Exbibyte,
|
||||
63,
|
||||
i18nc("binary data unit symbol", "EiB"),
|
||||
i18nc("unit description in lists", "exbibytes"),
|
||||
i18nc("unit synonyms for matching user input", "EiB;exbibyte;exbibytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 exbibytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 exbibyte", "%1 exbibytes"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Exbibit,
|
||||
60,
|
||||
i18nc("binary data unit symbol", "Eib"),
|
||||
i18nc("unit description in lists", "exbibits"),
|
||||
i18nc("unit synonyms for matching user input", "Eib;exbibit;exbibits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 exbibits"),
|
||||
ki18ncp("amount in units (integer)", "%1 exbibit", "%1 exbibits"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Exabyte,
|
||||
8e+18,
|
||||
i18nc("binary data unit symbol", "EB"),
|
||||
i18nc("unit description in lists", "exabytes"),
|
||||
i18nc("unit synonyms for matching user input", "EB;exabyte;exabytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 exabytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 exabyte", "%1 exabytes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Exabit,
|
||||
1e+18,
|
||||
i18nc("binary data unit symbol", "Eb"),
|
||||
i18nc("unit description in lists", "exabits"),
|
||||
i18nc("unit synonyms for matching user input", "Eb;exabit;exabits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 exabits"),
|
||||
ki18ncp("amount in units (integer)", "%1 exabit", "%1 exabits")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Pebibyte,
|
||||
53,
|
||||
i18nc("binary data unit symbol", "PiB"),
|
||||
i18nc("unit description in lists", "pebibytes"),
|
||||
i18nc("unit synonyms for matching user input", "PiB;pebibyte;pebibytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 pebibytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 pebibyte", "%1 pebibytes"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Pebibit,
|
||||
50,
|
||||
i18nc("binary data unit symbol", "Pib"),
|
||||
i18nc("unit description in lists", "pebibits"),
|
||||
i18nc("unit synonyms for matching user input", "Pib;pebibit;pebibits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 pebibits"),
|
||||
ki18ncp("amount in units (integer)", "%1 pebibit", "%1 pebibits"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Petabyte,
|
||||
8e+15,
|
||||
i18nc("binary data unit symbol", "PB"),
|
||||
i18nc("unit description in lists", "petabytes"),
|
||||
i18nc("unit synonyms for matching user input", "PB;petabyte;petabytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 petabytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 petabyte", "%1 petabytes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Petabit,
|
||||
1e+15,
|
||||
i18nc("binary data unit symbol", "Pb"),
|
||||
i18nc("unit description in lists", "petabits"),
|
||||
i18nc("unit synonyms for matching user input", "Pb;petabit;petabits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 petabits"),
|
||||
ki18ncp("amount in units (integer)", "%1 petabit", "%1 petabits")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Tebibyte,
|
||||
43,
|
||||
i18nc("binary data unit symbol", "TiB"),
|
||||
i18nc("unit description in lists", "tebibytes"),
|
||||
i18nc("unit synonyms for matching user input", "TiB;tebibyte;tebibytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 tebibytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 tebibyte", "%1 tebibytes"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Tebibit,
|
||||
40,
|
||||
i18nc("binary data unit symbol", "Tib"),
|
||||
i18nc("unit description in lists", "tebibits"),
|
||||
i18nc("unit synonyms for matching user input", "Tib;tebibit;tebibits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 tebibits"),
|
||||
ki18ncp("amount in units (integer)", "%1 tebibit", "%1 tebibits"))));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Terabyte,
|
||||
8e+12,
|
||||
i18nc("binary data unit symbol", "TB"),
|
||||
i18nc("unit description in lists", "terabytes"),
|
||||
i18nc("unit synonyms for matching user input", "TB;terabyte;terabytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 terabytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 terabyte", "%1 terabytes")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Terabit,
|
||||
1e+12,
|
||||
i18nc("binary data unit symbol", "Tb"),
|
||||
i18nc("unit description in lists", "terabits"),
|
||||
i18nc("unit synonyms for matching user input", "Tb;terabit;terabits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 terabits"),
|
||||
ki18ncp("amount in units (integer)", "%1 terabit", "%1 terabits")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Gibibyte,
|
||||
33,
|
||||
i18nc("binary data unit symbol", "GiB"),
|
||||
i18nc("unit description in lists", "gibibytes"),
|
||||
i18nc("unit synonyms for matching user input", "GiB;gibibyte;gibibytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 gibibytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 gibibyte", "%1 gibibytes"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Gibibit,
|
||||
30,
|
||||
i18nc("binary data unit symbol", "Gib"),
|
||||
i18nc("unit description in lists", "gibibits"),
|
||||
i18nc("unit synonyms for matching user input", "Gib;gibibit;gibibits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 gibibits"),
|
||||
ki18ncp("amount in units (integer)", "%1 gibibit", "%1 gibibits"))));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Gigabyte,
|
||||
8e+09,
|
||||
i18nc("binary data unit symbol", "GB"),
|
||||
i18nc("unit description in lists", "gigabytes"),
|
||||
i18nc("unit synonyms for matching user input", "GB;gigabyte;gigabytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 gigabytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigabyte", "%1 gigabytes")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Gigabit,
|
||||
1e+09,
|
||||
i18nc("binary data unit symbol", "Gb"),
|
||||
i18nc("unit description in lists", "gigabits"),
|
||||
i18nc("unit synonyms for matching user input", "Gb;gigabit;gigabits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 gigabits"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigabit", "%1 gigabits")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Mebibyte,
|
||||
23,
|
||||
i18nc("binary data unit symbol", "MiB"),
|
||||
i18nc("unit description in lists", "mebibytes"),
|
||||
i18nc("unit synonyms for matching user input", "MiB;mebibyte;mebibytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 mebibytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 mebibyte", "%1 mebibytes"))));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(new BinaryPowerOfTwoUnitPrivate(BinaryDataCategory,
|
||||
Mebibit,
|
||||
20,
|
||||
i18nc("binary data unit symbol", "Mib"),
|
||||
i18nc("unit description in lists", "mebibits"),
|
||||
i18nc("unit synonyms for matching user input", "Mib;mebibit;mebibits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 mebibits"),
|
||||
ki18ncp("amount in units (integer)", "%1 mebibit", "%1 mebibits"))));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Megabyte,
|
||||
8e+06,
|
||||
i18nc("binary data unit symbol", "MB"),
|
||||
i18nc("unit description in lists", "megabytes"),
|
||||
i18nc("unit synonyms for matching user input", "MB;megabyte;megabytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 megabytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 megabyte", "%1 megabytes")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Megabit,
|
||||
1e+06,
|
||||
i18nc("binary data unit symbol", "Mb"),
|
||||
i18nc("unit description in lists", "megabits"),
|
||||
i18nc("unit synonyms for matching user input", "Mb;megabit;megabits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 megabits"),
|
||||
ki18ncp("amount in units (integer)", "%1 megabit", "%1 megabits")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Kibibyte,
|
||||
8192,
|
||||
i18nc("binary data unit symbol", "KiB"),
|
||||
i18nc("unit description in lists", "kibibytes"),
|
||||
i18nc("unit synonyms for matching user input", "KiB;kibibyte;kibibytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kibibytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 kibibyte", "%1 kibibytes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Kibibit,
|
||||
1024,
|
||||
i18nc("binary data unit symbol", "Kib"),
|
||||
i18nc("unit description in lists", "kibibits"),
|
||||
i18nc("unit synonyms for matching user input", "Kib;kibibit;kibibits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kibibits"),
|
||||
ki18ncp("amount in units (integer)", "%1 kibibit", "%1 kibibits")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Kilobyte,
|
||||
8000,
|
||||
i18nc("binary data unit symbol", "kB"),
|
||||
i18nc("unit description in lists", "kilobytes"),
|
||||
i18nc("unit synonyms for matching user input", "kB;kilobyte;kilobytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kilobytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilobyte", "%1 kilobytes")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Kilobit,
|
||||
1000,
|
||||
i18nc("binary data unit symbol", "kb"),
|
||||
i18nc("unit description in lists", "kilobits"),
|
||||
i18nc("unit synonyms for matching user input", "kb;kilobit;kilobits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kilobits"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilobit", "%1 kilobits")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Byte,
|
||||
8,
|
||||
i18nc("binary data unit symbol", "B"),
|
||||
i18nc("unit description in lists", "bytes"),
|
||||
i18nc("unit synonyms for matching user input", "B;byte;bytes"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 bytes"),
|
||||
ki18ncp("amount in units (integer)", "%1 byte", "%1 bytes")));
|
||||
|
||||
d->addDefaultUnit(UnitPrivate::makeUnit(BinaryDataCategory,
|
||||
Bit,
|
||||
1,
|
||||
i18nc("binary data unit symbol", "b"),
|
||||
i18nc("unit description in lists", "bits"),
|
||||
i18nc("unit synonyms for matching user input", "b;bit;bits"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 bits"),
|
||||
ki18ncp("amount in units (integer)", "%1 bit", "%1 bits")));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
} // KUnitConversion namespace
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2019 Jonathan Rubenstein <jrubcop@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef BINARY_DATA_P_H
|
||||
#define BINARY_DATA_P_H
|
||||
|
||||
#include "unitcategory_p.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
namespace BinaryData
|
||||
{
|
||||
UnitCategory makeCategory();
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2008-2009 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "converter.h"
|
||||
|
||||
#include "acceleration_p.h"
|
||||
#include "angle_p.h"
|
||||
#include "area_p.h"
|
||||
#include "binary_data_p.h"
|
||||
#include "currency_p.h"
|
||||
#include "density_p.h"
|
||||
#include "electrical_current_p.h"
|
||||
#include "electrical_resistance_p.h"
|
||||
#include "energy_p.h"
|
||||
#include "force_p.h"
|
||||
#include "frequency_p.h"
|
||||
#include "fuel_efficiency_p.h"
|
||||
#include "length_p.h"
|
||||
#include "mass_p.h"
|
||||
#include "permeability_p.h"
|
||||
#include "power_p.h"
|
||||
#include "pressure_p.h"
|
||||
#include "temperature_p.h"
|
||||
#include "thermal_conductivity_p.h"
|
||||
#include "thermal_flux_p.h"
|
||||
#include "thermal_generation_p.h"
|
||||
#include "timeunit_p.h"
|
||||
#include "velocity_p.h"
|
||||
#include "voltage_p.h"
|
||||
#include "volume_p.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
class ConverterPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
ConverterPrivate()
|
||||
{
|
||||
m_categories[LengthCategory] = Length::makeCategory();
|
||||
m_categories[AreaCategory] = Area::makeCategory();
|
||||
m_categories[VolumeCategory] = Volume::makeCategory();
|
||||
m_categories[TemperatureCategory] = Temperature::makeCategory();
|
||||
m_categories[VelocityCategory] = Velocity::makeCategory();
|
||||
m_categories[MassCategory] = Mass::makeCategory();
|
||||
m_categories[PressureCategory] = Pressure::makeCategory();
|
||||
m_categories[EnergyCategory] = Energy::makeCategory();
|
||||
m_categories[CurrencyCategory] = Currency::makeCategory();
|
||||
m_categories[PowerCategory] = Power::makeCategory();
|
||||
m_categories[TimeCategory] = Time::makeCategory();
|
||||
m_categories[FuelEfficiencyCategory] = FuelEfficiency::makeCategory();
|
||||
m_categories[DensityCategory] = Density::makeCategory();
|
||||
m_categories[AccelerationCategory] = Acceleration::makeCategory();
|
||||
m_categories[ForceCategory] = Force::makeCategory();
|
||||
m_categories[AngleCategory] = Angle::makeCategory();
|
||||
m_categories[FrequencyCategory] = Frequency::makeCategory();
|
||||
m_categories[ThermalConductivityCategory] = ThermalConductivity::makeCategory();
|
||||
m_categories[ThermalFluxCategory] = ThermalFlux::makeCategory();
|
||||
m_categories[ThermalGenerationCategory] = ThermalGeneration::makeCategory();
|
||||
m_categories[VoltageCategory] = Voltage::makeCategory();
|
||||
m_categories[ElectricalCurrentCategory] = ElectricalCurrent::makeCategory();
|
||||
m_categories[ElectricalResistanceCategory] = ElectricalResistance::makeCategory();
|
||||
m_categories[PermeabilityCategory] = Permeability::makeCategory();
|
||||
m_categories[BinaryDataCategory] = BinaryData::makeCategory();
|
||||
}
|
||||
|
||||
#if KUNITCONVERSION_BUILD_DEPRECATED_SINCE(5, 91)
|
||||
bool operator==(const ConverterPrivate &other) const
|
||||
{
|
||||
return (m_categories == other.m_categories);
|
||||
}
|
||||
|
||||
bool operator!=(const ConverterPrivate &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
#endif
|
||||
|
||||
QMap<CategoryId, UnitCategory> m_categories;
|
||||
};
|
||||
|
||||
class QConverterSingleton
|
||||
{
|
||||
public:
|
||||
QConverterSingleton()
|
||||
: d(new ConverterPrivate())
|
||||
{
|
||||
}
|
||||
QExplicitlySharedDataPointer<ConverterPrivate> d;
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(QConverterSingleton, global_converter)
|
||||
|
||||
Converter::Converter()
|
||||
: d(global_converter->d)
|
||||
{
|
||||
}
|
||||
|
||||
Converter::~Converter()
|
||||
{
|
||||
}
|
||||
|
||||
Converter::Converter(const Converter &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
|
||||
Converter &Converter::operator=(const Converter &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if KUNITCONVERSION_BUILD_DEPRECATED_SINCE(5, 91)
|
||||
bool Converter::operator==(const Converter &other) const
|
||||
{
|
||||
if (d && other.d) {
|
||||
return (*d == *other.d);
|
||||
} else {
|
||||
return (d == other.d);
|
||||
}
|
||||
}
|
||||
|
||||
bool Converter::operator!=(const Converter &other) const
|
||||
{
|
||||
if (d && other.d) {
|
||||
return (*d != *other.d);
|
||||
} else {
|
||||
return (d != other.d);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Value Converter::convert(const Value &value, const QString &toUnit) const
|
||||
{
|
||||
if (d && value.unit().isValid()) {
|
||||
return value.unit().category().convert(value, toUnit);
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value Converter::convert(const Value &value, UnitId toUnit) const
|
||||
{
|
||||
if (d && value.unit().isValid()) {
|
||||
return value.unit().category().convert(value, toUnit);
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value Converter::convert(const Value &value, const Unit &toUnit) const
|
||||
{
|
||||
if (d && toUnit.isValid() && value.unit().isValid()) {
|
||||
return value.unit().category().convert(value, toUnit);
|
||||
}
|
||||
return Value();
|
||||
}
|
||||
|
||||
UnitCategory Converter::categoryForUnit(const QString &unit) const
|
||||
{
|
||||
const auto lstCategories = categories();
|
||||
for (const UnitCategory &u : lstCategories) {
|
||||
if (u.hasUnit(unit)) {
|
||||
return u;
|
||||
}
|
||||
}
|
||||
return UnitCategory();
|
||||
}
|
||||
|
||||
Unit Converter::unit(const QString &unitString) const
|
||||
{
|
||||
const auto lstCategories = categories();
|
||||
for (const UnitCategory &u : lstCategories) {
|
||||
Unit unitClass = u.unit(unitString);
|
||||
if (unitClass.isValid()) {
|
||||
return unitClass;
|
||||
}
|
||||
}
|
||||
return Unit();
|
||||
}
|
||||
|
||||
Unit Converter::unit(UnitId unitId) const
|
||||
{
|
||||
const auto lstCategories = categories();
|
||||
for (const UnitCategory &u : lstCategories) {
|
||||
Unit unitClass = u.unit(unitId);
|
||||
if (unitClass.isValid()) {
|
||||
return unitClass;
|
||||
}
|
||||
}
|
||||
return Unit();
|
||||
}
|
||||
|
||||
UnitCategory Converter::category(const QString &category) const
|
||||
{
|
||||
const auto lstCategories = categories();
|
||||
for (const UnitCategory &u : lstCategories) {
|
||||
if (u.name() == category) {
|
||||
return u;
|
||||
}
|
||||
}
|
||||
// not found
|
||||
return UnitCategory();
|
||||
}
|
||||
|
||||
UnitCategory Converter::category(CategoryId categoryId) const
|
||||
{
|
||||
if (d && d->m_categories.contains(categoryId)) {
|
||||
return d->m_categories[categoryId];
|
||||
}
|
||||
// not found
|
||||
return UnitCategory();
|
||||
}
|
||||
|
||||
QList<UnitCategory> Converter::categories() const
|
||||
{
|
||||
if (d) {
|
||||
return d->m_categories.values();
|
||||
}
|
||||
return QList<UnitCategory>();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2008-2009 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef KUNITCONVERSION_CONVERTER_H
|
||||
#define KUNITCONVERSION_CONVERTER_H
|
||||
|
||||
#include <kunitconversion/kunitconversion_export.h>
|
||||
|
||||
#include "unitcategory.h"
|
||||
|
||||
#include <QExplicitlySharedDataPointer>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
class Value;
|
||||
class UnitCategory;
|
||||
class ConverterPrivate;
|
||||
|
||||
/**
|
||||
* @short Class for converting values between units of measurement
|
||||
*
|
||||
* This is a class to convert values between different units of measurement.
|
||||
*
|
||||
* @see Unit, UnitCategory, Value
|
||||
*
|
||||
* @author Petri Damstén <damu@iki.fi>
|
||||
* @author John Layt <jlayt@kde.org>
|
||||
*/
|
||||
|
||||
class KUNITCONVERSION_EXPORT Converter
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a Converter instance.
|
||||
*/
|
||||
Converter();
|
||||
/**
|
||||
* Destroys this Converter instance.
|
||||
*/
|
||||
~Converter();
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param other existing Converter instance.
|
||||
*/
|
||||
Converter(const Converter &other);
|
||||
|
||||
/**
|
||||
* Assignment operator, assign @p other to this.
|
||||
**/
|
||||
Converter &operator=(const Converter &other);
|
||||
|
||||
// TODO KF6 de-inline
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
/**
|
||||
* Move-assigns @p other to this Converter instance, transferring the
|
||||
* ownership of the managed pointer to this instance.
|
||||
**/
|
||||
Converter &operator=(Converter &&other)
|
||||
{
|
||||
swap(other);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO KF6 remove
|
||||
/**
|
||||
* Swaps this Converter with @p other. This function is very fast and never fails.
|
||||
**/
|
||||
void swap(Converter &other)
|
||||
{
|
||||
d.swap(other.d);
|
||||
}
|
||||
|
||||
#if KUNITCONVERSION_ENABLE_DEPRECATED_SINCE(5, 91)
|
||||
/**
|
||||
* @return @c true if this Converter is equal to the @p other Converter.
|
||||
* @deprecated since 5.91, result is always true
|
||||
**/
|
||||
KUNITCONVERSION_DEPRECATED_VERSION(5, 91, "result is always true")
|
||||
bool operator==(const Converter &other) const;
|
||||
|
||||
/**
|
||||
* @return @c true if this Converter is not equal to the @p other Converter.
|
||||
* @deprecated since 5.91, result is always false
|
||||
**/
|
||||
KUNITCONVERSION_DEPRECATED_VERSION(5, 91, "result is always false")
|
||||
bool operator!=(const Converter &other) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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, UnitId toUnit) const;
|
||||
Value convert(const Value &value, const Unit &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
|
||||
**/
|
||||
Unit unit(const QString &unitString) const;
|
||||
|
||||
/**
|
||||
* Find unit for unit enum.
|
||||
*
|
||||
* @param unitId unit enum to find unit for.
|
||||
* @return unit for string unit
|
||||
**/
|
||||
Unit unit(UnitId 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(CategoryId categoryId) const;
|
||||
|
||||
/**
|
||||
* Returns a list of all unit categories.
|
||||
*
|
||||
* @return list of unit categories.
|
||||
**/
|
||||
QList<UnitCategory> categories() const;
|
||||
|
||||
private:
|
||||
QExplicitlySharedDataPointer<ConverterPrivate> d;
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,768 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "currency_p.h"
|
||||
#include "kunitconversion_debug.h"
|
||||
#include "unit_p.h"
|
||||
#include <KLocalizedString>
|
||||
#include <QAtomicInteger>
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QEventLoop>
|
||||
#include <QFileInfo>
|
||||
#include <QLocale>
|
||||
#include <QMutex>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkInterface>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QSaveFile>
|
||||
#include <QStandardPaths>
|
||||
#include <QXmlStreamReader>
|
||||
#include <mutex>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
static const char URL[] = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
|
||||
|
||||
static QString cacheLocation()
|
||||
{
|
||||
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/libkunitconversion/currency.xml");
|
||||
}
|
||||
|
||||
class CurrencyCategoryPrivate : public UnitCategoryPrivate
|
||||
{
|
||||
public:
|
||||
CurrencyCategoryPrivate(CategoryId id, const QString &name, const QString &description)
|
||||
: UnitCategoryPrivate(id, name, description)
|
||||
{
|
||||
}
|
||||
|
||||
Value convert(const Value &value, const Unit &toUnit) override;
|
||||
bool hasOnlineConversionTable() const override;
|
||||
void syncConversionTable(std::chrono::seconds updateSkipSeconds) override;
|
||||
bool m_initialized{false}; //!< indicates if units are prepared from currency table
|
||||
};
|
||||
|
||||
bool CurrencyCategoryPrivate::hasOnlineConversionTable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
UnitCategory Currency::makeCategory()
|
||||
{
|
||||
auto c = UnitCategoryPrivate::makeCategory(new CurrencyCategoryPrivate(CurrencyCategory, i18n("Currency"), i18n("From ECB")));
|
||||
auto d = UnitCategoryPrivate::get(c);
|
||||
KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (currency)", "%1 %2");
|
||||
|
||||
// Static rates
|
||||
d->addDefaultUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Eur,
|
||||
1.0,
|
||||
QStringLiteral("EUR"),
|
||||
i18nc("currency name", "Euro"),
|
||||
i18nc("EUR Euro - unit synonyms for matching user input", "euro;euros") + QStringLiteral(";EUR;") + QStringLiteral("€")
|
||||
+ QLatin1Char(';') + i18nc("currency name", "Euro"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 euros"),
|
||||
ki18ncp("amount in units (integer)", "%1 euro", "%1 euros")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Ats,
|
||||
0.0726728,
|
||||
QStringLiteral("ATS"),
|
||||
i18nc("currency name", "Austrian Schilling"),
|
||||
i18nc("ATS Austrian Schilling - unit synonyms for matching user input", "schilling;schillings") + QStringLiteral(";ATS;")
|
||||
+ QLocale::countryToString(QLocale::Austria) + QLatin1Char(';') + i18nc("currency name", "Austrian Schilling"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 schillings"),
|
||||
ki18ncp("amount in units (integer)", "%1 schilling", "%1 schillings")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Bef,
|
||||
0.0247894,
|
||||
QStringLiteral("BEF"),
|
||||
i18nc("currency name", "Belgian Franc"),
|
||||
i18nc("BEF Belgian Franc - unit synonyms for matching user input", "franc;francs") + QStringLiteral(";BEF;")
|
||||
+ QLocale::countryToString(QLocale::Belgium) + QLatin1Char(';') + i18nc("currency name", "Belgian Franc"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Belgian francs"),
|
||||
ki18ncp("amount in units (integer)", "%1 Belgian franc", "%1 Belgian francs")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Nlg,
|
||||
0.45378,
|
||||
QStringLiteral("NLG"),
|
||||
i18nc("currency name", "Netherlands Guilder"),
|
||||
i18nc("NLG Netherlands Guilder - unit synonyms for matching user input", "guilder;guilders") + QStringLiteral(";NLG;")
|
||||
+ QLocale::countryToString(QLocale::Netherlands) + QLatin1Char(';') + i18nc("currency name", "Netherlands Guilder"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 guilders"),
|
||||
ki18ncp("amount in units (integer)", "%1 guilder", "%1 guilders")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Fim,
|
||||
0.168188,
|
||||
QStringLiteral("FIM"),
|
||||
i18nc("currency name", "Finnish Markka"),
|
||||
i18nc("FIM Finnish Markka - unit synonyms for matching user input", "markka;markkas;markkaa") + QStringLiteral(";FIM;")
|
||||
+ QLocale::countryToString(QLocale::Finland) + QLatin1Char(';') + i18nc("currency name", "Finnish Markka"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 markkas"),
|
||||
ki18ncp("amount in units (integer)", "%1 markka", "%1 markkas"))); // Alternative = markkaa
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Frf,
|
||||
0.152449,
|
||||
QStringLiteral("FRF"),
|
||||
i18nc("currency name", "French Franc"),
|
||||
i18nc("FRF French Franc - unit synonyms for matching user input", "franc;francs") + QStringLiteral(";FRF;")
|
||||
+ QLocale::countryToString(QLocale::France) + QLatin1Char(';') + i18nc("currency name", "French Franc"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 French francs"),
|
||||
ki18ncp("amount in units (integer)", "%1 French franc", "%1 French francs")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Dem,
|
||||
0.511292,
|
||||
QStringLiteral("DEM"),
|
||||
i18nc("currency name", "German Mark"),
|
||||
i18nc("DEM German Mark - unit synonyms for matching user input", "mark;marks") + QStringLiteral(";DEM;")
|
||||
+ QLocale::countryToString(QLocale::Germany) + QLatin1Char(';') + i18nc("currency name", "German Mark"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 marks"),
|
||||
ki18ncp("amount in units (integer)", "%1 mark", "%1 marks")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Iep,
|
||||
1.26974,
|
||||
QStringLiteral("IEP"),
|
||||
i18nc("currency name", "Irish Pound"),
|
||||
i18nc("IEP Irish Pound - unit synonyms for matching user input", "Irish pound;Irish pounds") + QStringLiteral(";IEP;")
|
||||
+ QLocale::countryToString(QLocale::Ireland) + QLatin1Char(';') + i18nc("currency name", "Irish Pound"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Irish pounds"),
|
||||
ki18ncp("amount in units (integer)", "%1 Irish pound", "%1 Irish pounds")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Itl,
|
||||
0.000516457,
|
||||
QStringLiteral("ITL"),
|
||||
i18nc("currency name", "Italian Lira"),
|
||||
i18nc("ITL Italian Lira - unit synonyms for matching user input", "lira;liras") + QStringLiteral(";ITL;")
|
||||
+ QLocale::countryToString(QLocale::Italy) + QLatin1Char(';') + i18nc("currency name", "Italian Lira"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Italian lira"),
|
||||
ki18ncp("amount in units (integer)", "%1 Italian lira", "%1 Italian lira")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Luf,
|
||||
0.0247894,
|
||||
QStringLiteral("LUF"),
|
||||
i18nc("currency name", "Luxembourgish Franc"),
|
||||
i18nc("LUF Luxembourgish Franc - unit synonyms for matching user input", "franc;francs") + QStringLiteral(";LUF;")
|
||||
+ QLocale::countryToString(QLocale::Luxembourg) + QLatin1Char(';') + i18nc("currency name", "Luxembourgish Franc"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Luxembourgish francs"),
|
||||
ki18ncp("amount in units (integer)", "%1 Luxembourgish franc", "%1 Luxembourgish francs")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Pte,
|
||||
0.00498798,
|
||||
QStringLiteral("PTE"),
|
||||
i18nc("currency name", "Portuguese Escudo"),
|
||||
i18nc("PTE Portuguese Escudo - unit synonyms for matching user input", "escudo;escudos") + QStringLiteral(";PTE;")
|
||||
+ QLocale::countryToString(QLocale::Portugal) + QLatin1Char(';') + i18nc("currency name", "Portuguese Escudo"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 escudos"),
|
||||
ki18ncp("amount in units (integer)", "%1 escudo", "%1 escudos")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Esp,
|
||||
0.00601012,
|
||||
QStringLiteral("ESP"),
|
||||
i18nc("currency name", "Spanish Peseta"),
|
||||
i18nc("ESP Spanish Peseta - unit synonyms for matching user input", "peseta;pesetas") + QStringLiteral(";ESP;")
|
||||
+ QLocale::countryToString(QLocale::Spain) + QLatin1Char(';') + i18nc("currency name", "Spanish Peseta"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 pesetas"),
|
||||
ki18ncp("amount in units (integer)", "%1 peseta", "%1 pesetas")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Grd,
|
||||
0.0029347,
|
||||
QStringLiteral("GRD"),
|
||||
i18nc("currency name", "Greek Drachma"),
|
||||
i18nc("GRD Greek Drachma - unit synonyms for matching user input", "drachma;drachmas") + QStringLiteral(";GRD;")
|
||||
+ QLocale::countryToString(QLocale::Greece) + QLatin1Char(';') + i18nc("currency name", "Greek Drachma"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 drachmas"),
|
||||
ki18ncp("amount in units (integer)", "%1 drachma", "%1 drachmas")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Sit,
|
||||
0.00417293,
|
||||
QStringLiteral("SIT"),
|
||||
i18nc("currency name", "Slovenian Tolar"),
|
||||
i18nc("SIT Slovenian Tolar - unit synonyms for matching user input", "tolar;tolars;tolarjev") + QStringLiteral(";SIT;")
|
||||
+ QLocale::countryToString(QLocale::Slovenia) + QLatin1Char(';') + i18nc("currency name", "Slovenian Tolar"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 tolars"),
|
||||
ki18ncp("amount in units (integer)", "%1 tolar", "%1 tolars"))); // Alt: tolarjev/tolarja/tolarji
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Cyp,
|
||||
1.7086,
|
||||
QStringLiteral("CYP"),
|
||||
i18nc("currency name", "Cypriot Pound"),
|
||||
i18nc("CYP Cypriot Pound - unit synonyms for matching user input", "Cypriot pound;Cypriot pounds") + QStringLiteral(";CYP;")
|
||||
+ QLocale::countryToString(QLocale::Cyprus) + QLatin1Char(';') + i18nc("currency name", "Cypriot Pound"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Cypriot pounds"),
|
||||
ki18ncp("amount in units (integer)", "%1 Cypriot pound", "%1 Cypriot pounds")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Mtl,
|
||||
2.32937,
|
||||
QStringLiteral("MTL"),
|
||||
i18nc("currency name", "Maltese Lira"),
|
||||
i18nc("MTL Maltese Lira - unit synonyms for matching user input", "Maltese lira") + QStringLiteral(";MTL;")
|
||||
+ QLocale::countryToString(QLocale::Malta) + QLatin1Char(';') + i18nc("currency name", "Maltese Lira"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Maltese lira"),
|
||||
ki18ncp("amount in units (integer)", "%1 Maltese lira", "%1 Maltese lira")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Skk,
|
||||
0.0331939,
|
||||
QStringLiteral("SKK"),
|
||||
i18nc("currency name", "Slovak Koruna"),
|
||||
i18nc("SKK Slovak Koruna - unit synonyms for matching user input", "koruna;korunas;koruny;korun") + QStringLiteral(";SKK;")
|
||||
+ QLocale::countryToString(QLocale::Slovakia) + QLatin1Char(';') + i18nc("currency name", "Slovak Koruna"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Slovak korunas"),
|
||||
ki18ncp("amount in units (integer)", "%1 Slovak koruna", "%1 Slovak korunas"))); // Alt: koruny, korun
|
||||
|
||||
// From ECB
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Usd,
|
||||
qSNaN(),
|
||||
QStringLiteral("USD"),
|
||||
i18nc("currency name", "United States Dollar"),
|
||||
i18nc("USD United States Dollar - unit synonyms for matching user input", "dollar;dollars") + QStringLiteral(";USD;$;")
|
||||
+ QLocale::countryToString(QLocale::UnitedStates) + QLatin1Char(';') + i18nc("currency name", "United States Dollar"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 United States dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 United States dollar", "%1 United States dollars")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Jpy,
|
||||
qSNaN(),
|
||||
QStringLiteral("JPY"),
|
||||
i18nc("currency name", "Japanese Yen"),
|
||||
i18nc("JPY Japanese Yen - unit synonyms for matching user input", "yen") + QStringLiteral(";JPY;") + QStringLiteral("¥")
|
||||
+ QLatin1Char(';') + QLocale::countryToString(QLocale::Japan) + QLatin1Char(';') + i18nc("currency name", "Japanese Yen"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 yen"),
|
||||
ki18ncp("amount in units (integer)", "%1 yen", "%1 yen")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Bgn,
|
||||
qSNaN(),
|
||||
QStringLiteral("BGN"),
|
||||
i18nc("currency name", "Bulgarian Lev"),
|
||||
i18nc("BGN Bulgarian Lev - unit synonyms for matching user input", "lev;leva") + QStringLiteral(";BGN;")
|
||||
+ QLocale::countryToString(QLocale::Bulgaria) + QLatin1Char(';') + i18nc("currency name", "Bulgarian Lev"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 leva"),
|
||||
ki18ncp("amount in units (integer)", "%1 lev", "%1 leva")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Czk,
|
||||
qSNaN(),
|
||||
QStringLiteral("CZK"),
|
||||
i18nc("currency name", "Czech Koruna"),
|
||||
i18nc("CZK Czech Koruna - unit synonyms for matching user input", "koruna;korunas") + QStringLiteral(";CZK;")
|
||||
+ QLocale::countryToString(QLocale::CzechRepublic) + QLatin1Char(';') + i18nc("currency name", "Czech Koruna"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Czech korunas"),
|
||||
// Alt: koruny, korun
|
||||
ki18ncp("amount in units (integer)", "%1 Czech koruna", "%1 Czech korunas")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Dkk,
|
||||
qSNaN(),
|
||||
QStringLiteral("DKK"),
|
||||
i18nc("currency name", "Danish Krone"),
|
||||
i18nc("DKK Danish Krone - unit synonyms for matching user input", "Danish krone;Danish kroner") + QStringLiteral(";DKK;")
|
||||
+ QLocale::countryToString(QLocale::Denmark) + QLatin1Char(';') + i18nc("currency name", "Danish Krone"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Danish kroner"),
|
||||
ki18ncp("amount in units (integer)", "%1 Danish krone", "%1 Danish kroner")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Eek,
|
||||
qSNaN(),
|
||||
QStringLiteral("EEK"),
|
||||
i18nc("currency name", "Estonian Kroon"),
|
||||
i18nc("EEK Estonian Kroon - unit synonyms for matching user input", "kroon;kroons;krooni") + QStringLiteral(";EEK;")
|
||||
+ QLocale::countryToString(QLocale::Estonia) + QLatin1Char(';') + i18nc("currency name", "Estonian Kroon"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kroons"),
|
||||
ki18ncp("amount in units (integer)", "%1 kroon", "%1 kroons"))); // Alt: krooni
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Gbp,
|
||||
qSNaN(),
|
||||
QStringLiteral("GBP"),
|
||||
i18nc("currency name", "British Pound"),
|
||||
i18nc("GBP British Pound - unit synonyms for matching user input", "pound;pounds;pound sterling;pounds sterling")
|
||||
+ QStringLiteral(";GBP;") + QStringLiteral("£") + QLatin1Char(';') + QLocale::countryToString(QLocale::UnitedKingdom)
|
||||
+ QLatin1Char(';') + i18nc("currency name", "British Pound"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 pounds sterling"),
|
||||
ki18ncp("amount in units (integer)", "%1 pound sterling", "%1 pounds sterling")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Huf,
|
||||
qSNaN(),
|
||||
QStringLiteral("HUF"),
|
||||
i18nc("currency name", "Hungarian Forint"),
|
||||
i18nc("HUF hungarian Forint - unit synonyms for matching user input", "forint") + QStringLiteral(";HUF;")
|
||||
+ QLocale::countryToString(QLocale::Hungary) + QLatin1Char(';') + i18nc("currency name", "Hungarian Forint"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 forint"),
|
||||
ki18ncp("amount in units (integer)", "%1 forint", "%1 forint")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Ils,
|
||||
qSNaN(),
|
||||
QStringLiteral("ILS"),
|
||||
i18nc("currency name", "Israeli New Shekel"),
|
||||
i18nc("ILS Israeli New Shekel - unit synonyms for matching user input", "shekel;shekels;sheqel;sheqels;sheqalim")
|
||||
+ QStringLiteral(";ILS;") + QLocale::countryToString(QLocale::Israel) + QLatin1Char(';')
|
||||
+ i18nc("currency name", "Israeli New Shekel"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 shekels"),
|
||||
ki18ncp("amount in units (integer)", "%1 shekel", "%1 shekels")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Ltl,
|
||||
qSNaN(),
|
||||
QStringLiteral("LTL"),
|
||||
i18nc("currency name", "Lithuanian Litas"),
|
||||
i18nc("LTL Lithuanian Litas - unit synonyms for matching user input", "litas;litai;litu") + QStringLiteral(";LTL;")
|
||||
+ QLocale::countryToString(QLocale::Lithuania) + QLatin1Char(';') + i18nc("currency name", "Lithuanian Litas"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 litas"),
|
||||
ki18ncp("amount in units (integer)", "%1 litas", "%1 litai"))); // Alt: litu
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Lvl,
|
||||
qSNaN(),
|
||||
QStringLiteral("LVL"),
|
||||
i18nc("currency name", "Latvian Lats"),
|
||||
i18nc("LVL Latvian Lats - unit synonyms for matching user input", "lats;lati") + QStringLiteral(";LVL;")
|
||||
+ QLocale::countryToString(QLocale::Latvia) + QLatin1Char(';') + i18nc("currency name", "Latvian Lats"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 lati"),
|
||||
ki18ncp("amount in units (integer)", "%1 lats", "%1 lati")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Pln,
|
||||
qSNaN(),
|
||||
QStringLiteral("PLN"),
|
||||
i18nc("currency name", "Polish Zloty"),
|
||||
i18nc("PLN Polish Zloty - unit synonyms for matching user input", "zloty;zlotys;zloties") + QStringLiteral(";PLN;")
|
||||
+ QLocale::countryToString(QLocale::Poland) + QLatin1Char(';') + i18nc("currency name", "Polish Zloty"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 zlotys"),
|
||||
ki18ncp("amount in units (integer)", "%1 zloty", "%1 zlotys"))); // Alt: zloty, zlote, zlotych
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Ron,
|
||||
qSNaN(),
|
||||
QStringLiteral("RON"),
|
||||
i18nc("currency name", "Romanian Leu"),
|
||||
i18nc("RON Romanian Leu - unit synonyms for matching user input", "leu;lei") + QStringLiteral(";RON;")
|
||||
+ QLocale::countryToString(QLocale::Romania) + QLatin1Char(';') + i18nc("currency name", "Romanian Leu"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 lei"),
|
||||
ki18ncp("amount in units (integer)", "%1 leu", "%1 lei")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Sek,
|
||||
qSNaN(),
|
||||
QStringLiteral("SEK"),
|
||||
i18nc("currency name", "Swedish Krona"),
|
||||
i18nc("SEK Swedish Krona - unit synonyms for matching user input", "krona;kronor") + QStringLiteral(";SEK;")
|
||||
+ QLocale::countryToString(QLocale::Sweden) + QLatin1Char(';') + i18nc("currency name", "Swedish Krona"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kronor"),
|
||||
ki18ncp("amount in units (integer)", "%1 krona", "%1 kronor")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Chf,
|
||||
qSNaN(),
|
||||
QStringLiteral("CHF"),
|
||||
i18nc("currency name", "Swiss Franc"),
|
||||
i18nc("CHF Swiss Franc - unit synonyms for matching user input", "franc;francs") + QStringLiteral(";CHF;")
|
||||
+ QLocale::countryToString(QLocale::Switzerland) + QLatin1Char(';') + i18nc("currency name", "Swiss Franc"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Swiss francs"),
|
||||
ki18ncp("amount in units (integer)", "%1 Swiss franc", "%1 Swiss francs")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Nok,
|
||||
qSNaN(),
|
||||
QStringLiteral("NOK"),
|
||||
i18nc("currency name", "Norwegian Krone"),
|
||||
i18nc("Norwegian Krone - unit synonyms for matching user input", "Norwegian krone;Norwegian kroner") + QStringLiteral(";NOK;")
|
||||
+ QLocale::countryToString(QLocale::Norway) + QLatin1Char(';') + i18nc("currency name", "Norwegian Krone"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Norwegian kroner"),
|
||||
ki18ncp("amount in units (integer)", "%1 Norwegian krone", "%1 Norwegian kroner")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Hrk,
|
||||
qSNaN(),
|
||||
QStringLiteral("HRK"),
|
||||
i18nc("currency name", "Croatian Kuna"),
|
||||
i18nc("HRK Croatian Kuna - unit synonyms for matching user input", "kuna;kune") + QStringLiteral(";HRK;")
|
||||
+ QLocale::countryToString(QLocale::Croatia) + QLatin1Char(';') + i18nc("currency name", "Croatian Kuna"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kune"),
|
||||
ki18ncp("amount in units (integer)", "%1 kuna", "%1 kune")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Rub,
|
||||
qSNaN(),
|
||||
QStringLiteral("RUB"),
|
||||
i18nc("currency name", "Russian Ruble"),
|
||||
i18nc("RUB Russian Ruble - unit synonyms for matching user input", "ruble;rubles;rouble;roubles") + QStringLiteral(";RUB;")
|
||||
+ QLocale::countryToString(QLocale::Russia) + QLatin1Char(';') + i18nc("currency name", "Russian Ruble"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 rubles"),
|
||||
ki18ncp("amount in units (integer)", "%1 ruble", "%1 rubles"))); // Alt: rouble/roubles
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Try,
|
||||
qSNaN(),
|
||||
QStringLiteral("TRY"),
|
||||
i18nc("currency name", "Turkish Lira"),
|
||||
i18nc("TRY Turkish Lira - unit synonyms for matching user input", "lira") + QStringLiteral(";TRY;")
|
||||
+ QLocale::countryToString(QLocale::Turkey) + QLatin1Char(';') + i18nc("currency name", "Turkish Lira"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Turkish lira"),
|
||||
ki18ncp("amount in units (integer)", "%1 Turkish lira", "%1 Turkish lira")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Aud,
|
||||
qSNaN(),
|
||||
QStringLiteral("AUD"),
|
||||
i18nc("currency name", "Australian Dollar"),
|
||||
i18nc("AUD Australian Dollar - unit synonyms for matching user input", "Australian dollar;Australian dollars") + QStringLiteral(";AUD;")
|
||||
+ QLocale::countryToString(QLocale::Australia) + QLatin1Char(';') + i18nc("currency name", "Australian Dollar"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Australian dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 Australian dollar", "%1 Australian dollars")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Brl,
|
||||
qSNaN(),
|
||||
QStringLiteral("BRL"),
|
||||
i18nc("currency name", "Brazilian Real"),
|
||||
i18nc("BRL Brazilian Real - unit synonyms for matching user input", "real;reais") + QStringLiteral(";BRL;")
|
||||
+ QLocale::countryToString(QLocale::Brazil) + QLatin1Char(';') + i18nc("currency name", "Brazilian Real"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 reais"),
|
||||
ki18ncp("amount in units (integer)", "%1 real", "%1 reais")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Cad,
|
||||
qSNaN(),
|
||||
QStringLiteral("CAD"),
|
||||
i18nc("currency name", "Canadian Dollar"),
|
||||
i18nc("Canadian Dollar - unit synonyms for matching user input", "Canadian dollar;Canadian dollars") + QStringLiteral(";CAD;")
|
||||
+ QLocale::countryToString(QLocale::Canada) + QLatin1Char(';') + i18nc("currency name", "Canadian Dollar"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Canadian dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 Canadian dollar", "%1 Canadian dollars")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Cny,
|
||||
qSNaN(),
|
||||
QStringLiteral("CNY"),
|
||||
i18nc("currency name", "Chinese Yuan"),
|
||||
i18nc("Chinese Yuan - unit synonyms for matching user input", "yuan") + QStringLiteral(";CNY;")
|
||||
+ QLocale::countryToString(QLocale::China) + QLatin1Char(';') + i18nc("currency name", "Chinese Yuan"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 yuan"),
|
||||
ki18ncp("amount in units (integer)", "%1 yuan", "%1 yuan")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Hkd,
|
||||
qSNaN(),
|
||||
QStringLiteral("HKD"),
|
||||
i18nc("currency name", "Hong Kong Dollar"),
|
||||
i18nc("Hong Kong Dollar - unit synonyms for matching user input", "Hong Kong dollar;Hong Kong dollars") + QStringLiteral(";HKD;")
|
||||
+ QLocale::countryToString(QLocale::HongKong) + QLatin1Char(';') + i18nc("currency name", "Hong Kong Dollar"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Hong Kong dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 Hong Kong dollar", "%1 Hong Kong dollars")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Idr,
|
||||
qSNaN(),
|
||||
QStringLiteral("IDR"),
|
||||
i18nc("currency name", "Indonesian Rupiah"),
|
||||
i18nc("IDR Indonesian Rupiah - unit synonyms for matching user input", "rupiah;rupiahs") + QStringLiteral(";IDR;")
|
||||
+ QLocale::countryToString(QLocale::Indonesia) + QLatin1Char(';') + i18nc("currency name", "Indonesian Rupiah"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 rupiahs"),
|
||||
ki18ncp("amount in units (integer)", "%1 rupiah", "%1 rupiahs"))); // Alt: rupiah
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Inr,
|
||||
qSNaN(),
|
||||
QStringLiteral("INR"),
|
||||
i18nc("currency name", "Indian Rupee"),
|
||||
i18nc("INR Indian Rupee - unit synonyms for matching user input", "rupee;rupees") + QStringLiteral(";INR;")
|
||||
+ QLocale::countryToString(QLocale::India) + QLatin1Char(';') + i18nc("currency name", "Indian Rupee"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 rupees"),
|
||||
ki18ncp("amount in units (integer)", "%1 rupee", "%1 rupees"))); // Alt: rupee
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Krw,
|
||||
qSNaN(),
|
||||
QStringLiteral("KRW"),
|
||||
i18nc("currency name", "Korean Won"),
|
||||
i18nc("KRW Korean Won - unit synonyms for matching user input", "won") + QStringLiteral(";KRW;")
|
||||
+ QLocale::countryToString(QLocale::SouthKorea) + QLatin1Char(';') + i18nc("currency name", "Korean Won"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 won"),
|
||||
ki18ncp("amount in units (integer)", "%1 won", "%1 won")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Mxn,
|
||||
qSNaN(),
|
||||
QStringLiteral("MXN"),
|
||||
i18nc("currency name", "Mexican Peso"),
|
||||
i18nc("MXN Mexican Peso - unit synonyms for matching user input", "Mexican peso;Mexican pesos") + QStringLiteral(";MXN;")
|
||||
+ QLocale::countryToString(QLocale::Mexico) + QLatin1Char(';') + i18nc("currency name", "Mexican Peso"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Mexican pesos"),
|
||||
ki18ncp("amount in units (integer)", "%1 Mexican peso", "%1 Mexican pesos")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Myr,
|
||||
qSNaN(),
|
||||
QStringLiteral("MYR"),
|
||||
i18nc("currency name", "Malaysian Ringgit"),
|
||||
i18nc("MYR Malaysian Ringgit - unit synonyms for matching user input", "ringgit;ringgits") + QStringLiteral(";MYR;")
|
||||
+ QLocale::countryToString(QLocale::Malaysia) + QLatin1Char(';') + i18nc("currency name", "Malaysian Ringgit"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 ringgit"),
|
||||
ki18ncp("amount in units (integer)", "%1 ringgit", "%1 ringgit"))); // Alt: ringgits
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Nzd,
|
||||
qSNaN(),
|
||||
QStringLiteral("NZD"),
|
||||
i18nc("currency name", "New Zealand Dollar"),
|
||||
i18nc("NZD New Zealand Dollar - unit synonyms for matching user input", "New Zealand dollar;New Zealand dollars")
|
||||
+ QStringLiteral(";NZD;") + QLocale::countryToString(QLocale::NewZealand) + QLatin1Char(';')
|
||||
+ i18nc("currency name", "New Zealand Dollar"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 New Zealand dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 New Zealand dollar", "%1 New Zealand dollars")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Php,
|
||||
qSNaN(),
|
||||
QStringLiteral("PHP"),
|
||||
i18nc("currency name", "Philippine Peso"),
|
||||
i18nc("PHP Philippine Peso - unit synonyms for matching user input", "Philippine peso;Philippine pesos") + QStringLiteral(";PHP;")
|
||||
+ QLocale::countryToString(QLocale::Philippines) + QLatin1Char(';') + i18nc("currency name", "Philippine Peso"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Philippine pesos"),
|
||||
ki18ncp("amount in units (integer)", "%1 Philippine peso", "%1 Philippine pesos")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Sgd,
|
||||
qSNaN(),
|
||||
QStringLiteral("SGD"),
|
||||
i18nc("currency name", "Singapore Dollar"),
|
||||
i18nc("SGD Singapore Dollar - unit synonyms for matching user input", "Singapore dollar;Singapore dollars") + QStringLiteral(";SGD;")
|
||||
+ QLocale::countryToString(QLocale::Singapore) + QLatin1Char(';') + i18nc("currency name", "Singapore Dollar"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Singapore dollars"),
|
||||
ki18ncp("amount in units (integer)", "%1 Singapore dollar", "%1 Singapore dollars")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Thb,
|
||||
qSNaN(),
|
||||
QStringLiteral("THB"),
|
||||
i18nc("currency name", "Thai Baht"),
|
||||
i18nc("THB Thai Baht - unit synonyms for matching user input", "baht") + QStringLiteral(";THB;")
|
||||
+ QLocale::countryToString(QLocale::Thailand) + QLatin1Char(';') + i18nc("currency name", "Thai Baht"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 baht"),
|
||||
ki18ncp("amount in units (integer)", "%1 baht", "%1 baht")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Zar,
|
||||
qSNaN(),
|
||||
QStringLiteral("ZAR"),
|
||||
i18nc("currency name", "South African Rand"),
|
||||
i18nc("South African Rand - unit synonyms for matching user input", "rand") + QStringLiteral(";ZAR;")
|
||||
+ QLocale::countryToString(QLocale::SouthAfrica) + QLatin1Char(';') + i18nc("currency name", "South African Rand"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 rand"),
|
||||
ki18ncp("amount in units (integer)", "%1 rand", "%1 rand")));
|
||||
d->addUnit(UnitPrivate::makeUnit(CurrencyCategory,
|
||||
Isk,
|
||||
qSNaN(),
|
||||
QStringLiteral("ISK"),
|
||||
i18nc("currency name", "Icelandic Krona"),
|
||||
i18nc("Icelandic Krona - unit synonyms for matching user input", "Icelandic krona;Icelandic crown") + QStringLiteral(";ISK;")
|
||||
+ QLocale::countryToString(QLocale::Iceland) + QLatin1Char(';') + i18nc("currency name", "Icelandic Krona"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 Icelandic kronar"),
|
||||
ki18ncp("amount in units (integer)", "%1 Icelandic krona", "%1 Icelandic kronar")));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static bool isConnected()
|
||||
{
|
||||
// don't download currencies in autotests
|
||||
if (qEnvironmentVariableIsSet("KF5UNITCONVERT_NO_DOWNLOAD")) {
|
||||
return false;
|
||||
}
|
||||
bool ret = false;
|
||||
const auto listInterface = QNetworkInterface::allInterfaces();
|
||||
for (const QNetworkInterface &net : listInterface) {
|
||||
if (net.flags().testFlag(QNetworkInterface::IsUp) && !net.flags().testFlag(QNetworkInterface::IsLoopBack)) {
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QDateTime Currency::lastConversionTableUpdate()
|
||||
{
|
||||
QFileInfo info(cacheLocation());
|
||||
if (!info.exists()) {
|
||||
qCDebug(LOG_KUNITCONVERSION) << "No cache file available:" << cacheLocation();
|
||||
return QDateTime();
|
||||
} else {
|
||||
return info.lastModified();
|
||||
}
|
||||
}
|
||||
|
||||
void CurrencyCategoryPrivate::syncConversionTable(std::chrono::seconds updateSkipPeriod)
|
||||
{
|
||||
// sync call is expected to be guarded as being called only once
|
||||
auto updateCurrencyConversionTable = [this](const QString &cachePath, bool performNetworkSync) {
|
||||
qCDebug(LOG_KUNITCONVERSION) << "currency conversion table sync started";
|
||||
static QMutex mutex;
|
||||
QMutexLocker locker(&mutex);
|
||||
bool updateError{false};
|
||||
if (performNetworkSync) {
|
||||
if (isConnected()) {
|
||||
// Bug 345750: QNetworkReply does not work without an event loop and doesn't implement waitForReadyRead()
|
||||
QEventLoop loop;
|
||||
QNetworkAccessManager manager;
|
||||
auto *reply = manager.get(QNetworkRequest(QUrl(QString::fromLatin1(URL)))); // reply is owned by the network access manager
|
||||
QObject::connect(reply, &QNetworkReply::finished, [&] {
|
||||
if (!reply->error()) {
|
||||
QFileInfo info(cachePath);
|
||||
const QString cacheDir = info.absolutePath();
|
||||
if (!QFileInfo::exists(cacheDir)) {
|
||||
QDir().mkpath(cacheDir);
|
||||
}
|
||||
|
||||
QSaveFile cacheFile(cachePath);
|
||||
if (cacheFile.open(QFile::WriteOnly)) {
|
||||
cacheFile.write(reply->readAll());
|
||||
if (!cacheFile.commit()) {
|
||||
updateError = true;
|
||||
} else {
|
||||
qCInfo(LOG_KUNITCONVERSION) << "currency conversion table data obtained via network";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
updateError = true;
|
||||
qCCritical(LOG_KUNITCONVERSION) << "currency conversion table network error" << reply->error();
|
||||
}
|
||||
loop.quit();
|
||||
});
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
} else {
|
||||
qCInfo(LOG_KUNITCONVERSION) << "currency conversion table update has no network connection, abort update";
|
||||
}
|
||||
}
|
||||
|
||||
if (!updateError) {
|
||||
QFile file(cachePath);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QXmlStreamReader xml(&file);
|
||||
while (!xml.atEnd()) {
|
||||
xml.readNext();
|
||||
|
||||
if (xml.isStartElement() && xml.name() == QLatin1String("Cube")) {
|
||||
const auto attributes = xml.attributes();
|
||||
if (attributes.hasAttribute(QLatin1String("currency"))) {
|
||||
Unit unit = m_unitMap.value(attributes.value(QLatin1String("currency")).toString());
|
||||
if (unit.isValid()) {
|
||||
const auto multiplier = attributes.value(QLatin1String("rate")).toDouble();
|
||||
if (!qFuzzyIsNull(multiplier)) {
|
||||
unit.setUnitMultiplier(1.0 / multiplier);
|
||||
qCDebug(LOG_KUNITCONVERSION()) << "currency updated:" << unit.description() << multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateError = xml.hasError();
|
||||
if (updateError) {
|
||||
qCCritical(LOG_KUNITCONVERSION) << "currency conversion fetch could not parse obtained XML, update aborted";
|
||||
}
|
||||
}
|
||||
}
|
||||
m_initialized = !updateError;
|
||||
return !updateError;
|
||||
};
|
||||
|
||||
QFileInfo info(cacheLocation());
|
||||
if (!info.exists() || info.lastModified().secsTo(QDateTime::currentDateTime()) > updateSkipPeriod.count()) {
|
||||
updateCurrencyConversionTable(cacheLocation(), true);
|
||||
} else if (!m_initialized) {
|
||||
updateCurrencyConversionTable(cacheLocation(), false);
|
||||
}
|
||||
}
|
||||
|
||||
Value CurrencyCategoryPrivate::convert(const Value &value, const Unit &to)
|
||||
{
|
||||
// TODO KF6 remove this blocking call and change behavior that explicit call to syncConversionTable is mandatory before
|
||||
// first access to converted data, also to make syncs more explicit
|
||||
static QMutex updateFlag;
|
||||
{
|
||||
QMutexLocker locker(&updateFlag);
|
||||
CurrencyCategoryPrivate::syncConversionTable(24h);
|
||||
}
|
||||
|
||||
Value v = UnitCategoryPrivate::convert(value, to);
|
||||
return v;
|
||||
}
|
||||
|
||||
} // KUnitConversion namespace
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef CURRENCY_P_H
|
||||
#define CURRENCY_P_H
|
||||
|
||||
#include "unitcategory_p.h"
|
||||
#include <QDateTime>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
namespace Currency
|
||||
{
|
||||
UnitCategory makeCategory();
|
||||
/**
|
||||
* @brief Provides time of last conversion table update for usage in tests
|
||||
*
|
||||
* If no conversion table is available the QDateTime object is a null datetime.
|
||||
*
|
||||
* @internal exported for unit tests only
|
||||
*/
|
||||
KUNITCONVERSION_EXPORT QDateTime lastConversionTableUpdate();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2009 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "density_p.h"
|
||||
#include "unit_p.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
UnitCategory Density::makeCategory()
|
||||
{
|
||||
auto c = UnitCategoryPrivate::makeCategory(DensityCategory, i18n("Density"), i18n("Density"));
|
||||
auto d = UnitCategoryPrivate::get(c);
|
||||
KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (density)", "%1 %2");
|
||||
|
||||
d->addDefaultUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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³"),
|
||||
symbolString,
|
||||
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
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kilograms per liter"),
|
||||
ki18ncp("amount in units (integer)", "%1 kilogram per liter", "%1 kilograms per liter")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 grams per liter"),
|
||||
ki18ncp("amount in units (integer)", "%1 gram per liter", "%1 grams per liter")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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"),
|
||||
symbolString,
|
||||
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
|
||||
d->addUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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³"),
|
||||
symbolString,
|
||||
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")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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³"),
|
||||
symbolString,
|
||||
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")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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³"),
|
||||
symbolString,
|
||||
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")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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³"),
|
||||
symbolString,
|
||||
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")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(DensityCategory,
|
||||
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³"),
|
||||
symbolString,
|
||||
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")));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
} // KUnitConversion namespace
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* author Kashyap R Puranik
|
||||
* email kashthealien@gmail.com
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef DENSITY_P_H
|
||||
#define DENSITY_P_H
|
||||
|
||||
#include "unitcategory_p.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
namespace Density
|
||||
{
|
||||
UnitCategory makeCategory();
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2010 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
* SPDX-FileCopyrightText: 2014 Garret Wassermann <gwasser@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "electrical_current_p.h"
|
||||
#include "unit_p.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
UnitCategory ElectricalCurrent::makeCategory()
|
||||
{
|
||||
auto c = UnitCategoryPrivate::makeCategory(ElectricalCurrentCategory, i18n("ElectricalCurrent"), i18n("ElectricalCurrent"));
|
||||
auto d = UnitCategoryPrivate::get(c);
|
||||
KLocalizedString symbolString = ki18nc("%1 value, %2 unit symbol (electrical current", "%1 %2");
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Yottaampere,
|
||||
1e+24,
|
||||
i18nc("electrical current unit symbol", "YA"),
|
||||
i18nc("unit description in lists", "yottaamperes"),
|
||||
i18nc("unit synonyms for matching user input", "yottaampere;yottaamperes;YA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 yottaamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 yottaampere", "%1 yottaamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Zettaampere,
|
||||
1e+21,
|
||||
i18nc("electrical current unit symbol", "ZA"),
|
||||
i18nc("unit description in lists", "zettaamperes"),
|
||||
i18nc("unit synonyms for matching user input", "zettaampere;zettaamperes;ZA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 zettaamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 zettaampere", "%1 zettaamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Exaampere,
|
||||
1e+18,
|
||||
i18nc("electrical current unit symbol", "EA"),
|
||||
i18nc("unit description in lists", "exaamperes"),
|
||||
i18nc("unit synonyms for matching user input", "exaampere;exaamperes;EA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 exaamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 exaampere", "%1 exaamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Petaampere,
|
||||
1e+15,
|
||||
i18nc("electrical current unit symbol", "PA"),
|
||||
i18nc("unit description in lists", "petaamperes"),
|
||||
i18nc("unit synonyms for matching user input", "petaampere;petaamperes;PA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 petaamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 petaampere", "%1 petaamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Teraampere,
|
||||
1e+12,
|
||||
i18nc("electrical current unit symbol", "TA"),
|
||||
i18nc("unit description in lists", "teraamperes"),
|
||||
i18nc("unit synonyms for matching user input", "teraampere;teraamperes;TA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 teraamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 teraampere", "%1 teraamperes")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Gigaampere,
|
||||
1e+09,
|
||||
i18nc("electrical current unit symbol", "GA"),
|
||||
i18nc("unit description in lists", "gigaamperes"),
|
||||
i18nc("unit synonyms for matching user input", "gigaampere;gigaamperes;GA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 gigaamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 gigaampere", "%1 gigaamperes")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Megaampere,
|
||||
1e+06,
|
||||
i18nc("electrical current unit symbol", "MA"),
|
||||
i18nc("unit description in lists", "megaamperes"),
|
||||
i18nc("unit synonyms for matching user input", "megaampere;megaamperes;MA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 megaamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 megaampere", "%1 megaamperes")));
|
||||
|
||||
d->addCommonUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Kiloampere,
|
||||
1000,
|
||||
i18nc("electrical current unit symbol", "kA"),
|
||||
i18nc("unit description in lists", "kiloamperes"),
|
||||
i18nc("unit synonyms for matching user input", "kiloampere;kiloamperes;kA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 kiloamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 kiloampere", "%1 kiloamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Hectoampere,
|
||||
100,
|
||||
i18nc("electrical current unit symbol", "hA"),
|
||||
i18nc("unit description in lists", "hectoamperes"),
|
||||
i18nc("unit synonyms for matching user input", "hectoampere;hectoamperes;hA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 hectoamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 hectoampere", "%1 hectoamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Decaampere,
|
||||
10,
|
||||
i18nc("electrical current unit symbol", "daA"),
|
||||
i18nc("unit description in lists", "decaamperes"),
|
||||
i18nc("unit synonyms for matching user input", "decaampere;decaamperes;daA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 decaamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 decaampere", "%1 decaamperes")));
|
||||
|
||||
d->addDefaultUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Ampere,
|
||||
1,
|
||||
i18nc("electrical current unit symbol", "A"),
|
||||
i18nc("unit description in lists", "amperes"),
|
||||
i18nc("unit synonyms for matching user input", "amp;amps;ampere;amperes;A"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 amperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 ampere", "%1 amperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Deciampere,
|
||||
0.1,
|
||||
i18nc("electrical current unit symbol", "dA"),
|
||||
i18nc("unit description in lists", "deciamperes"),
|
||||
i18nc("unit synonyms for matching user input", "deciampere;deciamperes;dA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 deciamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 deciampere", "%1 deciamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Centiampere,
|
||||
0.01,
|
||||
i18nc("electrical current unit symbol", "cA"),
|
||||
i18nc("unit description in lists", "centiamperes"),
|
||||
i18nc("unit synonyms for matching user input", "centiampere;centiamperes;cA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 centiamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 centiampere", "%1 centiamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Milliampere,
|
||||
0.001,
|
||||
i18nc("electrical current unit symbol", "mA"),
|
||||
i18nc("unit description in lists", "milliamperes"),
|
||||
i18nc("unit synonyms for matching user input", "milliamp;milliamps;milliampere;milliamperes;mA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 milliamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 milliampere", "%1 milliamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Microampere,
|
||||
1e-06,
|
||||
i18nc("electrical current unit symbol", "µA"),
|
||||
i18nc("unit description in lists", "microamperes"),
|
||||
i18nc("unit synonyms for matching user input", "microamp;microamps;microampere;microamperes;µA;uA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 microamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 microampere", "%1 microamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Nanoampere,
|
||||
1e-09,
|
||||
i18nc("electrical current unit symbol", "nA"),
|
||||
i18nc("unit description in lists", "nanoamperes"),
|
||||
i18nc("unit synonyms for matching user input", "nanoamp;nanoamps;nanoampere;nanoamperes;nA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 nanoamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 nanoampere", "%1 nanoamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Picoampere,
|
||||
1e-12,
|
||||
i18nc("electrical current unit symbol", "pA"),
|
||||
i18nc("unit description in lists", "picoamperes"),
|
||||
i18nc("unit synonyms for matching user input", "picoamp;picoamps;picoampere;picoamperes;pA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 picoamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 picoampere", "%1 picoamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Femtoampere,
|
||||
1e-15,
|
||||
i18nc("electrical current unit symbol", "fA"),
|
||||
i18nc("unit description in lists", "femtoamperes"),
|
||||
i18nc("unit synonyms for matching user input", "femtoampere;femtoamperes;fA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 femtoamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 femtoampere", "%1 femtoamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Attoampere,
|
||||
1e-18,
|
||||
i18nc("electrical current unit symbol", "aA"),
|
||||
i18nc("unit description in lists", "attoamperes"),
|
||||
i18nc("unit synonyms for matching user input", "attoampere;attoamperes;aA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 attoamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 attoampere", "%1 attoamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Zeptoampere,
|
||||
1e-21,
|
||||
i18nc("electrical current unit symbol", "zA"),
|
||||
i18nc("unit description in lists", "zeptoamperes"),
|
||||
i18nc("unit synonyms for matching user input", "zeptoampere;zeptoamperes;zA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 zeptoamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 zeptoampere", "%1 zeptoamperes")));
|
||||
|
||||
d->addUnit(UnitPrivate::makeUnit(ElectricalCurrentCategory,
|
||||
Yoctoampere,
|
||||
1e-24,
|
||||
i18nc("electrical current unit symbol", "yA"),
|
||||
i18nc("unit description in lists", "yoctoamperes"),
|
||||
i18nc("unit synonyms for matching user input", "yoctoampere;yoctoamperes;yA"),
|
||||
symbolString,
|
||||
ki18nc("amount in units (real)", "%1 yoctoamperes"),
|
||||
ki18ncp("amount in units (integer)", "%1 yoctoampere", "%1 yoctoamperes")));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
} // KUnitConversion namespace
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2010 Petri Damstén <damu@iki.fi>
|
||||
* SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
|
||||
* SPDX-FileCopyrightText: 2014 Garret Wassermann <gwasser@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef ELECTRICALCURRENT_P_H
|
||||
#define ELECTRICALCURRENT_P_H
|
||||
|
||||
#include "unitcategory_p.h"
|
||||
|
||||
namespace KUnitConversion
|
||||
{
|
||||
namespace ElectricalCurrent
|
||||
{
|
||||
UnitCategory makeCategory();
|
||||
};
|
||||
|
||||
} // KUnitConversion namespace
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue