diff --git a/kmymoney/dialogs/CMakeLists.txt b/kmymoney/dialogs/CMakeLists.txt --- a/kmymoney/dialogs/CMakeLists.txt +++ b/kmymoney/dialogs/CMakeLists.txt @@ -20,6 +20,7 @@ kequitypriceupdatedlg.cpp kexportdlg.cpp kfindtransactiondlg.cpp + daterangedlg.cpp kgeneratesqldlg.cpp kgncimportoptionsdlg.cpp kgncpricesourcedlg.cpp @@ -62,7 +63,7 @@ keditscheduledlgdecl.ui kenterscheduledlgdecl.ui kequitypriceupdatedlgdecl.ui kexportdlgdecl.ui - kfindtransactiondlgdecl.ui kgeneratesqldlgdecl.ui kgncimportoptionsdlgdecl.ui + kfindtransactiondlgdecl.ui daterangedlgdecl.ui kgeneratesqldlgdecl.ui kgncimportoptionsdlgdecl.ui kgncpricesourcedlgdecl.ui kimportdlgdecl.ui kloadtemplatedlgdecl.ui kmymoneyfileinfodlgdecl.ui kmymoneypricedlgdecl.ui knewaccountdlgdecl.ui knewbankdlgdecl.ui knewbudgetdlgdecl.ui diff --git a/kmymoney/dialogs/daterangedlg.h b/kmymoney/dialogs/daterangedlg.h new file mode 100644 --- /dev/null +++ b/kmymoney/dialogs/daterangedlg.h @@ -0,0 +1,99 @@ +/*************************************************************************** + kfindtransactiondlg.h + ------------------- + copyright : (C) 2003 by Thomas Baumgart + email : ipwizard@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DATERANGEDLG_H +#define DATERANGEDLG_H + +// ---------------------------------------------------------------------------- +// QT Includes + +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +// KDE Includes + +#include + +// ---------------------------------------------------------------------------- +// Project Includes + +#include "mymoneyutils.h" +#include "mymoneytransactionfilter.h" + +namespace Ui +{ +class DateRangeDlgDecl; +} + +class DateRangeDlg : public QWidget +{ + Q_OBJECT + +public: + + /* + // Make sure to keep the following enum valus in sync with the values + // used by the GUI in daterangedlgdecl.ui + enum dateOptionE { + allDates = 0, + asOfToday, + currentMonth, + currentYear, + monthToDate, + yearToDate, + yearToMonth, + lastMonth, + lastYear, + last7Days, + last30Days, + last3Months, + last6Months, + last12Months, + next7Days, + next30Days, + next3Months, + next6Months, + next12Months, + userDefined, + last3ToNext3Months, + last11Months, + next18Months, + // insert new constants above of this line + dateOptionCount + }; + */ + DateRangeDlg(QWidget *parent = 0); + ~DateRangeDlg(); + Ui::DateRangeDlgDecl* m_ui; + +public slots: + void slotReset(); + void slotUpdateSelections(QString &txt); + void slotDateRangeChanged(int); + void slotDateChanged(); + +private: + void setupDatePage(); + + QDate m_startDates[MyMoneyTransactionFilter::dateOptionCount]; + QDate m_endDates[MyMoneyTransactionFilter::dateOptionCount]; +}; + +#endif diff --git a/kmymoney/dialogs/daterangedlg.cpp b/kmymoney/dialogs/daterangedlg.cpp new file mode 100644 --- /dev/null +++ b/kmymoney/dialogs/daterangedlg.cpp @@ -0,0 +1,139 @@ +/*************************************************************************** + kfindtransactiondlg.cpp + ------------------- + copyright : (C) 2003, 2007 by Thomas Baumgart + email : ipwizard@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +#include "daterangedlg.h" + +// ---------------------------------------------------------------------------- +// QT Includes + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +// KDE Includes + +#include +#include +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +// Project Includes + +#include +#include +#include +#include +#include +#include +#include + +#include "ui_daterangedlgdecl.h" + +DateRangeDlg::DateRangeDlg(QWidget *parent) : + QWidget(parent), + m_ui(new Ui::DateRangeDlgDecl) +{ + m_ui->setupUi(this); + setupDatePage(); +} + +DateRangeDlg::~DateRangeDlg() +{ + delete m_ui; +} + +void DateRangeDlg::slotReset() +{ + m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::allDates); + slotDateRangeChanged(MyMoneyTransactionFilter::allDates); +} + +void DateRangeDlg::slotUpdateSelections(QString &txt) +{ + if (m_ui->m_dateRange->currentItem() != 0) { + if (!txt.isEmpty()) + txt += ", "; + txt += i18n("Date"); + } +} + +void DateRangeDlg::setupDatePage() +{ + int i; + for (i = MyMoneyTransactionFilter::allDates; i < MyMoneyTransactionFilter::dateOptionCount; ++i) { + MyMoneyTransactionFilter::translateDateRange(static_cast(i), m_startDates[i], m_endDates[i]); + } + + connect(m_ui->m_dateRange, SIGNAL(itemSelected(int)), this, SLOT(slotDateRangeChanged(int))); + connect(m_ui->m_fromDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); + connect(m_ui->m_toDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); + + slotDateRangeChanged(MyMoneyTransactionFilter::allDates); +} + +void DateRangeDlg::slotDateRangeChanged(int idx) +{ + switch (idx) { + case MyMoneyTransactionFilter::allDates: + case MyMoneyTransactionFilter::userDefined: + m_ui->m_fromDate->loadDate(QDate()); + m_ui->m_toDate->loadDate(QDate()); + break; + default: + m_ui->m_fromDate->loadDate(m_startDates[idx]); + m_ui->m_toDate->loadDate(m_endDates[idx]); + break; + } +// slotUpdateSelections(); +} + +void DateRangeDlg::slotDateChanged() +{ + int idx; + for (idx = MyMoneyTransactionFilter::asOfToday; idx < MyMoneyTransactionFilter::dateOptionCount; ++idx) { + if (m_ui->m_fromDate->date() == m_startDates[idx] + && m_ui->m_toDate->date() == m_endDates[idx]) { + break; + } + } + //if no filter matched, set to user defined + if (idx == MyMoneyTransactionFilter::dateOptionCount) + idx = MyMoneyTransactionFilter::userDefined; + + m_ui->m_dateRange->blockSignals(true); + m_ui->m_dateRange->setCurrentItem(static_cast(idx)); + m_ui->m_dateRange->blockSignals(false); +// slotUpdateSelections(); +} diff --git a/kmymoney/dialogs/daterangedlgdecl.ui b/kmymoney/dialogs/daterangedlgdecl.ui new file mode 100644 --- /dev/null +++ b/kmymoney/dialogs/daterangedlgdecl.ui @@ -0,0 +1,63 @@ + + + DateRangeDlgDecl + + + + + + Range + + + false + + + + + + + + + + From + + + false + + + + + + + + + + To + + + false + + + + + + + + + + + + KMyMoneyPeriodCombo + QWidget +
kmymoneymvccombo.h
+ 1 +
+ + kMyMoneyDateInput + QWidget +
kmymoneydateinput.h
+
+
+ + +
diff --git a/kmymoney/dialogs/kbalancechartdlg.cpp b/kmymoney/dialogs/kbalancechartdlg.cpp --- a/kmymoney/dialogs/kbalancechartdlg.cpp +++ b/kmymoney/dialogs/kbalancechartdlg.cpp @@ -96,7 +96,8 @@ i18n("Generated Report") ); reportCfg.setChartByDefault(true); - reportCfg.setChartGridLines(false); + reportCfg.setChartCHGridLines(false); + reportCfg.setChartSVGridLines(false); reportCfg.setChartDataLabels(false); reportCfg.setChartType(MyMoneyReport::eChartLine); reportCfg.setIncludingForecast(true); diff --git a/kmymoney/dialogs/kfindtransactiondlg.h b/kmymoney/dialogs/kfindtransactiondlg.h --- a/kmymoney/dialogs/kfindtransactiondlg.h +++ b/kmymoney/dialogs/kfindtransactiondlg.h @@ -39,6 +39,7 @@ class QTreeWidget; class QTreeWidgetItem; +class DateRangeDlg; /** * @author Thomas Baumgart @@ -69,37 +70,6 @@ public: - /* - // Make sure to keep the following enum valus in sync with the values - // used by the GUI in kfindtransactiondlgdecl.ui - enum dateOptionE { - allDates = 0, - asOfToday, - currentMonth, - currentYear, - monthToDate, - yearToDate, - yearToMonth, - lastMonth, - lastYear, - last7Days, - last30Days, - last3Months, - last6Months, - last12Months, - next7Days, - next30Days, - next3Months, - next6Months, - next12Months, - userDefined, - last3ToNext3Months, - last11Months, - next18Months, - // insert new constants above of this line - dateOptionCount - }; - */ KFindTransactionDlg(QWidget *parent = 0); ~KFindTransactionDlg(); @@ -122,9 +92,6 @@ void slotUpdateSelections(); - virtual void slotDateRangeChanged(int); - virtual void slotDateChanged(); - virtual void slotAmountSelected(); virtual void slotAmountRangeSelected(); @@ -169,7 +136,6 @@ }; void setupCategoriesPage(); - void setupDatePage(); void setupAccountsPage(); void setupAmountPage(); void setupPayeesPage(); @@ -234,6 +200,7 @@ bool m_needReload; Ui::KFindTransactionDlgDecl* m_ui; + DateRangeDlg *m_dateRange; }; #endif diff --git a/kmymoney/dialogs/kfindtransactiondlg.cpp b/kmymoney/dialogs/kfindtransactiondlg.cpp --- a/kmymoney/dialogs/kfindtransactiondlg.cpp +++ b/kmymoney/dialogs/kfindtransactiondlg.cpp @@ -59,9 +59,11 @@ #include #include #include +#include #include "ui_kfindtransactiondlgdecl.h" #include "ui_ksortoptiondlg.h" +#include "ui_daterangedlgdecl.h" enum ItemRoles { ItemIdRole = Qt::UserRole @@ -119,6 +121,8 @@ m_ui(new Ui::KFindTransactionDlgDecl) { m_ui->setupUi(this); + m_dateRange = new DateRangeDlg(m_ui->m_dateTab); + m_ui->dateRangeLayout->insertWidget(0, m_dateRange); m_ui->ButtonGroup1->setId(m_ui->m_amountButton, 0); m_ui->ButtonGroup1->setId(m_ui->m_amountRangeButton, 1); @@ -133,7 +137,6 @@ setupAccountsPage(); setupCategoriesPage(); - setupDatePage(); setupAmountPage(); setupPayeesPage(); setupTagsPage(); @@ -232,8 +235,8 @@ // the following call implies a call to slotUpdateSelections, // that's why we call it last - m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::allDates); - slotDateRangeChanged(MyMoneyTransactionFilter::allDates); + m_dateRange->slotReset(); + slotUpdateSelections(); } void KFindTransactionDlg::slotUpdateSelections() @@ -259,12 +262,7 @@ txt += i18n("Account"); } - // Date tab - if (m_ui->m_dateRange->currentItem() != 0) { - if (!txt.isEmpty()) - txt += ", "; - txt += i18n("Date"); - } + m_dateRange->slotUpdateSelections(txt); // Amount tab if ((m_ui->m_amountButton->isChecked() && m_ui->m_amountEdit->isValid()) @@ -435,55 +433,6 @@ } } -void KFindTransactionDlg::setupDatePage() -{ - int i; - for (i = MyMoneyTransactionFilter::allDates; i < MyMoneyTransactionFilter::dateOptionCount; ++i) { - MyMoneyTransactionFilter::translateDateRange(static_cast(i), m_startDates[i], m_endDates[i]); - } - - connect(m_ui->m_dateRange, SIGNAL(itemSelected(int)), this, SLOT(slotDateRangeChanged(int))); - connect(m_ui->m_fromDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); - connect(m_ui->m_toDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); - - slotDateRangeChanged(MyMoneyTransactionFilter::allDates); -} - -void KFindTransactionDlg::slotDateRangeChanged(int idx) -{ - switch (idx) { - case MyMoneyTransactionFilter::allDates: - case MyMoneyTransactionFilter::userDefined: - m_ui->m_fromDate->loadDate(QDate()); - m_ui->m_toDate->loadDate(QDate()); - break; - default: - m_ui->m_fromDate->loadDate(m_startDates[idx]); - m_ui->m_toDate->loadDate(m_endDates[idx]); - break; - } - slotUpdateSelections(); -} - -void KFindTransactionDlg::slotDateChanged() -{ - int idx; - for (idx = MyMoneyTransactionFilter::asOfToday; idx < MyMoneyTransactionFilter::dateOptionCount; ++idx) { - if (m_ui->m_fromDate->date() == m_startDates[idx] - && m_ui->m_toDate->date() == m_endDates[idx]) { - break; - } - } - //if no filter matched, set to user defined - if (idx == MyMoneyTransactionFilter::dateOptionCount) - idx = MyMoneyTransactionFilter::userDefined; - - m_ui->m_dateRange->blockSignals(true); - m_ui->m_dateRange->setCurrentItem(static_cast(idx)); - m_ui->m_dateRange->blockSignals(false); - slotUpdateSelections(); -} - void KFindTransactionDlg::setupAmountPage() { connect(m_ui->m_amountButton, SIGNAL(clicked()), this, SLOT(slotAmountSelected())); @@ -717,8 +666,8 @@ } // Date tab - if (m_ui->m_dateRange->currentItem() != 0) { - m_filter.setDateFilter(m_ui->m_fromDate->date(), m_ui->m_toDate->date()); + if (m_dateRange->m_ui->m_dateRange->currentItem() != 0) { + m_filter.setDateFilter(m_dateRange->m_ui->m_fromDate->date(), m_dateRange->m_ui->m_toDate->date()); } // Amount tab diff --git a/kmymoney/dialogs/kfindtransactiondlgdecl.ui b/kmymoney/dialogs/kfindtransactiondlgdecl.ui --- a/kmymoney/dialogs/kfindtransactiondlgdecl.ui +++ b/kmymoney/dialogs/kfindtransactiondlgdecl.ui @@ -42,6 +42,9 @@ 3 + + 2 + Text @@ -141,52 +144,9 @@ Date - + - - - - - - - - - - Range - - - false - - - - - - - - - - To - - - false - - - - - - - From - - - false - - - - - - - - + @@ -957,17 +917,6 @@
../widgets/kmymoneyaccountselector.h
- KMyMoneyPeriodCombo - QWidget -
kmymoneymvccombo.h
- 1 -
- - kMyMoneyDateInput - QWidget -
kmymoneydateinput.h
-
- kMyMoneyEdit QWidget
kmymoneyedit.h
diff --git a/kmymoney/dialogs/kreportconfigurationfilterdlg.h b/kmymoney/dialogs/kreportconfigurationfilterdlg.h --- a/kmymoney/dialogs/kreportconfigurationfilterdlg.h +++ b/kmymoney/dialogs/kreportconfigurationfilterdlg.h @@ -28,6 +28,7 @@ // QT Includes #include +#include // ---------------------------------------------------------------------------- // KDE Includes @@ -45,6 +46,7 @@ class kMyMoneyReportConfigTab2Decl; class kMyMoneyReportConfigTab3Decl; class kMyMoneyReportConfigTabChartDecl; +class kMyMoneyReportConfigTabRangeDecl; class MyMoneyBudget; /** @@ -66,6 +68,7 @@ kMyMoneyReportConfigTab2Decl* m_tab2; kMyMoneyReportConfigTab3Decl* m_tab3; kMyMoneyReportConfigTabChartDecl* m_tabChart; + kMyMoneyReportConfigTabRangeDecl* m_tabRange; MyMoneyReport m_initialState; MyMoneyReport m_currentState; @@ -84,9 +87,9 @@ void slotUpdateCheckTransfers(); void slotUpdateColumnsCombo(); + void slotLogAxisChanged(int state); private: QVector m_budgets; }; - #endif diff --git a/kmymoney/dialogs/kreportconfigurationfilterdlg.cpp b/kmymoney/dialogs/kreportconfigurationfilterdlg.cpp --- a/kmymoney/dialogs/kreportconfigurationfilterdlg.cpp +++ b/kmymoney/dialogs/kreportconfigurationfilterdlg.cpp @@ -58,14 +58,19 @@ #include #include #include +#include + #include "ui_kfindtransactiondlgdecl.h" +#include "ui_daterangedlgdecl.h" +#include "ui_kmymoneyreportconfigtabrangedecl.h" KReportConfigurationFilterDlg::KReportConfigurationFilterDlg( MyMoneyReport report, QWidget *parent) : KFindTransactionDlg(parent), m_tab2(0), m_tab3(0), m_tabChart(0), + m_tabRange(0), m_initialState(report), m_currentState(report) { @@ -75,7 +80,6 @@ setWindowTitle(i18n("Report Configuration")); delete m_ui->TextLabel1; - // // Rework the buttons // @@ -99,15 +103,29 @@ m_tab2->setObjectName("kMyMoneyReportConfigTab2"); m_ui->m_criteriaTab->insertTab(1, m_tab2, i18n("Rows/Columns")); connect(m_tab2->findChild("m_comboRows"), SIGNAL(activated(int)), this, SLOT(slotRowTypeChanged(int))); - connect(m_tab2->findChild("m_comboColumns"), SIGNAL(activated(int)), this, SLOT(slotColumnTypeChanged(int))); connect(m_tab2->findChild("m_comboRows"), SIGNAL(activated(int)), this, SLOT(slotUpdateColumnsCombo())); - connect(m_tab2->findChild("m_comboColumns"), SIGNAL(activated(int)), this, SLOT(slotUpdateColumnsCombo())); //control the state of the includeTransfer check connect(m_ui->m_categoriesView, SIGNAL(stateChanged()), this, SLOT(slotUpdateCheckTransfers())); m_tabChart = new kMyMoneyReportConfigTabChartDecl(m_ui->m_criteriaTab); m_tabChart->setObjectName("kMyMoneyReportConfigTabChart"); m_ui->m_criteriaTab->insertTab(2, m_tabChart, i18n("Chart")); + + m_tabRange = new kMyMoneyReportConfigTabRangeDecl(m_ui->m_criteriaTab); + m_tabRange->setObjectName("kMyMoneyReportConfigTabRange"); + m_ui->m_criteriaTab->insertTab(3, m_tabRange, i18n("Range")); + + // date tab is going to be replaced by range tab, so delete it + m_ui->dateRangeLayout->removeWidget(m_dateRange); + m_dateRange->deleteLater(); + m_ui->m_criteriaTab->removeTab(m_ui->m_criteriaTab->indexOf(m_ui->m_dateTab)); + m_ui->m_dateTab->deleteLater(); + + m_dateRange = m_tabRange->m_dateRange; + + connect(m_tabRange->ui->m_comboColumns, SIGNAL(activated(int)), this, SLOT(slotColumnTypeChanged(int))); + connect(m_tabRange->ui->m_comboColumns, SIGNAL(activated(int)), this, SLOT(slotUpdateColumnsCombo())); + connect(m_tabChart->findChild("m_logYaxis"), SIGNAL(stateChanged(int)), this, SLOT(slotLogAxisChanged(int))); } else if (m_initialState.reportType() == MyMoneyReport::eQueryTable) { // eInvestmentHoldings is a special-case report, and you cannot configure the // rows & columns of that report. @@ -167,13 +185,6 @@ if (m_tab2->findChild("m_comboRows")->currentIndex() == 0) m_currentState.setShowingRowTotals(m_tab2->findChild("m_checkTotalColumn")->isChecked()); - MyMoneyReport::EColumnType ct[6] = { MyMoneyReport::eDays, MyMoneyReport::eWeeks, MyMoneyReport::eMonths, MyMoneyReport::eBiMonths, MyMoneyReport::eQuarters, MyMoneyReport::eYears }; - bool dy[6] = { true, true, false, false, false, false }; - m_currentState.setColumnType(ct[m_tab2->findChild("m_comboColumns")->currentIndex()]); - - //TODO (Ace) This should be implicit in the call above. MMReport needs fixin' - m_currentState.setColumnsAreDays(dy[m_tab2->findChild("m_comboColumns")->currentIndex()]); - m_currentState.setIncludingSchedules(m_tab2->findChild("m_checkScheduled")->isChecked()); m_currentState.setIncludingTransfers(m_tab2->findChild("m_checkTransfers")->isChecked()); @@ -237,14 +248,31 @@ MyMoneyReport::EChartType ct[5] = { MyMoneyReport::eChartLine, MyMoneyReport::eChartBar, MyMoneyReport::eChartStackedBar, MyMoneyReport::eChartPie, MyMoneyReport::eChartRing }; m_currentState.setChartType(ct[m_tabChart->findChild("m_comboType")->currentIndex()]); - m_currentState.setChartGridLines(m_tabChart->findChild("m_checkGridLines")->isChecked()); + m_currentState.setChartCHGridLines(m_tabChart->findChild("m_checkCHGridLines")->isChecked()); + m_currentState.setChartSVGridLines(m_tabChart->findChild("m_checkSVGridLines")->isChecked()); m_currentState.setChartDataLabels(m_tabChart->findChild("m_checkValues")->isChecked()); m_currentState.setChartByDefault(m_tabChart->findChild("m_checkShowChart")->isChecked()); m_currentState.setChartLineWidth(m_tabChart->findChild("m_lineWidth")->value()); + m_currentState.setLogYAxis(m_tabChart->findChild("m_logYaxis")->isChecked()); + } + + if (m_tabRange) { + m_currentState.setDataRangeStart(m_tabRange->ui->m_dataRangeStart->text()); + m_currentState.setDataRangeEnd(m_tabRange->ui->m_dataRangeEnd->text()); + m_currentState.setDataMajorTick(m_tabRange->ui->m_dataMajorTick->text()); + m_currentState.setDataMinorTick(m_tabRange->ui->m_dataMinorTick->text()); + m_currentState.setDataFilter((MyMoneyReport::dataOptionE)m_tabRange->ui->m_dataLock->currentIndex()); + + MyMoneyReport::EColumnType ct[6] = { MyMoneyReport::eDays, MyMoneyReport::eWeeks, MyMoneyReport::eMonths, MyMoneyReport::eBiMonths, MyMoneyReport::eQuarters, MyMoneyReport::eYears }; + bool dy[6] = { true, true, false, false, false, false }; + m_currentState.setColumnType(ct[m_tabRange->ui->m_comboColumns->currentIndex()]); + + //TODO (Ace) This should be implicit in the call above. MMReport needs fixin' + m_currentState.setColumnsAreDays(dy[m_tabRange->ui->m_comboColumns->currentIndex()]); } // setup the date lock - MyMoneyTransactionFilter::dateOptionE range = m_ui->m_dateRange->currentItem(); + MyMoneyTransactionFilter::dateOptionE range = m_dateRange->m_ui->m_dateRange->currentItem(); m_currentState.setDateFilter(range); done(true); @@ -258,20 +286,28 @@ void KReportConfigurationFilterDlg::slotColumnTypeChanged(int row) { if ((m_tab2->findChild("m_comboBudget")->isEnabled() && row < 2)) { - m_tab2->findChild("m_comboColumns")->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); + m_tabRange->ui->m_comboColumns->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); } } void KReportConfigurationFilterDlg::slotUpdateColumnsCombo() { const int monthlyIndex = 2; const int incomeExpenseIndex = 0; const bool isIncomeExpenseForecast = m_currentState.isIncludingForecast() && m_tab2->findChild("m_comboRows")->currentIndex() == incomeExpenseIndex; - if (isIncomeExpenseForecast && m_tab2->findChild("m_comboColumns")->currentIndex() != monthlyIndex) { - m_tab2->findChild("m_comboColumns")->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); + if (isIncomeExpenseForecast && m_tabRange->ui->m_comboColumns->currentIndex() != monthlyIndex) { + m_tabRange->ui->m_comboColumns->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); } } +void KReportConfigurationFilterDlg::slotLogAxisChanged(int state) +{ + if (state == Qt::Checked) + m_tabRange->setRangeLogarythmic(true); + else + m_tabRange->setRangeLogarythmic(false); +} + void KReportConfigurationFilterDlg::slotReset() { // @@ -328,39 +364,6 @@ slotRowTypeChanged(combo->currentIndex()); - combo = m_tab2->findChild("m_comboColumns"); - if (m_initialState.isColumnsAreDays()) { - switch (m_initialState.columnType()) { - case MyMoneyReport::eNoColumns: - case MyMoneyReport::eDays: - combo->setCurrentItem(i18nc("@item the columns will display daily data", "Daily"), false); - break; - case MyMoneyReport::eWeeks: - combo->setCurrentItem(i18nc("@item the columns will display weekly data", "Weekly"), false); - break; - default: - break; - } - } else { - switch (m_initialState.columnType()) { - case MyMoneyReport::eNoColumns: - case MyMoneyReport::eMonths: - combo->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); - break; - case MyMoneyReport::eBiMonths: - combo->setCurrentItem(i18nc("@item the columns will display bi-monthly data", "Bi-Monthly"), false); - break; - case MyMoneyReport::eQuarters: - combo->setCurrentItem(i18nc("@item the columns will display quarterly data", "Quarterly"), false); - break; - case MyMoneyReport::eYears: - combo->setCurrentItem(i18nc("@item the columns will display yearly data", "Yearly"), false); - break; - default: - break; - } - } - //load budgets combo if (m_initialState.rowType() == MyMoneyReport::eBudget || m_initialState.rowType() == MyMoneyReport::eBudgetActual) { @@ -456,10 +459,53 @@ case MyMoneyReport::eChartEnd: throw MYMONEYEXCEPTION("KReportConfigurationFilterDlg::slotReset(): Report has invalid charttype"); } - m_tabChart->findChild("m_checkGridLines")->setChecked(m_initialState.isChartGridLines()); + m_tabChart->findChild("m_checkCHGridLines")->setChecked(m_initialState.isChartCHGridLines()); + m_tabChart->findChild("m_checkSVGridLines")->setChecked(m_initialState.isChartSVGridLines()); m_tabChart->findChild("m_checkValues")->setChecked(m_initialState.isChartDataLabels()); m_tabChart->findChild("m_checkShowChart")->setChecked(m_initialState.isChartByDefault()); m_tabChart->findChild("m_lineWidth")->setValue(m_initialState.chartLineWidth()); + m_tabChart->findChild("m_logYaxis")->setChecked(m_initialState.isLogYAxis()); + } + + if (m_tabRange) { + m_tabRange->ui->m_dataRangeStart->setText(m_initialState.dataRangeStart()); + m_tabRange->ui->m_dataRangeEnd->setText(m_initialState.dataRangeEnd()); + m_tabRange->ui->m_dataMajorTick->setText(m_initialState.dataMajorTick()); + m_tabRange->ui->m_dataMinorTick->setText(m_initialState.dataMinorTick()); + m_tabRange->ui->m_dataLock->setCurrentIndex((int)m_initialState.dataFilter()); + + KComboBox *combo = m_tabRange->ui->m_comboColumns; + if (m_initialState.isColumnsAreDays()) { + switch (m_initialState.columnType()) { + case MyMoneyReport::eNoColumns: + case MyMoneyReport::eDays: + combo->setCurrentItem(i18nc("@item the columns will display daily data", "Daily"), false); + break; + case MyMoneyReport::eWeeks: + combo->setCurrentItem(i18nc("@item the columns will display weekly data", "Weekly"), false); + break; + default: + break; + } + } else { + switch (m_initialState.columnType()) { + case MyMoneyReport::eNoColumns: + case MyMoneyReport::eMonths: + combo->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); + break; + case MyMoneyReport::eBiMonths: + combo->setCurrentItem(i18nc("@item the columns will display bi-monthly data", "Bi-Monthly"), false); + break; + case MyMoneyReport::eQuarters: + combo->setCurrentItem(i18nc("@item the columns will display quarterly data", "Quarterly"), false); + break; + case MyMoneyReport::eYears: + combo->setCurrentItem(i18nc("@item the columns will display yearly data", "Yearly"), false); + break; + default: + break; + } + } } // @@ -621,27 +667,27 @@ m_initialState.updateDateFilter(); QDate dateFrom, dateTo; if (m_initialState.dateFilter(dateFrom, dateTo)) { - if (m_initialState.isUserDefined()) { - m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::userDefined); - m_ui->m_fromDate->setDate(dateFrom); - m_ui->m_toDate->setDate(dateTo); + if (m_initialState.isDateUserDefined()) { + m_dateRange->m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::userDefined); + m_dateRange->m_ui->m_fromDate->setDate(dateFrom); + m_dateRange->m_ui->m_toDate->setDate(dateTo); } else { - m_ui->m_fromDate->setDate(dateFrom); - m_ui->m_toDate->setDate(dateTo); - KFindTransactionDlg::slotDateChanged(); + m_dateRange->m_ui->m_fromDate->setDate(dateFrom); + m_dateRange->m_ui->m_toDate->setDate(dateTo); + m_dateRange->slotDateChanged(); } } else { - m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::allDates); - slotDateRangeChanged(MyMoneyTransactionFilter::allDates); + m_dateRange->m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::allDates); + m_dateRange->slotDateRangeChanged(MyMoneyTransactionFilter::allDates); } slotRightSize(); } void KReportConfigurationFilterDlg::slotDateChanged() { - if (m_ui->m_dateRange->currentItem() != MyMoneyTransactionFilter::userDefined) { - KFindTransactionDlg::slotDateChanged(); + if (m_dateRange->m_ui->m_dateRange->currentItem() != MyMoneyTransactionFilter::userDefined) { + m_dateRange->slotDateChanged(); } slotUpdateSelections(); } diff --git a/kmymoney/mymoney/mymoneyreport.h b/kmymoney/mymoney/mymoneyreport.h --- a/kmymoney/mymoney/mymoneyreport.h +++ b/kmymoney/mymoney/mymoneyreport.h @@ -67,6 +67,8 @@ enum EDetailLevel { eDetailNone = 0, eDetailAll, eDetailTop, eDetailGroup, eDetailTotal, eDetailEnd }; enum EChartType { eChartNone = 0, eChartLine, eChartBar, eChartPie, eChartRing, eChartStackedBar, eChartEnd }; + enum dataOptionE { automatic = 0, userDefined, dataOptionCount }; + static const QStringList kRowTypeText; static const QStringList kColumnTypeText; static const QStringList kQueryColumnsText; @@ -144,16 +146,34 @@ bool isChartDataLabels() const { return m_chartDataLabels; } - bool isChartGridLines() const { - return m_chartGridLines; + bool isChartCHGridLines() const { + return m_chartCHGridLines; + } + bool isChartSVGridLines() const { + return m_chartSVGridLines; } bool isChartByDefault() const { return m_chartByDefault; } uint chartLineWidth() const { return m_chartLineWidth; } - bool isIncludingSchedules() const { + bool isLogYAxis() const { + return m_logYaxis; + } + const QString& dataRangeStart() const { + return m_dataRangeStart; + } + const QString& dataRangeEnd() const { + return m_dataRangeEnd; + } + const QString& dataMajorTick() const { + return m_dataMajorTick; + } + const QString& dataMinorTick() const { + return m_dataMinorTick; + } + bool isIncludingSchedules() const { return m_includeSchedules; } bool isColumnsAreDays() const { @@ -189,8 +209,11 @@ bool isIncludingAveragePrice() const { return m_includeAveragePrice; } - bool isUserDefined() const { - return m_dateLock == userDefined; + bool isDateUserDefined() const { + return m_dateLock == MyMoneyTransactionFilter::userDefined; + } + bool isDataUserDefined() const { + return m_dataLock == MyMoneyReport::userDefined; } bool isMixedTime() const { return m_mixedTime; @@ -246,15 +269,33 @@ void setChartDataLabels(bool _f) { m_chartDataLabels = _f; } - void setChartGridLines(bool _f) { - m_chartGridLines = _f; + void setChartCHGridLines(bool _f) { + m_chartCHGridLines = _f; + } + void setChartSVGridLines(bool _f) { + m_chartSVGridLines = _f; } void setChartByDefault(bool _f) { m_chartByDefault = _f; } void setChartLineWidth(uint _f) { m_chartLineWidth = _f; } + void setLogYAxis(bool _f) { + m_logYaxis = _f; + } + void setDataRangeStart(const QString& _f) { + m_dataRangeStart = _f; + } + void setDataRangeEnd(const QString& _f) { + m_dataRangeEnd = _f; + } + void setDataMajorTick(const QString& _f) { + m_dataMajorTick = _f; + } + void setDataMinorTick(const QString& _f) { + m_dataMinorTick = _f; + } void setIncludingSchedules(bool _f) { m_includeSchedules = _f; } @@ -345,10 +386,14 @@ void setDateFilter(dateOptionE _u) { m_dateLock = _u; - if (_u != userDefined) + if (_u != MyMoneyTransactionFilter::userDefined) MyMoneyTransactionFilter::setDateFilter(_u); } + void setDataFilter(dataOptionE _u) { + m_dataLock = _u; + } + /** * Set the underlying date filter using the start and end dates provided. * Note that this does not LOCK to any range like setDateFilter(unsigned) @@ -375,7 +420,11 @@ * as is proper. */ void updateDateFilter() { - if (m_dateLock != userDefined) MyMoneyTransactionFilter::setDateFilter(m_dateLock); + if (m_dateLock != MyMoneyTransactionFilter::userDefined) MyMoneyTransactionFilter::setDateFilter(m_dateLock); + } + + MyMoneyReport::dataOptionE dataFilter() { + return m_dataLock; } /** @@ -590,7 +639,8 @@ /** * Whether grid lines should be drawn on the chart */ - bool m_chartGridLines; + bool m_chartCHGridLines; + bool m_chartSVGridLines; /** * Whether this report should be shown as a chart by default (otherwise it * should be shown as a textual report) @@ -600,6 +650,29 @@ * Width of the chart lines */ uint m_chartLineWidth; + + /** + * Whether Y axis is logarithmic or linear + */ + bool m_logYaxis; + + /** + * Y data range + */ + QString m_dataRangeStart; + QString m_dataRangeEnd; + + /** + * Y data range division + */ + QString m_dataMajorTick; + QString m_dataMinorTick; + + /** + * Whether data range should be calculated automatically or is user defined + */ + dataOptionE m_dataLock; + /** * Whether to include scheduled transactions */ diff --git a/kmymoney/mymoney/mymoneyreport.cpp b/kmymoney/mymoney/mymoneyreport.cpp --- a/kmymoney/mymoney/mymoneyreport.cpp +++ b/kmymoney/mymoney/mymoneyreport.cpp @@ -46,6 +46,7 @@ const QStringList kTypeText = QString("all,payments,deposits,transfers,none").split(','); const QStringList kStateText = QString("all,notreconciled,cleared,reconciled,frozen,none").split(','); const QStringList kDateLockText = QString("alldates,untiltoday,currentmonth,currentyear,monthtodate,yeartodate,yeartomonth,lastmonth,lastyear,last7days,last30days,last3months,last6months,last12months,next7days,next30days,next3months,next6months,next12months,userdefined,last3tonext3months,last11Months,currentQuarter,lastQuarter,nextQuarter,currentFiscalYear,lastFiscalYear,today,next18months").split(','); +const QStringList kDataLockText = QString("automatic,userdefined").split(','); const QStringList kAccountTypeText = QString("unknown,checkings,savings,cash,creditcard,loan,certificatedep,investment,moneymarket,asset,liability,currency,income,expense,assetloan,stock,equity,invalid").split(','); MyMoneyReport::MyMoneyReport() : @@ -61,12 +62,15 @@ m_columnType(eMonths), m_columnsAreDays(false), m_queryColumns(eQCnone), - m_dateLock(userDefined), + m_dateLock(MyMoneyTransactionFilter::userDefined), + m_dataLock(MyMoneyReport::automatic), m_accountGroupFilter(false), m_chartType(eChartLine), m_chartDataLabels(true), - m_chartGridLines(true), + m_chartCHGridLines(true), + m_chartSVGridLines(true), m_chartByDefault(false), + m_logYaxis(false), m_includeSchedules(false), m_includeTransfers(false), m_includeBudgetActuals(false), @@ -107,11 +111,14 @@ m_columnsAreDays(false), m_queryColumns(eQCnone), m_dateLock(_dl), + m_dataLock(MyMoneyReport::automatic), m_accountGroupFilter(false), m_chartType(eChartLine), m_chartDataLabels(true), - m_chartGridLines(true), + m_chartCHGridLines(true), + m_chartSVGridLines(true), m_chartByDefault(false), + m_logYaxis(false), m_includeSchedules(false), m_includeTransfers(false), m_includeBudgetActuals(false), @@ -342,6 +349,7 @@ e.setAttribute("loans", m_loans); 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); @@ -364,9 +372,16 @@ e.setAttribute("charttype", kChartTypeText[m_chartType]); } e.setAttribute("chartdatalabels", m_chartDataLabels); - e.setAttribute("chartgridlines", m_chartGridLines); + 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("dataLock", m_dataLock); e.setAttribute("skipZero", m_skipZero); if (m_reportType == ePivotTable) { @@ -559,7 +574,7 @@ // Date Filter // - if (m_dateLock == userDefined) { + if (m_dateLock == MyMoneyTransactionFilter::userDefined) { QDate dateFrom, dateTo; if (dateFilter(dateFrom, dateTo)) { QDomElement f = doc->createElement("DATES"); @@ -663,14 +678,22 @@ m_chartType = eChartLine; m_chartDataLabels = e.attribute("chartdatalabels", "1").toUInt(); - m_chartGridLines = e.attribute("chartgridlines", "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"); } else { m_chartDataLabels = true; - m_chartGridLines = true; + m_chartCHGridLines = true; + m_chartSVGridLines = true; m_chartByDefault = false; m_chartLineWidth = 1; + m_logYaxis = false; } QString datelockstr = e.attribute("datelock", "userdefined"); @@ -681,10 +704,20 @@ if (!ok) { i = kDateLockText.indexOf(datelockstr); if (i == -1) - i = userDefined; + 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)); + i = kRowTypeText.indexOf(e.attribute("rowtype", "expenseincome")); if (i != -1) { setRowType(static_cast(i)); diff --git a/kmymoney/reports/kreportchartview.h b/kmymoney/reports/kreportchartview.h --- a/kmymoney/reports/kreportchartview.h +++ b/kmymoney/reports/kreportchartview.h @@ -43,8 +43,12 @@ namespace reports { + class KReportChartView: public Chart { + Q_OBJECT +public slots: + void slotNeedUpdate(); public: KReportChartView(QWidget* parent); ~KReportChartView() {} diff --git a/kmymoney/reports/kreportchartview.cpp b/kmymoney/reports/kreportchartview.cpp --- a/kmymoney/reports/kreportchartview.cpp +++ b/kmymoney/reports/kreportchartview.cpp @@ -24,11 +24,13 @@ #include #include #include +#include // ---------------------------------------------------------------------------- // KDE Includes #include #include +#include // ---------------------------------------------------------------------------- // Project Includes @@ -114,6 +116,96 @@ // an account in a COLUMN, while line/bar prefer it in a ROW. setAccountSeries(true); + CartesianAxis *xAxis; + KBalanceAxis *yAxis; + switch (config.chartType()) { + case MyMoneyReport::eChartNone: + case MyMoneyReport::eChartEnd: + case MyMoneyReport::eChartLine: + case MyMoneyReport::eChartBar: + case MyMoneyReport::eChartStackedBar: { + CartesianCoordinatePlane* cartesianPlane = new CartesianCoordinatePlane; + replaceCoordinatePlane(cartesianPlane); + + // set-up axis type + if (config.isLogYAxis()) + cartesianPlane->setAxesCalcModeY(KChart::AbstractCoordinatePlane::Logarithmic); + else + cartesianPlane->setAxesCalcModeY(KChart::AbstractCoordinatePlane::Linear); + + // set-up grid + GridAttributes ga = cartesianPlane->gridAttributes(Qt::Vertical); + ga.setGridVisible(config.isChartCHGridLines()); + ga.setGridStepWidth(locale().toDouble(config.dataMajorTick())); + ga.setGridSubStepWidth(locale().toDouble(config.dataMinorTick())); + cartesianPlane->setGridAttributes(Qt::Vertical, ga); + + ga = cartesianPlane->gridAttributes(Qt::Horizontal); + ga.setGridVisible(config.isChartSVGridLines()); + cartesianPlane->setGridAttributes(Qt::Horizontal, ga); + + // set-up data range + cartesianPlane->setVerticalRange(qMakePair(locale().toDouble(config.dataRangeStart()), locale().toDouble(config.dataRangeEnd()))); + + //set-up x axis + xAxis = new CartesianAxis(); + xAxis->setPosition(CartesianAxis::Bottom); + xAxis->setTitleText(i18n("Time")); + TextAttributes xAxisTitleTextAttr(xAxis->titleTextAttributes()); + xAxisTitleTextAttr.setMinimalFontSize(QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize()); + xAxisTitleTextAttr.setPen(m_foregroundBrush.color()); + xAxis->setTitleTextAttributes(xAxisTitleTextAttr); + TextAttributes xAxisTextAttr(xAxis->textAttributes()); + xAxisTextAttr.setPen(m_foregroundBrush.color()); + xAxis->setTextAttributes(xAxisTextAttr); + RulerAttributes xAxisRulerAttr(xAxis->rulerAttributes()); + xAxisRulerAttr.setTickMarkPen(m_foregroundBrush.color()); + xAxisRulerAttr.setShowRulerLine(true); + xAxis->setRulerAttributes(xAxisRulerAttr); + + //set-up y axis + yAxis = new KBalanceAxis(); + yAxis->setPosition(CartesianAxis::Left); + + // TODO + // if the chart shows prices and no balance + // the axis title should be 'Price' + if (config.isIncludingPrice()) + yAxis->setTitleText(i18n("Price")); + else + yAxis->setTitleText(i18n("Balance")); + + TextAttributes yAxisTitleTextAttr(yAxis->titleTextAttributes()); + yAxisTitleTextAttr.setMinimalFontSize(QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize()); + yAxisTitleTextAttr.setPen(m_foregroundBrush.color()); + yAxis->setTitleTextAttributes(yAxisTitleTextAttr); + TextAttributes yAxisTextAttr(yAxis->textAttributes()); + yAxisTextAttr.setPen(m_foregroundBrush.color()); + yAxis->setTextAttributes(yAxisTextAttr); + RulerAttributes yAxisRulerAttr(yAxis->rulerAttributes()); + yAxisRulerAttr.setTickMarkPen(m_foregroundBrush.color()); + yAxisRulerAttr.setShowRulerLine(true); + yAxis->setRulerAttributes(yAxisRulerAttr); + break; + } + case MyMoneyReport::eChartPie: + case MyMoneyReport::eChartRing:{ + PolarCoordinatePlane* polarPlane = new PolarCoordinatePlane; + replaceCoordinatePlane(polarPlane); + + // set-up grid + GridAttributes ga = polarPlane->gridAttributes(true); + ga.setGridVisible(config.isChartCHGridLines()); + polarPlane->setGridAttributes(true, ga); + + ga = polarPlane->gridAttributes(false); + ga.setGridVisible(config.isChartSVGridLines()); + polarPlane->setGridAttributes(false, ga); + + break; + } + } + switch (config.chartType()) { case MyMoneyReport::eChartNone: case MyMoneyReport::eChartEnd: @@ -125,54 +217,44 @@ attributes.setMissingValuesPolicy(LineAttributes::MissingValuesAreBridged); diagram->setLineAttributes(attributes); } - - CartesianCoordinatePlane* cartesianPlane = new CartesianCoordinatePlane; - replaceCoordinatePlane(cartesianPlane); coordinatePlane()->replaceDiagram(diagram); + diagram->addAxis(xAxis); + diagram->addAxis(yAxis); break; } case MyMoneyReport::eChartBar: { KChart::BarDiagram* diagram = new KChart::BarDiagram; - CartesianCoordinatePlane* cartesianPlane = new CartesianCoordinatePlane; - replaceCoordinatePlane(cartesianPlane); coordinatePlane()->replaceDiagram(diagram); + diagram->addAxis(xAxis); + diagram->addAxis(yAxis); break; } case MyMoneyReport::eChartStackedBar: { KChart::BarDiagram* diagram = new KChart::BarDiagram; - CartesianCoordinatePlane* cartesianPlane = new CartesianCoordinatePlane; - replaceCoordinatePlane(cartesianPlane); diagram->setType(BarDiagram::Stacked); coordinatePlane()->replaceDiagram(diagram); + diagram->addAxis(xAxis); + diagram->addAxis(yAxis); break; } case MyMoneyReport::eChartPie: { KChart::PieDiagram* diagram = new KChart::PieDiagram; - PolarCoordinatePlane* polarPlane = new PolarCoordinatePlane; - replaceCoordinatePlane(polarPlane); coordinatePlane()->replaceDiagram(diagram); setAccountSeries(false); setSeriesTotals(true); break; } case MyMoneyReport::eChartRing: { KChart::RingDiagram* diagram = new KChart::RingDiagram; - PolarCoordinatePlane* polarPlane = new PolarCoordinatePlane; - replaceCoordinatePlane(polarPlane); - polarPlane->replaceDiagram(diagram); + coordinatePlane()->replaceDiagram(diagram); //chartView.params()->setRelativeRingThickness( true ); setAccountSeries(false); break; } } //get the diagram for later use AbstractDiagram* planeDiagram = coordinatePlane()->diagram(); - //set grid attributes - GridAttributes gridAttr(coordinatePlane()->globalGridAttributes()); - gridAttr.setGridVisible(config.isChartGridLines()); - coordinatePlane()->setGlobalGridAttributes(gridAttr); - //the palette - we set it here because it is a property of the diagram switch (KMyMoneySettings::chartsPalette()) { case 0: @@ -191,65 +273,6 @@ Legend* legend = new Legend(planeDiagram, this); legend->setTitleText(i18nc("Chart legend title", "Legend")); - //set up the axes for cartesian diagrams - if (config.chartType() == MyMoneyReport::eChartLine || - config.chartType() == MyMoneyReport::eChartBar || - config.chartType() == MyMoneyReport::eChartStackedBar) { - //set x axis - CartesianAxis *xAxis = new CartesianAxis(); - xAxis->setPosition(CartesianAxis::Bottom); - xAxis->setTitleText(i18n("Time")); - TextAttributes xAxisTitleTextAttr(xAxis->titleTextAttributes()); - xAxisTitleTextAttr.setMinimalFontSize(QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize()); - xAxisTitleTextAttr.setPen(m_foregroundBrush.color()); - xAxis->setTitleTextAttributes(xAxisTitleTextAttr); - TextAttributes xAxisTextAttr(xAxis->textAttributes()); - xAxisTextAttr.setPen(m_foregroundBrush.color()); - xAxis->setTextAttributes(xAxisTextAttr); - RulerAttributes xAxisRulerAttr(xAxis->rulerAttributes()); - xAxisRulerAttr.setTickMarkPen(m_foregroundBrush.color()); - xAxisRulerAttr.setShowRulerLine(true); - xAxis->setRulerAttributes(xAxisRulerAttr); - - - //set y axis - KBalanceAxis *yAxis = new KBalanceAxis(); - yAxis->setPosition(CartesianAxis::Left); - - // TODO - // if the chart shows prices and no balance - // the axis title should be 'Price' - if (config.isIncludingPrice()) { - yAxis->setTitleText(i18n("Price")); - } else { - yAxis->setTitleText(i18n("Balance")); - } - - TextAttributes yAxisTitleTextAttr(yAxis->titleTextAttributes()); - yAxisTitleTextAttr.setMinimalFontSize(QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize()); - yAxisTitleTextAttr.setPen(m_foregroundBrush.color()); - yAxis->setTitleTextAttributes(yAxisTitleTextAttr); - TextAttributes yAxisTextAttr(yAxis->textAttributes()); - yAxisTextAttr.setPen(m_foregroundBrush.color()); - yAxis->setTextAttributes(yAxisTextAttr); - RulerAttributes yAxisRulerAttr(yAxis->rulerAttributes()); - yAxisRulerAttr.setTickMarkPen(m_foregroundBrush.color()); - yAxisRulerAttr.setShowRulerLine(true); - yAxis->setRulerAttributes(yAxisRulerAttr); - - //add the axes to the corresponding diagram - if (config.chartType() == MyMoneyReport::eChartLine) { - KChart::LineDiagram* lineDiagram = qobject_cast(planeDiagram); - lineDiagram->addAxis(xAxis); - lineDiagram->addAxis(yAxis); - } else if (config.chartType() == MyMoneyReport::eChartBar || - config.chartType() == MyMoneyReport::eChartStackedBar) { - KChart::BarDiagram* barDiagram = qobject_cast(planeDiagram); - barDiagram->addAxis(xAxis); - barDiagram->addAxis(yAxis); - } - } - const bool blocked = m_model.blockSignals(true); // don't emit dataChanged() signal during each drawPivotRowSet switch (config.detailLevel()) { case MyMoneyReport::eDetailNone: @@ -390,8 +413,8 @@ //only show the column type in the header if there is more than one type if (rowTypeList.size() > 1) { legendText = QString(columnTypeHeaderList[i] + " - " + i18nc("Total balance", "Total")); - } else { legendText = QString(i18nc("Total balance", "Total")); + } else { } //set the legend text @@ -523,6 +546,55 @@ // the legend is needed only if at least two data sets are rendered removeLegend(); } + + // connect needLayoutPlanes, so dimension of chart can be known, so custom Y labels can be generated + connect(coordinatePlane(), SIGNAL(needLayoutPlanes()), this, SLOT(slotNeedUpdate())); + planeDiagram->update(); +} +void KReportChartView::slotNeedUpdate() +{ + disconnect(coordinatePlane(), SIGNAL(needLayoutPlanes()), this, SLOT(slotNeedUpdate())); // this won't cause hang-up in KReportsView::slotConfigure + QList grids = coordinatePlane()->gridDimensionsList(); + if (grids.isEmpty()) // ring and pie charts have no dimensions + return; + + if (grids.at(1).stepWidth == 0) // no labels? + return; + + QChar separator = locale().groupSeparator(); + QChar decimalPoint = locale().decimalPoint(); + int precision = KMyMoneyGlobalSettings().pricePrecision(); + + QStringList labels; + + CartesianCoordinatePlane* cartesianplane = qobject_cast(coordinatePlane()); + if (cartesianplane) { + if (cartesianplane->axesCalcModeY() == KChart::AbstractCoordinatePlane::Logarithmic) { + qreal labelValue = qFloor(log10(grids.at(1).start)); // first label is 10 to power of labelValue + uchar labelCount = qFloor(log10(grids.at(1).end)) - qFloor(log10(grids.at(1).start)) + 1; + for (uchar i = 0; i < labelCount; ++i) { + labels.append(locale().toString(qPow(10.0, labelValue), 'f', precision).remove(separator).remove(QRegularExpression("0+$")).remove(QRegularExpression("\\" + decimalPoint + "$"))); + ++labelValue; // next label is 10 to power of previous exponent + 1 + } + } else { + qreal labelValue = grids.at(1).start; // first label is start value + qreal step = grids.at(1).stepWidth; + uchar labelCount = qFloor((grids.at(1).end - grids.at(1).start) / grids.at(1).stepWidth) + 1; + for (uchar i = 0; i < labelCount; ++i) { + labels.append(locale().toString(labelValue, 'f', precision).remove(separator).remove(QRegularExpression("0+$")).remove(QRegularExpression("\\" + decimalPoint + "$"))); + labelValue += step; // next label is previous value + step value + } + } + } else + return; // nothing but cartesian plane is handled + + KChart::LineDiagram* lineDiagram = qobject_cast(coordinatePlane()->diagram()); + if (lineDiagram) + lineDiagram->axes().at(1)->setLabels(labels); + + KChart::BarDiagram* barDiagram = qobject_cast(coordinatePlane()->diagram()); + if (barDiagram) + barDiagram->axes().at(1)->setLabels(labels); } unsigned KReportChartView::drawPivotRowSet(int rowNum, const PivotGridRowSet& rowSet, const ERowType rowType, const QString& legendText, int startColumn, int endColumn) diff --git a/kmymoney/views/kforecastview.cpp b/kmymoney/views/kforecastview.cpp --- a/kmymoney/views/kforecastview.cpp +++ b/kmymoney/views/kforecastview.cpp @@ -1021,7 +1021,8 @@ i18n("Generated Report")); reportCfg.setChartByDefault(true); - reportCfg.setChartGridLines(false); + reportCfg.setChartCHGridLines(false); + reportCfg.setChartSVGridLines(false); reportCfg.setChartType(MyMoneyReport::eChartLine); reportCfg.setIncludingSchedules(false); // FIXME: this causes a crash diff --git a/kmymoney/views/khomeview.cpp b/kmymoney/views/khomeview.cpp --- a/kmymoney/views/khomeview.cpp +++ b/kmymoney/views/khomeview.cpp @@ -302,7 +302,8 @@ i18n("Generated Report")); reportCfg.setChartByDefault(true); - reportCfg.setChartGridLines(false); + reportCfg.setChartCHGridLines(false); + reportCfg.setChartSVGridLines(false); reportCfg.setChartDataLabels(false); reportCfg.setChartType(MyMoneyReport::eChartLine); reportCfg.setIncludingSchedules(false); diff --git a/kmymoney/views/kreportsview.h b/kmymoney/views/kreportsview.h --- a/kmymoney/views/kreportsview.h +++ b/kmymoney/views/kreportsview.h @@ -108,6 +108,7 @@ } void print(); void toggleChart(); + void updateDataRange(); void copyToClipboard(); void saveAs(const QString& filename, bool includeCSS = false); void updateReport(); diff --git a/kmymoney/views/kreportsview.cpp b/kmymoney/views/kreportsview.cpp --- a/kmymoney/views/kreportsview.cpp +++ b/kmymoney/views/kreportsview.cpp @@ -238,6 +238,30 @@ m_showingChart = ! m_showingChart; } +void KReportsView::KReportTab::updateDataRange() +{ + QList grids = m_chartView->coordinatePlane()->gridDimensionsList(); + if (grids.isEmpty()) + return; + QChar separator = locale().groupSeparator(); + QChar decimalPoint = locale().decimalPoint(); + int precision = KMyMoneyGlobalSettings().pricePrecision(); + QList> dims; + dims.append(qMakePair(QString(), grids.at(1).start)); + dims.append(qMakePair(QString(), grids.at(1).end)); + dims.append(qMakePair(QString(), grids.at(1).stepWidth)); + dims.append(qMakePair(QString(), grids.at(1).subStepWidth)); + + for (int i = 0; i < 4; ++i) { + dims[i].first = locale().toString(dims.at(i).second, 'f', precision).remove(separator).remove(QRegularExpression("0+$")).remove(QRegularExpression("\\" + decimalPoint + "$")); + } + + m_report.setDataRangeStart(dims.at(0).first); + m_report.setDataRangeEnd(dims.at(1).first); + m_report.setDataMajorTick(dims.at(2).first); + m_report.setDataMinorTick(dims.at(3).first); +} + /** * KReportsView Implementation */ @@ -663,6 +687,8 @@ return; } + tab->updateDataRange(); // range will be needed during configuration, but cannot be obtained earlier + MyMoneyReport report = tab->report(); if (report.comment() == i18n("Default Report") || report.comment() == i18n("Generated Report")) { report.setComment(i18n("Custom Report")); @@ -1173,7 +1199,8 @@ i18n("Default Report") )); list.back().setChartByDefault(true); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setChartType(MyMoneyReport::eChartLine); list.push_back(MyMoneyReport( @@ -1361,7 +1388,8 @@ i18n("Default Report") )); list.back().setChartByDefault(true); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setChartType(MyMoneyReport::eChartPie); list.back().setInvestmentsOnly(true); @@ -1374,7 +1402,8 @@ i18n("Default Report") )); list.back().setChartByDefault(true); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setChartType(MyMoneyReport::eChartLine); list.back().setColumnsAreDays(true); list.back().setInvestmentsOnly(true); @@ -1388,7 +1417,8 @@ i18n("Default Report") )); list.back().setChartByDefault(true); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setChartType(MyMoneyReport::eChartLine); list.back().setColumnsAreDays(true); list.back().setInvestmentsOnly(true); @@ -1407,7 +1437,8 @@ i18n("Default Report") )); list.back().setChartByDefault(true); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setChartType(MyMoneyReport::eChartLine); list.back().setColumnsAreDays(true); list.back().setInvestmentsOnly(true); @@ -1425,7 +1456,8 @@ i18n("Investment Moving Average"), i18n("Default Report") )); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setChartType(MyMoneyReport::eChartLine); list.back().setColumnsAreDays(true); list.back().setInvestmentsOnly(true); @@ -1442,7 +1474,8 @@ i18n("Default Report") )); list.back().setChartByDefault(true); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setChartType(MyMoneyReport::eChartLine); list.back().setColumnsAreDays(true); list.back().setInvestmentsOnly(true); @@ -1571,7 +1604,8 @@ i18n("Default Report") )); list.back().setChartByDefault(true); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setBudget("Any", true); list.back().setChartType(MyMoneyReport::eChartLine); @@ -1622,7 +1656,8 @@ list.back().setColumnsAreDays(true); list.back().setIncludingForecast(true); list.back().setChartByDefault(true); - list.back().setChartGridLines(false); + list.back().setChartCHGridLines(false); + list.back().setChartSVGridLines(false); list.back().setChartType(MyMoneyReport::eChartLine); groups.push_back(list); } diff --git a/kmymoney/widgets/CMakeLists.txt b/kmymoney/widgets/CMakeLists.txt --- a/kmymoney/widgets/CMakeLists.txt +++ b/kmymoney/widgets/CMakeLists.txt @@ -170,6 +170,7 @@ kschedulebriefwidget.ui kmymoneyreportcontroldecl.ui kmymoneyreportconfigtab1decl.ui kmymoneyreportconfigtab2decl.ui kmymoneyreportconfigtab3decl.ui kmymoneyreportconfigtabchartdecl.ui + kmymoneyreportconfigtabrangedecl.ui ) # using uic on the above UI files DEPENDS on libkmymoney.so. If uic diff --git a/kmymoney/widgets/kmymoneyreportconfigtab2decl.ui b/kmymoney/widgets/kmymoneyreportconfigtab2decl.ui --- a/kmymoney/widgets/kmymoneyreportconfigtab2decl.ui +++ b/kmymoney/widgets/kmymoneyreportconfigtab2decl.ui @@ -1,275 +1,235 @@ - - - - - - kMyMoneyReportConfigTab2Decl - - - - 0 - 0 - 600 - 278 - - - - Rows/Columns Tab - - - - - - <p>On this tab, you configure how you would like the rows and columns to be selected and organized.</p> - - - - - - - - - - Detail - - - false - - - - - - - <p>Choose what kind of accounts to display as the rows of this report.</p> - - - - All - - - - - Top-Level - - - - - Groups - - - - - Totals - - - - - - - - false - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - - - Budget - - - false - - - - - - - - - - - - - Columns - - - false - - - - - - - <p>Choose how large of a time period each column should encompass</p> - - - - Daily - - - - - Weekly - - - - - Monthly - - - - - Bi-Monthly - - - - - Quarterly - - - - - Yearly - - - - - - - - <p>Choose what kind of accounts to display as the rows of this report.</p> - - - - Income & Expenses - - - - - Assets & Liabilities - - - - - - - - Rows - - - false - - - - - - - false - - - Show totals column - - - - - - - Average days - - - false - - - - - - - 366 - - - 1 - - - - - - - - - - 94 - 21 - - - - QSizePolicy::Expanding - - - Qt::Horizontal - - - - - - - - - Include scheduled transactions - + + kMyMoneyReportConfigTab2Decl + + + + 0 + 0 + 600 + 280 + + + + Rows/Columns Tab + + + + + + <p>On this tab, you configure how you'd like the rows and columns to be selected and organized.</p> + + + + + + + + + + Detail + + + false + - - - - - Include transfers - + + + + + <p>Choose what kind of accounts to display as the rows of this report.</p> + + + + Income & Expenses + + + + + Assets & Liabilities + + + + + + + + Rows + + + false + + + + + + + false + + + Show totals column + + + + + + + Average days + + + false + - - - + + + + + 1 + + + 366 + + + + + + + <p>Choose what kind of accounts to display as the rows of this report.</p> + + - Include unused accounts/categories + All - - - - - - - 20 - 40 - + + + + Top-Level + + + + + Groups - - QSizePolicy::Expanding + + + + Totals - - Qt::Vertical + + + + + + + false + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 -
-
-
-
- + + 0 + + + 0 + + + 0 + + + + + Budget + + + false + + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 94 + 21 + + + + + + + + + + Include scheduled transactions + + + + + + + Include transfers + + + + + + + Include unused accounts/categories + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + - KMyMoneyGeneralCombo - QWidget -
kmymoneymvccombo.h
- 1 + KComboBox + QComboBox +
kcombobox.h
- - KComboBox - QComboBox -
kcombobox.h
-
-
- - + + KMyMoneyGeneralCombo + QWidget +
kmymoneymvccombo.h
+ 1 +
+
+ + + diff --git a/kmymoney/widgets/kmymoneyreportconfigtabchartdecl.ui b/kmymoney/widgets/kmymoneyreportconfigtabchartdecl.ui --- a/kmymoney/widgets/kmymoneyreportconfigtabchartdecl.ui +++ b/kmymoney/widgets/kmymoneyreportconfigtabchartdecl.ui @@ -7,7 +7,7 @@ 0 0 600 - 174 + 234 @@ -42,7 +42,7 @@ - + @@ -63,34 +63,52 @@ - - - <p>Select this option to show horizontal and vertical grid lines on the chart.</p> - - - Show grid lines - - - - - - - <p>Select this option to draw the numeric values for data points next to their plot location.</p> - - - Draw values on chart - - - - - - - <p>Select this option to cause the report to be shown as a chart when you first open the report. Otherwise, it will come up as a text report.</p> - - - Show as chart by default - - + + + + + <p>Select this option to draw the numeric values for data points next to their plot location.</p> + + + Draw values on chart + + + + + + + <p>Select this option to cause the report to be shown as a chart when you first open the report. Otherwise, it will come up as a text report.</p> + + + Show as chart by default + + + + + + + SV grid lines + + + + + + + <p>Select this option to show horizontal and vertical grid lines on the chart.</p> + + + CH grid lines + + + + + + + Logarithmic vertical axis + + + + @@ -163,13 +181,9 @@ KMyMoneyGeneralCombo - KComboBox + QWidget
kmymoneymvccombo.h
-
- - KComboBox - QComboBox -
kcombobox.h
+ 1
diff --git a/kmymoney/widgets/kmymoneyreportconfigtabimpl.h b/kmymoney/widgets/kmymoneyreportconfigtabimpl.h --- a/kmymoney/widgets/kmymoneyreportconfigtabimpl.h +++ b/kmymoney/widgets/kmymoneyreportconfigtabimpl.h @@ -21,14 +21,18 @@ #define KMYMONEYREPORTCONFIGTABIMPL_H #include +#include + +class DateRangeDlg; namespace Ui { class kMyMoneyReportConfigTab1Decl; class kMyMoneyReportConfigTab2Decl; class kMyMoneyReportConfigTab3Decl; class kMyMoneyReportConfigTabChartDecl; -}; +class kMyMoneyReportConfigTabRangeDecl; +} class kMyMoneyReportConfigTab1Decl : public QWidget { @@ -59,12 +63,69 @@ class kMyMoneyReportConfigTabChartDecl : public QWidget { + Q_OBJECT public: kMyMoneyReportConfigTabChartDecl(QWidget *parent); virtual ~kMyMoneyReportConfigTabChartDecl(); -private: Ui::kMyMoneyReportConfigTabChartDecl* ui; +private slots: + void slotChartTypeChanged(int index); }; +class kMyMoneyReportConfigTabRangeDecl : public QWidget +{ + Q_OBJECT +public: + kMyMoneyReportConfigTabRangeDecl(QWidget *parent); + virtual ~kMyMoneyReportConfigTabRangeDecl(); + Ui::kMyMoneyReportConfigTabRangeDecl* ui; + DateRangeDlg *m_dateRange; + void setRangeLogarythmic(bool set); +private: + enum EDimension { eRangeStart = 0, eRangeEnd, eMajorTick, eMinorTick}; +private slots: + void slotEditingFinished(EDimension dim); + void slotEditingFinishedStart(); + void slotEditingFinishedEnd(); + void slotEditingFinishedMajor(); + void slotEditingFinishedMinor(); + void slotDataLockChanged(int index); +}; + +class MyDoubleValidator : public QDoubleValidator +{ +public: + MyDoubleValidator(int decimals, QObject * parent = 0) : + QDoubleValidator(0, 0, decimals, parent) + { + } + + QValidator::State validate(QString &s, int &i) const + { + Q_UNUSED(i); + if (s.isEmpty() || s == "-") { + return QValidator::Intermediate; + } + + QChar decimalPoint = locale().decimalPoint(); + + if(s.indexOf(decimalPoint) != -1) { + int charsAfterPoint = s.length() - s.indexOf(decimalPoint) - 1; + + if (charsAfterPoint > decimals()) { + return QValidator::Invalid; + } + } + + bool ok; + locale().toDouble(s, &ok); + + if (ok) { + return QValidator::Acceptable; + } else { + return QValidator::Invalid; + } + } +}; #endif /* KMYMONEYREPORTCONFIGTABIMPL_H */ diff --git a/kmymoney/widgets/kmymoneyreportconfigtabimpl.cpp b/kmymoney/widgets/kmymoneyreportconfigtabimpl.cpp --- a/kmymoney/widgets/kmymoneyreportconfigtabimpl.cpp +++ b/kmymoney/widgets/kmymoneyreportconfigtabimpl.cpp @@ -18,13 +18,17 @@ */ #include "kmymoneyreportconfigtabimpl.h" +#include "kmymoneyglobalsettings.h" #include +#include #include "ui_kmymoneyreportconfigtab1decl.h" #include "ui_kmymoneyreportconfigtab2decl.h" #include "ui_kmymoneyreportconfigtab3decl.h" #include "ui_kmymoneyreportconfigtabchartdecl.h" +#include "ui_kmymoneyreportconfigtabrangedecl.h" +#include "ui_daterangedlgdecl.h" #include "mymoney/mymoneyreport.h" @@ -86,10 +90,147 @@ ui->m_comboType->addItem(i18nc("type of graphic chart", "Stacked Bar"), MyMoneyReport::eChartStackedBar); ui->m_comboType->addItem(i18nc("type of graphic chart", "Pie"), MyMoneyReport::eChartPie); ui->m_comboType->addItem(i18nc("type of graphic chart", "Ring"), MyMoneyReport::eChartRing); + connect(ui->m_comboType, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChartTypeChanged(int))); + emit ui->m_comboType->currentIndexChanged(ui->m_comboType->currentIndex()); } kMyMoneyReportConfigTabChartDecl::~kMyMoneyReportConfigTabChartDecl() { delete ui; } +void kMyMoneyReportConfigTabChartDecl::slotChartTypeChanged(int index) +{ + if (index == MyMoneyReport::EChartType::eChartPie || + index == MyMoneyReport::EChartType::eChartRing) { + ui->m_checkCHGridLines->setText(i18n("Show circular grid lines")); + ui->m_checkSVGridLines->setText(i18n("Show sagittal grid lines")); + ui->m_logYaxis->setChecked(false); + ui->m_logYaxis->setEnabled(false); + } else { + ui->m_checkCHGridLines->setText(i18n("Show horizontal grid lines")); + ui->m_checkSVGridLines->setText(i18n("Show vertical grid lines")); + ui->m_logYaxis->setEnabled(true); + } +} + +kMyMoneyReportConfigTabRangeDecl::kMyMoneyReportConfigTabRangeDecl(QWidget *parent) + : QWidget(parent) +{ + ui = new Ui::kMyMoneyReportConfigTabRangeDecl; + ui->setupUi(this); + m_dateRange = new DateRangeDlg(this->parentWidget()); + ui->dateRangeGrid->addWidget(m_dateRange,0,0,1,2); + MyDoubleValidator *dblVal = new MyDoubleValidator(KMyMoneyGlobalSettings::pricePrecision()); + ui->m_dataRangeStart->setValidator(dblVal); + ui->m_dataRangeEnd->setValidator(dblVal); + ui->m_dataMajorTick->setValidator(dblVal); + ui->m_dataMinorTick->setValidator(dblVal); + connect(ui->m_dataRangeStart, SIGNAL(editingFinished()), this, SLOT(slotEditingFinishedStart())); + connect(ui->m_dataRangeEnd, SIGNAL(editingFinished()), this, SLOT(slotEditingFinishedEnd())); + connect(ui->m_dataMajorTick, SIGNAL(editingFinished()), this, SLOT(slotEditingFinishedMajor())); + connect(ui->m_dataMinorTick, SIGNAL(editingFinished()), this, SLOT(slotEditingFinishedMinor())); + connect(ui->m_dataLock, SIGNAL(currentIndexChanged(int)), this, SLOT(slotDataLockChanged(int))); + emit ui->m_dataLock->currentIndexChanged(ui->m_dataLock->currentIndex()); +} + +kMyMoneyReportConfigTabRangeDecl::~kMyMoneyReportConfigTabRangeDecl() +{ + delete ui; +} + +void kMyMoneyReportConfigTabRangeDecl::setRangeLogarythmic(bool set) +{ + // major and minor tick have no influence if axis is logarithmic so hide them + if (set) { + ui->lblDataMajorTick->hide(); + ui->lblDataMinorTick->hide(); + ui->m_dataMajorTick->hide(); + ui->m_dataMinorTick->hide(); + } else { + ui->lblDataMajorTick->show(); + ui->lblDataMinorTick->show(); + ui->m_dataMajorTick->show(); + ui->m_dataMinorTick->show(); + } +} + +void kMyMoneyReportConfigTabRangeDecl::slotEditingFinished(EDimension dim) +{ + qreal dataRangeStart = locale().toDouble(ui->m_dataRangeStart->text()); + qreal dataRangeEnd = locale().toDouble(ui->m_dataRangeEnd->text()); + qreal dataMajorTick = locale().toDouble(ui->m_dataMajorTick->text()); + qreal dataMinorTick = locale().toDouble(ui->m_dataMinorTick->text()); + if (dataRangeEnd < dataRangeStart) { // end must be higher than start + if (dim == eRangeEnd) { + ui->m_dataRangeStart->setText(ui->m_dataRangeEnd->text()); + dataRangeStart = dataRangeEnd; + } else { + ui->m_dataRangeEnd->setText(ui->m_dataRangeStart->text()); + dataRangeEnd = dataRangeStart; + } + } + if ((dataRangeStart != 0 || dataRangeEnd != 0)) { // if data range isn't going to be reset + if ((dataRangeEnd - dataRangeStart) < dataMajorTick) // major tick cannot be greater than data range + dataMajorTick = dataRangeEnd - dataRangeStart; + + if (dataMajorTick != 0 && // if major tick isn't going to be reset + dataMajorTick < (dataRangeEnd - dataRangeStart) * 0.01) // constraint major tick to be greater or equal to 1% of data range + dataMajorTick = (dataRangeEnd - dataRangeStart) * 0.01; // that should produce more than 256 Y labels in KReportChartView::slotNeedUpdate + + ui->m_dataMajorTick->setText(locale().toString(dataMajorTick, 'f', KMyMoneySettings::pricePrecision()).remove(locale().groupSeparator()).remove(QRegularExpression("0+$")).remove(QRegularExpression("\\" + locale().decimalPoint() + "$"))); + } + + if (dataMajorTick < dataMinorTick) { // major tick must be higher than minor + if (dim == eMinorTick) { + ui->m_dataMajorTick->setText(ui->m_dataMinorTick->text()); + dataMajorTick = dataMinorTick; + } else { + ui->m_dataMinorTick->setText(ui->m_dataMajorTick->text()); + dataMinorTick = dataMajorTick; + } + } + + if (dataMinorTick < dataMajorTick * 0.1) { // constraint minor tick to be greater or equal to 10% of major tick + dataMinorTick = dataMajorTick * 0.1; + ui->m_dataMinorTick->setText(locale().toString(dataMinorTick, 'f', KMyMoneySettings::pricePrecision()).remove(locale().groupSeparator()).remove(QRegularExpression("0+$")).remove(QRegularExpression("\\" + locale().decimalPoint() + "$"))); + } +} + +void kMyMoneyReportConfigTabRangeDecl::slotEditingFinishedStart() +{ + slotEditingFinished(eRangeStart); +} + +void kMyMoneyReportConfigTabRangeDecl::slotEditingFinishedEnd() +{ + slotEditingFinished(eRangeEnd); +} + +void kMyMoneyReportConfigTabRangeDecl::slotEditingFinishedMajor() +{ + slotEditingFinished(eMajorTick); +} + +void kMyMoneyReportConfigTabRangeDecl::slotEditingFinishedMinor() +{ + slotEditingFinished(eMinorTick); +} + +void kMyMoneyReportConfigTabRangeDecl::slotDataLockChanged(int index) { + if (index == MyMoneyReport::dataOptionE::automatic) { + ui->m_dataRangeStart->setText(QStringLiteral("0")); + ui->m_dataRangeEnd->setText(QStringLiteral("0")); + ui->m_dataMajorTick->setText(QStringLiteral("0")); + ui->m_dataMinorTick->setText(QStringLiteral("0")); + ui->m_dataRangeStart->setEnabled(false); + ui->m_dataRangeEnd->setEnabled(false); + ui->m_dataMajorTick->setEnabled(false); + ui->m_dataMinorTick->setEnabled(false); + } else { + ui->m_dataRangeStart->setEnabled(true); + ui->m_dataRangeEnd->setEnabled(true); + ui->m_dataMajorTick->setEnabled(true); + ui->m_dataMinorTick->setEnabled(true); + } +} diff --git a/kmymoney/widgets/kmymoneyreportconfigtabrangedecl.ui b/kmymoney/widgets/kmymoneyreportconfigtabrangedecl.ui new file mode 100644 --- /dev/null +++ b/kmymoney/widgets/kmymoneyreportconfigtabrangedecl.ui @@ -0,0 +1,224 @@ + + + kMyMoneyReportConfigTabRangeDecl + + + + 0 + 0 + 600 + 246 + + + + Chart Tab + + + + + + <p>On this tab, you configure the chart drawn for this report.</p> + + + + + + Date range + + + + 0 + + + 0 + + + + + 6 + + + 0 + + + 6 + + + 0 + + + + + Ticks + + + + + + + + 0 + 0 + + + + <p>Choose how large of a time period each column should encompass</p> + + + + Daily + + + + + Weekly + + + + + Monthly + + + + + Bi-Monthly + + + + + Quarterly + + + + + Yearly + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Data range + + + + 12 + + + 12 + + + + + + 0 + 0 + + + + From + + + + + + + Minor tick length + + + + + + + To + + + + + + + + + + + Automatic + + + + + User defined + + + + + + + + Range + + + + + + + + + + + + + Major tick length + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + KComboBox + QComboBox +
kcombobox.h
+
+
+ + +