From: Carsten Niehaus Date: Sun, 1 Jan 2006 12:35:32 +0000 (+0000) Subject: * Oh, forgot this part of the commit. X-Git-Tag: v3.80.2~199 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=69335e37d5ae08612525a4c7d43735f79d8d21a1;p=libqmvoc.git * Oh, forgot this part of the commit. * tempunit.h -> type * other files: improve the API svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=493070 --- diff --git a/libscience/moleculeparser.cpp b/libscience/moleculeparser.cpp index 58a6531..398c601 100644 --- a/libscience/moleculeparser.cpp +++ b/libscience/moleculeparser.cpp @@ -109,9 +109,10 @@ ElementCountMap::multiply(int _factor) // class MoleculeParser -MoleculeParser::MoleculeParser() +MoleculeParser::MoleculeParser( const QList& list) : Parser() { + m_elementList = list; } @@ -294,28 +295,31 @@ MoleculeParser::getNextToken() Element * MoleculeParser::lookupElement( const QString& _name ) { - /** PORTING this cannot work because of course there is no KDO known in - * this library. We need to find a workaround here... - - QList elementList = KalziumDataObject::instance()->ElementList; +//X QList elementList = KalziumDataObject::instance()->ElementList; - //kdDebug() << "looking up " << _name << endl; + kdDebug() << "looking up " << _name << endl; - QList::ConstIterator it = elementList.constBegin(); - const QList::ConstIterator end = elementList.constEnd(); +//X QList::ConstIterator it = elementList.constBegin(); +//X const QList::ConstIterator end = elementList.constEnd(); - for (; it != end; ++it) { - if ( (*it)->dataAsVariant(ChemicalDataObject::symbol) == _name ) { + foreach( Element* e, m_elementList ){ + if ( e->dataAsVariant(ChemicalDataObject::symbol) == _name ) { kdDebug() << "Found element " << _name << endl; - return *it; + return e; } } +//X for (; it != end; ++it) { +//X if ( (*it)->dataAsVariant(ChemicalDataObject::symbol) == _name ) { +//X kdDebug() << "Found element " << _name << endl; +//X return *it; +//X } +//X } + //if there is an error make m_error true. m_error = true; kdDebug() << k_funcinfo << "no such element, parsing error!: " << _name << endl; - */ return NULL; } diff --git a/libscience/moleculeparser.h b/libscience/moleculeparser.h index 57342ed..d51cc77 100644 --- a/libscience/moleculeparser.h +++ b/libscience/moleculeparser.h @@ -170,9 +170,11 @@ class MoleculeParser : public Parser { public: /** + * @param list This list of chemical elements will be used internally + * for searching and matching with searched strings * Constructor */ - MoleculeParser(); + MoleculeParser( const QList& list ); /** * Constructor @@ -206,6 +208,8 @@ public: bool parseTerm(double *_resultMass, ElementCountMap *_resultMap); + QList m_elementList; + static const int ELEMENT_TOKEN = 300; Element *lookupElement( const QString& _name ); diff --git a/libscience/tempunit.h b/libscience/tempunit.h index 8ba318c..45153d3 100644 --- a/libscience/tempunit.h +++ b/libscience/tempunit.h @@ -20,15 +20,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include -#include +#include +#include /** * This class obtains all the info needed to work with the units of measure * of temperature. * * It has static methods you can call to get the various infos. The most - * important methods is convert(), that performs conversions. + * important method is convert(), that performs conversions. * * @author Pino Toscano */