[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeplasma-addons/applets/unitconverter
From:       Sujith Haridasan <sujith.h () gmail ! com>
Date:       2010-01-10 11:34:57
Message-ID: 1263123297.658243.12107.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1072564 by sujithh:

A fix to unitconvertor to make consistant of adding zero just after the decimal in \
the result box when the input box contains zero after the decimal.


 M  +9 -2      unitconverter.cpp  


--- trunk/KDE/kdeplasma-addons/applets/unitconverter/unitconverter.cpp \
#1072563:1072564 @@ -23,6 +23,7 @@
 #include <QGraphicsLinearLayout>
 #include <QGraphicsProxyWidget>
 #include <QLabel>
+#include <QRegExp>
 #include <KComboBox>
 #include <KLineEdit>
 #include <Plasma/ComboBox>
@@ -110,8 +111,14 @@
     if (!in.isNull() && !out.isNull()) {
         Value dblValueIn(m_pTxtValue1->text().toDouble(), in);
         Value dblValueOut = dblValueIn.convertTo(out->id());
-
-        m_pTxtValue2->setText(QString::number(dblValueOut.number()));
+        QRegExp decimalCheck("^\\d+\\.0$");
+        QRegExp onlyDecimal("^\\d+$");
+        if(decimalCheck.exactMatch(m_pTxtValue1->text()) && \
onlyDecimal.exactMatch(QString::number(dblValueOut.number()))) { +           QString \
addZero = QString::number(dblValueOut.number()) + ".0"; +           \
m_pTxtValue2->setText(addZero); +	} else {
+           m_pTxtValue2->setText(QString::number(dblValueOut.number()));
+	}
     }
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic