From c69a8d9a558665a6d518dd8cd505b9897426a0c0 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 13 Jun 2005 21:08:42 +0000 Subject: [PATCH] Method moving. svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=425102 --- kalzium/src/element.cpp | 27 +++++++++++++++++++++++++++ kalzium/src/element.h | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/kalzium/src/element.cpp b/kalzium/src/element.cpp index 65e18d9..9043c63 100644 --- a/kalzium/src/element.cpp +++ b/kalzium/src/element.cpp @@ -731,3 +731,30 @@ Isotope::Isotope( int neutrons, double percentage, double weight, double halfli m_format = format; m_weight = weight; } + +QString Isotope::halflifeToHtml() const +{ + QString halflife; + + if ( !seconds() )//years + { + if ( m_halflife > 1000000 ) + halflife = i18n("%1 million years").arg( m_halflife/1000000.0 ); + if ( m_halflife > 1000000000 ) + halflife = i18n("%1 billion years").arg( m_halflife/1000000000.0 ); + else + halflife = i18n("%1 years").arg( m_halflife ); +// return halflife; + } + else + { + if ( m_halflife < 120 ) + halflife = i18n("%1 seconds").arg( m_halflife ); + else if ( m_halflife > 1200 ) + halflife = i18n("%1 minutes").arg( m_halflife/60.0 ); + else if ( m_halflife > 12000 ) + halflife = i18n("%1 days").arg( m_halflife/3600.0 ); + } + + return halflife; +} diff --git a/kalzium/src/element.h b/kalzium/src/element.h index b277cc2..a599353 100644 --- a/kalzium/src/element.h +++ b/kalzium/src/element.h @@ -41,7 +41,7 @@ class Isotope public: Isotope( int neutrons, double percentage, double weight, double halflife, QString format ); - bool seconds() { + bool seconds() const{ if ( m_format == "seconds" ) return true; else @@ -64,6 +64,8 @@ class Isotope return m_weight; } + QString halflifeToHtml() const; + private: /** * it is either "years" or "seconds". Usually we use seconds. But some -- 2.47.3