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

KUnitConversion

unit.h

Go to the documentation of this file.
00001 /*
00002  *   Copyright (C) 2007-2009 Petri Damstén <damu@iki.fi>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #ifndef KUNITCONVERSION_UNIT_H
00021 #define KUNITCONVERSION_UNIT_H
00022 
00023 #include <QtCore/QString>
00024 #include <ksharedptr.h>
00025 #include "kunitconversion_export.h"
00026 
00027 class KLocalizedString;
00028 
00029 namespace KUnitConversion
00030 {
00031 
00032 class UnitCategory;
00033 
00034 class KUNITCONVERSION_EXPORT Complex
00035 {
00036 public:
00037     Complex();
00038     virtual ~Complex();
00039     virtual double toDefault(double) const = 0;
00040     virtual double fromDefault(double) const = 0;
00041 };
00042 
00043 class KUNITCONVERSION_EXPORT Unit : public QSharedData
00044 {
00045 public:
00046     Unit(UnitCategory* category, int id, double multiplier, const QString& symbol,
00047          const QString& description, const QString& match,
00048          const KLocalizedString& real, const KLocalizedString& integer);
00049     Unit(UnitCategory* category, int id, const Complex* complex, const QString& symbol,
00050          const QString& description, const QString& match,
00051          const KLocalizedString& real, const KLocalizedString& integer);
00052     virtual ~Unit();
00053 
00057     QString description() const;
00058 
00062     QString symbol() const;
00063 
00074     QString toString(double value, int fieldWidth = 0, char format = 'g', int precision = -1,
00075                      const QChar& fillChar = QLatin1Char(' ')) const;
00076 
00087     QString toSymbolString(double value, int fieldWidth = 0, char format = 'g',
00088                            int precision = -1, const QChar& fillChar = QLatin1Char(' ')) const;
00089 
00093     double multiplier() const;
00094 
00098     void setMultiplier(double multiplier);
00099 
00103     UnitCategory* category() const;
00104 
00108     bool isValid() const;
00109 
00113     int id() const;
00114 
00115 protected:
00116     double toDefault(double value) const;
00117     double fromDefault(double value) const;
00118 
00119 private:
00120     friend class UnitCategory;
00121     class Private;
00122     Private* const d;
00123 };
00124 
00125 typedef KSharedPtr<Unit> UnitPtr;
00126 
00127 #define UP(id, m, s, d, sy, r, i) \
00128     (KUnitConversion::UnitPtr(new KUnitConversion::Unit(this, id, m, s, d, sy, r, i)))
00129 #define U(id, m, s, d, sy, r, i) (new KUnitConversion::Unit(this, id, m, s, d, sy, r, i))
00130 
00131 } // KUnitConversion namespace
00132 
00133 #endif

KUnitConversion

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • 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
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal