electronegativityPauling/**< the electronegativity in the definition of Pauling*/,
radiusCovalent/**< the covalent radius */,
radiusVDW/**< the van der Waals radius */,
- meltingpoint,
- boilingpoint,
- periodTableBlock,
- nameOrigin,
- orbit,
- period
+ meltingpoint/**< the meltingpoint */,
+ boilingpoint/**< the boilingpoint */,
+ periodTableBlock/**< the block of the element */,
+ nameOrigin/**< the origin of the name */,
+ orbit/**< the quantumorbit of the element */,
+ period/**< the period of the element */,
+ date/**< date of discovery of the element. When 0, the element has been known in ancient times. */,
+ discoverer/** The name of the discoverer(s) */
};
/**
/**
* Set the data of this object to @p v
+ * @param v the value of the object
*/
void setData( QVariant v ){
m_value = v;
return m_unit;
}
+ /**
+ * set the unit of this object to @p unit
+ * @param the BlueObeliskUnit of this object
+ */
void setUnit( BlueObeliskUnit unit ){
m_unit = unit;
}
bool ElementSaxParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs)
{
- if (localName == "elementType") {
+ if (localName == "elementType")
+ {
currentElement_ = new Element();
inElement_ = true;
- } else if (inElement_ && localName == "scalar") {
- for (int i = 0; i < attrs.length(); ++i) {
+ } else if (inElement_ && localName == "scalar")
+ {
+ for (int i = 0; i < attrs.length(); ++i)
+ {
+ if ( attrs.localName( i ) == "unit" )
+ {
+ currentUnit_ = unit( attrs.value( i ) );
+ continue;
+ }
if (attrs.value(i) == "bo:atomicNumber")
inAtomicNumber_ = true;
elements_.append(currentElement_);
currentElement_ = 0;
+ currentDataObject_ = 0;
inElement_ = false;
}
+ else if ( localName == "scalar" )
+ {
+ if ( currentUnit_ != ChemicalDataObject::noUnit )
+ currentDataObject_->setUnit( currentUnit_ );
+
+ currentUnit_ = ChemicalDataObject::noUnit;
+ }
return true;
}
bool ElementSaxParser::characters(const QString &ch)
{
- ChemicalDataObject *dataobject = new ChemicalDataObject();
+ currentDataObject_ = new ChemicalDataObject();
ChemicalDataObject::BlueObelisk type;
QVariant value;
else//it is a non known value. Do not create a wrong object but return
return true;
- dataobject->setData( value );
- dataobject->setType( type );
+ currentDataObject_->setData( value );
+ currentDataObject_->setType( type );
if ( currentElement_ )
- currentElement_->addData( dataobject );
+ currentElement_->addData( currentDataObject_ );
return true;
}
{
return elements_;
}
+
+ChemicalDataObject::BlueObeliskUnit ElementSaxParser::unit( const QString& unit )
+{
+ if ( unit == "bo:kelvin" )
+ return ChemicalDataObject::kelvin;
+ else if ( unit == "bo:ev" )
+ return ChemicalDataObject::ev;
+ else if ( unit == "bo:nm" )
+ return ChemicalDataObject::nm;
+ else if ( unit == "bo:pm" )
+ return ChemicalDataObject::pm;
+ else if ( unit == "bo:noUnit" )
+ return ChemicalDataObject::noUnit;
+ else
+ return ChemicalDataObject::noUnit;
+}
#include <qxml.h>
+#include "chemicaldataobject.h"
+
class Element;
+
+/**
+ * @author Carsten Niehaus <cniehaus@kde.org>
+ */
class ElementSaxParser : public QXmlDefaultHandler
{
public:
+ /**
+ * Constructor
+ */
ElementSaxParser();
bool startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs);
QList<Element*> getElements();
private:
+ ChemicalDataObject *currentDataObject_;
+ ChemicalDataObject::BlueObeliskUnit currentUnit_;
+
+ /**
+ * @return the BlueObeliskUnit of a ChemicalDataObject corresponding to @p text
+ * @param text the attribute-text of the XML parsed
+ */
+ ChemicalDataObject::BlueObeliskUnit unit( const QString& text );
+
Element *currentElement_;
QList<Element*> elements_;
bool inElement_;