1/*
2 * SPDX-FileCopyrightText: 2007-2009 Petri Damstén <damu@iki.fi>
3 * SPDX-FileCopyrightText: 2014 John Layt <jlayt@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#ifndef KUNITCONVERSION_UNIT_P_H
9#define KUNITCONVERSION_UNIT_P_H
10
11#include "unit.h"
12#include "unitcategory.h"
13#include "unitcategory_p.h"
14
15#include <KLocalizedString>
16
17namespace KUnitConversion
18{
19class UnitPrivate : public QSharedData
20{
21public:
22 UnitPrivate();
23
24 UnitPrivate(CategoryId categoryId,
25 UnitId id,
26 qreal multiplier,
27 const QString &symbol,
28 const QString &description,
29 const QString &matchString,
30 const KLocalizedString &symbolString,
31 const KLocalizedString &realString,
32 const KLocalizedString &integerString);
33
34 virtual ~UnitPrivate();
35
36 UnitPrivate *clone();
37 bool operator==(const UnitPrivate &other) const;
38 bool operator!=(const UnitPrivate &other) const;
39
40 void setUnitMultiplier(qreal multiplier);
41 qreal unitMultiplier() const;
42
43 virtual qreal toDefault(qreal value) const;
44 virtual qreal fromDefault(qreal value) const;
45
46 static inline Unit makeUnit(UnitPrivate *dd)
47 {
48 return Unit(dd);
49 }
50 static inline Unit makeUnit(CategoryId categoryId,
51 UnitId id,
52 qreal multiplier,
53 const QString &symbol,
54 const QString &description,
55 const QString &matchString,
56 const KLocalizedString &symbolString,
57 const KLocalizedString &realString,
58 const KLocalizedString &integerString)
59 {
60 return Unit(new UnitPrivate(categoryId, id, multiplier, symbol, description, matchString, symbolString, realString, integerString));
61 }
62
63 CategoryId m_categoryId;
64 UnitId m_id;
65 qreal m_multiplier;
66 QString m_symbol;
67 QString m_description;
68 QString m_matchString;
69 KLocalizedString m_symbolString;
70 KLocalizedString m_realString;
71 KLocalizedString m_integerString;
72 UnitCategoryPrivate *m_category = nullptr; // emulating a weak_ptr, as we otherwise have an undeleteable reference cycle
73};
74
75} // KUnitConversion namespace
76
77#endif // KUNITCONVERSION_UNIT_P_H
78

source code of kunitconversion/src/unit_p.h