summaryrefslogtreecommitdiffstats
path: root/kcalc/knumber/knumber.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:52:55 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:52:55 +0000
commit5f5ee2367157176ed223b86343eb0a9e4022e020 (patch)
tree6a9c87f14ee38e90eff3c77c784f14e4f38fd5a1 /kcalc/knumber/knumber.cpp
parent4facf42feec57b22dcf46badc115ad6c5b5cc512 (diff)
downloadtdeutils-5f5ee2367157176ed223b86343eb0a9e4022e020.tar.gz
tdeutils-5f5ee2367157176ed223b86343eb0a9e4022e020.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1157653 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcalc/knumber/knumber.cpp')
-rw-r--r--kcalc/knumber/knumber.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/kcalc/knumber/knumber.cpp b/kcalc/knumber/knumber.cpp
index d282b26..80bae1f 100644
--- a/kcalc/knumber/knumber.cpp
+++ b/kcalc/knumber/knumber.cpp
@@ -22,8 +22,8 @@
#include <config.h>
-#include <qregexp.h>
-#include <qstring.h>
+#include <tqregexp.h>
+#include <tqstring.h>
#include "knumber.h"
@@ -94,17 +94,17 @@ KNumber::KNumber(KNumber const & num)
}
-KNumber::KNumber(QString const & num)
+KNumber::KNumber(TQString const & num)
{
- if (QRegExp("^(inf|-inf|nan)$").exactMatch(num))
+ if (TQRegExp("^(inf|-inf|nan)$").exactMatch(num))
_num = new _knumerror(num);
- else if (QRegExp("^[+-]?\\d+$").exactMatch(num))
+ else if (TQRegExp("^[+-]?\\d+$").exactMatch(num))
_num = new _knuminteger(num);
- else if (QRegExp("^[+-]?\\d+/\\d+$").exactMatch(num)) {
+ else if (TQRegExp("^[+-]?\\d+/\\d+$").exactMatch(num)) {
_num = new _knumfraction(num);
simplifyRational();
}
- else if (QRegExp("^[+-]?\\d+(\\.\\d*)?(e[+-]?\\d+)?$").exactMatch(num))
+ else if (TQRegExp("^[+-]?\\d+(\\.\\d*)?(e[+-]?\\d+)?$").exactMatch(num))
if (_fraction_input == true) {
_num = new _knumfraction(num);
simplifyRational();
@@ -228,7 +228,7 @@ KNumber & KNumber::operator -=(KNumber const &arg)
}
// increase the digit at 'position' by one
-static void _inc_by_one(QString &str, int position)
+static void _inc_by_one(TQString &str, int position)
{
for (int i = position; i >= 0; i--)
{
@@ -274,7 +274,7 @@ static void _inc_by_one(QString &str, int position)
}
// Cut off if more digits in fractional part than 'precision'
-static void _round(QString &str, int precision)
+static void _round(TQString &str, int precision)
{
int decimalSymbolPos = str.find('.');
@@ -287,7 +287,7 @@ static void _round(QString &str, int precision)
}
// fill up with more than enough zeroes (in case fractional part too short)
- str.append(QString().fill('0', precision));
+ str.append(TQString().fill('0', precision));
// Now decide whether to round up or down
char last_char = str[decimalSymbolPos + precision + 1].latin1();
@@ -319,11 +319,11 @@ static void _round(QString &str, int precision)
if (precision == 0) str = str.section('.', 0, 0);
}
-static QString roundNumber(const QString &numStr, int precision)
+static TQString roundNumber(const TQString &numStr, int precision)
{
- QString tmpString = numStr;
+ TQString tmpString = numStr;
if (precision < 0 ||
- ! QRegExp("^[+-]?\\d+(\\.\\d+)*(e[+-]?\\d+)?$").exactMatch(tmpString))
+ ! TQRegExp("^[+-]?\\d+(\\.\\d+)*(e[+-]?\\d+)?$").exactMatch(tmpString))
return numStr;
@@ -333,12 +333,12 @@ static QString roundNumber(const QString &numStr, int precision)
// Split off exponential part (including 'e'-symbol)
- QString mantString = tmpString.section('e', 0, 0,
- QString::SectionCaseInsensitiveSeps);
- QString expString = tmpString.section('e', 1, 1,
- QString::SectionCaseInsensitiveSeps |
- QString::SectionIncludeLeadingSep);
- if (expString.length() == 1) expString = QString();
+ TQString mantString = tmpString.section('e', 0, 0,
+ TQString::SectionCaseInsensitiveSeps);
+ TQString expString = tmpString.section('e', 1, 1,
+ TQString::SectionCaseInsensitiveSeps |
+ TQString::SectionIncludeLeadingSep);
+ if (expString.length() == 1) expString = TQString();
_round(mantString, precision);
@@ -349,9 +349,9 @@ static QString roundNumber(const QString &numStr, int precision)
}
-QString const KNumber::toQString(int width, int prec) const
+TQString const KNumber::toQString(int width, int prec) const
{
- QString tmp_str;
+ TQString tmp_str;
if (*this == Zero) // important to avoid infinite loops below
return "0";
@@ -363,7 +363,7 @@ QString const KNumber::toQString(int width, int prec) const
tmp_str = (KNumber("1.0")*(*this)).toQString(width, -1);
_fraction_input = tmp_bool;
} else
- tmp_str = QString(_num->ascii());
+ tmp_str = TQString(_num->ascii());
break;
case FractionType:
if (_float_output) {
@@ -376,13 +376,13 @@ QString const KNumber::toQString(int width, int prec) const
// split off integer part
KNumber int_part = this->integerPart();
if (int_part == Zero)
- tmp_str = QString(_num->ascii());
+ tmp_str = TQString(_num->ascii());
else if (int_part < Zero)
tmp_str = int_part.toQString() + " " + (int_part - *this)._num->ascii();
else
tmp_str = int_part.toQString() + " " + (*this - int_part)._num->ascii();
} else
- tmp_str = QString(_num->ascii());
+ tmp_str = TQString(_num->ascii());
if (width > 0 && tmp_str.length() > width) {
//result needs to be cut-off
@@ -396,13 +396,13 @@ QString const KNumber::toQString(int width, int prec) const
break;
case FloatType:
if (width > 0)
- tmp_str = QString(_num->ascii(width));
+ tmp_str = TQString(_num->ascii(width));
else
// rough estimate for maximal decimal precision (10^3 = 2^10)
- tmp_str = QString(_num->ascii(3*mpf_get_default_prec()/10));
+ tmp_str = TQString(_num->ascii(3*mpf_get_default_prec()/10));
break;
default:
- return QString(_num->ascii());
+ return TQString(_num->ascii());
}
if (prec >= 0)