]> Git trees. - libqmvoc.git/commitdiff
new API: find the elements of the molecule
authorCarsten Niehaus <cniehaus@gmx.de>
Thu, 5 Jan 2006 18:09:50 +0000 (18:09 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Thu, 5 Jan 2006 18:09:50 +0000 (18:09 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=494591

libscience/moleculeparser.cpp
libscience/moleculeparser.h

index db686d15af808f40e0d732ed386fad3dbff9816f..8a013a8504ef073a2e51315b934e5f7f8c4d67fb 100644 (file)
@@ -56,6 +56,20 @@ ElementCountMap::add(ElementCountMap &_map)
        
 }
 
+QList<Element*> 
+ElementCountMap::elements()
+{
+       QList<Element*> list;
+
+       foreach( ElementCount* c, m_map ){
+               Element* e = c->m_element;
+               if ( !list.contains( e ) )
+                       list << e;
+       }
+
+       return list;
+}
+
 
 void
 ElementCountMap::add(Element *_element, int _count)
index d51cc77bdf84c739ad6ad7752e2543d9bbc361c5..5a857736ba496577a8134a484beca6ff203a6175 100644 (file)
@@ -22,7 +22,7 @@
 
 
 /**
- * @class ElementCountMap
+ * @class ElementCount
  * @author Inge Wallin
  */
 class ElementCount 
@@ -83,7 +83,7 @@ class ElementCount
  * This class is used to count the elements in the molecule
  * which is being calculated
  * 
- * @class ElementCount
+ * @class ElementCountMap
  * @author Inge Wallin
  */
 class ElementCountMap 
@@ -115,6 +115,13 @@ class ElementCountMap
                 */
                void           add(ElementCountMap &_map);
 
+               /**
+                * Returns the elements in the molecule. For example, if the molecule 
+                * is CO2, a list with C and O will be returned.
+                * @return the elements in the molecule
+                */
+               QList<Element*> elements();
+
                /**
                 * @param _element
                 * @param _count