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

kalzium/libscience

  • sources
  • kde-4.12
  • kdeedu
  • kalzium
  • libscience
chemicaldataobject.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Carsten Niehaus *
3  * cniehaus@kde.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "chemicaldataobject.h"
22 #include <kunitconversion/converter.h>
23 #include <kdebug.h>
24 
25 #include <QLatin1String>
26 
27 class ChemicalDataObjectPrivate : public QSharedData
28 {
29 public:
30  ChemicalDataObjectPrivate();
31  ~ChemicalDataObjectPrivate();
32 
33  QVariant m_value;
34  QVariant m_errorValue;
35  ChemicalDataObject::BlueObelisk m_type;
36  int m_unit;
37 };
38 
39 //########################
40 ChemicalDataObjectPrivate::ChemicalDataObjectPrivate()
41  : QSharedData()
42 {
43 }
44 
45 ChemicalDataObjectPrivate::~ChemicalDataObjectPrivate()
46 {
47 }
48 //##############
49 
50 ChemicalDataObject::ChemicalDataObject( const QVariant& v, BlueObelisk type, const QVariant& errorValue )
51  : d(new ChemicalDataObjectPrivate)
52 {
53  d->m_value = v;
54  d->m_errorValue = errorValue;
55  d->m_type = type;
56  d->m_unit = KUnitConversion::NoUnit;
57 }
58 
59 ChemicalDataObject::ChemicalDataObject()
60  : d(new ChemicalDataObjectPrivate)
61 {
62  d->m_errorValue = QVariant();
63  d->m_unit = KUnitConversion::NoUnit;
64 }
65 
66 ChemicalDataObject::ChemicalDataObject(const ChemicalDataObject &other)
67  : d(other.d)
68 {
69 }
70 
71 ChemicalDataObject::~ChemicalDataObject()
72 {
73 }
74 
75 ChemicalDataObject& ChemicalDataObject::operator=(const ChemicalDataObject &other)
76 {
77  d = other.d;
78  return *this;
79 }
80 
81 bool ChemicalDataObject::operator==( const int v ) const
82 {
83  if ( d->m_value.type() != QVariant::Int )
84  return false;
85 
86  return d->m_value.toInt() == v;
87 }
88 
89 bool ChemicalDataObject::operator==( const bool v ) const
90 {
91  if ( d->m_value.type() != QVariant::Bool )
92  return false;
93 
94  return d->m_value.toBool() == v;
95 }
96 
97 bool ChemicalDataObject::operator==( const double v ) const
98 {
99  if ( d->m_value.type() != QVariant::Double )
100  return false;
101 
102  return d->m_value.toDouble() == v;
103 }
104 
105 bool ChemicalDataObject::operator==( const QString& v ) const
106 {
107  if ( d->m_value.type() != QVariant::String )
108  return false;
109 
110  return d->m_value.toString() == v;
111 }
112 
113 bool ChemicalDataObject::operator==(const ChemicalDataObject &other) const
114 {
115  return d == other.d;
116 }
117 
118 bool ChemicalDataObject::operator!=(const ChemicalDataObject &other) const
119 {
120  return d != other.d;
121 }
122 
123 QString ChemicalDataObject::valueAsString() const
124 {
125  return d->m_value.toString();
126 }
127 
128 ChemicalDataObject::BlueObelisk ChemicalDataObject::type() const
129 {
130  return d->m_type;
131 }
132 
133 QVariant ChemicalDataObject::value() const
134 {
135  return d->m_value;
136 }
137 
138 QVariant ChemicalDataObject::errorValue() const
139 {
140  return d->m_errorValue;
141 }
142 
143 void ChemicalDataObject::setUnit( int unit )
144 {
145  d->m_unit = unit;
146 }
147 
148 int ChemicalDataObject::unit() const
149 {
150  return d->m_unit;
151 }
152 
153 void ChemicalDataObject::setData( const QVariant& v )
154 {
155  d->m_value = v;
156 }
157 
158 void ChemicalDataObject::setErrorValue( const QVariant& v )
159 {
160  d->m_errorValue = v;
161 }
162 
163 void ChemicalDataObject::setType( BlueObelisk type )
164 {
165  d->m_type = type;
166 }
167 
168 void ChemicalDataObject::setType( int type )
169 {
170  d->m_type = ( ChemicalDataObject::BlueObelisk ) type;
171 }
172 
173 QString ChemicalDataObject::unitAsString() const
174 {
175  return KUnitConversion::Converter().unit(d->m_unit).data()->symbol();
176 }
ChemicalDataObject::operator=
ChemicalDataObject & operator=(const ChemicalDataObject &other)
Definition: chemicaldataobject.cpp:75
ChemicalDataObject::unit
int unit() const
Definition: chemicaldataobject.cpp:148
ChemicalDataObject::type
BlueObelisk type() const
Definition: chemicaldataobject.cpp:128
ChemicalDataObject::operator==
bool operator==(const int v) const
Compare the value v with the data of this object.
Definition: chemicaldataobject.cpp:81
ChemicalDataObject::unitAsString
QString unitAsString() const
Definition: chemicaldataobject.cpp:173
ChemicalDataObject::setType
void setType(BlueObelisk type)
Definition: chemicaldataobject.cpp:163
ChemicalDataObject::operator!=
bool operator!=(const ChemicalDataObject &other) const
Definition: chemicaldataobject.cpp:118
ChemicalDataObject::errorValue
QVariant errorValue() const
Definition: chemicaldataobject.cpp:138
ChemicalDataObject::setUnit
void setUnit(int unit)
set the unit of this object to unit
Definition: chemicaldataobject.cpp:143
ChemicalDataObject
A ChemicalDataObject is an object which contains information about a chemical element.
Definition: chemicaldataobject.h:38
chemicaldataobject.h
ChemicalDataObject::ChemicalDataObject
ChemicalDataObject()
Constructor.
Definition: chemicaldataobject.cpp:59
ChemicalDataObject::setData
void setData(const QVariant &v)
Set the data of this object to v.
Definition: chemicaldataobject.cpp:153
ChemicalDataObject::valueAsString
QString valueAsString() const
Every ChemicalDataObject contains one data.
Definition: chemicaldataobject.cpp:123
ChemicalDataObject::BlueObelisk
BlueObelisk
The BlueObelisk-project defines in their XML file the dataset with the names of the enum plus "bo:"...
Definition: chemicaldataobject.h:47
ChemicalDataObject::~ChemicalDataObject
~ChemicalDataObject()
Destructor.
Definition: chemicaldataobject.cpp:71
ChemicalDataObject::setErrorValue
void setErrorValue(const QVariant &v)
Set the error value of this object to v.
Definition: chemicaldataobject.cpp:158
ChemicalDataObject::value
QVariant value() const
Every ChemicalDataObject contains one data.
Definition: chemicaldataobject.cpp:133
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:31 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalzium/libscience

Skip menu "kalzium/libscience"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



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