KUnitConversion
value.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_VALUE_H 00021 #define KUNITCONVERSION_VALUE_H 00022 00023 #include <QtCore/QString> 00024 #include "unit.h" 00025 #include "kunitconversion_export.h" 00026 00027 class QVariant; 00028 00029 namespace KUnitConversion 00030 { 00031 00032 class KUNITCONVERSION_EXPORT Value 00033 { 00034 public: 00035 Value(); 00036 Value(double n, UnitPtr u); 00037 Value(double n, const QString& u); 00038 Value(double n, int u); 00039 Value(const QVariant& n, const QString& u); 00040 ~Value(); 00041 00047 bool isValid() const; 00048 00059 QString toString(int fieldWidth = 0, char format = 'g', int precision = -1, 00060 const QChar& fillChar = QLatin1Char(' ')) const; 00061 00072 QString toSymbolString(int fieldWidth = 0, char format = 'g', int precision = -1, 00073 const QChar& fillChar = QLatin1Char(' ')) const; 00074 00078 double number() const; 00079 00084 Value& round(uint decimals); 00085 00089 UnitPtr unit() const; 00090 00094 Value convertTo(UnitPtr unit) const; 00095 00099 Value convertTo(int unit) const; 00100 00104 Value convertTo(const QString& unit) const; 00105 00106 Value& operator=(const Value&); 00107 00108 private: 00109 class Private; 00110 Private* const d; 00111 }; 00112 00113 } // KUnitConversion namespace 00114 00115 #endif
KDE 4.6 API Reference