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

List:       kde-commits
Subject:    [kcalc/KDE/4.10] /: back port of the fix for bug #319115
From:       Evan Teran <eteran () alum ! rit ! edu>
Date:       2013-04-30 20:23:00
Message-ID: 20130430202300.D8119A603F () git ! kde ! org
[Download RAW message or body]

Git commit 862e7bfe2128bcc8b51b1df1e5c5e8e74a4623e1 by Evan Teran.
Committed on 30/04/2013 at 22:23.
Pushed by teran into branch 'KDE/4.10'.

back port of the fix for bug #319115

M  +16   -3    kcalcdisplay.cpp
M  +1    -1    knumber/knumber.cpp

http://commits.kde.org/kcalc/862e7bfe2128bcc8b51b1df1e5c5e8e74a4623e1

diff --git a/kcalcdisplay.cpp b/kcalcdisplay.cpp
index 3081df3..a675e09 100644
--- a/kcalcdisplay.cpp
+++ b/kcalcdisplay.cpp
@@ -31,8 +31,10 @@ along with this program.  If not, see \
<http://www.gnu.org/licenses/>.  #include <kglobal.h>
 #include <klocale.h>
 #include <knotification.h>
+
 #include "kcalc_core.h"
 #include "kcalc_settings.h"
+
 #include "kcalcdisplay.moc"
 
 //------------------------------------------------------------------------------
@@ -290,8 +292,11 @@ void KCalcDisplay::slotPaste(bool bClipboard) {
 		tmp_num_base = NB_BINARY;
 		tmp_str.remove(0, 2);
 	} else if (tmp_str.startsWith(QLatin1String("0"))) {
-		tmp_num_base = NB_OCTAL;
-		tmp_str.remove(0, 1);
+		// we don't want this to trigger on "0.xxxxxx" cases
+		if(tmp_str.length() < 2 || QString(tmp_str[1]) != KNumber::decimalSeparator()) {
+			tmp_num_base = NB_OCTAL;
+			tmp_str.remove(0, 1);
+		}
 	}
 
 	if (tmp_num_base != NB_DECIMAL) {
@@ -537,7 +542,15 @@ void KCalcDisplay::setText(const QString &string)
 			text_ = groupDigits(text_, hexadecimalGrouping_);
 			break;
 		}
-    }
+    } else if(special) {
+#if 0
+		// TODO: enable this code, it replaces the "inf" with an actual infinity
+		//       symbol, but what should be put into the clip board when they copy?
+		if(string.contains(QLatin1String("inf"))) {
+			text_.replace("inf", QChar(0x221e));
+		}
+#endif
+	}
 
     update();
     emit changedText(text_);
diff --git a/knumber/knumber.cpp b/knumber/knumber.cpp
index ac49573..752996b 100644
--- a/knumber/knumber.cpp
+++ b/knumber/knumber.cpp
@@ -278,7 +278,7 @@ KNumber::KNumber(const QString &s) : value_(0) {
 	const QRegExp special_regex(QLatin1String("^(inf|-inf|nan)$"));
 	const QRegExp integer_regex(QLatin1String("^[+-]?\\d+$"));
 	const QRegExp fraction_regex(QLatin1String("^[+-]?\\d+/\\d+$"));
-	const QRegExp float_regex(QString(QLatin1String("^([+-]?\\d+)(%1\\d*)?(e([+-]?\\d+))?$")).arg(QRegExp::escape(DecimalSeparator)));
 +	const QRegExp float_regex(QString(QLatin1String("^([+-]?\\d*)(%1\\d*)?(e([+-]?\\d+))?$")).arg(QRegExp::escape(DecimalSeparator)));
  
 	if (special_regex.exactMatch(s)) {
 		value_ = new detail::knumber_error(s);


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

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