From: Carsten Niehaus Date: Thu, 5 Jan 2006 18:09:50 +0000 (+0000) Subject: new API: find the elements of the molecule X-Git-Tag: v3.80.2~188 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=39b410cc44be566501f840d63820c6719be76542;p=libqmvoc.git new API: find the elements of the molecule svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=494591 --- diff --git a/libscience/moleculeparser.cpp b/libscience/moleculeparser.cpp index db686d1..8a013a8 100644 --- a/libscience/moleculeparser.cpp +++ b/libscience/moleculeparser.cpp @@ -56,6 +56,20 @@ ElementCountMap::add(ElementCountMap &_map) } +QList +ElementCountMap::elements() +{ + QList 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) diff --git a/libscience/moleculeparser.h b/libscience/moleculeparser.h index d51cc77..5a85773 100644 --- a/libscience/moleculeparser.h +++ b/libscience/moleculeparser.h @@ -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 elements(); + /** * @param _element * @param _count