#ifndef ISOTOPE_H
#define ISOTOPE_H
/***************************************************************************
- * Copyright (C) 2005 by Carsten Niehaus *
+ * Copyright (C) 2005-2008 by Carsten Niehaus *
* cniehaus@kde.org *
* *
* This program is free software; you can redistribute it and/or modify *
QString spin() const;
+ /**
+ * @return the magnetic moment of the Isotope
+ */
QString magmoment() const;
QString abundance() const;
+ /**
+ * @return for example '17' if halflife of this Isotope is 17 seconds
+ * @ref halflife()
+ */
double halflife() const;
/**
- * @return the ChemicalDataObject of the halflife of the Isotope
+ * @return for example 's' if the unit of the halflife of this Isotope is given in
+ * seconds
*/
- ChemicalDataObject halflifeObject() const;
+ QString halflifeUnit() const;
/**
* add the ChemicalDataObject @p o
*/
void addData( ChemicalDataObject o );
+ /**
+ * Set the number of nucleons of the isotope to @number
+ */
void setNucleons( int number );
/**
/***************************************************************************
-copyright : (C) 2005 by Carsten Niehaus
+copyright : (C) 2005-2008 by Carsten Niehaus
email : cniehaus@kde.org
***************************************************************************/
/***************************************************************************
#include "chemicaldataobject.h"
#include "isotope.h"
-#include <kdebug.h>
+#include <QDebug>
class IsotopeParser::Private
bool IsotopeParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs)
{
-//X kDebug() << "IsotopeParser::startElement()";
if (localName == "isotopeList")
{
d->inElement = true;
if ( attrs.localName( i ) == "id" )
d->currentElementSymbol = attrs.value( i );
-//X kDebug() << "Symbol of the current Element: " << attrs.value( i );
}
} else if ( d->inElement && localName == "isotope")
{
-//X kDebug() << "setting inIsotope true!";
d->currentIsotope = new Isotope();
d->currentIsotope->addData( ChemicalDataObject( QVariant( d->currentElementSymbol ), ChemicalDataObject::symbol ) );
d->inIsotope = true;
if ( attrs.localName( i ) == "number" )
{
d->currentIsotope->setNucleons( attrs.value( i ).toInt() );
-//X kDebug() << attrs.value( i ).toInt();
}
}
} else if (d->inIsotope && localName == "scalar")
else if (attrs.value(i) == "bo:halfLife"){
for (int i = 0; i < attrs.length(); ++i)
{
- qDebug() << attrs.localName( i );
if (attrs.localName(i) == "units") {
- if ( attrs.value(i) == "siUnits:s" )
- {
+ if ( attrs.value(i) == "siUnits:s" ) {
d->currentUnit = ChemicalDataObject::s;
- }
- else if ( attrs.value(i) == "siUnits:y" )
- {
+ } else if ( attrs.value(i) == "siUnits:y" ) {
d->currentUnit = ChemicalDataObject::y;
} else {
d->currentUnit = ChemicalDataObject::noUnit;
}
}
}
+
d->currentDataObject.setUnit( d->currentUnit );
d->inHalfLife = true;
}
bool IsotopeParser::endElement( const QString&, const QString& localName, const QString& )
{
-//X kDebug() << "IsotopeParser::endElement()";
if ( localName == "isotope" )
{
d->isotopes.append(d->currentIsotope);
}
else if ( localName == "isotopeList" )
{//a new list of isotopes start...
-//X kDebug() << "setting d->inElement FALSE";
d->inElement = false;
}
bool IsotopeParser::characters(const QString &ch)
{
-//X kDebug() << "IsotopeParser::characters() with ch: " << ch;
- d->currentDataObject = ChemicalDataObject();
ChemicalDataObject::BlueObelisk type;
QVariant value;
}
else if (d->inHalfLife) {
value = ch.toDouble();
- if(ch=="-1"){value=-2;}
type = ChemicalDataObject::halfLife;
d->inHalfLife = false;
}
/***************************************************************************
- * Copyright (C) 2005, 2006 by Carsten Niehaus <cniehaus@kde.org> *
+ * Copyright (C) 2005, 2006, 2008 by Carsten Niehaus <cniehaus@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
foreach( Isotope* i, v ){
if ( i )
{
- if (i->nucleons() == 50 ){
+//X if (i->nucleons() == 50 ){
+//X qDebug() << " Isotope of " << i->parentElementSymbol() << " with a mass of " << i->mass();
+//X qDebug() << " Halflife: " << i->halflife() << i->halflifeUnit( );
+//X }
+ if (i->parentElementSymbol() == "Ti" ){
qDebug() << " Isotope of " << i->parentElementSymbol() << " with a mass of " << i->mass();
- qDebug() << " Halflife: " << i->halflife() << i->halflifeObject().unitAsString( );
+ qDebug() << " Halflife: " << i->halflife() << i->halflifeUnit( );
}
}
}