diff --git a/kmymoney/dialogs/kreportconfigurationfilterdlg.cpp b/kmymoney/dialogs/kreportconfigurationfilterdlg.cpp --- a/kmymoney/dialogs/kreportconfigurationfilterdlg.cpp +++ b/kmymoney/dialogs/kreportconfigurationfilterdlg.cpp @@ -472,7 +472,7 @@ case MyMoneyReport::eChartRing: combo->setCurrentItem(m_initialState.chartType()); break; - case MyMoneyReport::eChartEnd: + default: throw MYMONEYEXCEPTION("KReportConfigurationFilterDlg::slotReset(): Report has invalid charttype"); } m_tabChart->ui->m_checkCHGridLines->setChecked(m_initialState.isChartCHGridLines()); diff --git a/kmymoney/mymoney/mymoneyreport.h b/kmymoney/mymoney/mymoneyreport.h --- a/kmymoney/mymoney/mymoneyreport.h +++ b/kmymoney/mymoney/mymoneyreport.h @@ -390,7 +390,7 @@ /** * This method allows you to clear the underlying transaction filter */ - void clear(); + void clearTransactionFilter(); /** * This method allows you to set the underlying transaction filter diff --git a/kmymoney/mymoney/mymoneyreport.cpp b/kmymoney/mymoney/mymoneyreport.cpp --- a/kmymoney/mymoney/mymoneyreport.cpp +++ b/kmymoney/mymoney/mymoneyreport.cpp @@ -40,7 +40,7 @@ const MyMoneyReport::EReportType MyMoneyReport::kTypeArray[] = { eNoReport, ePivotTable, ePivotTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, eQueryTable, ePivotTable, ePivotTable, eInfoTable, eInfoTable, eInfoTable, eQueryTable, eQueryTable, eNoReport }; const QStringList MyMoneyReport::kDetailLevelText = QString("none,all,top,group,total,invalid").split(','); -const QStringList MyMoneyReport::kChartTypeText = QString("none,line,bar,pie,ring,stackedbar,invalid").split(','); +const QStringList MyMoneyReport::kChartTypeText = QString("none,line,bar,pie,ring,stackedbar").split(','); // This should live in mymoney/mymoneytransactionfilter.h const QStringList kTypeText = QString("all,payments,deposits,transfers,none").split(','); @@ -71,6 +71,11 @@ m_chartSVGridLines(true), m_chartByDefault(false), m_logYaxis(false), + m_dataRangeStart('0'), + m_dataRangeEnd('0'), + m_dataMajorTick('0'), + m_dataMinorTick('0'), + m_yLabelsPrecision(0), m_dataLock(MyMoneyReport::automatic), m_includeSchedules(false), m_includeTransfers(false), @@ -123,6 +128,11 @@ m_chartSVGridLines(true), m_chartByDefault(false), m_logYaxis(false), + m_dataRangeStart('0'), + m_dataRangeEnd('0'), + m_dataMajorTick('0'), + m_dataMinorTick('0'), + m_yLabelsPrecision(0), m_dataLock(MyMoneyReport::automatic), m_includeSchedules(false), m_includeTransfers(false), @@ -195,7 +205,7 @@ clearId(); } -void MyMoneyReport::clear() +void MyMoneyReport::clearTransactionFilter() { m_accountGroupFilter = false; m_accountGroups.clear(); @@ -340,8 +350,18 @@ // older versions of the program as new features are added to the reports. // Feel free to change the minor type every time a change is made here. - writeBaseXML(*doc, e); + // write report's internals + if (m_reportType == ePivotTable) + e.setAttribute("type", "pivottable 1.15"); + else if (m_reportType == eQueryTable) + e.setAttribute("type", "querytable 1.14"); + else if (m_reportType == eInfoTable) + e.setAttribute("type", "infotable 1.0"); + e.setAttribute("group", m_group); + e.setAttribute("id", m_id); + + // write general tab if (anonymous) { e.setAttribute("name", m_id); e.setAttribute("comment", QString(m_comment).fill('x')); @@ -349,59 +369,60 @@ e.setAttribute("name", m_name); e.setAttribute("comment", m_comment); } - e.setAttribute("group", m_group); e.setAttribute("convertcurrency", m_convertCurrency); e.setAttribute("favorite", m_favorite); - e.setAttribute("tax", m_tax); - e.setAttribute("investments", m_investments); - e.setAttribute("loans", m_loans); - e.setAttribute("hidetransactions", m_hideTransactions); - e.setAttribute("rowtype", kRowTypeText[m_rowType]); - e.setAttribute("datelock", kDateLockText[m_dateLock]); - e.setAttribute("datalock", kDataLockText[m_dataLock]); - e.setAttribute("includeschedules", m_includeSchedules); - e.setAttribute("columnsaredays", m_columnsAreDays); - e.setAttribute("includestransfers", m_includeTransfers); - if (!m_budgetId.isEmpty()) - e.setAttribute("budget", m_budgetId); - e.setAttribute("includesactuals", m_includeBudgetActuals); - e.setAttribute("includeunused", m_includeUnusedAccounts); - e.setAttribute("includesforecast", m_includeForecast); - e.setAttribute("includesprice", m_includePrice); - e.setAttribute("includesaverageprice", m_includeAveragePrice); - e.setAttribute("mixedtime", m_mixedTime); - e.setAttribute("includesmovingaverage", m_includeMovingAverage); - if (m_includeMovingAverage) - e.setAttribute("movingaveragedays", m_movingAverageDays); - - if (m_chartType < 0 || m_chartType >= kChartTypeText.size()) { - qDebug("m_chartType out of bounds with %d on report of type %d. Default to none.", m_chartType, m_reportType); - e.setAttribute("charttype", kChartTypeText[0]); - } else { - e.setAttribute("charttype", kChartTypeText[m_chartType]); - } - e.setAttribute("chartdatalabels", m_chartDataLabels); - e.setAttribute("chartchgridlines", m_chartCHGridLines); - e.setAttribute("chartsvgridlines", m_chartSVGridLines); - e.setAttribute("chartbydefault", m_chartByDefault); - e.setAttribute("chartlinewidth", m_chartLineWidth); - e.setAttribute("logYaxis", m_logYaxis); - e.setAttribute("dataRangeStart", m_dataRangeStart); - e.setAttribute("dataRangeEnd", m_dataRangeEnd); - e.setAttribute("dataMajorTick", m_dataMajorTick); - e.setAttribute("dataMinorTick", m_dataMinorTick); - e.setAttribute("yLabelsPrecision", m_yLabelsPrecision); - e.setAttribute("dataLock", m_dataLock); e.setAttribute("skipZero", m_skipZero); - e.setAttribute("detail", kDetailLevelText[m_detailLevel]); + + e.setAttribute("datelock", kDateLockText[m_dateLock]); if (m_reportType == ePivotTable) { - e.setAttribute("type", "pivottable 1.15"); - e.setAttribute("columntype", kColumnTypeText[m_columnType]); + // write report's internals + e.setAttribute("includesactuals", m_includeBudgetActuals); + e.setAttribute("includesforecast", m_includeForecast); + e.setAttribute("includesprice", m_includePrice); + e.setAttribute("includesaverageprice", m_includeAveragePrice); + e.setAttribute("mixedtime", m_mixedTime); + + // write rows/columns tab + if (!m_budgetId.isEmpty()) + e.setAttribute("budget", m_budgetId); + + e.setAttribute("rowtype", kRowTypeText[m_rowType]); e.setAttribute("showrowtotals", m_showRowTotals); - } else if (m_reportType == eQueryTable) { - e.setAttribute("type", "querytable 1.14"); + e.setAttribute("detail", kDetailLevelText[m_detailLevel]); + e.setAttribute("includesmovingaverage", m_includeMovingAverage); + if (m_includeMovingAverage) + e.setAttribute("movingaveragedays", m_movingAverageDays); + + e.setAttribute("includeschedules", m_includeSchedules); + e.setAttribute("includestransfers", m_includeTransfers); + e.setAttribute("includeunused", m_includeUnusedAccounts); + e.setAttribute("columnsaredays", m_columnsAreDays); + + // write chart tab + if (m_chartType < 0 || m_chartType >= kChartTypeText.size()) { + qDebug("m_chartType out of bounds with %d on report of type %d. Default to none.", m_chartType, m_reportType); + e.setAttribute("charttype", kChartTypeText[eChartNone]); + } else + e.setAttribute("charttype", kChartTypeText[m_chartType]); + + e.setAttribute("chartchgridlines", m_chartCHGridLines); + e.setAttribute("chartsvgridlines", m_chartSVGridLines); + e.setAttribute("chartdatalabels", m_chartDataLabels); + e.setAttribute("chartbydefault", m_chartByDefault); + e.setAttribute("logYaxis", m_logYaxis); + e.setAttribute("chartlinewidth", m_chartLineWidth); + e.setAttribute("columntype", kColumnTypeText[m_columnType]); + e.setAttribute("datalock", kDataLockText[m_dataLock]); + e.setAttribute("dataRangeStart", m_dataRangeStart); + e.setAttribute("dataRangeEnd", m_dataRangeEnd); + e.setAttribute("dataMajorTick", m_dataMajorTick); + e.setAttribute("dataMinorTick", m_dataMinorTick); + e.setAttribute("yLabelsPrecision", m_yLabelsPrecision); + } else if (m_reportType == eQueryTable) { + // write rows/columns tab + e.setAttribute("rowtype", kRowTypeText[m_rowType]); QStringList columns; unsigned qc = m_queryColumns; unsigned it_qc = eQCbegin; @@ -414,15 +435,20 @@ } e.setAttribute("querycolumns", columns.join(",")); + e.setAttribute("tax", m_tax); + e.setAttribute("investments", m_investments); + e.setAttribute("loans", m_loans); + e.setAttribute("hidetransactions", m_hideTransactions); + e.setAttribute("detail", kDetailLevelText[m_detailLevel]); + + // write capital gains tab if (m_queryColumns & eQCcapitalgain) { e.setAttribute("settlementperiod", m_settlementPeriod); e.setAttribute("showSTLTCapitalGains", m_showSTLTCapitalGains); e.setAttribute("tseparator", m_tseparator.toString(Qt::ISODate)); } - } else if (m_reportType == eInfoTable) { - e.setAttribute("type", "infotable 1.0"); + } else if (m_reportType == eInfoTable) e.setAttribute("showrowtotals", m_showRowTotals); - } // // Text Filter @@ -609,223 +635,202 @@ // should be able to be loaded by this method (as long as it's one of the // report types supported in this version, of course) - bool result = false; - - if ( - "REPORT" == e.tagName() - && - ( - (e.attribute("type").indexOf("pivottable 1.") == 0) - || - (e.attribute("type").indexOf("querytable 1.") == 0) - || - (e.attribute("type").indexOf("infotable 1.") == 0) - ) - ) { - result = true; - clear(); - - int i; - m_name = e.attribute("name"); - m_comment = e.attribute("comment", "Extremely old report"); - - //set report type - if (!e.attribute("type").indexOf("pivottable")) { - m_reportType = MyMoneyReport::ePivotTable; - } else if (!e.attribute("type").indexOf("querytable")) { - m_reportType = MyMoneyReport::eQueryTable; - } else if (!e.attribute("type").indexOf("infotable")) { - m_reportType = MyMoneyReport::eInfoTable; - } else { - m_reportType = MyMoneyReport::eNoReport; - } - - // Removed the line that screened out loading reports that are called - // "Default Report". It's possible for the user to change the comment - // to this, and we'd hate for it to break as a result. - m_group = e.attribute("group"); - m_id = e.attribute("id"); + if (e.tagName().compare("REPORT") != 0) + return false; + + // read report's internals + QString type = e.attribute("type"); + if (type.startsWith("pivottable")) + m_reportType = ePivotTable; + else if (type.startsWith("querytable")) + m_reportType = eQueryTable; + else if (type.startsWith("infotable")) + m_reportType = eInfoTable; + else + return false; + + m_group = e.attribute("group"); + m_id = e.attribute("id"); + + clearTransactionFilter(); + + int i; + + // read date tab + QString datelockstr = e.attribute("datelock", "userdefined"); + // Handle the pivot 1.2/query 1.1 case where the values were saved as + // numbers + bool ok = false; + i = datelockstr.toUInt(&ok); + if (!ok) { + i = kDateLockText.indexOf(datelockstr); + if (i == -1) + i = MyMoneyTransactionFilter::userDefined; + } + setDateFilter(static_cast(i)); - //check for reports with older settings which didn't have the detail attribute - if (e.hasAttribute("detail")) { - i = kDetailLevelText.indexOf(e.attribute("detail", "all")); - if (i != -1) - m_detailLevel = static_cast(i); - } else if (e.attribute("showsubaccounts", "0").toUInt()) { - //set to show all accounts - m_detailLevel = eDetailAll; - } else { - //set to show the top level account instead - m_detailLevel = eDetailTop; - } + // read general tab + m_name = e.attribute("name"); + m_comment = e.attribute("comment", "Extremely old report"); + m_convertCurrency = e.attribute("convertcurrency", "1").toUInt(); + m_favorite = e.attribute("favorite", "0").toUInt(); + m_skipZero = e.attribute("skipZero", "0").toUInt(); - m_convertCurrency = e.attribute("convertcurrency", "1").toUInt(); - m_favorite = e.attribute("favorite", "0").toUInt(); - m_tax = e.attribute("tax", "0").toUInt(); - m_investments = e.attribute("investments", "0").toUInt(); - m_loans = e.attribute("loans", "0").toUInt(); - m_hideTransactions = e.attribute("hidetransactions", "0").toUInt(); - m_includeSchedules = e.attribute("includeschedules", "0").toUInt(); - m_columnsAreDays = e.attribute("columnsaredays", "0").toUInt(); - m_includeTransfers = e.attribute("includestransfers", "0").toUInt(); - if (e.hasAttribute("budget")) - m_budgetId = e.attribute("budget"); + if (m_reportType == ePivotTable) { + // read report's internals m_includeBudgetActuals = e.attribute("includesactuals", "0").toUInt(); - m_includeUnusedAccounts = e.attribute("includeunused", "0").toUInt(); m_includeForecast = e.attribute("includesforecast", "0").toUInt(); m_includePrice = e.attribute("includesprice", "0").toUInt(); m_includeAveragePrice = e.attribute("includesaverageprice", "0").toUInt(); m_mixedTime = e.attribute("mixedtime", "0").toUInt(); - m_includeMovingAverage = e.attribute("includesmovingaverage", "0").toUInt(); - m_skipZero = e.attribute("skipZero", "0").toUInt(); - if (m_includeMovingAverage) - m_movingAverageDays = e.attribute("movingaveragedays", "1").toUInt(); - - //only load chart data if it is a pivot table - m_chartType = static_cast(0); - if (m_reportType == ePivotTable) { - i = kChartTypeText.indexOf(e.attribute("charttype")); - - if (i >= 0) - m_chartType = static_cast(i); - - // if it is invalid, set to first type - if (m_chartType >= eChartEnd) - m_chartType = eChartLine; - - m_chartDataLabels = e.attribute("chartdatalabels", "1").toUInt(); - m_chartCHGridLines = e.attribute("chartchgridlines", "1").toUInt(); - m_chartSVGridLines = e.attribute("chartsvgridlines", "1").toUInt(); - m_chartByDefault = e.attribute("chartbydefault", "0").toUInt(); - m_chartLineWidth = e.attribute("chartlinewidth", QString(m_lineWidth)).toUInt(); - m_logYaxis = e.attribute("logYaxis", "0").toUInt(); - m_dataRangeStart = e.attribute("dataRangeStart", "0"); - m_dataRangeEnd = e.attribute("dataRangeEnd", "0"); - m_dataMajorTick = e.attribute("dataMajorTick", "0"); - m_dataMinorTick = e.attribute("dataMinorTick", "0"); - m_yLabelsPrecision = e.attribute("yLabelsPrecision", "2").toUInt(); - } else { - m_chartDataLabels = true; - m_chartCHGridLines = true; - m_chartSVGridLines = true; - m_chartByDefault = false; - m_chartLineWidth = 1; - m_logYaxis = false; - } - QString datelockstr = e.attribute("datelock", "userdefined"); - // Handle the pivot 1.2/query 1.1 case where the values were saved as - // numbers - bool ok = false; - i = datelockstr.toUInt(&ok); - if (!ok) { - i = kDateLockText.indexOf(datelockstr); - if (i == -1) - i = MyMoneyTransactionFilter::userDefined; - } - setDateFilter(static_cast(i)); - - QString datalockstr = e.attribute("dataLock", "userdefined"); - ok = false; - i = datalockstr.toUInt(&ok); - if (!ok) { - i = kDataLockText.indexOf(datalockstr); - if (i == -1) - i = MyMoneyReport::userDefined; - } - setDataFilter(static_cast(i)); + // read rows/columns tab + if (e.hasAttribute("budget")) + m_budgetId = e.attribute("budget"); - i = kRowTypeText.indexOf(e.attribute("rowtype", "expenseincome")); - if (i != -1) { + i = kRowTypeText.indexOf(e.attribute("rowtype")); + if (i != -1) setRowType(static_cast(i)); - // recent versions of KMyMoney always showed a total column for - // income/expense reports. We turn it on for backward compatibility - // here. If the total column is turned off, the flag will be reset - // in the next step - if (i == eExpenseIncome) - m_showRowTotals = true; - } + else + setRowType(eExpenseIncome); + if (e.hasAttribute("showrowtotals")) m_showRowTotals = e.attribute("showrowtotals").toUInt(); + else if (rowType() == eExpenseIncome) // for backward compatibility + m_showRowTotals = true; - i = kColumnTypeText.indexOf(e.attribute("columntype", "months")); + //check for reports with older settings which didn't have the detail attribute + i = kDetailLevelText.indexOf(e.attribute("detail")); + if (i != -1) + m_detailLevel = static_cast(i); + else + m_detailLevel = eDetailAll; + + m_includeMovingAverage = e.attribute("includesmovingaverage", "0").toUInt(); + if (m_includeMovingAverage) + m_movingAverageDays = e.attribute("movingaveragedays", "1").toUInt(); + m_includeSchedules = e.attribute("includeschedules", "0").toUInt(); + m_includeTransfers = e.attribute("includestransfers", "0").toUInt(); + m_includeUnusedAccounts = e.attribute("includeunused", "0").toUInt(); + m_columnsAreDays = e.attribute("columnsaredays", "0").toUInt(); + + // read chart tab + i = kChartTypeText.indexOf(e.attribute("charttype")); + if (i != -1) + m_chartType = static_cast(i); + else + m_chartType = eChartNone; + + m_chartCHGridLines = e.attribute("chartchgridlines", "1").toUInt(); + m_chartSVGridLines = e.attribute("chartsvgridlines", "1").toUInt(); + m_chartDataLabels = e.attribute("chartdatalabels", "1").toUInt(); + m_chartByDefault = e.attribute("chartbydefault", "0").toUInt(); + m_logYaxis = e.attribute("logYaxis", "0").toUInt(); + m_chartLineWidth = e.attribute("chartlinewidth", QString(m_lineWidth)).toUInt(); + + // read range tab + i = kColumnTypeText.indexOf(e.attribute("columntype")); if (i != -1) setColumnType(static_cast(i)); + else + setColumnType(eMonths); + + i = kDataLockText.indexOf(e.attribute("datalock")); + if (i != -1) + setDataFilter(static_cast(i)); + else + setDataFilter(MyMoneyReport::userDefined); + + m_dataRangeStart = e.attribute("dataRangeStart", "0"); + m_dataRangeEnd = e.attribute("dataRangeEnd", "0"); + m_dataMajorTick = e.attribute("dataMajorTick", "0"); + m_dataMinorTick = e.attribute("dataMinorTick", "0"); + m_yLabelsPrecision = e.attribute("yLabelsPrecision", "2").toUInt(); + } else if (m_reportType == eQueryTable) { + // read rows/columns tab + i = kRowTypeText.indexOf(e.attribute("rowtype")); + if (i != -1) + setRowType(static_cast(i)); + else + setRowType(eAccount); unsigned qc = 0; QStringList columns = e.attribute("querycolumns", "none").split(','); - QStringList::const_iterator it_column = columns.constBegin(); - while (it_column != columns.constEnd()) { - i = kQueryColumnsText.indexOf(*it_column); + foreach (const auto column, columns) { + i = kQueryColumnsText.indexOf(column); if (i > 0) qc |= (1 << (i - 1)); - - ++it_column; } setQueryColumns(static_cast(qc)); - if (m_reportType == eQueryTable && m_queryColumns & eQCcapitalgain) { + m_tax = e.attribute("tax", "0").toUInt(); + m_investments = e.attribute("investments", "0").toUInt(); + m_loans = e.attribute("loans", "0").toUInt(); + m_hideTransactions = e.attribute("hidetransactions", "0").toUInt(); + m_detailLevel = kDetailLevelText.indexOf(e.attribute("detail", "none")) == eDetailAll ? eDetailAll : eDetailNone; + + // read capital gains tab + if (m_queryColumns & eQCcapitalgain) { m_showSTLTCapitalGains = e.attribute("showSTLTCapitalGains", "0").toUInt(); m_settlementPeriod = e.attribute("settlementperiod", "3").toUInt(); m_tseparator = QDate::fromString(e.attribute("tseparator", QDate::currentDate().addYears(-1).toString(Qt::ISODate)),Qt::ISODate); } + } else if (m_reportType == eInfoTable) { + if (e.hasAttribute("showrowtotals")) + m_showRowTotals = e.attribute("showrowtotals").toUInt(); + else + m_showRowTotals = true; + } - QDomNode child = e.firstChild(); - while (!child.isNull() && child.isElement()) { - QDomElement c = child.toElement(); - if ("TEXT" == c.tagName() && c.hasAttribute("pattern")) { - setTextFilter(QRegExp(c.attribute("pattern"), - c.attribute("casesensitive", "1").toUInt() - ? Qt::CaseSensitive : Qt::CaseInsensitive, - c.attribute("regex", "1").toUInt() - ? QRegExp::Wildcard : QRegExp::RegExp), - c.attribute("inverttext", "0").toUInt()); - } - if ("TYPE" == c.tagName() && c.hasAttribute("type")) { - i = kTypeText.indexOf(c.attribute("type")); - if (i != -1) - addType(i); - } - if ("STATE" == c.tagName() && c.hasAttribute("state")) { - i = kStateText.indexOf(c.attribute("state")); - if (i != -1) - addState(i); - } - if ("NUMBER" == c.tagName()) { - setNumberFilter(c.attribute("from"), c.attribute("to")); - } - if ("AMOUNT" == c.tagName()) { - setAmountFilter(MyMoneyMoney(c.attribute("from", "0/100")), MyMoneyMoney(c.attribute("to", "0/100"))); - } - if ("DATES" == c.tagName()) { - QDate from, to; - if (c.hasAttribute("from")) - from = QDate::fromString(c.attribute("from"), Qt::ISODate); - if (c.hasAttribute("to")) - to = QDate::fromString(c.attribute("to"), Qt::ISODate); - MyMoneyTransactionFilter::setDateFilter(from, to); - } - if ("PAYEE" == c.tagName()) { - addPayee(c.attribute("id")); - } - if ("TAG" == c.tagName()) { - addTag(c.attribute("id")); - } - if ("CATEGORY" == c.tagName() && c.hasAttribute("id")) { - addCategory(c.attribute("id")); - } - if ("ACCOUNT" == c.tagName() && c.hasAttribute("id")) { - addAccount(c.attribute("id")); - } - if ("ACCOUNTGROUP" == c.tagName() && c.hasAttribute("group")) { - i = kAccountTypeText.indexOf(c.attribute("group")); - if (i != -1) - addAccountGroup(static_cast(i)); - } - child = child.nextSibling(); + QDomNode child = e.firstChild(); + while (!child.isNull() && child.isElement()) { + QDomElement c = child.toElement(); + if ("TEXT" == c.tagName() && c.hasAttribute("pattern")) { + setTextFilter(QRegExp(c.attribute("pattern"), + c.attribute("casesensitive", "1").toUInt() + ? Qt::CaseSensitive : Qt::CaseInsensitive, + c.attribute("regex", "1").toUInt() + ? QRegExp::Wildcard : QRegExp::RegExp), + c.attribute("inverttext", "0").toUInt()); + } + if ("TYPE" == c.tagName() && c.hasAttribute("type")) { + i = kTypeText.indexOf(c.attribute("type")); + if (i != -1) + addType(i); } + if ("STATE" == c.tagName() && c.hasAttribute("state")) { + i = kStateText.indexOf(c.attribute("state")); + if (i != -1) + addState(i); + } + if ("NUMBER" == c.tagName()) + setNumberFilter(c.attribute("from"), c.attribute("to")); + if ("AMOUNT" == c.tagName()) + setAmountFilter(MyMoneyMoney(c.attribute("from", "0/100")), MyMoneyMoney(c.attribute("to", "0/100"))); + if ("DATES" == c.tagName()) { + QDate from, to; + if (c.hasAttribute("from")) + from = QDate::fromString(c.attribute("from"), Qt::ISODate); + if (c.hasAttribute("to")) + to = QDate::fromString(c.attribute("to"), Qt::ISODate); + MyMoneyTransactionFilter::setDateFilter(from, to); + } + if ("PAYEE" == c.tagName()) + addPayee(c.attribute("id")); + if ("TAG" == c.tagName()) + addTag(c.attribute("id")); + if ("CATEGORY" == c.tagName() && c.hasAttribute("id")) + addCategory(c.attribute("id")); + if ("ACCOUNT" == c.tagName() && c.hasAttribute("id")) + addAccount(c.attribute("id")); + if ("ACCOUNTGROUP" == c.tagName() && c.hasAttribute("group")) { + i = kAccountTypeText.indexOf(c.attribute("group")); + if (i != -1) + addAccountGroup(static_cast(i)); + } + child = child.nextSibling(); } - return result; + return true; } void MyMoneyReport::writeXML(QDomDocument& document, QDomElement& parent) const diff --git a/kmymoney/reports/tests/pivottable-test.cpp b/kmymoney/reports/tests/pivottable-test.cpp --- a/kmymoney/reports/tests/pivottable-test.cpp +++ b/kmymoney/reports/tests/pivottable-test.cpp @@ -209,7 +209,7 @@ QVERIFY(spending_f.m_grid.m_total[eActual][2] == (-moSolo)); QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moSolo)); - filter.clear(); + filter.clearTransactionFilter(); filter.setRowType(MyMoneyReport::eAssetLiability); filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); XMLandback(filter); @@ -242,7 +242,7 @@ QVERIFY(spending_f.m_grid.m_total[eActual][3] == (-moParent - moChild)); QVERIFY(spending_f.m_grid.m_total[eActual].m_total == (-moParent - moChild)); - filter.clear(); + filter.clearTransactionFilter(); filter.setRowType(MyMoneyReport::eAssetLiability); filter.setDateFilter(QDate(2004, 9, 1), QDate(2005, 1, 1).addDays(-1)); filter.setName("Net Worth with Sub-Account"); @@ -448,7 +448,7 @@ QVERIFY(spending_fnc.m_grid["Expense"]["Foreign"][acJpyCash][eActual][4] == (moJpyTransaction)); filter.setConvertCurrency(true); - filter.clear(); + filter.clearTransactionFilter(); filter.setName("Multiple currency net worth"); filter.setRowType(MyMoneyReport::eAssetLiability); filter.setDateFilter(QDate(2004, 1, 1), QDate(2005, 1, 1).addDays(-1)); @@ -563,14 +563,14 @@ QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo); - filter.clear(); + filter.clearTransactionFilter(); filter.addType(MyMoneyTransactionFilter::deposits); XMLandback(filter); PivotTable spending_f2(filter); QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == moParent1); - filter.clear(); + filter.clearTransactionFilter(); filter.addType(MyMoneyTransactionFilter::transfers); XMLandback(filter); PivotTable spending_f3(filter); @@ -625,7 +625,7 @@ QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == -moSolo - moParent1); - filter.clear(); + filter.clearTransactionFilter(); filter.addState(MyMoneyTransactionFilter::notReconciled); XMLandback(filter); PivotTable spending_f3(filter); @@ -701,7 +701,7 @@ PivotTable spending_f(filter); QVERIFY(spending_f.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2 - moSolo - moParent1 - moParent2); - filter.clear(); + filter.clearTransactionFilter(); XMLandback(filter); PivotTable spending_f2(filter); QVERIFY(spending_f2.m_grid.m_total[eActual].m_total == -moSolo - moParent1 - moParent2 - moSolo - moParent1 - moParent2 - moSolo - moParent1 - moParent2);