From fecb0e67b23e8b83ba7fc881bb57bc48c0852d62 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 5 Jul 2011 06:00:29 +0000 Subject: 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 --- kmymoney2/reports/querytable.cpp | 192 +++++++++++++++++++-------------------- 1 file changed, 96 insertions(+), 96 deletions(-) (limited to 'kmymoney2/reports/querytable.cpp') diff --git a/kmymoney2/reports/querytable.cpp b/kmymoney2/reports/querytable.cpp index 29702c6..cc38a2f 100644 --- a/kmymoney2/reports/querytable.cpp +++ b/kmymoney2/reports/querytable.cpp @@ -25,9 +25,9 @@ // ---------------------------------------------------------------------------- // QT Includes -#include -#include -#include +#include +#include +#include // ---------------------------------------------------------------------------- // KDE Includes @@ -59,7 +59,7 @@ namespace reports { // // **************************************************************************** -QDate CashFlowListItem::m_sToday = QDate::currentDate(); +TQDate CashFlowListItem::m_sToday = TQDate::tqcurrentDate(); MyMoneyMoney CashFlowListItem::NPV( double _rate ) const { @@ -158,12 +158,12 @@ double CashFlowList::calculateXIRR ( void ) const double CashFlowList::xirrResult ( double& rate ) const { - QDate date; + TQDate date; double r = rate + 1.0; double res = 0.00000;//back().value().toDouble(); - QValueList::const_iterator list_it = begin(); + TQValueList::const_iterator list_it = begin(); while( list_it != end() ) { double e_i = ( (* list_it).today().daysTo ( (* list_it).date() ) ) / 365.0; MyMoneyMoney val = (* list_it).value(); @@ -178,12 +178,12 @@ double CashFlowList::xirrResult ( double& rate ) const double CashFlowList::xirrResultDerive ( double& rate ) const { - QDate date; + TQDate date; double r = rate + 1.0; double res = 0.00000; - QValueList::const_iterator list_it = begin(); + TQValueList::const_iterator list_it = begin(); while( list_it != end() ) { double e_i = ( (* list_it).today().daysTo ( (* list_it).date() ) ) / 365.0; MyMoneyMoney val = (* list_it).value(); @@ -225,7 +225,7 @@ void CashFlowList::dumpDebug(void) const const_iterator it_item = begin(); while ( it_item != end() ) { - kdDebug(2) << (*it_item).date().toString(Qt::ISODate) << " " << (*it_item).value().toString() << endl; + kdDebug(2) << TQString((*it_item).date().toString(Qt::ISODate)) << " " << (*it_item).value().toString() << endl; ++it_item; } } @@ -334,7 +334,7 @@ void QueryTable::init(void) throw new MYMONEYEXCEPTION("QueryTable::QueryTable(): unhandled row type"); } - QString sort = m_group + "," + m_columns + ",id,rank"; + TQString sort = m_group + "," + m_columns + ",id,rank"; switch (m_config.rowType()) { case MyMoneyReport::eAccountByTopAccount: @@ -350,32 +350,32 @@ void QueryTable::init(void) unsigned qc = m_config.queryColumns(); - if ( qc & MyMoneyReport::eQCnumber ) + if ( qc & MyMoneyReport::eTQCnumber ) m_columns += ",number"; - if ( qc & MyMoneyReport::eQCpayee ) + if ( qc & MyMoneyReport::eTQCpayee ) m_columns += ",payee"; - if ( qc & MyMoneyReport::eQCcategory ) + if ( qc & MyMoneyReport::eTQCcategory ) m_columns += ",category"; - if ( qc & MyMoneyReport::eQCaccount ) + if ( qc & MyMoneyReport::eTQCaccount ) m_columns += ",account"; - if ( qc & MyMoneyReport::eQCreconciled ) + if ( qc & MyMoneyReport::eTQCreconciled ) m_columns += ",reconcileflag"; - if ( qc & MyMoneyReport::eQCmemo ) + if ( qc & MyMoneyReport::eTQCmemo ) m_columns += ",memo"; - if ( qc & MyMoneyReport::eQCaction ) + if ( qc & MyMoneyReport::eTQCaction ) m_columns += ",action"; - if ( qc & MyMoneyReport::eQCshares ) + if ( qc & MyMoneyReport::eTQCshares ) m_columns += ",shares"; - if ( qc & MyMoneyReport::eQCprice ) + if ( qc & MyMoneyReport::eTQCprice ) m_columns += ",price"; - if ( qc & MyMoneyReport::eQCperformance ) + if ( qc & MyMoneyReport::eTQCperformance ) m_columns += ",startingbal,buys,sells,reinvestincome,cashincome,return,returninvestment"; - if ( qc & MyMoneyReport::eQCloan ) + if ( qc & MyMoneyReport::eTQCloan ) { m_columns += ",payment,interest,fees"; m_postcolumns = "balance"; } - if ( qc & MyMoneyReport::eQCbalance) + if ( qc & MyMoneyReport::eTQCbalance) m_postcolumns = "balance"; TableRow::setSortCriteria(sort); @@ -417,14 +417,14 @@ void QueryTable::constructTransactionTable(void) } // support for opening and closing balances - QMap accts; + TQMap accts; //get all transactions for this report - QValueList transactions = file->transactionList(report); - for (QValueList::const_iterator it_transaction = transactions.begin(); it_transaction != transactions.end(); ++it_transaction) { + TQValueList transactions = file->transactionList(report); + for (TQValueList::const_iterator it_transaction = transactions.begin(); it_transaction != transactions.end(); ++it_transaction) { TableRow qA, qS; - QDate pd; + TQDate pd; qA["id"] = qS["id"] = (* it_transaction).id(); qA["entrydate"] = qS["entrydate"] = (* it_transaction).entryDate().toString(Qt::ISODate); @@ -432,8 +432,8 @@ void QueryTable::constructTransactionTable(void) qA["commodity"] = qS["commodity"] = (* it_transaction).commodity(); pd = (* it_transaction).postDate(); - qA["month"] = qS["month"] = i18n("Month of %1").arg(QDate(pd.year(),pd.month(),1).toString(Qt::ISODate)); - qA["week"] = qS["week"] = i18n("Week of %1").arg(pd.addDays(1-pd.dayOfWeek()).toString(Qt::ISODate)); + qA["month"] = qS["month"] = i18n("Month of %1").tqarg(TQDate(pd.year(),pd.month(),1).toString(Qt::ISODate)); + qA["week"] = qS["week"] = i18n("Week of %1").tqarg(pd.addDays(1-pd.dayOfWeek()).toString(Qt::ISODate)); qA["currency"] = qS["currency"] = ""; @@ -450,8 +450,8 @@ void QueryTable::constructTransactionTable(void) // to be the account (qA) that will have the sub-item "split" entries. we add // one transaction entry (qS) for each subsequent entry in the split. - const QValueList& splits = (*it_transaction).splits(); - QValueList::const_iterator myBegin, it_split; + const TQValueList& splits = (*it_transaction).splits(); + TQValueList::const_iterator myBegin, it_split; //S_end = splits.end(); for (it_split = splits.begin(), myBegin = splits.end(); it_split != splits.end(); ++it_split) { @@ -491,7 +491,7 @@ void QueryTable::constructTransactionTable(void) // split entries (qS) normally. bool loan_special_case = false; - if(m_config.queryColumns() & MyMoneyReport::eQCloan) { + if(m_config.queryColumns() & MyMoneyReport::eTQCloan) { ReportAccount splitAcc = (*it_split).accountId(); loan_special_case = splitAcc.isLoan(); } @@ -517,10 +517,10 @@ void QueryTable::constructTransactionTable(void) bool include_me = true; bool transaction_text = false; //indicates whether a text should be considered as a match for the transaction or for a split only - QString a_fullname = ""; - QString a_memo = ""; + TQString a_fullname = ""; + TQString a_memo = ""; unsigned int pass = 1; - QString myBeginCurrency = (file->account((*myBegin).accountId())).currencyId(); //currency of the main split + TQString myBeginCurrency = (file->account((*myBegin).accountId())).currencyId(); //currency of the main split do { MyMoneyMoney xr; ReportAccount splitAcc = (* it_split).accountId(); @@ -532,8 +532,8 @@ void QueryTable::constructTransactionTable(void) if(fraction == -1) fraction = file->baseCurrency().smallestAccountFraction(); - QString institution = splitAcc.institutionId(); - QString payee = (*it_split).payeeId(); + TQString institution = splitAcc.institutionId(); + TQString payee = (*it_split).payeeId(); //convert to base currency if ( m_config.isConvertCurrency() ) { @@ -548,8 +548,8 @@ void QueryTable::constructTransactionTable(void) if (splitAcc.isInvest()) { - // use the institution of the parent for stock accounts - institution = splitAcc.parent().institutionId(); + // use the institution of the tqparent for stock accounts + institution = splitAcc.tqparent().institutionId(); MyMoneyMoney shares = (*it_split).shares(); qA["action"] = (*it_split).action(); @@ -559,7 +559,7 @@ void QueryTable::constructTransactionTable(void) if (((*it_split).action() == MyMoneySplit::ActionBuyShares) && (*it_split).shares().isNegative()) qA["action"] = "Sell"; - qA["investaccount"] = splitAcc.parent().name(); + qA["investaccount"] = splitAcc.tqparent().name(); } if (it_split == myBegin) { @@ -671,7 +671,7 @@ void QueryTable::constructTransactionTable(void) //--- default case includes all transaction details else { - //this is when the splits are going to be shown as children of the main split + //this is when the splits are going to be shown as tqchildren of the main split if ((splits.count() > 2) && use_summary) { qA["value"] = ""; @@ -693,8 +693,8 @@ void QueryTable::constructTransactionTable(void) if (! splitAcc.isIncomeExpense()) { qA["category"] = ((*it_split).shares().isNegative()) ? - i18n("Transfer from %1").arg(splitAcc.fullName()) - : i18n("Transfer to %1").arg(splitAcc.fullName()); + i18n("Transfer from %1").tqarg(splitAcc.fullName()) + : i18n("Transfer to %1").tqarg(splitAcc.fullName()); qA["topcategory"] = splitAcc.topParentName(); qA["categorytype"] = i18n("Transfer"); } @@ -735,8 +735,8 @@ void QueryTable::constructTransactionTable(void) qS["topaccount"] = splitAcc.topParentName(); qS["category"] = ((*it_split).shares().isNegative()) - ? i18n("Transfer to %1").arg(a_fullname) - : i18n("Transfer from %1").arg(a_fullname); + ? i18n("Transfer to %1").tqarg(a_fullname) + : i18n("Transfer from %1").tqarg(a_fullname); qS["institution"] = institution.isEmpty() ? i18n("No Institution") @@ -807,14 +807,14 @@ void QueryTable::constructTransactionTable(void) return; } - QDate startDate, endDate; + TQDate startDate, endDate; report.validDateRange(startDate, endDate); - QString strStartDate = startDate.toString(Qt::ISODate); - QString strEndDate = endDate.toString(Qt::ISODate); + TQString strStartDate = startDate.toString(Qt::ISODate); + TQString strEndDate = endDate.toString(Qt::ISODate); startDate = startDate.addDays(-1); - QMap::const_iterator it_account, accts_end; + TQMap::const_iterator it_account, accts_end; for (it_account = accts.begin(); it_account != accts.end(); ++it_account) { TableRow qA; @@ -827,11 +827,11 @@ void QueryTable::constructTransactionTable(void) if(fraction == -1) fraction = file->baseCurrency().smallestAccountFraction(); - QString institution = account.institutionId(); + TQString institution = account.institutionId(); - // use the institution of the parent for stock accounts + // use the institution of the tqparent for stock accounts if (account.isInvest()) - institution = account.parent().institutionId(); + institution = account.tqparent().institutionId(); MyMoneyMoney startBalance, endBalance, startPrice, endPrice; MyMoneyMoney startShares, endShares; @@ -868,7 +868,7 @@ void QueryTable::constructTransactionTable(void) qA["postdate"] = strStartDate; qA["balance"] = startBalance.convert(fraction).toString(); - qA["value"] = QString(); + qA["value"] = TQString(); qA["id"] = "A"; m_rows += qA; @@ -904,8 +904,8 @@ void QueryTable::constructPerformanceRow( const ReportAccount& account, TableRow // Account, Value on , Buys, Sells, Income, Value on , Return% MyMoneyReport report = m_config; - QDate startingDate; - QDate endingDate; + TQDate startingDate; + TQDate endingDate; MyMoneyMoney price; report.validDateRange( startingDate, endingDate ); startingDate = startingDate.addDays(-1); @@ -923,11 +923,11 @@ void QueryTable::constructPerformanceRow( const ReportAccount& account, TableRow { MyMoneyTransactionFilter filter; //get the transactions for the time before the report - filter.setDateFilter(QDate(), startingDate); + filter.setDateFilter(TQDate(), startingDate); filter.addAccount(account.id()); filter.setReportAllSplits(true); - QValueList startTransactions = file->transactionList(filter); + TQValueList startTransactions = file->transactionList(filter); if(startTransactions.size() > 0) { //get the last transaction @@ -973,8 +973,8 @@ void QueryTable::constructPerformanceRow( const ReportAccount& account, TableRow report.setConsiderCategory(true); report.clearAccountFilter(); report.addAccount(account.id()); - QValueList transactions = file->transactionList( report ); - QValueList::const_iterator it_transaction = transactions.begin(); + TQValueList transactions = file->transactionList( report ); + TQValueList::const_iterator it_transaction = transactions.begin(); while ( it_transaction != transactions.end() ) { // s is the split for the stock account @@ -990,7 +990,7 @@ void QueryTable::constructPerformanceRow( const ReportAccount& account, TableRow MyMoneyMoney value = s.value() * price; - const QString& action = s.action(); + const TQString& action = s.action(); if ( action == MyMoneySplit::ActionBuyShares ) { if ( s.value().isPositive() ) { @@ -1005,8 +1005,8 @@ void QueryTable::constructPerformanceRow( const ReportAccount& account, TableRow reinvestincome += CashFlowListItem( (*it_transaction).postDate(), value ); } else if ( action == MyMoneySplit::ActionDividend || action == MyMoneySplit::ActionYield ) { // find the split with the category, which has the actual amount of the dividend - QValueList splits = (*it_transaction).splits(); - QValueList::const_iterator it_split = splits.begin(); + TQValueList splits = (*it_transaction).splits(); + TQValueList::const_iterator it_split = splits.begin(); bool found = false; while( it_split != splits.end() ) { ReportAccount acc = (*it_split).accountId(); @@ -1074,7 +1074,7 @@ void QueryTable::constructPerformanceRow( const ReportAccount& account, TableRow result["return"] = annualReturn.toString(); result["returninvestment"] = returnInvestment.toString(); } - catch (QString e) + catch (TQString e) { kdDebug(2) << e << endl; } @@ -1094,9 +1094,9 @@ void QueryTable::constructAccountTable(void) //make sure we have all subaccounts of investment accounts includeInvestmentSubAccounts(); - QValueList accounts; + TQValueList accounts; file->accountList(accounts); - QValueList::const_iterator it_account = accounts.begin(); + TQValueList::const_iterator it_account = accounts.begin(); while ( it_account != accounts.end() ) { ReportAccount account = *it_account; @@ -1146,9 +1146,9 @@ void QueryTable::constructAccountTable(void) qaccountrow["price"] = ( netprice.reduce() ).convert(MyMoneyMoney::precToDenom(KMyMoneyGlobalSettings::pricePrecision())).toString(); qaccountrow["value"] = ( netprice.reduce() * shares.reduce() ).convert(fraction).toString(); - QString iid = (*it_account).institutionId(); + TQString iid = (*it_account).institutionId(); - // If an account does not have an institution, get it from the top-parent. + // If an account does not have an institution, get it from the top-tqparent. if ( iid.isEmpty() && ! account.isTopLevel() ) { ReportAccount topaccount = account.topParent(); @@ -1169,7 +1169,7 @@ void QueryTable::constructAccountTable(void) constructPerformanceRow( account, qaccountrow ); } else - qaccountrow["equitytype"] = QString(); + qaccountrow["equitytype"] = TQString(); // don't add the account if it is closed. In fact, the business logic // should prevent that an account can be closed with a balance not equal @@ -1194,14 +1194,14 @@ void QueryTable::constructSplitsTable(void) report.setConsiderCategory(true); // support for opening and closing balances - QMap accts; + TQMap accts; //get all transactions for this report - QValueList transactions = file->transactionList(report); - for (QValueList::const_iterator it_transaction = transactions.begin(); it_transaction != transactions.end(); ++it_transaction) { + TQValueList transactions = file->transactionList(report); + for (TQValueList::const_iterator it_transaction = transactions.begin(); it_transaction != transactions.end(); ++it_transaction) { TableRow qA, qS; - QDate pd; + TQDate pd; qA["id"] = qS["id"] = (* it_transaction).id(); qA["entrydate"] = qS["entrydate"] = (* it_transaction).entryDate().toString(Qt::ISODate); @@ -1209,8 +1209,8 @@ void QueryTable::constructSplitsTable(void) qA["commodity"] = qS["commodity"] = (* it_transaction).commodity(); pd = (* it_transaction).postDate(); - qA["month"] = qS["month"] = i18n("Month of %1").arg(QDate(pd.year(),pd.month(),1).toString(Qt::ISODate)); - qA["week"] = qS["week"] = i18n("Week of %1").arg(pd.addDays(1-pd.dayOfWeek()).toString(Qt::ISODate)); + qA["month"] = qS["month"] = i18n("Month of %1").tqarg(TQDate(pd.year(),pd.month(),1).toString(Qt::ISODate)); + qA["week"] = qS["week"] = i18n("Week of %1").tqarg(pd.addDays(1-pd.dayOfWeek()).toString(Qt::ISODate)); qA["currency"] = qS["currency"] = ""; @@ -1226,8 +1226,8 @@ void QueryTable::constructSplitsTable(void) // that is not an income or expense account if there is no stock or loan account) // to be the account (qA) that will have the sub-item "split" entries. we add // one transaction entry (qS) for each subsequent entry in the split. - const QValueList& splits = (*it_transaction).splits(); - QValueList::const_iterator myBegin, it_split; + const TQValueList& splits = (*it_transaction).splits(); + TQValueList::const_iterator myBegin, it_split; //S_end = splits.end(); for (it_split = splits.begin(), myBegin = splits.end(); it_split != splits.end(); ++it_split) { @@ -1266,7 +1266,7 @@ void QueryTable::constructSplitsTable(void) // reference (loan) account (qA). however, we process the matching // split entries (qS) normally. bool loan_special_case = false; - if(m_config.queryColumns() & MyMoneyReport::eQCloan) { + if(m_config.queryColumns() & MyMoneyReport::eTQCloan) { ReportAccount splitAcc = (*it_split).accountId(); loan_special_case = splitAcc.isLoan(); } @@ -1276,8 +1276,8 @@ void QueryTable::constructSplitsTable(void) bool include_me = true; bool transaction_text = false; //indicates whether a text should be considered as a match for the transaction or for a split only - QString a_fullname = ""; - QString a_memo = ""; + TQString a_fullname = ""; + TQString a_memo = ""; unsigned int pass = 1; do { @@ -1291,8 +1291,8 @@ void QueryTable::constructSplitsTable(void) if(fraction == -1) fraction = file->baseCurrency().smallestAccountFraction(); - QString institution = splitAcc.institutionId(); - QString payee = (*it_split).payeeId(); + TQString institution = splitAcc.institutionId(); + TQString payee = (*it_split).payeeId(); if ( m_config.isConvertCurrency() ) { xr = (splitAcc.deepCurrencyPrice((*it_transaction).postDate()) * splitAcc.baseCurrencyPrice((*it_transaction).postDate())).reduce(); @@ -1308,8 +1308,8 @@ void QueryTable::constructSplitsTable(void) if (splitAcc.isInvest()) { - // use the institution of the parent for stock accounts - institution = splitAcc.parent().institutionId(); + // use the institution of the tqparent for stock accounts + institution = splitAcc.tqparent().institutionId(); MyMoneyMoney shares = (*it_split).shares(); qA["action"] = (*it_split).action(); @@ -1319,7 +1319,7 @@ void QueryTable::constructSplitsTable(void) if (((*it_split).action() == MyMoneySplit::ActionBuyShares) && (*it_split).shares().isNegative()) qA["action"] = "Sell"; - qA["investaccount"] = splitAcc.parent().name(); + qA["investaccount"] = splitAcc.tqparent().name(); } include_me = m_config.includes(splitAcc); @@ -1364,8 +1364,8 @@ void QueryTable::constructSplitsTable(void) //fill in account information if (! splitAcc.isIncomeExpense() && it_split != myBegin) { qA["account"] = ((*it_split).shares().isNegative()) ? - i18n("Transfer to %1").arg(myBeginAcc.fullName()) - : i18n("Transfer from %1").arg(myBeginAcc.fullName()); + i18n("Transfer to %1").tqarg(myBeginAcc.fullName()) + : i18n("Transfer from %1").tqarg(myBeginAcc.fullName()); } else if (it_split == myBegin ) { //handle the main split if((splits.count() > 2)) { @@ -1373,7 +1373,7 @@ void QueryTable::constructSplitsTable(void) qA["account"] = i18n("[Split Transaction]"); } else { //fill the account name of the second split - QValueList::const_iterator tempSplit = splits.begin(); + TQValueList::const_iterator tempSplit = splits.begin(); //there are supposed to be only 2 splits if we ever get here if(tempSplit == myBegin && splits.count() > 1) @@ -1383,8 +1383,8 @@ void QueryTable::constructSplitsTable(void) ReportAccount tempSplitAcc = (*tempSplit).accountId(); if (! tempSplitAcc.isIncomeExpense()) { qA["account"] = ((*it_split).shares().isNegative()) ? - i18n("Transfer to %1").arg(tempSplitAcc.fullName()) - : i18n("Transfer from %1").arg(tempSplitAcc.fullName()); + i18n("Transfer to %1").tqarg(tempSplitAcc.fullName()) + : i18n("Transfer from %1").tqarg(tempSplitAcc.fullName()); } else { qA["account"] = tempSplitAcc.fullName(); } @@ -1439,14 +1439,14 @@ void QueryTable::constructSplitsTable(void) return; } - QDate startDate, endDate; + TQDate startDate, endDate; report.validDateRange(startDate, endDate); - QString strStartDate = startDate.toString(Qt::ISODate); - QString strEndDate = endDate.toString(Qt::ISODate); + TQString strStartDate = startDate.toString(Qt::ISODate); + TQString strEndDate = endDate.toString(Qt::ISODate); startDate = startDate.addDays(-1); - QMap::const_iterator it_account, accts_end; + TQMap::const_iterator it_account, accts_end; for (it_account = accts.begin(); it_account != accts.end(); ++it_account) { TableRow qA; @@ -1459,11 +1459,11 @@ void QueryTable::constructSplitsTable(void) if(fraction == -1) fraction = file->baseCurrency().smallestAccountFraction(); - QString institution = account.institutionId(); + TQString institution = account.institutionId(); - // use the institution of the parent for stock accounts + // use the institution of the tqparent for stock accounts if (account.isInvest()) - institution = account.parent().institutionId(); + institution = account.tqparent().institutionId(); MyMoneyMoney startBalance, endBalance, startPrice, endPrice; MyMoneyMoney startShares, endShares; @@ -1500,7 +1500,7 @@ void QueryTable::constructSplitsTable(void) qA["postdate"] = strStartDate; qA["balance"] = startBalance.convert(fraction).toString(); - qA["value"] = QString(); + qA["value"] = TQString(); qA["id"] = "A"; m_rows += qA; -- cgit v1.2.3