Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/daterangedlg.cpp
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | kfindtransactiondlg.cpp | ||||
3 | ------------------- | ||||
4 | copyright : (C) 2003, 2007 by Thomas Baumgart | ||||
5 | email : ipwizard@users.sourceforge.net | ||||
6 | ***************************************************************************/ | ||||
7 | | ||||
8 | /*************************************************************************** | ||||
9 | * * | ||||
10 | * This program is free software; you can redistribute it and/or modify * | ||||
11 | * it under the terms of the GNU General Public License as published by * | ||||
12 | * the Free Software Foundation; either version 2 of the License, or * | ||||
13 | * (at your option) any later version. * | ||||
14 | * * | ||||
15 | ***************************************************************************/ | ||||
16 | | ||||
17 | #include <config-kmymoney.h> | ||||
18 | | ||||
19 | #include "daterangedlg.h" | ||||
20 | | ||||
21 | // ---------------------------------------------------------------------------- | ||||
22 | // QT Includes | ||||
23 | | ||||
24 | #include <QLabel> | ||||
25 | #include <QButtonGroup> | ||||
26 | #include <QRadioButton> | ||||
27 | #include <QCheckBox> | ||||
28 | #include <QTimer> | ||||
29 | #include <QTabWidget> | ||||
30 | #include <QLayout> | ||||
31 | #include <QKeyEvent> | ||||
32 | #include <QList> | ||||
33 | #include <QResizeEvent> | ||||
34 | #include <QEvent> | ||||
35 | #include <QPushButton> | ||||
36 | #include <QDialogButtonBox> | ||||
37 | #include <QVBoxLayout> | ||||
38 | | ||||
39 | // ---------------------------------------------------------------------------- | ||||
40 | // KDE Includes | ||||
41 | | ||||
42 | #include <klineedit.h> | ||||
43 | #include <kcombobox.h> | ||||
44 | #include <kstandardguiitem.h> | ||||
45 | #include <khelpclient.h> | ||||
46 | #include <KGuiItem> | ||||
47 | #include <KStandardGuiItem> | ||||
48 | #include <KConfigGroup> | ||||
49 | #include <KLocalizedString> | ||||
50 | | ||||
51 | // ---------------------------------------------------------------------------- | ||||
52 | // Project Includes | ||||
53 | | ||||
54 | #include <kmymoneydateinput.h> | ||||
55 | #include <kmymoneyedit.h> | ||||
56 | #include <kmymoneylineedit.h> | ||||
57 | #include <kmymoneyaccountselector.h> | ||||
58 | #include <mymoneyfile.h> | ||||
59 | #include <kmymoneyglobalsettings.h> | ||||
60 | #include <transaction.h> | ||||
61 | | ||||
62 | #include "ui_daterangedlgdecl.h" | ||||
63 | | ||||
64 | DateRangeDlg::DateRangeDlg(QWidget *parent) : | ||||
65 | QWidget(parent), | ||||
66 | m_ui(new Ui::DateRangeDlgDecl) | ||||
67 | { | ||||
68 | m_ui->setupUi(this); | ||||
69 | setupDatePage(); | ||||
70 | } | ||||
71 | | ||||
72 | DateRangeDlg::~DateRangeDlg() | ||||
73 | { | ||||
74 | delete m_ui; | ||||
75 | } | ||||
76 | | ||||
77 | void DateRangeDlg::slotReset() | ||||
78 | { | ||||
79 | m_ui->m_dateRange->setCurrentItem(MyMoneyTransactionFilter::allDates); | ||||
80 | slotDateRangeChanged(MyMoneyTransactionFilter::allDates); | ||||
81 | } | ||||
82 | | ||||
83 | void DateRangeDlg::slotUpdateSelections(QString &txt) | ||||
84 | { | ||||
85 | if (m_ui->m_dateRange->currentItem() != 0) { | ||||
86 | if (!txt.isEmpty()) | ||||
87 | txt += ", "; | ||||
88 | txt += i18n("Date"); | ||||
89 | } | ||||
90 | } | ||||
91 | | ||||
92 | void DateRangeDlg::setupDatePage() | ||||
93 | { | ||||
94 | int i; | ||||
95 | for (i = MyMoneyTransactionFilter::allDates; i < MyMoneyTransactionFilter::dateOptionCount; ++i) { | ||||
96 | MyMoneyTransactionFilter::translateDateRange(static_cast<MyMoneyTransactionFilter::dateOptionE>(i), m_startDates[i], m_endDates[i]); | ||||
97 | } | ||||
98 | | ||||
99 | connect(m_ui->m_dateRange, SIGNAL(itemSelected(int)), this, SLOT(slotDateRangeChanged(int))); | ||||
100 | connect(m_ui->m_fromDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); | ||||
101 | connect(m_ui->m_toDate, SIGNAL(dateChanged(QDate)), this, SLOT(slotDateChanged())); | ||||
102 | | ||||
103 | slotDateRangeChanged(MyMoneyTransactionFilter::allDates); | ||||
104 | } | ||||
105 | | ||||
106 | void DateRangeDlg::slotDateRangeChanged(int idx) | ||||
107 | { | ||||
108 | switch (idx) { | ||||
109 | case MyMoneyTransactionFilter::allDates: | ||||
110 | case MyMoneyTransactionFilter::userDefined: | ||||
111 | m_ui->m_fromDate->loadDate(QDate()); | ||||
112 | m_ui->m_toDate->loadDate(QDate()); | ||||
113 | break; | ||||
114 | default: | ||||
115 | m_ui->m_fromDate->loadDate(m_startDates[idx]); | ||||
116 | m_ui->m_toDate->loadDate(m_endDates[idx]); | ||||
117 | break; | ||||
118 | } | ||||
119 | // slotUpdateSelections(); | ||||
120 | } | ||||
121 | | ||||
122 | void DateRangeDlg::slotDateChanged() | ||||
123 | { | ||||
124 | int idx; | ||||
125 | for (idx = MyMoneyTransactionFilter::asOfToday; idx < MyMoneyTransactionFilter::dateOptionCount; ++idx) { | ||||
126 | if (m_ui->m_fromDate->date() == m_startDates[idx] | ||||
127 | && m_ui->m_toDate->date() == m_endDates[idx]) { | ||||
128 | break; | ||||
129 | } | ||||
130 | } | ||||
131 | //if no filter matched, set to user defined | ||||
132 | if (idx == MyMoneyTransactionFilter::dateOptionCount) | ||||
133 | idx = MyMoneyTransactionFilter::userDefined; | ||||
134 | | ||||
135 | m_ui->m_dateRange->blockSignals(true); | ||||
136 | m_ui->m_dateRange->setCurrentItem(static_cast<MyMoneyTransactionFilter::dateOptionE>(idx)); | ||||
137 | m_ui->m_dateRange->blockSignals(false); | ||||
138 | // slotUpdateSelections(); | ||||
139 | } |