From 39b410cc44be566501f840d63820c6719be76542 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Thu, 5 Jan 2006 18:09:50 +0000 Subject: [PATCH] new API: find the elements of the molecule svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=494591 --- libscience/moleculeparser.cpp | 14 ++++++++++++++ libscience/moleculeparser.h | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) 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 -- 2.47.3