From 6b3919caafaa71574e33f56adc37d474a42e4c4c Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 30 May 2005 21:51:49 +0000 Subject: [PATCH] Improve the orbits parsing routine. svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=419944 --- kalzium/src/element.cpp | 9 ++++++--- kalzium/src/element.h | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kalzium/src/element.cpp b/kalzium/src/element.cpp index 8c74979..64da02c 100644 --- a/kalzium/src/element.cpp +++ b/kalzium/src/element.cpp @@ -41,10 +41,13 @@ Element::Element() { } -QString Element::parsedOrbits() +QString Element::parsedOrbits( bool canBeEmpty ) { - if ( m_orbits == "0" ) - return i18n( "structure means orbital configuration in this case", "Unknown structure" ); + if ( m_orbits.isEmpty() ) + if ( !canBeEmpty ) + return i18n( "structure means orbital configuration in this case", "Unknown structure" ); + else + return ""; QString orbits = m_orbits; QRegExp rxs("([a-z])([0-9]+)"); diff --git a/kalzium/src/element.h b/kalzium/src/element.h index 4e2247c..168418e 100644 --- a/kalzium/src/element.h +++ b/kalzium/src/element.h @@ -237,8 +237,10 @@ class Element{ * @return the orbits of the element. The QString is already * parsed so that the numbers are superscripts and the first * block is bold. + * @param canBeEmpty specifies if the string returned can be + * empty instead of a "Unknown structure" one. */ - QString parsedOrbits(); + QString parsedOrbits( bool canBeEmpty = false ); /** * @return the boiling point of the element in Kelvin -- 2.47.3