]> Git trees. - libqmvoc.git/commitdiff
d-pointify
authorAlbert Astals Cid <tsdgeos@terra.es>
Sun, 23 Oct 2005 16:29:10 +0000 (16:29 +0000)
committerAlbert Astals Cid <tsdgeos@terra.es>
Sun, 23 Oct 2005 16:29:10 +0000 (16:29 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=473419

libscience/chemicaldataobject.cpp
libscience/chemicaldataobject.h

index 84a78b8fe50ac8c3e1080be826de7a6ce56757eb..a440336c7b97b47dbeac004d7c79665c6c70b163 100644 (file)
 
 #include <kdebug.h>
 
-ChemicalDataObject::ChemicalDataObject( const QVariant& v, BlueObelisk type )
+class ChemicalDataObjectPrivate
 {
-       m_value = v;
-       m_type = type;
-       m_unit = ChemicalDataObject::noUnit;
+       public:
+               QVariant m_value;
+               ChemicalDataObject::BlueObelisk m_type;
+               ChemicalDataObject::BlueObeliskUnit m_unit;
 };
 
-ChemicalDataObject::ChemicalDataObject() 
+ChemicalDataObject::ChemicalDataObject( const QVariant& v, BlueObelisk type ) : d(new ChemicalDataObjectPrivate()
 {
-       m_value = QVariant();
-       m_unit = ChemicalDataObject::noUnit;
+       d->m_value = v;
+       d->m_type = type;
+       d->m_unit = ChemicalDataObject::noUnit;
+};
+
+ChemicalDataObject::ChemicalDataObject() : d(new ChemicalDataObjectPrivate())
+{
+       d->m_value = QVariant();
+       d->m_unit = ChemicalDataObject::noUnit;
 }
 
 bool ChemicalDataObject::operator==( const int v ) const
 {
        kdDebug() << "ChemicalDataObject::operator==() with int" << endl;
-       if ( m_value.type() != QVariant::Int )  
+       if ( d->m_value.type() != QVariant::Int )       
                return false;
        
-       return m_value.toInt() == v;
+       return d->m_value.toInt() == v;
 }
 
 bool ChemicalDataObject::operator==( const bool v ) const
 {
        kdDebug() << "ChemicalDataObject::operator==() with bool" << endl;
-       if ( m_value.type() != QVariant::Bool ) 
+       if ( d->m_value.type() != QVariant::Bool )      
                return false;
        
-       return m_value.toBool() == v;
+       return d->m_value.toBool() == v;
 }
 
 bool ChemicalDataObject::operator==( const double v ) const
 {
        kdDebug() << "ChemicalDataObject::operator==() with double" << endl;
-       if ( m_value.type() != QVariant::Double )       
+       if ( d->m_value.type() != QVariant::Double )    
                return false;
        
-       return m_value.toDouble() == v;
+       return d->m_value.toDouble() == v;
 }
 
 bool ChemicalDataObject::operator==( const QString& v ) const
 {
        kdDebug() << "ChemicalDataObject::operator==() with QString" << endl;
-       if ( m_value.type() != QVariant::String )       
+       if ( d->m_value.type() != QVariant::String )    
                return false;
 
-       return m_value.toString() == v;
+       return d->m_value.toString() == v;
 }
 
 ChemicalDataObject::~ChemicalDataObject()
-{}
+{
+       delete d;
+}
 
 QString ChemicalDataObject::valueAsString() const
 {
-       return m_value.toString();
+       return d->m_value.toString();
 }
 
 ChemicalDataObject::BlueObelisk ChemicalDataObject::type() const
 {
-       return m_type;
+       return d->m_type;
 }
 
 QVariant ChemicalDataObject::value() const
 {
-       return m_value;
+       return d->m_value;
 }
 
 void ChemicalDataObject::setUnit( ChemicalDataObject::BlueObeliskUnit unit )
 {
-       m_unit = unit;
+       d->m_unit = unit;
 }
 
 ChemicalDataObject::BlueObeliskUnit ChemicalDataObject::unit() const
 {
-       return m_unit;
+       return d->m_unit;
 }
 
 void ChemicalDataObject::setData( const QVariant& v )
 {
-       m_value = v;
+       d->m_value = v;
 }
 
 void ChemicalDataObject::setType( BlueObelisk type )
 {
-       m_type = type;
+       d->m_type = type;
 }
 
 void ChemicalDataObject::setType( int type )
 {
-       m_type = ( ChemicalDataObject::BlueObelisk ) type;
+       d->m_type = ( ChemicalDataObject::BlueObelisk ) type;
 }
 
 QString ChemicalDataObject::dictRef() const
 {
        QString botype;
-       switch ( m_type ){
+       switch ( d->m_type ){
                case atomicNumber:
                        botype = "atomicNumber";
                        break;
@@ -181,7 +191,7 @@ QString ChemicalDataObject::dictRef() const
 QString ChemicalDataObject::unitAsString() const
 {
        QString bounit;
-       switch ( m_unit ){
+       switch ( d->m_unit ){
                case kelvin:
                        bounit = "kelvin";
                        break;
index dc294a472f61d74fee72a29b527b212b9400fd4d..2e95b80cac3911138c9f2204741f8b55542e81a0 100644 (file)
@@ -23,6 +23,8 @@
 #include <QVariant>
 #include <QString>
 
+class ChemicalDataObjectPrivate;
+
 /**
  * A ChemicalDataObject is an object which contains information about 
  * a chemical element. This can for example be a boiling point. The information
@@ -186,9 +188,7 @@ class ChemicalDataObject
                static BlueObeliskUnit unit( const QString& unitname );
                
        private:
-               QVariant m_value;
-               BlueObelisk m_type;
-               BlueObeliskUnit m_unit;
+               ChemicalDataObjectPrivate *d;
 };
 
 #endif // CHEMICALDATAOBJECT_H