]> Git trees. - libqmvoc.git/commitdiff
Commiting my new operators. I need some help here, perhaps pino can look at this
authorCarsten Niehaus <cniehaus@gmx.de>
Tue, 18 Oct 2005 17:53:55 +0000 (17:53 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Tue, 18 Oct 2005 17:53:55 +0000 (17:53 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=471765

libscience/chemicaldataobject.cpp
libscience/chemicaldataobject.h
libscience/element.cpp
libscience/element.h

index 96c2c4b98aac75e0bd480401d4d636452b42906b..1616486b0a6aa7e81acd9917513eae04ea62803b 100644 (file)
@@ -33,3 +33,25 @@ QString ChemicalDataObject::valueAsString()
 {
        return m_value.toString();
 }
+
+bool ChemicalDataObject::operator==( const int v )
+{
+       if ( m_value.type() != QVariant::Int )  
+               return false;
+       
+       if ( m_value.toInt() == v )
+               return true;
+       
+       return false;
+}
+
+bool ChemicalDataObject::operator==( const QString& v )
+{
+       if ( m_value.type() != QVariant::String )       
+               return false;
+
+       if ( m_value.toString() == v )
+               return true;
+
+       return false;
+}
index e5d32572b4b6e3adaa79a38347a9a2e7b4ffaa77..f07a78f5d4c3cad71821d438c6281a01f79fb2c3 100644 (file)
@@ -53,6 +53,9 @@ class ChemicalDataObject
                        radiusCovalent/**< the covalent radius */,
                        radiusVDW/**< the van der Waals radius */
                };
+
+               bool operator== ( const int );
+               bool operator== ( const QString& );
                
                /**
                 * public constructor
index 22b5f4d940750b40eea16ceec29321da32b0f25f..0b5de82d82274ca11cfc02607fbaea92db752138 100644 (file)
@@ -38,12 +38,14 @@ Element::Element()
        m_abundance = 0;
 }
 
-QVariant Element::data(ChemicalDataObject::BlueObelisk type)
+ChemicalDataObject* Element::data(ChemicalDataObject::BlueObelisk type)
 {
        foreach( ChemicalDataObject*o, dataList ) {
                if ( o->type() == type )
-                       return o->value();
+                       return o;
        }
+
+       return 0;
 }
 
 QString Element::dataAsString(ChemicalDataObject::BlueObelisk type)
@@ -52,6 +54,7 @@ QString Element::dataAsString(ChemicalDataObject::BlueObelisk type)
                if ( o->type() == type )
                        return o->valueAsString();
        }
+       return "";
 }
 
 Isotope* Element::isotopeByNucleons( int numberOfNucleons )
index cbe682b841b0b5fb7a684addec79118a37192da2..716db5ec060bd0536107703c92b1067ecc8c693e 100644 (file)
@@ -431,17 +431,17 @@ class Element{
                        return m_Color; 
                }
 
-               QList<ChemicalDataObject*> dataList;
-
                void addData( ChemicalDataObject*o ){
                        dataList.append( o );
                }
 
-               QVariant data( ChemicalDataObject::BlueObelisk type );
+               ChemicalDataObject* data( ChemicalDataObject::BlueObelisk type );
                
                QString dataAsString( ChemicalDataObject::BlueObelisk type );
 
        private:
+               QList<ChemicalDataObject*> dataList;
+
                /**
                 * the integer num represents the number of the element
                 */