1 | /* This file is part of the KDE Frameworks |
2 | |
3 | SPDX-FileCopyrightText: 2013 Alex Merry <alex.merry@kdemail.net> |
4 | SPDX-FileCopyrightText: 2013 John Layt <jlayt@kde.org> |
5 | SPDX-FileCopyrightText: 2010 Michael Leupold <lemma@confuego.org> |
6 | SPDX-FileCopyrightText: 2009 Michael Pyne <mpyne@kde.org> |
7 | SPDX-FileCopyrightText: 2008 Albert Astals Cid <aacid@kde.org> |
8 | |
9 | SPDX-License-Identifier: LGPL-2.0-or-later |
10 | */ |
11 | |
12 | #include "kformatprivate_p.h" |
13 | |
14 | KFormat::KFormat(const QLocale &locale) |
15 | : d(new KFormatPrivate(locale)) |
16 | { |
17 | } |
18 | |
19 | KFormat::KFormat(const KFormat &other) |
20 | : d(other.d) |
21 | { |
22 | } |
23 | |
24 | KFormat &KFormat::operator=(const KFormat &other) |
25 | { |
26 | d = other.d; |
27 | return *this; |
28 | } |
29 | |
30 | KFormat::~KFormat() |
31 | { |
32 | } |
33 | |
34 | QString KFormat::formatByteSize(double size, int precision, KFormat::BinaryUnitDialect dialect, KFormat::BinarySizeUnits units) const |
35 | { |
36 | return d->formatByteSize(size, precision, dialect, units); |
37 | } |
38 | |
39 | QString KFormat::formatValue(double value, KFormat::Unit unit, int precision, KFormat::UnitPrefix prefix, KFormat::BinaryUnitDialect dialect) const |
40 | { |
41 | return d->formatValue(value, unit, unitString: QString(), precision, prefix, dialect); |
42 | } |
43 | |
44 | QString KFormat::formatValue(double value, const QString &unit, int precision, KFormat::UnitPrefix prefix) const |
45 | { |
46 | return d->formatValue(value, unit: KFormat::Unit::Other, unitString: unit, precision, prefix, dialect: MetricBinaryDialect); |
47 | } |
48 | |
49 | // TODO KF6 Merge both methods |
50 | QString KFormat::formatValue(double value, const QString &unit, int precision, KFormat::UnitPrefix prefix, KFormat::BinaryUnitDialect dialect) const |
51 | { |
52 | return d->formatValue(value, unit: KFormat::Unit::Other, unitString: unit, precision, prefix, dialect); |
53 | } |
54 | |
55 | QString KFormat::formatDuration(quint64 msecs, KFormat::DurationFormatOptions options) const |
56 | { |
57 | return d->formatDuration(msecs, options); |
58 | } |
59 | |
60 | QString KFormat::formatDecimalDuration(quint64 msecs, int decimalPlaces) const |
61 | { |
62 | return d->formatDecimalDuration(msecs, decimalPlaces); |
63 | } |
64 | |
65 | QString KFormat::formatSpelloutDuration(quint64 msecs) const |
66 | { |
67 | return d->formatSpelloutDuration(msecs); |
68 | } |
69 | |
70 | QString KFormat::formatRelativeDate(const QDate &date, QLocale::FormatType format) const |
71 | { |
72 | return d->formatRelativeDate(date, format); |
73 | } |
74 | |
75 | QString KFormat::formatRelativeDateTime(const QDateTime &dateTime, QLocale::FormatType format) const |
76 | { |
77 | return d->formatRelativeDateTime(dateTime, format); |
78 | } |
79 | |
80 | #include "moc_kformat.cpp" |
81 | |