From: Carsten Niehaus Date: Sat, 21 May 2005 09:56:27 +0000 (+0000) Subject: Make the ionisationenergies work again. No many how many ion.energies X-Git-Tag: v3.80.2~300^2~147 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=22771fb60cd75b05517b800c4cedcef0363834f6;p=libqmvoc.git Make the ionisationenergies work again. No many how many ion.energies Kalzium knows about :-) svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=416353 --- diff --git a/kalzium/src/element.cpp b/kalzium/src/element.cpp index a493b3d..a8e14ff 100644 --- a/kalzium/src/element.cpp +++ b/kalzium/src/element.cpp @@ -83,37 +83,33 @@ double Element::meanweight() return m_weight/m_number; } -const QString Element::adjustUnits( const int type ) +const QString Element::adjustUnits( const int type, double value ) { QString v = QString::null; - - double val = 0.0; //the value to convert - - if ( type == IE || type == IE2 ) //an ionization energy + if ( type == IE ) //an ionization energy { - if ( type == IE ) - val = ie(); - else - val = ie2(); - - if ( val == -1 ) - v = i18n( "Value unknown" ); - else + if ( Prefs::energies() == 0 ) { - if ( Prefs::energies() == 0 ) - { - val*=96.6; - v = QString::number( val ); - v.append( "kJ/mol" ); - } - else // use electronvolt - { - v = QString::number( val ); - v.append( "eV" ); - } + value*=96.6; + v = QString::number( value ); + v.append( "kJ/mol" ); + } + else // use electronvolt + { + v = QString::number( value ); + v.append( "eV" ); } } - else if ( type == BOILINGPOINT || type == MELTINGPOINT ) // convert a temperature + return v; +} + +const QString Element::adjustUnits( const int type ) +{ + QString v = QString::null; + + double val = 0.0; //the value to convert + + if ( type == BOILINGPOINT || type == MELTINGPOINT ) // convert a temperature { if ( type == BOILINGPOINT ) val = boiling(); @@ -442,7 +438,7 @@ KalziumDataObject::KalziumDataObject() } if (!layoutFile.open(IO_ReadOnly)) - KMessageBox::information( 0, i18n("data.xml io-errro"), i18n( "Loading File - IO_ReadOnly" ) ); + KMessageBox::information( 0, i18n("data.xml IO-error"), i18n( "Loading File - IO_ReadOnly" ) ); ///Check if document is well-formed if (!doc.setContent(&layoutFile)) @@ -502,6 +498,13 @@ EList KalziumDataObject::readData( QDomDocument &dataDocument ) QString oxydation = domElement.namedItem( "oxydation" ).toElement().text(); QString acidicbehaviour = domElement.namedItem( "acidicbehaviour" ).toElement().text(); QString isotopes = domElement.namedItem( "isotopes" ).toElement().text(); + + QDomNodeList elist = domElement.elementsByTagName( "energy" ); + QValueList ionlist; + for( uint i = 0; i < elist.length(); i++ ) + { + ionlist.append( elist.item( i ).toElement().text().toDouble() ); + } Element *e = new Element(); e->setDate(date); @@ -519,6 +522,7 @@ EList KalziumDataObject::readData( QDomDocument &dataDocument ) e->setOxydation(oxydation); e->setAcidicbehaviour(acidicbehaviour); e->setIsotopes(isotopes); + e->setIonisationList( ionlist ); e->setWeight( weight ); e->setEN( en ); diff --git a/kalzium/src/element.h b/kalzium/src/element.h index 11eaf9d..cbe74a8 100644 --- a/kalzium/src/element.h +++ b/kalzium/src/element.h @@ -33,6 +33,7 @@ struct coordinate; typedef QValueList EList; typedef QValueList CList; +typedef QValueList doubleList; /** * @short this class contains all Element-objects as @@ -104,6 +105,14 @@ class Element{ void setOxydation( QString value ) { m_oxstage = value; } void setAcidicbehaviour( QString value ) { m_acidbeh = value; } void setIsotopes( QString value ) { m_isotopes = value; } + + void setIonisationList( doubleList l ){ + m_ionenergies = l; + } + + QValueList ionisationList() const{ + return m_ionenergies; + } /** @@ -278,6 +287,11 @@ class Element{ */ const QString adjustUnits( const int type ); + /** + * needed for values stored in a QValueList + */ + const QString adjustUnits( const int type, double value ); + /** * missing */ @@ -342,6 +356,8 @@ class Element{ m_orbits, m_isotopes, m_scientist; + + doubleList m_ionenergies; public: /**