Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/kreportconfigurationfilterdlg.cpp
Context not available. | |||||
58 | #include <kmymoneyaccountselector.h> | 58 | #include <kmymoneyaccountselector.h> | ||
---|---|---|---|---|---|
59 | #include <mymoneyfile.h> | 59 | #include <mymoneyfile.h> | ||
60 | #include <mymoneyreport.h> | 60 | #include <mymoneyreport.h> | ||
61 | #include <daterangedlg.h> | ||||
62 | | ||||
61 | #include "ui_kfindtransactiondlgdecl.h" | 63 | #include "ui_kfindtransactiondlgdecl.h" | ||
64 | #include "ui_daterangedlgdecl.h" | ||||
65 | #include "ui_kmymoneyreportconfigtabrangedecl.h" | ||||
62 | 66 | | |||
63 | KReportConfigurationFilterDlg::KReportConfigurationFilterDlg( | 67 | KReportConfigurationFilterDlg::KReportConfigurationFilterDlg( | ||
64 | MyMoneyReport report, QWidget *parent) | 68 | MyMoneyReport report, QWidget *parent) | ||
Context not available. | |||||
66 | m_tab2(0), | 70 | m_tab2(0), | ||
67 | m_tab3(0), | 71 | m_tab3(0), | ||
68 | m_tabChart(0), | 72 | m_tabChart(0), | ||
73 | m_tabRange(0), | ||||
69 | m_initialState(report), | 74 | m_initialState(report), | ||
70 | m_currentState(report) | 75 | m_currentState(report) | ||
71 | { | 76 | { | ||
Context not available. | |||||
75 | 80 | | |||
76 | setWindowTitle(i18n("Report Configuration")); | 81 | setWindowTitle(i18n("Report Configuration")); | ||
77 | delete m_ui->TextLabel1; | 82 | delete m_ui->TextLabel1; | ||
78 | | ||||
79 | // | 83 | // | ||
80 | // Rework the buttons | 84 | // Rework the buttons | ||
81 | // | 85 | // | ||
Context not available. | |||||
99 | m_tab2->setObjectName("kMyMoneyReportConfigTab2"); | 103 | m_tab2->setObjectName("kMyMoneyReportConfigTab2"); | ||
100 | m_ui->m_criteriaTab->insertTab(1, m_tab2, i18n("Rows/Columns")); | 104 | m_ui->m_criteriaTab->insertTab(1, m_tab2, i18n("Rows/Columns")); | ||
101 | connect(m_tab2->findChild<KComboBox*>("m_comboRows"), SIGNAL(activated(int)), this, SLOT(slotRowTypeChanged(int))); | 105 | connect(m_tab2->findChild<KComboBox*>("m_comboRows"), SIGNAL(activated(int)), this, SLOT(slotRowTypeChanged(int))); | ||
102 | connect(m_tab2->findChild<KComboBox*>("m_comboColumns"), SIGNAL(activated(int)), this, SLOT(slotColumnTypeChanged(int))); | | |||
103 | connect(m_tab2->findChild<KComboBox*>("m_comboRows"), SIGNAL(activated(int)), this, SLOT(slotUpdateColumnsCombo())); | 106 | connect(m_tab2->findChild<KComboBox*>("m_comboRows"), SIGNAL(activated(int)), this, SLOT(slotUpdateColumnsCombo())); | ||
104 | connect(m_tab2->findChild<KComboBox*>("m_comboColumns"), SIGNAL(activated(int)), this, SLOT(slotUpdateColumnsCombo())); | | |||
105 | //control the state of the includeTransfer check | 107 | //control the state of the includeTransfer check | ||
106 | connect(m_ui->m_categoriesView, SIGNAL(stateChanged()), this, SLOT(slotUpdateCheckTransfers())); | 108 | connect(m_ui->m_categoriesView, SIGNAL(stateChanged()), this, SLOT(slotUpdateCheckTransfers())); | ||
107 | 109 | | |||
108 | m_tabChart = new kMyMoneyReportConfigTabChartDecl(m_ui->m_criteriaTab); | 110 | m_tabChart = new kMyMoneyReportConfigTabChartDecl(m_ui->m_criteriaTab); | ||
109 | m_tabChart->setObjectName("kMyMoneyReportConfigTabChart"); | 111 | m_tabChart->setObjectName("kMyMoneyReportConfigTabChart"); | ||
110 | m_ui->m_criteriaTab->insertTab(2, m_tabChart, i18n("Chart")); | 112 | m_ui->m_criteriaTab->insertTab(2, m_tabChart, i18n("Chart")); | ||
113 | | ||||
114 | m_tabRange = new kMyMoneyReportConfigTabRangeDecl(m_ui->m_criteriaTab); | ||||
115 | m_tabRange->setObjectName("kMyMoneyReportConfigTabRange"); | ||||
116 | m_ui->m_criteriaTab->insertTab(3, m_tabRange, i18n("Range")); | ||||
117 | | ||||
118 | // date tab is going to be replaced by range tab, so delete it | ||||
119 | m_ui->dateRangeLayout->removeWidget(m_dateRange); | ||||
120 | m_dateRange->deleteLater(); | ||||
121 | m_ui->m_criteriaTab->removeTab(m_ui->m_criteriaTab->indexOf(m_ui->m_dateTab)); | ||||
122 | m_ui->m_dateTab->deleteLater(); | ||||
123 | | ||||
124 | m_dateRange = m_tabRange->m_dateRange; | ||||
125 | | ||||
126 | connect(m_tabRange->ui->m_comboColumns, SIGNAL(activated(int)), this, SLOT(slotColumnTypeChanged(int))); | ||||
127 | connect(m_tabRange->ui->m_comboColumns, SIGNAL(activated(int)), this, SLOT(slotUpdateColumnsCombo())); | ||||
128 | connect(m_tabChart->findChild<QCheckBox*>("m_logYaxis"), SIGNAL(stateChanged(int)), this, SLOT(slotLogAxisChanged(int))); | ||||
111 | } else if (m_initialState.reportType() == MyMoneyReport::eQueryTable) { | 129 | } else if (m_initialState.reportType() == MyMoneyReport::eQueryTable) { | ||
112 | // eInvestmentHoldings is a special-case report, and you cannot configure the | 130 | // eInvestmentHoldings is a special-case report, and you cannot configure the | ||
113 | // rows & columns of that report. | 131 | // rows & columns of that report. | ||
Context not available. | |||||
167 | if (m_tab2->findChild<KComboBox*>("m_comboRows")->currentIndex() == 0) | 185 | if (m_tab2->findChild<KComboBox*>("m_comboRows")->currentIndex() == 0) | ||
168 | m_currentState.setShowingRowTotals(m_tab2->findChild<QCheckBox*>("m_checkTotalColumn")->isChecked()); | 186 | m_currentState.setShowingRowTotals(m_tab2->findChild<QCheckBox*>("m_checkTotalColumn")->isChecked()); | ||
169 | 187 | | |||
170 | MyMoneyReport::EColumnType ct[6] = { MyMoneyReport::eDays, MyMoneyReport::eWeeks, MyMoneyReport::eMonths, MyMoneyReport::eBiMonths, MyMoneyReport::eQuarters, MyMoneyReport::eYears }; | | |||
171 | bool dy[6] = { true, true, false, false, false, false }; | | |||
172 | m_currentState.setColumnType(ct[m_tab2->findChild<KComboBox*>("m_comboColumns")->currentIndex()]); | | |||
173 | | ||||
174 | //TODO (Ace) This should be implicit in the call above. MMReport needs fixin' | | |||
175 | m_currentState.setColumnsAreDays(dy[m_tab2->findChild<KComboBox*>("m_comboColumns")->currentIndex()]); | | |||
176 | | ||||
177 | m_currentState.setIncludingSchedules(m_tab2->findChild<QCheckBox*>("m_checkScheduled")->isChecked()); | 188 | m_currentState.setIncludingSchedules(m_tab2->findChild<QCheckBox*>("m_checkScheduled")->isChecked()); | ||
178 | 189 | | |||
179 | m_currentState.setIncludingTransfers(m_tab2->findChild<QCheckBox*>("m_checkTransfers")->isChecked()); | 190 | m_currentState.setIncludingTransfers(m_tab2->findChild<QCheckBox*>("m_checkTransfers")->isChecked()); | ||
Context not available. | |||||
237 | MyMoneyReport::EChartType ct[5] = { MyMoneyReport::eChartLine, MyMoneyReport::eChartBar, MyMoneyReport::eChartStackedBar, MyMoneyReport::eChartPie, MyMoneyReport::eChartRing }; | 248 | MyMoneyReport::EChartType ct[5] = { MyMoneyReport::eChartLine, MyMoneyReport::eChartBar, MyMoneyReport::eChartStackedBar, MyMoneyReport::eChartPie, MyMoneyReport::eChartRing }; | ||
238 | m_currentState.setChartType(ct[m_tabChart->findChild<KMyMoneyGeneralCombo*>("m_comboType")->currentIndex()]); | 249 | m_currentState.setChartType(ct[m_tabChart->findChild<KMyMoneyGeneralCombo*>("m_comboType")->currentIndex()]); | ||
239 | 250 | | |||
240 | m_currentState.setChartGridLines(m_tabChart->findChild<QCheckBox*>("m_checkGridLines")->isChecked()); | 251 | m_currentState.setChartCHGridLines(m_tabChart->findChild<QCheckBox*>("m_checkCHGridLines")->isChecked()); | ||
252 | m_currentState.setChartSVGridLines(m_tabChart->findChild<QCheckBox*>("m_checkSVGridLines")->isChecked()); | ||||
241 | m_currentState.setChartDataLabels(m_tabChart->findChild<QCheckBox*>("m_checkValues")->isChecked()); | 253 | m_currentState.setChartDataLabels(m_tabChart->findChild<QCheckBox*>("m_checkValues")->isChecked()); | ||
242 | m_currentState.setChartByDefault(m_tabChart->findChild<QCheckBox*>("m_checkShowChart")->isChecked()); | 254 | m_currentState.setChartByDefault(m_tabChart->findChild<QCheckBox*>("m_checkShowChart")->isChecked()); | ||
243 | m_currentState.setChartLineWidth(m_tabChart->findChild<QSpinBox*>("m_lineWidth")->value()); | 255 | m_currentState.setChartLineWidth(m_tabChart->findChild<QSpinBox*>("m_lineWidth")->value()); | ||
256 | m_currentState.setLogYAxis(m_tabChart->findChild<QCheckBox*>("m_logYaxis")->isChecked()); | ||||
257 | } | ||||
258 | | ||||
259 | if (m_tabRange) { | ||||
260 | m_currentState.setDataRangeStart(m_tabRange->ui->m_dataRangeStart->text()); | ||||
261 | m_currentState.setDataRangeEnd(m_tabRange->ui->m_dataRangeEnd->text()); | ||||
262 | m_currentState.setDataMajorTick(m_tabRange->ui->m_dataMajorTick->text()); | ||||
263 | m_currentState.setDataMinorTick(m_tabRange->ui->m_dataMinorTick->text()); | ||||
264 | m_currentState.setDataFilter((MyMoneyReport::dataOptionE)m_tabRange->ui->m_dataLock->currentIndex()); | ||||
265 | | ||||
266 | MyMoneyReport::EColumnType ct[6] = { MyMoneyReport::eDays, MyMoneyReport::eWeeks, MyMoneyReport::eMonths, MyMoneyReport::eBiMonths, MyMoneyReport::eQuarters, MyMoneyReport::eYears }; | ||||
267 | bool dy[6] = { true, true, false, false, false, false }; | ||||
268 | m_currentState.setColumnType(ct[m_tabRange->ui->m_comboColumns->currentIndex()]); | ||||
269 | | ||||
270 | //TODO (Ace) This should be implicit in the call above. MMReport needs fixin' | ||||
271 | m_currentState.setColumnsAreDays(dy[m_tabRange->ui->m_comboColumns->currentIndex()]); | ||||
244 | } | 272 | } | ||
245 | 273 | | |||
246 | // setup the date lock | 274 | // setup the date lock | ||
247 | MyMoneyTransactionFilter::dateOptionE range = m_ui->m_dateRange->currentItem(); | 275 | MyMoneyTransactionFilter::dateOptionE range = m_dateRange->m_ui->m_dateRange->currentItem(); | ||
248 | m_currentState.setDateFilter(range); | 276 | m_currentState.setDateFilter(range); | ||
249 | 277 | | |||
250 | done(true); | 278 | done(true); | ||
Context not available. | |||||
258 | void KReportConfigurationFilterDlg::slotColumnTypeChanged(int row) | 286 | void KReportConfigurationFilterDlg::slotColumnTypeChanged(int row) | ||
259 | { | 287 | { | ||
260 | if ((m_tab2->findChild<KMyMoneyGeneralCombo*>("m_comboBudget")->isEnabled() && row < 2)) { | 288 | if ((m_tab2->findChild<KMyMoneyGeneralCombo*>("m_comboBudget")->isEnabled() && row < 2)) { | ||
261 | m_tab2->findChild<KComboBox*>("m_comboColumns")->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); | 289 | m_tabRange->ui->m_comboColumns->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); | ||
262 | } | 290 | } | ||
263 | } | 291 | } | ||
264 | 292 | | |||
Context not available. | |||||
267 | const int monthlyIndex = 2; | 295 | const int monthlyIndex = 2; | ||
268 | const int incomeExpenseIndex = 0; | 296 | const int incomeExpenseIndex = 0; | ||
269 | const bool isIncomeExpenseForecast = m_currentState.isIncludingForecast() && m_tab2->findChild<KComboBox*>("m_comboRows")->currentIndex() == incomeExpenseIndex; | 297 | const bool isIncomeExpenseForecast = m_currentState.isIncludingForecast() && m_tab2->findChild<KComboBox*>("m_comboRows")->currentIndex() == incomeExpenseIndex; | ||
270 | if (isIncomeExpenseForecast && m_tab2->findChild<KComboBox*>("m_comboColumns")->currentIndex() != monthlyIndex) { | 298 | if (isIncomeExpenseForecast && m_tabRange->ui->m_comboColumns->currentIndex() != monthlyIndex) { | ||
271 | m_tab2->findChild<KComboBox*>("m_comboColumns")->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); | 299 | m_tabRange->ui->m_comboColumns->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); | ||
272 | } | 300 | } | ||
273 | } | 301 | } | ||
274 | 302 | | |||
303 | void KReportConfigurationFilterDlg::slotLogAxisChanged(int state) | ||||
304 | { | ||||
305 | if (state == Qt::Checked) | ||||
306 | m_tabRange->setRangeLogarythmic(true); | ||||
307 | else | ||||
308 | m_tabRange->setRangeLogarythmic(false); | ||||
309 | } | ||||
310 | | ||||
275 | void KReportConfigurationFilterDlg::slotReset() | 311 | void KReportConfigurationFilterDlg::slotReset() | ||
276 | { | 312 | { | ||
277 | // | 313 | // | ||
Context not available. | |||||
328 | 364 | | |||
329 | slotRowTypeChanged(combo->currentIndex()); | 365 | slotRowTypeChanged(combo->currentIndex()); | ||
330 | 366 | | |||
331 | combo = m_tab2->findChild<KComboBox*>("m_comboColumns"); | | |||
332 | if (m_initialState.isColumnsAreDays()) { | | |||
333 | switch (m_initialState.columnType()) { | | |||
334 | case MyMoneyReport::eNoColumns: | | |||
335 | case MyMoneyReport::eDays: | | |||
336 | combo->setCurrentItem(i18nc("@item the columns will display daily data", "Daily"), false); | | |||
337 | break; | | |||
338 | case MyMoneyReport::eWeeks: | | |||
339 | combo->setCurrentItem(i18nc("@item the columns will display weekly data", "Weekly"), false); | | |||
340 | break; | | |||
341 | default: | | |||
342 | break; | | |||
343 | } | | |||
344 | } else { | | |||
345 | switch (m_initialState.columnType()) { | | |||
346 | case MyMoneyReport::eNoColumns: | | |||
347 | case MyMoneyReport::eMonths: | | |||
348 | combo->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); | | |||
349 | break; | | |||
350 | case MyMoneyReport::eBiMonths: | | |||
351 | combo->setCurrentItem(i18nc("@item the columns will display bi-monthly data", "Bi-Monthly"), false); | | |||
352 | break; | | |||
353 | case MyMoneyReport::eQuarters: | | |||
354 | combo->setCurrentItem(i18nc("@item the columns will display quarterly data", "Quarterly"), false); | | |||
355 | break; | | |||
356 | case MyMoneyReport::eYears: | | |||
357 | combo->setCurrentItem(i18nc("@item the columns will display yearly data", "Yearly"), false); | | |||
358 | break; | | |||
359 | default: | | |||
360 | break; | | |||
361 | } | | |||
362 | } | | |||
363 | | ||||
364 | //load budgets combo | 367 | //load budgets combo | ||
365 | if (m_initialState.rowType() == MyMoneyReport::eBudget | 368 | if (m_initialState.rowType() == MyMoneyReport::eBudget | ||
366 | || m_initialState.rowType() == MyMoneyReport::eBudgetActual) { | 369 | || m_initialState.rowType() == MyMoneyReport::eBudgetActual) { | ||
Context not available. | |||||
456 | case MyMoneyReport::eChartEnd: | 459 | case MyMoneyReport::eChartEnd: | ||
457 | throw MYMONEYEXCEPTION("KReportConfigurationFilterDlg::slotReset(): Report has invalid charttype"); | 460 | throw MYMONEYEXCEPTION("KReportConfigurationFilterDlg::slotReset(): Report has invalid charttype"); | ||
458 | } | 461 | } | ||
459 | m_tabChart->findChild<QCheckBox*>("m_checkGridLines")->setChecked(m_initialState.isChartGridLines()); | 462 | m_tabChart->findChild<QCheckBox*>("m_checkCHGridLines")->setChecked(m_initialState.isChartCHGridLines()); | ||
463 | m_tabChart->findChild<QCheckBox*>("m_checkSVGridLines")->setChecked(m_initialState.isChartSVGridLines()); | ||||
460 | m_tabChart->findChild<QCheckBox*>("m_checkValues")->setChecked(m_initialState.isChartDataLabels()); | 464 | m_tabChart->findChild<QCheckBox*>("m_checkValues")->setChecked(m_initialState.isChartDataLabels()); | ||
461 | m_tabChart->findChild<QCheckBox*>("m_checkShowChart")->setChecked(m_initialState.isChartByDefault()); | 465 | m_tabChart->findChild<QCheckBox*>("m_checkShowChart")->setChecked(m_initialState.isChartByDefault()); | ||
462 | m_tabChart->findChild<QSpinBox*>("m_lineWidth")->setValue(m_initialState.chartLineWidth()); | 466 | m_tabChart->findChild<QSpinBox*>("m_lineWidth")->setValue(m_initialState.chartLineWidth()); | ||
467 | m_tabChart->findChild<QCheckBox*>("m_logYaxis")->setChecked(m_initialState.isLogYAxis()); | ||||
468 | } | ||||
469 | | ||||
470 | if (m_tabRange) { | ||||
471 | m_tabRange->ui->m_dataRangeStart->setText(m_initialState.dataRangeStart()); | ||||
472 | m_tabRange->ui->m_dataRangeEnd->setText(m_initialState.dataRangeEnd()); | ||||
473 | m_tabRange->ui->m_dataMajorTick->setText(m_initialState.dataMajorTick()); | ||||
474 | m_tabRange->ui->m_dataMinorTick->setText(m_initialState.dataMinorTick()); | ||||
475 | m_tabRange->ui->m_dataLock->setCurrentIndex((int)m_initialState.dataFilter()); | ||||
476 | | ||||
477 | KComboBox *combo = m_tabRange->ui->m_comboColumns; | ||||
478 | if (m_initialState.isColumnsAreDays()) { | ||||
479 | switch (m_initialState.columnType()) { | ||||
480 | case MyMoneyReport::eNoColumns: | ||||
481 | case MyMoneyReport::eDays: | ||||
482 | combo->setCurrentItem(i18nc("@item the columns will display daily data", "Daily"), false); | ||||
483 | break; | ||||
484 | case MyMoneyReport::eWeeks: | ||||
485 | combo->setCurrentItem(i18nc("@item the columns will display weekly data", "Weekly"), false); | ||||
486 | break; | ||||
487 | default: | ||||
488 | break; | ||||
489 | } | ||||
490 | } else { | ||||
491 | switch (m_initialState.columnType()) { | ||||
492 | case MyMoneyReport::eNoColumns: | ||||
493 | case MyMoneyReport::eMonths: | ||||
494 | combo->setCurrentItem(i18nc("@item the columns will display monthly data", "Monthly"), false); | ||||
495 | break; | ||||
496 | case MyMoneyReport::eBiMonths: | ||||
497 | combo->setCurrentItem(i18nc("@item the columns will display bi-monthly data", "Bi-Monthly"), false); | ||||
498 | break; | ||||
499 | case MyMoneyReport::eQuarters: | ||||
500 | combo->setCurrentItem(i18nc("@item the columns will display quarterly data", "Quarterly"), false); | ||||
501 | break; | ||||
502 | case MyMoneyReport::eYears: | ||||
503 | combo->setCurrentItem(i18nc("@item the columns will display yearly data", "Yearly"), false); | ||||
504 | break; | ||||
505 | default: | ||||
506 | break; | ||||
507 | } | ||||
508 | } | ||||
463 | } | 509 | } | ||
464 | 510 | | |||
465 | // | 511 | // | ||
Context not available. | |||||
621 | m_initialState.updateDateFilter(); | 667 | m_initialState.updateDateFilter(); | ||
622 | QDate dateFrom, dateTo; | 668 | QDate dateFrom, dateTo; | ||
623 | if (m_initialState.dateFilter(dateFrom, dateTo)) { | 669 | if (m_initialState.dateFilter(dateFrom, dateTo)) { | ||
624 | if (m_initialState.isUserDefined()) { | 670 | if (m_initialState.isDateUserDefined()) { | ||
625 | m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::userDefined); | 671 | m_dateRange->m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::userDefined); | ||
626 | m_ui->m_fromDate->setDate(dateFrom); | 672 | m_dateRange->m_ui->m_fromDate->setDate(dateFrom); | ||
627 | m_ui->m_toDate->setDate(dateTo); | 673 | m_dateRange->m_ui->m_toDate->setDate(dateTo); | ||
628 | } else { | 674 | } else { | ||
629 | m_ui->m_fromDate->setDate(dateFrom); | 675 | m_dateRange->m_ui->m_fromDate->setDate(dateFrom); | ||
630 | m_ui->m_toDate->setDate(dateTo); | 676 | m_dateRange->m_ui->m_toDate->setDate(dateTo); | ||
631 | KFindTransactionDlg::slotDateChanged(); | 677 | m_dateRange->slotDateChanged(); | ||
632 | } | 678 | } | ||
633 | } else { | 679 | } else { | ||
634 | m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::allDates); | 680 | m_dateRange->m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::allDates); | ||
635 | slotDateRangeChanged(MyMoneyTransactionFilter::allDates); | 681 | m_dateRange->slotDateRangeChanged(MyMoneyTransactionFilter::allDates); | ||
636 | } | 682 | } | ||
637 | 683 | | |||
638 | slotRightSize(); | 684 | slotRightSize(); | ||
Context not available. | |||||
640 | 686 | | |||
641 | void KReportConfigurationFilterDlg::slotDateChanged() | 687 | void KReportConfigurationFilterDlg::slotDateChanged() | ||
642 | { | 688 | { | ||
643 | if (m_ui->m_dateRange->currentItem() != MyMoneyTransactionFilter::userDefined) { | 689 | if (m_dateRange->m_ui->m_dateRange->currentItem() != MyMoneyTransactionFilter::userDefined) { | ||
644 | KFindTransactionDlg::slotDateChanged(); | 690 | m_dateRange->slotDateChanged(); | ||
645 | } | 691 | } | ||
646 | slotUpdateSelections(); | 692 | slotUpdateSelections(); | ||
647 | } | 693 | } | ||
Context not available. |