]> Git trees. - libqmvoc.git/commitdiff
Method moving.
authorPino Toscano <pino@kde.org>
Mon, 13 Jun 2005 21:08:42 +0000 (21:08 +0000)
committerPino Toscano <pino@kde.org>
Mon, 13 Jun 2005 21:08:42 +0000 (21:08 +0000)
svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=425102

kalzium/src/element.cpp
kalzium/src/element.h

index 65e18d9abbdbec7f96c345782d65342723eab19e..9043c63adfa2c0cd8a15f55a7b00e93aeaa04c80 100644 (file)
@@ -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;
+}
index b277cc201fe2e73c744fcb74768c8558dee0d3f0..a5993537d6b25eeca178d3f6e59ca6806c4a40cf 100644 (file)
@@ -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