• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KUnitConversion

  • kunitconversion
unit.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#ifndef KUNITCONVERSION_UNIT_H
21#define KUNITCONVERSION_UNIT_H
22
23#include <QtCore/QString>
24#include <ksharedptr.h>
25#include "kunitconversion_export.h"
26
27class KLocalizedString;
28
29namespace KUnitConversion
30{
31
32class UnitCategory;
33
34class KUNITCONVERSION_EXPORT Complex
35{
36public:
37 Complex();
38 virtual ~Complex();
39 virtual double toDefault(double) const = 0;
40 virtual double fromDefault(double) const = 0;
41};
42
43class KUNITCONVERSION_EXPORT Unit : public QSharedData
44{
45public:
46 Unit(UnitCategory* category, int id, double multiplier, const QString& symbol,
47 const QString& description, const QString& match,
48 const KLocalizedString& real, const KLocalizedString& integer);
49 Unit(UnitCategory* category, int id, const Complex* complex, const QString& symbol,
50 const QString& description, const QString& match,
51 const KLocalizedString& real, const KLocalizedString& integer);
52 virtual ~Unit();
53
57 QString description() const;
58
62 QString symbol() const;
63
74 QString toString(double value, int fieldWidth = 0, char format = 'g', int precision = -1,
75 const QChar& fillChar = QLatin1Char(' ')) const;
76
87 QString toSymbolString(double value, int fieldWidth = 0, char format = 'g',
88 int precision = -1, const QChar& fillChar = QLatin1Char(' ')) const;
89
93 double multiplier() const;
94
98 void setMultiplier(double multiplier);
99
103 UnitCategory* category() const;
104
108 bool isValid() const;
109
113 int id() const;
114
115protected:
116 double toDefault(double value) const;
117 double fromDefault(double value) const;
118
119private:
120 friend class UnitCategory;
121 class Private;
122 Private* const d;
123};
124
125typedef KSharedPtr<Unit> UnitPtr;
126
127#define UP(id, m, s, d, sy, r, i) \
128 (KUnitConversion::UnitPtr(new KUnitConversion::Unit(this, id, m, s, d, sy, r, i)))
129#define U(id, m, s, d, sy, r, i) (new KUnitConversion::Unit(this, id, m, s, d, sy, r, i))
130
131} // KUnitConversion namespace
132
133#endif
KUnitConversion::Complex
Definition: unit.h:35
KUnitConversion::Complex::fromDefault
virtual double fromDefault(double) const =0
KUnitConversion::Complex::toDefault
virtual double toDefault(double) const =0
KUnitConversion::UnitCategory
Definition: unitcategory.h:34
KUnitConversion::Unit
Definition: unit.h:44
QSharedData
kunitconversion_export.h
KUnitConversion
Definition: converter.cpp:46
KUnitConversion::UnitPtr
KSharedPtr< Unit > UnitPtr
Definition: unit.h:125
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KUnitConversion

Skip menu "KUnitConversion"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal