]> Git trees. - libqmvoc.git/commitdiff
* Introducing ChemicalDataObject. Lets see if this new concept works out or not
authorCarsten Niehaus <cniehaus@gmx.de>
Tue, 18 Oct 2005 10:01:57 +0000 (10:01 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Tue, 18 Oct 2005 10:01:57 +0000 (10:01 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=471636

libscience/element.cpp
libscience/element.h
libscience/elementparser.cpp
libscience/elementparser.h

index f6a919cfbfdc999626b088d16da237c01e0bf9c0..f7cc6a87fc841066e957f247e5cd4e5a8c8fd67a 100644 (file)
@@ -28,6 +28,8 @@
 #include <kurl.h>
 #include <kstandarddirs.h>
 
+#include <QVariant>
+
 Element::Element()
 {
        m_radioactive = false;
@@ -266,3 +268,18 @@ double Element::radius( RADIUSTYPE type )
        return 0.0;
 }
 
+
+ChemicalDataObject::ChemicalDataObject( QVariant v, BlueObelisk type )
+{
+       m_value = v;
+       m_type = type;
+};
+
+ChemicalDataObject::ChemicalDataObject() 
+{
+}
+
+QString ChemicalDataObject::valueAsString()
+{
+       return m_value.toString();
+}
index d0bb65f1619e54c1d990679d35a090b0ed13a89b..0c88c40e5ac20583549e6b87c1d0ca51d8ba4884 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <QColor>
 #include <QList>
+#include <QVariant>
 
 #include <kdemacros.h>
 
@@ -100,6 +101,10 @@ class Element{
                        return m_origin;
                }
 
+               /**
+                * The orbit of for example Lithium (Li) is "He 2s1"
+                * @return the orbital structure of the element
+                */
                QString orbits() const{
                        return m_orbits;
                }
@@ -478,5 +483,105 @@ class Element{
                doubleList m_ionenergies;
 };
 
+/**
+ * @author Carsten Niehaus <cniehaus@kde.org
+ */
+class ChemicalDataObject
+{
+       public:
+               /**
+                * The BlueObelisk-project defines in their xml-file the dataset
+                * with the names of the enum plus 'bo:'. So for symbol
+                * it is 'bo:symbol'. To avoid confusion I will choose the very
+                * same naming
+                */
+               enum BlueObelisk
+               {
+                       atomicNumber = 0 /**< The atomic number of the element */,
+                       symbol/**< the symbol of the element */,
+                       name/**< The IUPAC-name of the element */,
+                       mass/**< # IUPAC Official Masses */,
+                       exactMass/**< exact masses of the most common isotopes for each element */,
+                       ionization/**< First inizationenergy */,
+                       electronAffinity/**< the electronaffinity of the element */,
+                       electronegativityPauling/**< the electronegativity in the definition of Pauling*/,
+                       radiusCovalent/**< the covalent radius */,
+                       radiusVDW/**< the van der Waals radius */
+               };
+               
+               /**
+                * public constructor
+                */
+               ChemicalDataObject();
+
+               /**
+                * public constructor
+                * @param v the data of the object
+                * @param type the type of the data
+                */
+               ChemicalDataObject(QVariant v, 
+                               BlueObelisk type);
+
+               /**
+                * set the data of this object to @p v
+                */
+               void setData( QVariant *v ){
+                       m_value = v;
+               }
+               
+               /**
+                * public destructor
+                */
+               ~ChemicalDataObject();
+
+               /**
+                * Every ChemicalDataObject contains one data. For example a
+                * integer value which represents the boilingpoint. This method
+                * returns the value as a QString
+                * 
+                * For bool, the returned string will be "false" or "true"
+                * For a QString, the QString will be returned
+                * For a int or double, the value will be returned as a QString
+                *
+                * @return the value as a QString.
+                */
+               QString valueAsString();
+               
+               /**
+                * Every ChemicalDataObject contains one data. For example a
+                * integer value which represents the boilingpoint. This method
+                * returns the value as a QVariant
+                *
+                * @return the value as a QVariant.
+                */
+               QVariant value() const{
+                       return m_value;
+               }
+
+               /**
+                * @return the type of dataset of this object
+                */
+               BlueObelisk type() const{
+                       return m_type;
+               }
+
+               /**
+                * @param type the type of this object
+                */
+               void setType( BlueObelisk type ){
+                       m_type = type;
+               }
+
+               /**
+                * @overload
+                */
+               void setType( int type ){
+                       m_type = ( BlueObelisk ) type;
+               }
+
+       private:
+               QVariant m_value;
+               BlueObelisk m_type;
+};
 
 #endif
index b02d9f8ff8f9fb9224a91c6f2ce3a21ee68d6fa5..59ebcb3f61c06a4e6490cb9cc4bc00af1820a876 100644 (file)
@@ -19,7 +19,6 @@ email                : cniehaus@kde.org
 #include <QStringList>
 
 #include <kdebug.h>
-#include <kurl.h>
 
 ElementSaxParser::ElementSaxParser()
 : QXmlDefaultHandler(), currentElement_(0), 
index d3123addc9aa52af4e97d621417d26af49d88dd1..af1aa5b1b132e73cd271db06685e5fe031450405 100644 (file)
  *                                                                         *
  ***************************************************************************/
 
-#include <QString>
 #include <QList>
-#include <QStringList>
-#include <qdom.h>
 
 #include <qxml.h>
 
 class Element;
 
-//X /**
-//X  * This class gives access to the elements which are listed in a CML-file
-//X  * @author Carsten Niehaus <cniehaus@kde.org>
-//X  */
-//X class ElementParser
-//X {
-//X    public:
-//X            /**
-//X             * @return the Element with the symbol symbol
-//X             * @param dataDocument the document to parse
-//X             * @param symbol the symbol of the Element which is looked for
-//X             */
-//X            static Element* loadElement( const QString& symbol, const QDomDocument& dataDocument );
-//X            
-//X            /**
-//X             * @return the element represented in the QDomeElement @p element
-//X             * @param element the XML-representation of the Element
-//X             */
-//X            static Element* loadElement( const QDomElement& element );
-//X 
-//X            /**
-//X             * @return all chemical elements in the xml-file
-//X             * @param dataDocument the document to parse
-//X             */
-//X            static QList<Element*> loadAllElements(const QDomDocument& dataDocument);
-//X            
-//X    private:
-//X            /**
-//X             * @return a QStringList with the symbols of all known elements
-//X             * @param dataDocument the document to parse
-//X             */
-//X            static QStringList loadElementSymbols(const QDomDocument& dataDocument);
-//X 
-//X };
-
-
 class ElementSaxParser : public QXmlDefaultHandler
 {
        public:
@@ -76,7 +37,7 @@ class ElementSaxParser : public QXmlDefaultHandler
                bool inElement_;
                bool inName_,
                         inMass_,
-                        inSymbol_,
-                        inAtomicNumber_;
+                        inAtomicNumber_,
+                        inSymbol_;
 };
 #endif // ELEMENTPARSER_H