Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/kfindtransactiondlg.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | #include <kmymoneydateinput.h> | 54 | #include <kmymoneydateinput.h> | ||
55 | #include <kmymoneyedit.h> | 55 | #include <kmymoneyedit.h> | ||
56 | #include <kmymoneylineedit.h> | 56 | #include <kmymoneylineedit.h> | ||
57 | #include <kmymoneyaccountselector.h> | 57 | #include <kmymoneyaccountselector.h> | ||
58 | #include <mymoneyfile.h> | 58 | #include <mymoneyfile.h> | ||
59 | #include <kmymoneyglobalsettings.h> | 59 | #include <kmymoneyglobalsettings.h> | ||
60 | #include <register.h> | 60 | #include <register.h> | ||
61 | #include <transaction.h> | 61 | #include <transaction.h> | ||
62 | #include <daterangedlg.h> | ||||
62 | 63 | | |||
63 | #include "ui_kfindtransactiondlgdecl.h" | 64 | #include "ui_kfindtransactiondlgdecl.h" | ||
64 | #include "ui_ksortoptiondlg.h" | 65 | #include "ui_ksortoptiondlg.h" | ||
66 | #include "ui_daterangedlgdecl.h" | ||||
65 | 67 | | |||
66 | enum ItemRoles { | 68 | enum ItemRoles { | ||
67 | ItemIdRole = Qt::UserRole | 69 | ItemIdRole = Qt::UserRole | ||
68 | }; | 70 | }; | ||
69 | 71 | | |||
70 | struct KSortOptionDlg::Private { | 72 | struct KSortOptionDlg::Private { | ||
71 | Ui::KSortOptionDlg ui; | 73 | Ui::KSortOptionDlg ui; | ||
72 | }; | 74 | }; | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
114 | 116 | | |||
115 | 117 | | |||
116 | KFindTransactionDlg::KFindTransactionDlg(QWidget *parent) : | 118 | KFindTransactionDlg::KFindTransactionDlg(QWidget *parent) : | ||
117 | QDialog(parent), | 119 | QDialog(parent), | ||
118 | m_needReload(false), | 120 | m_needReload(false), | ||
119 | m_ui(new Ui::KFindTransactionDlgDecl) | 121 | m_ui(new Ui::KFindTransactionDlgDecl) | ||
120 | { | 122 | { | ||
121 | m_ui->setupUi(this); | 123 | m_ui->setupUi(this); | ||
124 | m_dateRange = new DateRangeDlg(m_ui->m_dateTab); | ||||
125 | m_ui->dateRangeLayout->insertWidget(0, m_dateRange); | ||||
122 | 126 | | |||
123 | m_ui->ButtonGroup1->setId(m_ui->m_amountButton, 0); | 127 | m_ui->ButtonGroup1->setId(m_ui->m_amountButton, 0); | ||
124 | m_ui->ButtonGroup1->setId(m_ui->m_amountRangeButton, 1); | 128 | m_ui->ButtonGroup1->setId(m_ui->m_amountRangeButton, 1); | ||
125 | 129 | | |||
126 | m_ui->m_register->installEventFilter(this); | 130 | m_ui->m_register->installEventFilter(this); | ||
127 | m_ui->m_tabWidget->setTabEnabled(m_ui->m_tabWidget->indexOf(m_ui->m_resultPage), false); | 131 | m_ui->m_tabWidget->setTabEnabled(m_ui->m_tabWidget->indexOf(m_ui->m_resultPage), false); | ||
128 | 132 | | |||
129 | // 'cause we don't have a separate setupTextPage | 133 | // 'cause we don't have a separate setupTextPage | ||
130 | connect(m_ui->m_textEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateSelections())); | 134 | connect(m_ui->m_textEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateSelections())); | ||
131 | // if return is pressed trigger a search (slotSearch checks if it's possible to perform the search) | 135 | // if return is pressed trigger a search (slotSearch checks if it's possible to perform the search) | ||
132 | connect(m_ui->m_textEdit, SIGNAL(returnPressed()), this, SLOT(slotSearch())); | 136 | connect(m_ui->m_textEdit, SIGNAL(returnPressed()), this, SLOT(slotSearch())); | ||
133 | 137 | | |||
134 | setupAccountsPage(); | 138 | setupAccountsPage(); | ||
135 | setupCategoriesPage(); | 139 | setupCategoriesPage(); | ||
136 | setupDatePage(); | | |||
137 | setupAmountPage(); | 140 | setupAmountPage(); | ||
138 | setupPayeesPage(); | 141 | setupPayeesPage(); | ||
139 | setupTagsPage(); | 142 | setupTagsPage(); | ||
140 | setupDetailsPage(); | 143 | setupDetailsPage(); | ||
141 | 144 | | |||
142 | // We don't need to add the default into the list (see ::slotShowHelp() why) | 145 | // We don't need to add the default into the list (see ::slotShowHelp() why) | ||
143 | // m_helpAnchor[m_ui->m_textTab] = QString("details.search"); | 146 | // m_helpAnchor[m_ui->m_textTab] = QString("details.search"); | ||
144 | m_helpAnchor[m_ui->m_accountTab] = QString("details.search.account"); | 147 | m_helpAnchor[m_ui->m_accountTab] = QString("details.search.account"); | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 199 | { | |||
227 | m_ui->m_nrButton->setChecked(true); | 230 | m_ui->m_nrButton->setChecked(true); | ||
228 | m_ui->m_nrRangeButton->setChecked(false); | 231 | m_ui->m_nrRangeButton->setChecked(false); | ||
229 | 232 | | |||
230 | m_ui->m_tabWidget->setTabEnabled(m_ui->m_tabWidget->indexOf(m_ui->m_resultPage), false); | 233 | m_ui->m_tabWidget->setTabEnabled(m_ui->m_tabWidget->indexOf(m_ui->m_resultPage), false); | ||
231 | m_ui->m_tabWidget->setCurrentIndex(m_ui->m_tabWidget->indexOf(m_ui->m_criteriaTab)); | 234 | m_ui->m_tabWidget->setCurrentIndex(m_ui->m_tabWidget->indexOf(m_ui->m_criteriaTab)); | ||
232 | 235 | | |||
233 | // the following call implies a call to slotUpdateSelections, | 236 | // the following call implies a call to slotUpdateSelections, | ||
234 | // that's why we call it last | 237 | // that's why we call it last | ||
235 | m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::allDates); | 238 | m_dateRange->slotReset(); | ||
236 | slotDateRangeChanged(MyMoneyTransactionFilter::allDates); | 239 | slotUpdateSelections(); | ||
237 | } | 240 | } | ||
238 | 241 | | |||
239 | void KFindTransactionDlg::slotUpdateSelections() | 242 | void KFindTransactionDlg::slotUpdateSelections() | ||
240 | { | 243 | { | ||
241 | QString txt; | 244 | QString txt; | ||
242 | 245 | | |||
243 | // Text tab | 246 | // Text tab | ||
244 | if (!m_ui->m_textEdit->text().isEmpty()) { | 247 | if (!m_ui->m_textEdit->text().isEmpty()) { | ||
Show All 9 Lines | |||||
254 | 257 | | |||
255 | // Account tab | 258 | // Account tab | ||
256 | if (!m_ui->m_accountsView->allItemsSelected()) { | 259 | if (!m_ui->m_accountsView->allItemsSelected()) { | ||
257 | if (!txt.isEmpty()) | 260 | if (!txt.isEmpty()) | ||
258 | txt += ", "; | 261 | txt += ", "; | ||
259 | txt += i18n("Account"); | 262 | txt += i18n("Account"); | ||
260 | } | 263 | } | ||
261 | 264 | | |||
262 | // Date tab | 265 | m_dateRange->slotUpdateSelections(txt); | ||
263 | if (m_ui->m_dateRange->currentItem() != 0) { | | |||
264 | if (!txt.isEmpty()) | | |||
265 | txt += ", "; | | |||
266 | txt += i18n("Date"); | | |||
267 | } | | |||
268 | 266 | | |||
269 | // Amount tab | 267 | // Amount tab | ||
270 | if ((m_ui->m_amountButton->isChecked() && m_ui->m_amountEdit->isValid()) | 268 | if ((m_ui->m_amountButton->isChecked() && m_ui->m_amountEdit->isValid()) | ||
271 | || (m_ui->m_amountRangeButton->isChecked() | 269 | || (m_ui->m_amountRangeButton->isChecked() | ||
272 | && (m_ui->m_amountFromEdit->isValid() || m_ui->m_amountToEdit->isValid()))) { | 270 | && (m_ui->m_amountFromEdit->isValid() || m_ui->m_amountToEdit->isValid()))) { | ||
273 | if (!txt.isEmpty()) | 271 | if (!txt.isEmpty()) | ||
274 | txt += ", "; | 272 | txt += ", "; | ||
275 | txt += i18n("Amount"); | 273 | txt += i18n("Amount"); | ||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Line(s) | 427 | for (int i = 0; i < item->childCount(); ++i) { | |||
430 | it_v = item->child(i); | 428 | it_v = item->child(i); | ||
431 | QVariant idData = it_v->data(0, ItemIdRole); | 429 | QVariant idData = it_v->data(0, ItemIdRole); | ||
432 | if (list.contains(idData.toString())) | 430 | if (list.contains(idData.toString())) | ||
433 | it_v->setCheckState(0, state ? Qt::Checked : Qt::Unchecked); | 431 | it_v->setCheckState(0, state ? Qt::Checked : Qt::Unchecked); | ||
434 | selectSubItems(it_v, list, state); | 432 | selectSubItems(it_v, list, state); | ||
435 | } | 433 | } | ||
436 | } | 434 | } | ||
437 | 435 | | |||
438 | void KFindTransactionDlg::setupDatePage() | | |||
439 | { | | |||
440 | int i; | | |||
441 | for (i = MyMoneyTransactionFilter::allDates; i < MyMoneyTransactionFilter::dateOptionCount; ++i) { | | |||
442 | MyMoneyTransactionFilter::translateDateRange(static_cast<MyMoneyTransactionFilter::dateOptionE>(i), m_startDates[i], m_endDates[i]); | | |||
443 | } | | |||
444 | | ||||
445 | connect(m_ui->m_dateRange, SIGNAL(itemSelected(int)), this, SLOT(slotDateRangeChanged(int))); | | |||
446 | connect(m_ui->m_fromDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); | | |||
447 | connect(m_ui->m_toDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); | | |||
448 | | ||||
449 | slotDateRangeChanged(MyMoneyTransactionFilter::allDates); | | |||
450 | } | | |||
451 | | ||||
452 | void KFindTransactionDlg::slotDateRangeChanged(int idx) | | |||
453 | { | | |||
454 | switch (idx) { | | |||
455 | case MyMoneyTransactionFilter::allDates: | | |||
456 | case MyMoneyTransactionFilter::userDefined: | | |||
457 | m_ui->m_fromDate->loadDate(QDate()); | | |||
458 | m_ui->m_toDate->loadDate(QDate()); | | |||
459 | break; | | |||
460 | default: | | |||
461 | m_ui->m_fromDate->loadDate(m_startDates[idx]); | | |||
462 | m_ui->m_toDate->loadDate(m_endDates[idx]); | | |||
463 | break; | | |||
464 | } | | |||
465 | slotUpdateSelections(); | | |||
466 | } | | |||
467 | | ||||
468 | void KFindTransactionDlg::slotDateChanged() | | |||
469 | { | | |||
470 | int idx; | | |||
471 | for (idx = MyMoneyTransactionFilter::asOfToday; idx < MyMoneyTransactionFilter::dateOptionCount; ++idx) { | | |||
472 | if (m_ui->m_fromDate->date() == m_startDates[idx] | | |||
473 | && m_ui->m_toDate->date() == m_endDates[idx]) { | | |||
474 | break; | | |||
475 | } | | |||
476 | } | | |||
477 | //if no filter matched, set to user defined | | |||
478 | if (idx == MyMoneyTransactionFilter::dateOptionCount) | | |||
479 | idx = MyMoneyTransactionFilter::userDefined; | | |||
480 | | ||||
481 | m_ui->m_dateRange->blockSignals(true); | | |||
482 | m_ui->m_dateRange->setCurrentItem(static_cast<MyMoneyTransactionFilter::dateOptionE>(idx)); | | |||
483 | m_ui->m_dateRange->blockSignals(false); | | |||
484 | slotUpdateSelections(); | | |||
485 | } | | |||
486 | | ||||
487 | void KFindTransactionDlg::setupAmountPage() | 436 | void KFindTransactionDlg::setupAmountPage() | ||
488 | { | 437 | { | ||
489 | connect(m_ui->m_amountButton, SIGNAL(clicked()), this, SLOT(slotAmountSelected())); | 438 | connect(m_ui->m_amountButton, SIGNAL(clicked()), this, SLOT(slotAmountSelected())); | ||
490 | connect(m_ui->m_amountRangeButton, SIGNAL(clicked()), this, SLOT(slotAmountRangeSelected())); | 439 | connect(m_ui->m_amountRangeButton, SIGNAL(clicked()), this, SLOT(slotAmountRangeSelected())); | ||
491 | 440 | | |||
492 | connect(m_ui->m_amountEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateSelections())); | 441 | connect(m_ui->m_amountEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateSelections())); | ||
493 | connect(m_ui->m_amountFromEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateSelections())); | 442 | connect(m_ui->m_amountFromEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateSelections())); | ||
494 | connect(m_ui->m_amountToEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateSelections())); | 443 | connect(m_ui->m_amountToEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateSelections())); | ||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Line(s) | 649 | if (!KMyMoneyGlobalSettings::expertMode()) { | |||
712 | } | 661 | } | ||
713 | list += missing; | 662 | list += missing; | ||
714 | } | 663 | } | ||
715 | 664 | | |||
716 | m_filter.addAccount(list); | 665 | m_filter.addAccount(list); | ||
717 | } | 666 | } | ||
718 | 667 | | |||
719 | // Date tab | 668 | // Date tab | ||
720 | if (m_ui->m_dateRange->currentItem() != 0) { | 669 | if (m_dateRange->m_ui->m_dateRange->currentItem() != 0) { | ||
721 | m_filter.setDateFilter(m_ui->m_fromDate->date(), m_ui->m_toDate->date()); | 670 | m_filter.setDateFilter(m_dateRange->m_ui->m_fromDate->date(), m_dateRange->m_ui->m_toDate->date()); | ||
722 | } | 671 | } | ||
723 | 672 | | |||
724 | // Amount tab | 673 | // Amount tab | ||
725 | if ((m_ui->m_amountButton->isChecked() && m_ui->m_amountEdit->isValid())) { | 674 | if ((m_ui->m_amountButton->isChecked() && m_ui->m_amountEdit->isValid())) { | ||
726 | m_filter.setAmountFilter(m_ui->m_amountEdit->value(), m_ui->m_amountEdit->value()); | 675 | m_filter.setAmountFilter(m_ui->m_amountEdit->value(), m_ui->m_amountEdit->value()); | ||
727 | 676 | | |||
728 | } else if ((m_ui->m_amountRangeButton->isChecked() | 677 | } else if ((m_ui->m_amountRangeButton->isChecked() | ||
729 | && (m_ui->m_amountFromEdit->isValid() || m_ui->m_amountToEdit->isValid()))) { | 678 | && (m_ui->m_amountFromEdit->isValid() || m_ui->m_amountToEdit->isValid()))) { | ||
▲ Show 20 Lines • Show All 256 Lines • Show Last 20 Lines |