diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-25 05:28:35 +0000 |
commit | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (patch) | |
tree | 8e9244c4d4957c36be81e15b566b4aa5ea26c982 /kspread/valueparser.cc | |
parent | 1210f27b660efb7b37ff43ec68763e85a403471f (diff) | |
download | koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.tar.gz koffice-f008adb5a77e094eaf6abf3fc0f36958e66896a5.zip |
TQt4 port koffice
This should enable compilation under both Qt3 and Qt4; fixes for any missed components will be forthcoming
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238284 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kspread/valueparser.cc')
-rw-r--r-- | kspread/valueparser.cc | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/kspread/valueparser.cc b/kspread/valueparser.cc index 2d2604a1..9acd3705 100644 --- a/kspread/valueparser.cc +++ b/kspread/valueparser.cc @@ -36,7 +36,7 @@ KLocale* ValueParser::locale() return parserLocale; } -void ValueParser::parse (const QString& str, Cell *cell) +void ValueParser::parse (const TQString& str, Cell *cell) { FormatType format = cell->formatType(); @@ -50,7 +50,7 @@ void ValueParser::parse (const QString& str, Cell *cell) return; } - QString strStripped = str.stripWhiteSpace(); + TQString strStripped = str.stripWhiteSpace(); // Try parsing as various datatypes, to find the type of the cell @@ -85,7 +85,7 @@ void ValueParser::parse (const QString& str, Cell *cell) cell->setValue (Value (str)); } -Value ValueParser::parse (const QString &str) +Value ValueParser::parse (const TQString &str) { Value val; @@ -101,7 +101,7 @@ Value ValueParser::parse (const QString &str) bool ok; - QString strStripped = str.stripWhiteSpace(); + TQString strStripped = str.stripWhiteSpace(); // Try parsing as various datatypes, to find the type of the string // First as number @@ -139,7 +139,7 @@ Value ValueParser::parse (const QString &str) return val; } -bool ValueParser::tryParseBool (const QString& str, Cell *cell) +bool ValueParser::tryParseBool (const TQString& str, Cell *cell) { bool ok; Value val = tryParseBool (str, &ok); @@ -148,7 +148,7 @@ bool ValueParser::tryParseBool (const QString& str, Cell *cell) return ok; } -bool ValueParser::tryParseNumber (const QString& str, Cell *cell) +bool ValueParser::tryParseNumber (const TQString& str, Cell *cell) { bool ok; Value val = tryParseNumber (str, &ok); @@ -157,7 +157,7 @@ bool ValueParser::tryParseNumber (const QString& str, Cell *cell) return ok; } -bool ValueParser::tryParseDate (const QString& str, Cell *cell) +bool ValueParser::tryParseDate (const TQString& str, Cell *cell) { bool ok; Value value = tryParseDate (str, &ok); @@ -166,7 +166,7 @@ bool ValueParser::tryParseDate (const QString& str, Cell *cell) return ok; } -bool ValueParser::tryParseTime (const QString& str, Cell *cell) +bool ValueParser::tryParseTime (const TQString& str, Cell *cell) { bool ok; Value value = tryParseTime (str, &ok); @@ -176,12 +176,12 @@ bool ValueParser::tryParseTime (const QString& str, Cell *cell) } -Value ValueParser::tryParseBool (const QString& str, bool *ok) +Value ValueParser::tryParseBool (const TQString& str, bool *ok) { Value val; if (ok) *ok = false; - const QString& lowerStr = str.lower(); + const TQString& lowerStr = str.lower(); if ((lowerStr == "true") || (lowerStr == parserLocale->translate("true").lower())) @@ -199,20 +199,20 @@ Value ValueParser::tryParseBool (const QString& str, bool *ok) return val; } -double ValueParser::readNumber(const QString &_str, bool * ok, bool * isInt) +double ValueParser::readNumber(const TQString &_str, bool * ok, bool * isInt) { - QString str = _str.stripWhiteSpace(); - bool neg = str.find(parserLocale->negativeSign()) == 0; + TQString str = _str.stripWhiteSpace(); + bool neg = str.tqfind(parserLocale->negativeSign()) == 0; if (neg) str.remove( 0, parserLocale->negativeSign().length() ); /* will hold the scientific notation portion of the number. Example, with 2.34E+23, exponentialPart == "E+23" */ - QString exponentialPart; + TQString exponentialPart; int EPos; - EPos = str.find('E', 0, false); + EPos = str.tqfind('E', 0, false); if (EPos != -1) { @@ -220,9 +220,9 @@ double ValueParser::readNumber(const QString &_str, bool * ok, bool * isInt) str = str.left(EPos); } - int pos = str.find(parserLocale->decimalSymbol()); - QString major; - QString minor; + int pos = str.tqfind(parserLocale->decimalSymbol()); + TQString major; + TQString minor; if ( pos == -1 ) { major = str; @@ -238,7 +238,7 @@ double ValueParser::readNumber(const QString &_str, bool * ok, bool * isInt) // Remove thousand separators int thlen = parserLocale->thousandsSeparator().length(); int lastpos = 0; - while ( ( pos = major.find( parserLocale->thousandsSeparator() ) ) > 0 ) + while ( ( pos = major.tqfind( parserLocale->thousandsSeparator() ) ) > 0 ) { // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N int fromEnd = major.length() - pos; @@ -260,7 +260,7 @@ double ValueParser::readNumber(const QString &_str, bool * ok, bool * isInt) return 0.0; } - QString tot; + TQString tot; if (neg) tot = '-'; tot += major + '.' + minor + exponentialPart; @@ -268,12 +268,12 @@ double ValueParser::readNumber(const QString &_str, bool * ok, bool * isInt) return tot.toDouble(ok); } -Value ValueParser::tryParseNumber (const QString& str, bool *ok) +Value ValueParser::tryParseNumber (const TQString& str, bool *ok) { Value value; bool percent = false; - QString str2; + TQString str2; if( str.at(str.length()-1)=='%') { str2 = str.left (str.length()-1).stripWhiteSpace(); @@ -290,7 +290,7 @@ Value ValueParser::tryParseNumber (const QString& str, bool *ok) if (!(*ok)) { val = str2.toDouble(ok); - if (str.contains('.')) + if (str.tqcontains('.')) isInt = false; else isInt = true; @@ -315,7 +315,7 @@ Value ValueParser::tryParseNumber (const QString& str, bool *ok) else value.setValue (val); - if ( str2.contains('E') || str2.contains('e') ) + if ( str2.tqcontains('E') || str2.tqcontains('e') ) fmtType = Scientific_format; else { @@ -330,10 +330,10 @@ Value ValueParser::tryParseNumber (const QString& str, bool *ok) return value; } -Value ValueParser::tryParseDate (const QString& str, bool *ok) +Value ValueParser::tryParseDate (const TQString& str, bool *ok) { bool valid = false; - QDate tmpDate = parserLocale->readDate (str, &valid); + TQDate tmpDate = parserLocale->readDate (str, &valid); if (!valid) { // Try without the year @@ -341,8 +341,8 @@ Value ValueParser::tryParseDate (const QString& str, bool *ok) // For instance %Y-%m-%d becomes %m-%d and %d/%m/%Y becomes %d/%m // If the year is in the middle, say %m-%Y/%d, we'll remove the sep. // before it (%m/%d). - QString fmt = parserLocale->dateFormatShort(); - int yearPos = fmt.find ("%Y", 0, false); + TQString fmt = parserLocale->dateFormatShort(); + int yearPos = fmt.tqfind ("%Y", 0, false); if ( yearPos > -1 ) { if ( yearPos == 0 ) @@ -369,8 +369,8 @@ Value ValueParser::tryParseDate (const QString& str, bool *ok) // The following fixes the problem, 3/4/1955 will always be 1955 - QString fmt = parserLocale->dateFormatShort(); - if( ( fmt.contains( "%y" ) == 1 ) && ( tmpDate.year() > 2999 ) ) + TQString fmt = parserLocale->dateFormatShort(); + if( ( fmt.tqcontains( "%y" ) == 1 ) && ( tmpDate.year() > 2999 ) ) tmpDate = tmpDate.addYears( -1900 ); // this is another HACK ! @@ -383,13 +383,13 @@ Value ValueParser::tryParseDate (const QString& str, bool *ok) // (e.g 3/4/45 is Mar 4, 1945 not Mar 4, 2045) if( ( tmpDate.year() >= 2030 ) && ( tmpDate.year() <= 2069 ) ) { - QString yearFourDigits = QString::number( tmpDate.year() ); - QString yearTwoDigits = QString::number( tmpDate.year() % 100 ); + TQString yearFourDigits = TQString::number( tmpDate.year() ); + TQString yearTwoDigits = TQString::number( tmpDate.year() % 100 ); // if year is 2045, check to see if "2045" isn't there --> actual // input is "45" - if( ( str.contains( yearTwoDigits ) >= 1 ) && - ( str.contains( yearFourDigits ) == 0 ) ) + if( ( str.tqcontains( yearTwoDigits ) >= 1 ) && + ( str.tqcontains( yearFourDigits ) == 0 ) ) tmpDate = tmpDate.addYears( -100 ); } @@ -401,8 +401,8 @@ Value ValueParser::tryParseDate (const QString& str, bool *ok) } if (!valid) { - //try to use the standard Qt date parsing, using ISO 8601 format - tmpDate = QDate::fromString(str,Qt::ISODate); + //try to use the standard TQt date parsing, using ISO 8601 format + tmpDate = TQDate::fromString(str,Qt::ISODate); if (tmpDate.isValid()) { valid = true; @@ -415,7 +415,7 @@ Value ValueParser::tryParseDate (const QString& str, bool *ok) return Value (tmpDate); } -Value ValueParser::tryParseTime (const QString& str, bool *ok) +Value ValueParser::tryParseTime (const TQString& str, bool *ok) { if (ok) *ok = false; @@ -424,29 +424,29 @@ Value ValueParser::tryParseTime (const QString& str, bool *ok) bool duration = false; Value val; - QDateTime tmpTime = readTime (str, true, &valid, duration); + TQDateTime tmpTime = readTime (str, true, &valid, duration); if (!tmpTime.isValid()) tmpTime = readTime (str, false, &valid, duration); if (!valid) { - QTime tm; + TQTime tm; if (parserLocale->use12Clock()) { - QString stringPm = parserLocale->translate("pm"); - QString stringAm = parserLocale->translate("am"); + TQString stringPm = parserLocale->translate("pm"); + TQString stringAm = parserLocale->translate("am"); int pos=0; - if((pos=str.find(stringPm))!=-1) + if((pos=str.tqfind(stringPm))!=-1) { - QString tmp=str.mid(0,str.length()-stringPm.length()); + TQString tmp=str.mid(0,str.length()-stringPm.length()); tmp=tmp.simplifyWhiteSpace(); tm = parserLocale->readTime(tmp+" "+stringPm, &valid); if (!valid) tm = parserLocale->readTime(tmp+":00 "+stringPm, &valid); } - else if((pos=str.find(stringAm))!=-1) + else if((pos=str.tqfind(stringAm))!=-1) { - QString tmp = str.mid(0,str.length()-stringAm.length()); + TQString tmp = str.mid(0,str.length()-stringAm.length()); tmp = tmp.simplifyWhiteSpace(); tm = parserLocale->readTime (tmp + " " + stringAm, &valid); if (!valid) @@ -474,15 +474,15 @@ Value ValueParser::tryParseTime (const QString& str, bool *ok) return val; } -QDateTime ValueParser::readTime (const QString & intstr, bool withSeconds, +TQDateTime ValueParser::readTime (const TQString & intstr, bool withSeconds, bool *ok, bool & duration) { duration = false; - QString str = intstr.simplifyWhiteSpace().lower(); - QString format = parserLocale->timeFormat().simplifyWhiteSpace(); + TQString str = intstr.simplifyWhiteSpace().lower(); + TQString format = parserLocale->timeFormat().simplifyWhiteSpace(); if ( !withSeconds ) { - int n = format.find("%S"); + int n = format.tqfind("%S"); format = format.left( n - 1 ); } @@ -494,7 +494,7 @@ QDateTime ValueParser::readTime (const QString & intstr, bool withSeconds, uint strpos = 0; uint formatpos = 0; - QDate refDate( 1899, 12, 31 ); + TQDate refDate( 1899, 12, 31 ); uint l = format.length(); uint sl = str.length(); @@ -504,7 +504,7 @@ QDateTime ValueParser::readTime (const QString & intstr, bool withSeconds, if ( !(l > formatpos && sl > strpos) ) goto error; - QChar c( format.at( formatpos++ ) ); + TQChar c( format.at( formatpos++ ) ); if (c != '%') { @@ -524,7 +524,7 @@ QDateTime ValueParser::readTime (const QString & intstr, bool withSeconds, { case 'p': { - QString s; + TQString s; s = parserLocale->translate("pm").lower(); int len = s.length(); if (str.mid(strpos, len) == s) @@ -600,13 +600,13 @@ QDateTime ValueParser::readTime (const QString & intstr, bool withSeconds, if (ok) *ok = true; - return QDateTime( refDate, QTime( hour, minute, second ) ); + return TQDateTime( refDate, TQTime( hour, minute, second ) ); error: if (ok) *ok = false; // return invalid date if it didn't work - return QDateTime( refDate, QTime( -1, -1, -1 ) ); + return TQDateTime( refDate, TQTime( -1, -1, -1 ) ); } /** @@ -615,7 +615,7 @@ QDateTime ValueParser::readTime (const QString & intstr, bool withSeconds, * @param pos the position to start at. It will be updated when we parse it. * @return the integer read in the string, or -1 if no string */ -int ValueParser::readInt (const QString &str, uint &pos) +int ValueParser::readInt (const TQString &str, uint &pos) { if (!str.at(pos).isDigit()) return -1; |