]> Git trees. - libqmvoc.git/commitdiff
* Oh, forgot this part of the commit.
authorCarsten Niehaus <cniehaus@gmx.de>
Sun, 1 Jan 2006 12:35:32 +0000 (12:35 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sun, 1 Jan 2006 12:35:32 +0000 (12:35 +0000)
* tempunit.h -> type
* other files: improve the API

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=493070

libscience/moleculeparser.cpp
libscience/moleculeparser.h
libscience/tempunit.h

index 58a6531d9f320f3f59bedf65b2c7b72c9a8b5128..398c6018d538c0b90b0dda1e718ed27357f95a71 100644 (file)
@@ -109,9 +109,10 @@ ElementCountMap::multiply(int _factor)
 //                    class MoleculeParser
 
 
-MoleculeParser::MoleculeParser()
+MoleculeParser::MoleculeParser( const QList<Element*>& 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<Element*> elementList = KalziumDataObject::instance()->ElementList;
+//X     QList<Element*> elementList = KalziumDataObject::instance()->ElementList;
 
-    //kdDebug() << "looking up " << _name << endl;
+    kdDebug() << "looking up " << _name << endl;
 
-    QList<Element*>::ConstIterator        it  = elementList.constBegin();
-    const QList<Element*>::ConstIterator  end = elementList.constEnd();
+//X     QList<Element*>::ConstIterator        it  = elementList.constBegin();
+//X     const QList<Element*>::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;
 }
index 57342ed604fe170bc5706a1cfd13ffe98caaf95e..d51cc77bdf84c739ad6ad7752e2543d9bbc361c5 100644 (file)
@@ -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<Element*>& list );
        
        /**
         * Constructor
@@ -206,6 +208,8 @@ public:
     bool      parseTerm(double          *_resultMass, 
                                                ElementCountMap *_resultMap);
 
+       QList<Element*> m_elementList;
+
     static const int  ELEMENT_TOKEN = 300;
 
     Element  *lookupElement( const QString& _name );
index 8ba318c7ae4143650e8304d4d564a68212bbfc04..45153d3819f0ebda25e93b965b544502f0b5ceb4 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.          *
  ***************************************************************************/
 
-#include <qpair.h>
-#include <qstringlist.h>
+#include <QPair>
+#include <QStringList>
 
 /**
  * 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
  */