diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-05 06:00:29 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-05 06:00:29 +0000 |
commit | fecb0e67b23e8b83ba7fc881bb57bc48c0852d62 (patch) | |
tree | 6b8614802f0d01b353bc9ba78aff2090846c198e /kmymoney2/mymoney/mymoneymoney.cpp | |
parent | dadc34655c3ab961b0b0b94a10eaaba710f0b5e8 (diff) | |
download | kmymoney-fecb0e67b23e8b83ba7fc881bb57bc48c0852d62.tar.gz kmymoney-fecb0e67b23e8b83ba7fc881bb57bc48c0852d62.zip |
TQt4 port kmymoney
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmymoney@1239855 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmymoney2/mymoney/mymoneymoney.cpp')
-rw-r--r-- | kmymoney2/mymoney/mymoneymoney.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/kmymoney2/mymoney/mymoneymoney.cpp b/kmymoney2/mymoney/mymoneymoney.cpp index 993a872..ccf1d80 100644 --- a/kmymoney2/mymoney/mymoneymoney.cpp +++ b/kmymoney2/mymoney/mymoneymoney.cpp @@ -28,7 +28,7 @@ // ---------------------------------------------------------------------------- // QT Includes -#include <qregexp.h> +#include <tqregexp.h> // ---------------------------------------------------------------------------- // Project Includes @@ -111,7 +111,7 @@ void MyMoneyMoney::setFileVersion(fileVersionE version) _fileVersion = version; } -MyMoneyMoney::MyMoneyMoney(const QString& pszAmount) +MyMoneyMoney::MyMoneyMoney(const TQString& pszAmount) { m_num = 0; m_denom = 1; @@ -122,15 +122,15 @@ MyMoneyMoney::MyMoneyMoney(const QString& pszAmount) // take care of prices given in the form "8 5/16" // and our own internal represenation - QRegExp regExp("^((\\d+)\\s+|-)?(\\d+)/(\\d+)"); + TQRegExp regExp("^((\\d+)\\s+|-)?(\\d+)/(\\d+)"); // +-#2-+ +-#3-+ +-#4-+ // +-----#1-----+ if (regExp.search(pszAmount) > -1) { m_num = regExp.cap(3).toLongLong(); m_denom = regExp.cap(4).toLongLong(); - const QString& part1 = regExp.cap(1); + const TQString& part1 = regExp.cap(1); if(!part1.isEmpty()) { - if(part1 == QString("-")) { + if(part1 == TQString("-")) { m_num = -m_num; } else { @@ -140,16 +140,16 @@ MyMoneyMoney::MyMoneyMoney(const QString& pszAmount) return; } - QString res = pszAmount; + TQString res = pszAmount; // get rid of anything that is not // a) numeric // b) _decimalSeparator // c) negative indicator - QString validChars = QString("\\d%1").arg(QChar(decimalSeparator())); + TQString validChars = TQString("\\d%1").tqarg(TQChar(decimalSeparator())); // we need to escape the minus sign here, because later on it will be // part of "\d,-()" and that does not work. It needs to be "\d,\-()" // And we need two of them, because we're in C - QString negChars("\\-"); + TQString negChars("\\-"); if(_negativeMonetarySignPosition == ParensAround) { // Since we want to allow '-' as well as '()' for negative entry // we just add the parens here. @@ -158,13 +158,13 @@ MyMoneyMoney::MyMoneyMoney(const QString& pszAmount) validChars += negChars; // qDebug("0: '%s'", validChars.data()); - QRegExp invChars(QString("[^%1]").arg(validChars)); + TQRegExp invChars(TQString("[^%1]").tqarg(validChars)); // qDebug("1: '%s'", res.data()); res.remove(invChars); - QRegExp negCharSet(QString("[%1]").arg(negChars)); + TQRegExp negCharSet(TQString("[%1]").tqarg(negChars)); bool isNegative = false; - if(res.find(negCharSet) != -1) { + if(res.tqfind(negCharSet) != -1) { isNegative = true; res.remove(negCharSet); } @@ -172,7 +172,7 @@ MyMoneyMoney::MyMoneyMoney(const QString& pszAmount) int pos; // qDebug("3: '%s'", res.data()); - if((pos = res.find(_decimalSeparator)) != -1) { + if((pos = res.tqfind(_decimalSeparator)) != -1) { // make sure, we get the denominator right m_denom = precToDenom(res.length() - pos - 1); @@ -187,25 +187,25 @@ MyMoneyMoney::MyMoneyMoney(const QString& pszAmount) m_num = -m_num; } -QString MyMoneyMoney::formatMoney(int denom, bool showThousandSeparator) const +TQString MyMoneyMoney::formatMoney(int denom, bool showThousandSeparator) const { return formatMoney("", denomToPrec(denom), showThousandSeparator); } -QString MyMoneyMoney::formatMoney(const MyMoneyAccount& acc, const MyMoneySecurity& sec, bool showThousandSeparator) const +TQString MyMoneyMoney::formatMoney(const MyMoneyAccount& acc, const MyMoneySecurity& sec, bool showThousandSeparator) const { return formatMoney(sec.tradingSymbol(), denomToPrec(acc.fraction()), showThousandSeparator); } -QString MyMoneyMoney::formatMoney(const MyMoneySecurity& sec, bool showThousandSeparator) const +TQString MyMoneyMoney::formatMoney(const MyMoneySecurity& sec, bool showThousandSeparator) const { return formatMoney(sec.tradingSymbol(), denomToPrec(sec.smallestAccountFraction()), showThousandSeparator); } -QString MyMoneyMoney::formatMoney(const QString& currency, const int prec, bool showThousandSeparator) const +TQString MyMoneyMoney::formatMoney(const TQString& currency, const int prec, bool showThousandSeparator) const { - QString res; - QString tmpCurrency = currency; + TQString res; + TQString tmpCurrency = currency; int tmpPrec = prec; signed64 denom = 1; signed64 m_64Value; @@ -240,15 +240,15 @@ QString MyMoneyMoney::formatMoney(const QString& currency, const int prec, bool if(left & 0xFFFFFFFF00000000LL) { signed64 tmp = left; - // QString.sprintf("%Ld") did not work :-(, so I had to + // TQString.sprintf("%Ld") did not work :-(, so I had to // do it the old ugly way. while(tmp) { - res.insert(0, QString("%1").arg(static_cast<int>(tmp % 10))); + res.insert(0, TQString("%1").tqarg(static_cast<int>(tmp % 10))); tmp /= 10; } } else - res = QString("%1").arg((long)left); + res = TQString("%1").tqarg((long)left); if(showThousandSeparator) { int pos = res.length(); @@ -262,13 +262,13 @@ QString MyMoneyMoney::formatMoney(const QString& currency, const int prec, bool // using // - // res += QString("%1").arg(right).rightJustify(prec, '0', true); + // res += TQString("%1").tqarg(right).rightJustify(prec, '0', true); // // caused some weird results if right was rather large. Eg: right being // 666600000 should have appended a 0, but instead it prepended a 0. With // res being "2," the result wasn't "2,6666000000" as expected, but rather // "2,0666600000" which was not usable. The code below works for me. - QString rs = QString("%1").arg(right); + TQString rs = TQString("%1").tqarg(right); if(prec != -1) rs = rs.rightJustify(prec, '0', true); else { @@ -276,14 +276,14 @@ QString MyMoneyMoney::formatMoney(const QString& currency, const int prec, bool // no trailing zeroes or decimal separators while(rs.endsWith("0")) rs.truncate(rs.length()-1); - while(rs.endsWith(QChar(decimalSeparator()))) + while(rs.endsWith(TQChar(decimalSeparator()))) rs.truncate(rs.length()-1); } res += rs; } signPosition signpos = bNegative ? _negativeMonetarySignPosition : _positiveMonetarySignPosition; - QString sign = bNegative ? "-" : ""; + TQString sign = bNegative ? "-" : ""; switch(signpos) { case ParensAround: @@ -316,37 +316,37 @@ QString MyMoneyMoney::formatMoney(const QString& currency, const int prec, bool return res; } -const QString MyMoneyMoney::toString(void) const +const TQString MyMoneyMoney::toString(void) const { signed64 tmp = m_num < 0 ? - m_num : m_num; - QString res; - QString resf; + TQString res; + TQString resf; - // QString.sprintf("%Ld") did not work :-(, so I had to + // TQString.sprintf("%Ld") did not work :-(, so I had to // do it the old ugly way. while(tmp) { - res.prepend(QString("%1").arg(static_cast<int>(tmp % 10))); + res.prepend(TQString("%1").tqarg(static_cast<int>(tmp % 10))); tmp /= 10; } if(res.isEmpty()) - res = QString("0"); + res = TQString("0"); if(m_num < 0) res.prepend('-'); tmp = m_denom; while(tmp) { - resf.prepend(QString("%1").arg(static_cast<int>(tmp % 10))); + resf.prepend(TQString("%1").tqarg(static_cast<int>(tmp % 10))); tmp /= 10; } return res + "/" + resf; } -QDataStream &operator<<(QDataStream &s, const MyMoneyMoney &_money) +TQDataStream &operator<<(TQDataStream &s, const MyMoneyMoney &_money) { // We WILL lose data here if the user has more than 2 billion pounds :-( // QT defined it here as long: - // qglobal.h:typedef long Q_INT64; + // qglobal.h:typedef long TQ_INT64; MyMoneyMoney money = _money.convert(100); @@ -355,7 +355,7 @@ QDataStream &operator<<(QDataStream &s, const MyMoneyMoney &_money) if(money.m_num & 0xffffffff00000000LL) qWarning("Lost data while writing out MyMoneyMoney object using deprecated 4 byte writer"); - s << static_cast<Q_INT32> (money.m_num & 0xffffffff); + s << static_cast<TQ_INT32> (money.m_num & 0xffffffff); break; default: @@ -363,16 +363,16 @@ QDataStream &operator<<(QDataStream &s, const MyMoneyMoney &_money) // tricky fall through here case MyMoneyMoney::FILE_8_BYTE_VALUE: - s << static_cast<Q_INT32> (money.m_num >> 32); - s << static_cast<Q_INT32> (money.m_num & 0xffffffff); + s << static_cast<TQ_INT32> (money.m_num >> 32); + s << static_cast<TQ_INT32> (money.m_num & 0xffffffff); break; } return s; } -QDataStream &operator>>(QDataStream &s, MyMoneyMoney &money) +TQDataStream &operator>>(TQDataStream &s, MyMoneyMoney &money) { - Q_INT32 tmp; + TQ_INT32 tmp; switch(MyMoneyMoney::_fileVersion) { case MyMoneyMoney::FILE_4_BYTE_VALUE: s >> tmp; |