Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/keditscheduledlg.cpp
Context not available. | |||||
4 | begin : Mon Sep 3 2007 | 4 | begin : Mon Sep 3 2007 | ||
---|---|---|---|---|---|
5 | copyright : (C) 2007 by Thomas Baumgart | 5 | copyright : (C) 2007 by Thomas Baumgart | ||
6 | email : Thomas Baumgart <ipwizard@users.sourceforge.net> | 6 | email : Thomas Baumgart <ipwizard@users.sourceforge.net> | ||
7 | (C) 2017 by Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> | ||||
7 | ***************************************************************************/ | 8 | ***************************************************************************/ | ||
8 | 9 | | |||
9 | /*************************************************************************** | 10 | /*************************************************************************** | ||
Context not available. | |||||
32 | #include <KStandardGuiItem> | 33 | #include <KStandardGuiItem> | ||
33 | #include <KLineEdit> | 34 | #include <KLineEdit> | ||
34 | #include <KHelpClient> | 35 | #include <KHelpClient> | ||
35 | #include <KGuiItem> | | |||
36 | #include <KLocalizedString> | 36 | #include <KLocalizedString> | ||
37 | 37 | | |||
38 | // ---------------------------------------------------------------------------- | 38 | // ---------------------------------------------------------------------------- | ||
39 | // Project Includes | 39 | // Project Includes | ||
40 | 40 | | |||
41 | #include "ui_keditscheduledlg.h" | ||||
42 | | ||||
41 | #include "mymoneyfile.h" | 43 | #include "mymoneyfile.h" | ||
42 | #include "mymoneyschedule.h" | 44 | #include "mymoneyschedule.h" | ||
43 | #include "mymoneytransaction.h" | 45 | #include "mymoneytransaction.h" | ||
Context not available. | |||||
54 | 56 | | |||
55 | using namespace eMyMoney; | 57 | using namespace eMyMoney; | ||
56 | 58 | | |||
57 | class KEditScheduleDlg::Private | 59 | class KEditScheduleDlgPrivate | ||
58 | { | 60 | { | ||
61 | Q_DISABLE_COPY(KEditScheduleDlgPrivate) | ||||
62 | Q_DECLARE_PUBLIC(KEditScheduleDlg) | ||||
63 | | ||||
59 | public: | 64 | public: | ||
60 | MyMoneySchedule m_schedule; | 65 | KEditScheduleDlgPrivate(KEditScheduleDlg *qq) : | ||
61 | KMyMoneyRegister::Transaction* m_item; | 66 | q_ptr(qq), | ||
62 | QWidgetList m_tabOrderWidgets; | 67 | ui(new Ui::KEditScheduleDlg) | ||
63 | TransactionEditor* m_editor; | 68 | { | ||
64 | kMandatoryFieldGroup* m_requiredFields; | 69 | } | ||
65 | }; | | |||
66 | 70 | | |||
67 | KEditScheduleDlg::KEditScheduleDlg(const MyMoneySchedule& schedule, QWidget *parent) : | 71 | ~KEditScheduleDlgPrivate() | ||
68 | KEditScheduleDlgDecl(parent), | 72 | { | ||
69 | d(new Private) | 73 | delete ui; | ||
70 | { | 74 | } | ||
71 | setModal(true); | 75 | | ||
72 | d->m_schedule = schedule; | 76 | void init() | ||
73 | d->m_editor = 0; | 77 | { | ||
78 | Q_Q(KEditScheduleDlg); | ||||
79 | ui->setupUi(q); | ||||
74 | 80 | | |||
75 | KGuiItem::assign(buttonOk, KStandardGuiItem::ok()); | 81 | m_requiredFields = new kMandatoryFieldGroup(q); | ||
76 | KGuiItem::assign(buttonCancel, KStandardGuiItem::cancel()); | 82 | m_requiredFields->setOkButton(ui->buttonBox->button(QDialogButtonBox::Ok)); // button to be enabled when all fields present | ||
77 | KGuiItem::assign(buttonHelp, KStandardGuiItem::help()); | | |||
78 | 83 | | |||
79 | d->m_requiredFields = new kMandatoryFieldGroup(this); | 84 | // make sure, we have a tabbar with the form | ||
80 | d->m_requiredFields->setOkButton(buttonOk); // button to be enabled when all fields present | 85 | // insert it after the horizontal line | ||
86 | ui->m_paymentInformationLayout->insertWidget(2, ui->m_form->tabBar(ui->m_form->parentWidget())); | ||||
81 | 87 | | |||
82 | // make sure, we have a tabbar with the form | 88 | // we never need to see the register | ||
83 | // insert it after the horizontal line | 89 | ui->m_register->hide(); | ||
84 | m_paymentInformationLayout->insertWidget(2, m_form->tabBar(m_form->parentWidget())); | | |||
85 | 90 | | |||
86 | // we never need to see the register | 91 | // ... setup the form ... | ||
87 | m_register->hide(); | 92 | ui->m_form->setupForm(m_schedule.account()); | ||
88 | 93 | | |||
89 | // ... setup the form ... | 94 | // ... and the register ... | ||
90 | m_form->setupForm(d->m_schedule.account()); | 95 | ui->m_register->clear(); | ||
91 | 96 | | |||
92 | // ... and the register ... | 97 | // ... now add the transaction to register and form ... | ||
93 | m_register->clear(); | 98 | auto t = transaction(); | ||
99 | if (m_schedule.transaction().splits().isEmpty()) | ||||
100 | m_item = KMyMoneyRegister::Register::transactionFactory(ui->m_register, t, MyMoneySplit(), 0); | ||||
101 | else | ||||
102 | m_item = KMyMoneyRegister::Register::transactionFactory(ui->m_register, t, | ||||
103 | m_schedule.transaction().splits().isEmpty() ? MyMoneySplit() : m_schedule.transaction().splits().front(), 0); | ||||
104 | ui->m_register->selectItem(m_item); | ||||
105 | // show the account row | ||||
106 | m_item->setShowRowInForm(0, true); | ||||
107 | | ||||
108 | ui->m_form->slotSetTransaction(m_item); | ||||
109 | | ||||
110 | // setup widget contents | ||||
111 | ui->m_nameEdit->setText(m_schedule.name()); | ||||
112 | | ||||
113 | ui->m_frequencyEdit->setCurrentItem((int)m_schedule.occurrencePeriod()); | ||||
114 | if (ui->m_frequencyEdit->currentItem() == Schedule::Occurrence::Any) | ||||
115 | ui->m_frequencyEdit->setCurrentItem((int)Schedule::Occurrence::Monthly); | ||||
116 | q->slotFrequencyChanged((int)ui->m_frequencyEdit->currentItem()); | ||||
117 | ui->m_frequencyNoEdit->setValue(m_schedule.occurrenceMultiplier()); | ||||
118 | | ||||
119 | // load option widgets | ||||
120 | ui->m_paymentMethodEdit->insertItem(i18n("Direct deposit"), (int)Schedule::PaymentType::DirectDeposit); | ||||
121 | ui->m_paymentMethodEdit->insertItem(i18n("Manual deposit"), (int)Schedule::PaymentType::ManualDeposit); | ||||
122 | ui->m_paymentMethodEdit->insertItem(i18n("Direct debit"), (int)Schedule::PaymentType::DirectDebit); | ||||
123 | ui->m_paymentMethodEdit->insertItem(i18n("Standing order"), (int)Schedule::PaymentType::StandingOrder); | ||||
124 | ui->m_paymentMethodEdit->insertItem(i18n("Bank transfer"), (int)Schedule::PaymentType::BankTransfer); | ||||
125 | ui->m_paymentMethodEdit->insertItem(i18n("Write check"), (int)Schedule::PaymentType::WriteChecque); | ||||
126 | ui->m_paymentMethodEdit->insertItem(i18nc("Other payment method", "Other"), (int)Schedule::PaymentType::Other); | ||||
127 | | ||||
128 | auto method = m_schedule.paymentType(); | ||||
129 | if (method == Schedule::PaymentType::Any) | ||||
130 | method = Schedule::PaymentType::Other; | ||||
131 | ui->m_paymentMethodEdit->setCurrentItem((int)method); | ||||
132 | | ||||
133 | switch (m_schedule.weekendOption()) { | ||||
134 | case Schedule::WeekendOption::MoveNothing: | ||||
135 | ui->m_weekendOptionEdit->setCurrentIndex(0); | ||||
136 | break; | ||||
137 | case Schedule::WeekendOption::MoveBefore: | ||||
138 | ui->m_weekendOptionEdit->setCurrentIndex(1); | ||||
139 | break; | ||||
140 | case Schedule::WeekendOption::MoveAfter: | ||||
141 | ui->m_weekendOptionEdit->setCurrentIndex(2); | ||||
142 | break; | ||||
143 | } | ||||
144 | ui->m_estimateEdit->setChecked(!m_schedule.isFixed()); | ||||
145 | ui->m_lastDayInMonthEdit->setChecked(m_schedule.lastDayInMonth()); | ||||
146 | ui->m_autoEnterEdit->setChecked(m_schedule.autoEnter()); | ||||
147 | ui->m_endSeriesEdit->setChecked(m_schedule.willEnd()); | ||||
148 | | ||||
149 | ui->m_endOptionsFrame->setEnabled(m_schedule.willEnd()); | ||||
150 | if (m_schedule.willEnd()) { | ||||
151 | ui->m_RemainingEdit->setValue(m_schedule.transactionsRemaining()); | ||||
152 | ui->m_FinalPaymentEdit->setDate(m_schedule.endDate()); | ||||
153 | } | ||||
94 | 154 | | |||
95 | // ... now add the transaction to register and form ... | 155 | q->connect(ui->m_RemainingEdit, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), | ||
96 | MyMoneyTransaction t = transaction(); | 156 | q, &KEditScheduleDlg::slotRemainingChanged); | ||
97 | if (d->m_schedule.transaction().splits().isEmpty()) | 157 | q->connect(ui->m_FinalPaymentEdit, &kMyMoneyDateInput::dateChanged, | ||
98 | d->m_item = KMyMoneyRegister::Register::transactionFactory(m_register, t, MyMoneySplit(), 0); | 158 | q, &KEditScheduleDlg::slotEndDateChanged); | ||
99 | else | 159 | q->connect(ui->m_frequencyEdit, &KMyMoneyGeneralCombo::itemSelected, | ||
100 | d->m_item = KMyMoneyRegister::Register::transactionFactory(m_register, t, | 160 | q, &KEditScheduleDlg::slotFrequencyChanged); | ||
101 | d->m_schedule.transaction().splits().isEmpty() ? MyMoneySplit() : d->m_schedule.transaction().splits().front(), 0); | 161 | q->connect(ui->m_frequencyNoEdit, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), | ||
102 | m_register->selectItem(d->m_item); | 162 | q, &KEditScheduleDlg::slotOccurrenceMultiplierChanged); | ||
103 | // show the account row | 163 | q->connect(ui->buttonBox, &QDialogButtonBox::helpRequested, q, &KEditScheduleDlg::slotShowHelp); | ||
104 | d->m_item->setShowRowInForm(0, true); | 164 | | ||
165 | q->setModal(true); | ||||
166 | // force the initial height to be as small as possible | ||||
167 | QTimer::singleShot(0, q, SLOT(slotSetupSize())); | ||||
168 | | ||||
169 | // we just hide the variation field for now and enable the logic | ||||
170 | // once we have a respective member in the MyMoneySchedule object | ||||
171 | ui->m_variation->hide(); | ||||
172 | } | ||||
105 | 173 | | |||
106 | m_form->slotSetTransaction(d->m_item); | 174 | /** | ||
175 | * Helper method to recalculate and update Transactions Remaining | ||||
176 | * when other values are changed | ||||
177 | */ | ||||
178 | void updateTransactionsRemaining() | ||||
179 | { | ||||
180 | auto remain = m_schedule.transactionsRemaining(); | ||||
181 | if (remain != ui->m_RemainingEdit->value()) { | ||||
182 | ui->m_RemainingEdit->blockSignals(true); | ||||
183 | ui->m_RemainingEdit->setValue(remain); | ||||
184 | ui->m_RemainingEdit->blockSignals(false); | ||||
185 | } | ||||
186 | } | ||||
107 | 187 | | |||
108 | // setup widget contents | 188 | MyMoneyTransaction transaction() const | ||
109 | m_nameEdit->setText(d->m_schedule.name()); | 189 | { | ||
190 | auto t = m_schedule.transaction(); | ||||
110 | 191 | | |||
111 | m_frequencyEdit->setCurrentItem((int)d->m_schedule.occurrencePeriod()); | 192 | if (m_editor) { | ||
112 | if (m_frequencyEdit->currentItem() == Schedule::Occurrence::Any) | 193 | m_editor->createTransaction(t, m_schedule.transaction(), m_schedule.transaction().splits().isEmpty() ? MyMoneySplit() : m_schedule.transaction().splits().front(), false); | ||
113 | m_frequencyEdit->setCurrentItem((int)Schedule::Occurrence::Monthly); | 194 | } | ||
114 | slotFrequencyChanged((int)m_frequencyEdit->currentItem()); | | |||
115 | m_frequencyNoEdit->setValue(d->m_schedule.occurrenceMultiplier()); | | |||
116 | 195 | | |||
117 | // load option widgets | 196 | t.clearId(); | ||
118 | m_paymentMethodEdit->insertItem(i18n("Direct deposit"), (int)Schedule::PaymentType::DirectDeposit); | 197 | t.setEntryDate(QDate()); | ||
119 | m_paymentMethodEdit->insertItem(i18n("Manual deposit"), (int)Schedule::PaymentType::ManualDeposit); | 198 | return t; | ||
120 | m_paymentMethodEdit->insertItem(i18n("Direct debit"), (int)Schedule::PaymentType::DirectDebit); | | |||
121 | m_paymentMethodEdit->insertItem(i18n("Standing order"), (int)Schedule::PaymentType::StandingOrder); | | |||
122 | m_paymentMethodEdit->insertItem(i18n("Bank transfer"), (int)Schedule::PaymentType::BankTransfer); | | |||
123 | m_paymentMethodEdit->insertItem(i18n("Write check"), (int)Schedule::PaymentType::WriteChecque); | | |||
124 | m_paymentMethodEdit->insertItem(i18nc("Other payment method", "Other"), (int)Schedule::PaymentType::Other); | | |||
125 | | ||||
126 | auto method = d->m_schedule.paymentType(); | | |||
127 | if (method == Schedule::PaymentType::Any) | | |||
128 | method = Schedule::PaymentType::Other; | | |||
129 | m_paymentMethodEdit->setCurrentItem((int)method); | | |||
130 | | ||||
131 | switch (d->m_schedule.weekendOption()) { | | |||
132 | case Schedule::WeekendOption::MoveNothing: | | |||
133 | m_weekendOptionEdit->setCurrentIndex(0); | | |||
134 | break; | | |||
135 | case Schedule::WeekendOption::MoveBefore: | | |||
136 | m_weekendOptionEdit->setCurrentIndex(1); | | |||
137 | break; | | |||
138 | case Schedule::WeekendOption::MoveAfter: | | |||
139 | m_weekendOptionEdit->setCurrentIndex(2); | | |||
140 | break; | | |||
141 | } | | |||
142 | m_estimateEdit->setChecked(!d->m_schedule.isFixed()); | | |||
143 | m_lastDayInMonthEdit->setChecked(d->m_schedule.lastDayInMonth()); | | |||
144 | m_autoEnterEdit->setChecked(d->m_schedule.autoEnter()); | | |||
145 | m_endSeriesEdit->setChecked(d->m_schedule.willEnd()); | | |||
146 | | ||||
147 | m_endOptionsFrame->setEnabled(d->m_schedule.willEnd()); | | |||
148 | if (d->m_schedule.willEnd()) { | | |||
149 | m_RemainingEdit->setValue(d->m_schedule.transactionsRemaining()); | | |||
150 | m_FinalPaymentEdit->setDate(d->m_schedule.endDate()); | | |||
151 | } | 199 | } | ||
200 | | ||||
201 | KEditScheduleDlg *q_ptr; | ||||
202 | Ui::KEditScheduleDlg *ui; | ||||
203 | MyMoneySchedule m_schedule; | ||||
204 | KMyMoneyRegister::Transaction* m_item; | ||||
205 | QWidgetList m_tabOrderWidgets; | ||||
206 | TransactionEditor* m_editor; | ||||
207 | kMandatoryFieldGroup* m_requiredFields; | ||||
208 | }; | ||||
152 | 209 | | |||
153 | connect(m_RemainingEdit, SIGNAL(valueChanged(int)), | 210 | KEditScheduleDlg::KEditScheduleDlg(const MyMoneySchedule& schedule, QWidget *parent) : | ||
154 | this, SLOT(slotRemainingChanged(int))); | 211 | QDialog(parent), | ||
155 | connect(m_FinalPaymentEdit, SIGNAL(dateChanged(QDate)), | 212 | d_ptr(new KEditScheduleDlgPrivate(this)) | ||
156 | this, SLOT(slotEndDateChanged(QDate))); | 213 | { | ||
157 | connect(m_frequencyEdit, SIGNAL(itemSelected(int)), | 214 | Q_D(KEditScheduleDlg); | ||
158 | this, SLOT(slotFrequencyChanged(int))); | 215 | d->m_schedule = schedule; | ||
159 | connect(m_frequencyNoEdit, SIGNAL(valueChanged(int)), | 216 | d->m_editor = 0; | ||
160 | this, SLOT(slotOccurrenceMultiplierChanged(int))); | 217 | d->init(); | ||
161 | connect(buttonHelp, SIGNAL(clicked()), this, SLOT(slotShowHelp())); | | |||
162 | | ||||
163 | // force the initial height to be as small as possible | | |||
164 | QTimer::singleShot(0, this, SLOT(slotSetupSize())); | | |||
165 | | ||||
166 | // we just hide the variation field for now and enable the logic | | |||
167 | // once we have a respective member in the MyMoneySchedule object | | |||
168 | m_variation->hide(); | | |||
169 | } | 218 | } | ||
170 | 219 | | |||
171 | KEditScheduleDlg::~KEditScheduleDlg() | 220 | KEditScheduleDlg::~KEditScheduleDlg() | ||
172 | { | 221 | { | ||
222 | Q_D(KEditScheduleDlg); | ||||
173 | delete d; | 223 | delete d; | ||
174 | } | 224 | } | ||
175 | 225 | | |||
Context not available. | |||||
180 | 230 | | |||
181 | TransactionEditor* KEditScheduleDlg::startEdit() | 231 | TransactionEditor* KEditScheduleDlg::startEdit() | ||
182 | { | 232 | { | ||
183 | KMyMoneyRegister::SelectedTransactions list(m_register); | 233 | Q_D(KEditScheduleDlg); | ||
184 | TransactionEditor* editor = d->m_item->createEditor(m_form, list, QDate()); | 234 | KMyMoneyRegister::SelectedTransactions list(d->ui->m_register); | ||
235 | TransactionEditor* editor = d->m_item->createEditor(d->ui->m_form, list, QDate()); | ||||
185 | 236 | | |||
186 | // check that we use the same transaction commodity in all selected transactions | 237 | // check that we use the same transaction commodity in all selected transactions | ||
187 | // if not, we need to update this in the editor's list. The user can also bail out | 238 | // if not, we need to update this in the editor's list. The user can also bail out | ||
Context not available. | |||||
196 | } | 247 | } | ||
197 | 248 | | |||
198 | if (editor) { | 249 | if (editor) { | ||
199 | editor->m_scheduleInfo = m_nameEdit->text(); | 250 | editor->setScheduleInfo(d->ui->m_nameEdit->text()); | ||
200 | connect(editor, SIGNAL(transactionDataSufficient(bool)), buttonOk, SLOT(setEnabled(bool))); | 251 | connect(editor, &TransactionEditor::transactionDataSufficient, d->ui->buttonBox->button(QDialogButtonBox::Ok), &QWidget::setEnabled); | ||
201 | connect(editor, SIGNAL(escapePressed()), buttonCancel, SLOT(animateClick())); | 252 | connect(editor, &TransactionEditor::escapePressed, d->ui->buttonBox->button(QDialogButtonBox::Cancel), &QAbstractButton::animateClick); | ||
202 | connect(editor, SIGNAL(returnPressed()), buttonOk, SLOT(animateClick())); | 253 | connect(editor, &TransactionEditor::returnPressed, d->ui->buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::animateClick); | ||
203 | 254 | | |||
204 | connect(MyMoneyFile::instance(), SIGNAL(dataChanged()), editor, SLOT(slotReloadEditWidgets())); | 255 | connect(MyMoneyFile::instance(), &MyMoneyFile::dataChanged, editor, &TransactionEditor::slotReloadEditWidgets); | ||
205 | // connect(editor, SIGNAL(finishEdit(KMyMoneyRegister::SelectedTransactions)), this, SLOT(slotLeaveEditMode(KMyMoneyRegister::SelectedTransactions))); | 256 | // connect(editor, SIGNAL(finishEdit(KMyMoneyRegister::SelectedTransactions)), this, SLOT(slotLeaveEditMode(KMyMoneyRegister::SelectedTransactions))); | ||
206 | connect(editor, SIGNAL(createPayee(QString,QString&)), kmymoney, SLOT(slotPayeeNew(QString,QString&))); | 257 | connect(editor, &TransactionEditor::createPayee, kmymoney, static_cast<void (KMyMoneyApp::*)(const QString&, QString&)>(&KMyMoneyApp::slotPayeeNew)); | ||
207 | connect(editor, SIGNAL(createTag(QString,QString&)), kmymoney, SLOT(slotTagNew(QString,QString&))); | 258 | connect(editor, &TransactionEditor::createTag, kmymoney, static_cast<void (KMyMoneyApp::*)(const QString&, QString&)>(&KMyMoneyApp::slotTagNew)); | ||
208 | connect(editor, SIGNAL(createCategory(MyMoneyAccount&,MyMoneyAccount)), kmymoney, SLOT(slotCategoryNew(MyMoneyAccount&,MyMoneyAccount))); | 259 | connect(editor, &TransactionEditor::createCategory, kmymoney, static_cast<void (KMyMoneyApp::*)(MyMoneyAccount&, const MyMoneyAccount&)>(&KMyMoneyApp::slotCategoryNew)); | ||
209 | connect(editor, SIGNAL(createSecurity(MyMoneyAccount&,MyMoneyAccount)), kmymoney, SLOT(slotInvestmentNew(MyMoneyAccount&,MyMoneyAccount))); | 260 | connect(editor, &TransactionEditor::createSecurity, kmymoney, static_cast<void (KMyMoneyApp::*)(MyMoneyAccount&, const MyMoneyAccount&)>(&KMyMoneyApp::slotInvestmentNew)); | ||
210 | connect(MyMoneyFile::instance(), SIGNAL(dataChanged()), editor, SLOT(slotReloadEditWidgets())); | 261 | connect(MyMoneyFile::instance(), &MyMoneyFile::dataChanged, editor, &TransactionEditor::slotReloadEditWidgets); | ||
211 | 262 | | |||
212 | // create the widgets, place them in the parent and load them with data | 263 | // create the widgets, place them in the parent and load them with data | ||
213 | // setup tab order | 264 | // setup tab order | ||
Context not available. | |||||
219 | break; | 270 | break; | ||
220 | case Schedule::Type::Bill: | 271 | case Schedule::Type::Bill: | ||
221 | action = KMyMoneyRegister::ActionWithdrawal; | 272 | action = KMyMoneyRegister::ActionWithdrawal; | ||
222 | editor->m_paymentMethod = d->m_schedule.paymentType(); | 273 | editor->setPaymentMethod(d->m_schedule.paymentType()); | ||
223 | break; | 274 | break; | ||
224 | case Schedule::Type::Transfer: | 275 | case Schedule::Type::Transfer: | ||
225 | action = KMyMoneyRegister::ActionTransfer; | 276 | action = KMyMoneyRegister::ActionTransfer; | ||
Context not available. | |||||
231 | if (d->m_schedule.transaction().splits().count() > 0) { | 282 | if (d->m_schedule.transaction().splits().count() > 0) { | ||
232 | auto isDeposit = false; | 283 | auto isDeposit = false; | ||
233 | auto isTransfer = false; | 284 | auto isTransfer = false; | ||
234 | foreach (const auto split, d->m_schedule.transaction().splits()) { | 285 | auto splits = d->m_schedule.transaction().splits(); | ||
286 | foreach (const auto split, splits) { | ||||
235 | if (split.accountId() == d->m_schedule.account().id()) { | 287 | if (split.accountId() == d->m_schedule.account().id()) { | ||
236 | isDeposit = !(split.shares().isNegative()); | 288 | isDeposit = !(split.shares().isNegative()); | ||
237 | } else { | 289 | } else { | ||
Context not available. | |||||
261 | 313 | | |||
262 | Q_ASSERT(!d->m_tabOrderWidgets.isEmpty()); | 314 | Q_ASSERT(!d->m_tabOrderWidgets.isEmpty()); | ||
263 | 315 | | |||
264 | d->m_tabOrderWidgets.push_front(m_paymentMethodEdit); | 316 | d->m_tabOrderWidgets.push_front(d->ui->m_paymentMethodEdit); | ||
265 | 317 | | |||
266 | // editor->setup() leaves the tabbar as the last widget in the stack, but we | 318 | // editor->setup() leaves the tabbar as the last widget in the stack, but we | ||
267 | // need it as first here. So we move it around. | 319 | // need it as first here. So we move it around. | ||
Context not available. | |||||
276 | 328 | | |||
277 | // don't forget our three buttons and additional widgets | 329 | // don't forget our three buttons and additional widgets | ||
278 | // make sure to use the correct order | 330 | // make sure to use the correct order | ||
279 | d->m_tabOrderWidgets.push_front(m_frequencyEdit); | 331 | d->m_tabOrderWidgets.push_front(d->ui->m_frequencyEdit); | ||
280 | d->m_tabOrderWidgets.push_front(m_frequencyNoEdit); | 332 | d->m_tabOrderWidgets.push_front(d->ui->m_frequencyNoEdit); | ||
281 | d->m_tabOrderWidgets.push_front(m_nameEdit); | 333 | d->m_tabOrderWidgets.push_front(d->ui->m_nameEdit); | ||
282 | 334 | | |||
283 | d->m_tabOrderWidgets.append(m_weekendOptionEdit); | 335 | d->m_tabOrderWidgets.append(d->ui->m_weekendOptionEdit); | ||
284 | d->m_tabOrderWidgets.append(m_estimateEdit); | 336 | d->m_tabOrderWidgets.append(d->ui->m_estimateEdit); | ||
285 | d->m_tabOrderWidgets.append(m_variation); | 337 | d->m_tabOrderWidgets.append(d->ui->m_variation); | ||
286 | d->m_tabOrderWidgets.append(m_lastDayInMonthEdit); | 338 | d->m_tabOrderWidgets.append(d->ui->m_lastDayInMonthEdit); | ||
287 | d->m_tabOrderWidgets.append(m_autoEnterEdit); | 339 | d->m_tabOrderWidgets.append(d->ui->m_autoEnterEdit); | ||
288 | d->m_tabOrderWidgets.append(m_endSeriesEdit); | 340 | d->m_tabOrderWidgets.append(d->ui->m_endSeriesEdit); | ||
289 | d->m_tabOrderWidgets.append(m_RemainingEdit); | 341 | d->m_tabOrderWidgets.append(d->ui->m_RemainingEdit); | ||
290 | d->m_tabOrderWidgets.append(m_FinalPaymentEdit); | 342 | d->m_tabOrderWidgets.append(d->ui->m_FinalPaymentEdit); | ||
291 | 343 | | |||
292 | d->m_tabOrderWidgets.append(buttonOk); | 344 | d->m_tabOrderWidgets.append(d->ui->buttonBox->button(QDialogButtonBox::Ok)); | ||
293 | d->m_tabOrderWidgets.append(buttonCancel); | 345 | d->m_tabOrderWidgets.append(d->ui->buttonBox->button(QDialogButtonBox::Cancel)); | ||
294 | d->m_tabOrderWidgets.append(buttonHelp); | 346 | d->m_tabOrderWidgets.append(d->ui->buttonBox->button(QDialogButtonBox::Help)); | ||
295 | for (int i = 0; i < d->m_tabOrderWidgets.size(); ++i) { | 347 | for (auto i = 0; i < d->m_tabOrderWidgets.size(); ++i) { | ||
296 | QWidget* w = d->m_tabOrderWidgets.at(i); | 348 | QWidget* w = d->m_tabOrderWidgets.at(i); | ||
297 | if (w) { | 349 | if (w) { | ||
298 | w->installEventFilter(this); | 350 | w->installEventFilter(this); | ||
Context not available. | |||||
303 | // connect the postdate modification signal to our update routine | 355 | // connect the postdate modification signal to our update routine | ||
304 | kMyMoneyDateInput* dateEdit = dynamic_cast<kMyMoneyDateInput*>(editor->haveWidget("postdate")); | 356 | kMyMoneyDateInput* dateEdit = dynamic_cast<kMyMoneyDateInput*>(editor->haveWidget("postdate")); | ||
305 | if (dateEdit) | 357 | if (dateEdit) | ||
306 | connect(dateEdit, SIGNAL(dateChanged(QDate)), this, SLOT(slotPostDateChanged(QDate))); | 358 | connect(dateEdit, &kMyMoneyDateInput::dateChanged, this, &KEditScheduleDlg::slotPostDateChanged); | ||
307 | 359 | | |||
308 | m_nameEdit->setFocus(); | 360 | d->ui->m_nameEdit->setFocus(); | ||
309 | 361 | | |||
310 | // add the required fields to the mandatory group | 362 | // add the required fields to the mandatory group | ||
311 | d->m_requiredFields->add(m_nameEdit); | 363 | d->m_requiredFields->add(d->ui->m_nameEdit); | ||
312 | d->m_requiredFields->add(editor->haveWidget("account")); | 364 | d->m_requiredFields->add(editor->haveWidget("account")); | ||
313 | d->m_requiredFields->add(editor->haveWidget("category")); | 365 | d->m_requiredFields->add(editor->haveWidget("category")); | ||
314 | d->m_requiredFields->add(editor->haveWidget("amount")); | 366 | d->m_requiredFields->add(editor->haveWidget("amount")); | ||
Context not available. | |||||
322 | d->m_editor = editor; | 374 | d->m_editor = editor; | ||
323 | slotSetPaymentMethod((int)d->m_schedule.paymentType()); | 375 | slotSetPaymentMethod((int)d->m_schedule.paymentType()); | ||
324 | 376 | | |||
325 | connect(m_paymentMethodEdit, SIGNAL(itemSelected(int)), this, SLOT(slotSetPaymentMethod(int))); | 377 | connect(d->ui->m_paymentMethodEdit, &KMyMoneyGeneralCombo::itemSelected, this, &KEditScheduleDlg::slotSetPaymentMethod); | ||
326 | connect(editor, SIGNAL(operationTypeChanged(int)), this, SLOT(slotFilterPaymentType(int))); | 378 | connect(editor, &TransactionEditor::operationTypeChanged, this, &KEditScheduleDlg::slotFilterPaymentType); | ||
327 | } | 379 | } | ||
328 | 380 | | |||
329 | return editor; | 381 | return editor; | ||
Context not available. | |||||
331 | 383 | | |||
332 | void KEditScheduleDlg::accept() | 384 | void KEditScheduleDlg::accept() | ||
333 | { | 385 | { | ||
386 | Q_D(KEditScheduleDlg); | ||||
334 | // Force the focus to be on the OK button. This will trigger creation | 387 | // Force the focus to be on the OK button. This will trigger creation | ||
335 | // of any unknown objects (payees, categories etc.) | 388 | // of any unknown objects (payees, categories etc.) | ||
336 | buttonOk->setFocus(); | 389 | d->ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus(); | ||
337 | 390 | | |||
338 | // only accept if the button is really still enabled. We could end | 391 | // only accept if the button is really still enabled. We could end | ||
339 | // up here, if the user filled all fields, the focus is on the category | 392 | // up here, if the user filled all fields, the focus is on the category | ||
Context not available. | |||||
341 | // OK button in this context, he will be asked if he wants to create | 394 | // OK button in this context, he will be asked if he wants to create | ||
342 | // the category or not. In case he decides no, we end up here with no | 395 | // the category or not. In case he decides no, we end up here with no | ||
343 | // category filled in, so we don't run through the final acceptance. | 396 | // category filled in, so we don't run through the final acceptance. | ||
344 | if (buttonOk->isEnabled()) | 397 | if (d->ui->buttonBox->button(QDialogButtonBox::Ok)->isEnabled()) | ||
345 | KEditScheduleDlgDecl::accept(); | 398 | QDialog::accept(); | ||
346 | } | 399 | } | ||
347 | 400 | | |||
348 | const MyMoneySchedule& KEditScheduleDlg::schedule() const | 401 | const MyMoneySchedule& KEditScheduleDlg::schedule() | ||
349 | { | 402 | { | ||
403 | Q_D(KEditScheduleDlg); | ||||
350 | if (d->m_editor) { | 404 | if (d->m_editor) { | ||
351 | MyMoneyTransaction t = transaction(); | 405 | auto t = d->transaction(); | ||
352 | if (d->m_schedule.nextDueDate() != t.postDate()) { | 406 | if (d->m_schedule.nextDueDate() != t.postDate()) { | ||
353 | d->m_schedule.setNextDueDate(t.postDate()); | 407 | d->m_schedule.setNextDueDate(t.postDate()); | ||
354 | d->m_schedule.setStartDate(t.postDate()); | 408 | d->m_schedule.setStartDate(t.postDate()); | ||
355 | } | 409 | } | ||
356 | d->m_schedule.setTransaction(t); | 410 | d->m_schedule.setTransaction(t); | ||
357 | d->m_schedule.setName(m_nameEdit->text()); | 411 | d->m_schedule.setName(d->ui->m_nameEdit->text()); | ||
358 | d->m_schedule.setFixed(!m_estimateEdit->isChecked()); | 412 | d->m_schedule.setFixed(!d->ui->m_estimateEdit->isChecked()); | ||
359 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(m_frequencyEdit->currentItem())); | 413 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(d->ui->m_frequencyEdit->currentItem())); | ||
360 | d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); | 414 | d->m_schedule.setOccurrenceMultiplier(d->ui->m_frequencyNoEdit->value()); | ||
361 | 415 | | |||
362 | switch (m_weekendOptionEdit->currentIndex()) { | 416 | switch (d->ui->m_weekendOptionEdit->currentIndex()) { | ||
363 | case 0: | 417 | case 0: | ||
364 | d->m_schedule.setWeekendOption(Schedule::WeekendOption::MoveNothing); | 418 | d->m_schedule.setWeekendOption(Schedule::WeekendOption::MoveNothing); | ||
365 | break; | 419 | break; | ||
Context not available. | |||||
391 | qDebug("No tabbar found in KEditScheduleDlg::schedule(). Defaulting type to BILL"); | 445 | qDebug("No tabbar found in KEditScheduleDlg::schedule(). Defaulting type to BILL"); | ||
392 | } | 446 | } | ||
393 | 447 | | |||
394 | if(m_lastDayInMonthEdit->isEnabled()) | 448 | if(d->ui->m_lastDayInMonthEdit->isEnabled()) | ||
395 | d->m_schedule.setLastDayInMonth(m_lastDayInMonthEdit->isChecked()); | 449 | d->m_schedule.setLastDayInMonth(d->ui->m_lastDayInMonthEdit->isChecked()); | ||
396 | else | 450 | else | ||
397 | d->m_schedule.setLastDayInMonth(false); | 451 | d->m_schedule.setLastDayInMonth(false); | ||
398 | d->m_schedule.setAutoEnter(m_autoEnterEdit->isChecked()); | 452 | d->m_schedule.setAutoEnter(d->ui->m_autoEnterEdit->isChecked()); | ||
399 | d->m_schedule.setPaymentType(static_cast<Schedule::PaymentType>(m_paymentMethodEdit->currentItem())); | 453 | d->m_schedule.setPaymentType(static_cast<Schedule::PaymentType>(d->ui->m_paymentMethodEdit->currentItem())); | ||
400 | if (m_endSeriesEdit->isEnabled() && m_endSeriesEdit->isChecked()) { | 454 | if (d->ui->m_endSeriesEdit->isEnabled() && d->ui->m_endSeriesEdit->isChecked()) { | ||
401 | d->m_schedule.setEndDate(m_FinalPaymentEdit->date()); | 455 | d->m_schedule.setEndDate(d->ui->m_FinalPaymentEdit->date()); | ||
402 | } else { | 456 | } else { | ||
403 | d->m_schedule.setEndDate(QDate()); | 457 | d->m_schedule.setEndDate(QDate()); | ||
404 | } | 458 | } | ||
Context not available. | |||||
406 | return d->m_schedule; | 460 | return d->m_schedule; | ||
407 | } | 461 | } | ||
408 | 462 | | |||
409 | MyMoneyTransaction KEditScheduleDlg::transaction() const | | |||
410 | { | | |||
411 | MyMoneyTransaction t = d->m_schedule.transaction(); | | |||
412 | | ||||
413 | if (d->m_editor) { | | |||
414 | d->m_editor->createTransaction(t, d->m_schedule.transaction(), d->m_schedule.transaction().splits().isEmpty() ? MyMoneySplit() : d->m_schedule.transaction().splits().front(), false); | | |||
415 | } | | |||
416 | | ||||
417 | t.clearId(); | | |||
418 | t.setEntryDate(QDate()); | | |||
419 | return t; | | |||
420 | } | | |||
421 | | ||||
422 | bool KEditScheduleDlg::focusNextPrevChild(bool next) | 463 | bool KEditScheduleDlg::focusNextPrevChild(bool next) | ||
423 | { | 464 | { | ||
424 | bool rc = false; | 465 | Q_D(KEditScheduleDlg); | ||
425 | QWidget *w = 0; | 466 | auto rc = false; | ||
426 | 467 | | |||
427 | w = qApp->focusWidget(); | 468 | auto w = qApp->focusWidget(); | ||
428 | int currentWidgetIndex = d->m_tabOrderWidgets.indexOf(w); | 469 | auto currentWidgetIndex = d->m_tabOrderWidgets.indexOf(w); | ||
429 | while (w && currentWidgetIndex == -1) { | 470 | while (w && currentWidgetIndex == -1) { | ||
430 | // qDebug("'%s' not in list, use parent", qPrintable(w->objectName())); | 471 | // qDebug("'%s' not in list, use parent", qPrintable(w->objectName())); | ||
431 | w = w->parentWidget(); | 472 | w = w->parentWidget(); | ||
Context not available. | |||||
456 | 497 | | |||
457 | void KEditScheduleDlg::resizeEvent(QResizeEvent* ev) | 498 | void KEditScheduleDlg::resizeEvent(QResizeEvent* ev) | ||
458 | { | 499 | { | ||
459 | m_register->resize(KMyMoneyRegister::DetailColumn); | 500 | Q_D(KEditScheduleDlg); | ||
460 | m_form->resize(KMyMoneyTransactionForm::ValueColumn1); | 501 | d->ui->m_register->resize(KMyMoneyRegister::DetailColumn); | ||
461 | KEditScheduleDlgDecl::resizeEvent(ev); | 502 | d->ui->m_form->resize(KMyMoneyTransactionForm::ValueColumn1); | ||
503 | QDialog::resizeEvent(ev); | ||||
462 | } | 504 | } | ||
463 | 505 | | |||
464 | 506 | | |||
465 | void KEditScheduleDlg::slotRemainingChanged(int value) | 507 | void KEditScheduleDlg::slotRemainingChanged(int value) | ||
466 | { | 508 | { | ||
509 | Q_D(KEditScheduleDlg); | ||||
467 | // Make sure the required fields are set | 510 | // Make sure the required fields are set | ||
468 | kMyMoneyDateInput* dateEdit = dynamic_cast<kMyMoneyDateInput*>(d->m_editor->haveWidget("postdate")); | 511 | auto dateEdit = dynamic_cast<kMyMoneyDateInput*>(d->m_editor->haveWidget("postdate")); | ||
469 | d->m_schedule.setNextDueDate(dateEdit->date()); | 512 | d->m_schedule.setNextDueDate(dateEdit->date()); | ||
470 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(m_frequencyEdit->currentItem())); | 513 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(d->ui->m_frequencyEdit->currentItem())); | ||
471 | d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); | 514 | d->m_schedule.setOccurrenceMultiplier(d->ui->m_frequencyNoEdit->value()); | ||
472 | 515 | | |||
473 | if (d->m_schedule.transactionsRemaining() != value) { | 516 | if (d->m_schedule.transactionsRemaining() != value) { | ||
474 | m_FinalPaymentEdit->blockSignals(true); | 517 | d->ui->m_FinalPaymentEdit->blockSignals(true); | ||
475 | m_FinalPaymentEdit->setDate(d->m_schedule.dateAfter(value)); | 518 | d->ui->m_FinalPaymentEdit->setDate(d->m_schedule.dateAfter(value)); | ||
476 | m_FinalPaymentEdit->blockSignals(false); | 519 | d->ui->m_FinalPaymentEdit->blockSignals(false); | ||
477 | } | 520 | } | ||
478 | } | 521 | } | ||
479 | 522 | | |||
480 | void KEditScheduleDlg::slotEndDateChanged(const QDate& date) | 523 | void KEditScheduleDlg::slotEndDateChanged(const QDate& date) | ||
481 | { | 524 | { | ||
525 | Q_D(KEditScheduleDlg); | ||||
482 | // Make sure the required fields are set | 526 | // Make sure the required fields are set | ||
483 | kMyMoneyDateInput* dateEdit = dynamic_cast<kMyMoneyDateInput*>(d->m_editor->haveWidget("postdate")); | 527 | auto dateEdit = dynamic_cast<kMyMoneyDateInput*>(d->m_editor->haveWidget("postdate")); | ||
484 | d->m_schedule.setNextDueDate(dateEdit->date()); | 528 | d->m_schedule.setNextDueDate(dateEdit->date()); | ||
485 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(m_frequencyEdit->currentItem())); | 529 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(d->ui->m_frequencyEdit->currentItem())); | ||
486 | d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); | 530 | d->m_schedule.setOccurrenceMultiplier(d->ui->m_frequencyNoEdit->value()); | ||
487 | 531 | | |||
488 | if (d->m_schedule.endDate() != date) { | 532 | if (d->m_schedule.endDate() != date) { | ||
489 | d->m_schedule.setEndDate(date); | 533 | d->m_schedule.setEndDate(date); | ||
490 | updateTransactionsRemaining(); | 534 | d->updateTransactionsRemaining(); | ||
491 | } | 535 | } | ||
492 | } | 536 | } | ||
493 | 537 | | |||
494 | void KEditScheduleDlg::slotPostDateChanged(const QDate& date) | 538 | void KEditScheduleDlg::slotPostDateChanged(const QDate& date) | ||
495 | { | 539 | { | ||
540 | Q_D(KEditScheduleDlg); | ||||
496 | if (d->m_schedule.nextDueDate() != date) { | 541 | if (d->m_schedule.nextDueDate() != date) { | ||
497 | if (m_endOptionsFrame->isEnabled()) { | 542 | if (d->ui->m_endOptionsFrame->isEnabled()) { | ||
498 | d->m_schedule.setNextDueDate(date); | 543 | d->m_schedule.setNextDueDate(date); | ||
499 | d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); | 544 | d->m_schedule.setOccurrenceMultiplier(d->ui->m_frequencyNoEdit->value()); | ||
500 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(m_frequencyEdit->currentItem())); | 545 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(d->ui->m_frequencyEdit->currentItem())); | ||
501 | d->m_schedule.setEndDate(m_FinalPaymentEdit->date()); | 546 | d->m_schedule.setEndDate(d->ui->m_FinalPaymentEdit->date()); | ||
502 | updateTransactionsRemaining(); | 547 | d->updateTransactionsRemaining(); | ||
503 | } | 548 | } | ||
504 | } | 549 | } | ||
505 | } | 550 | } | ||
506 | 551 | | |||
507 | void KEditScheduleDlg::slotSetPaymentMethod(int item) | 552 | void KEditScheduleDlg::slotSetPaymentMethod(int item) | ||
508 | { | 553 | { | ||
509 | kMyMoneyLineEdit* dateEdit = dynamic_cast<kMyMoneyLineEdit*>(d->m_editor->haveWidget("number")); | 554 | Q_D(KEditScheduleDlg); | ||
555 | auto dateEdit = dynamic_cast<kMyMoneyLineEdit*>(d->m_editor->haveWidget("number")); | ||||
510 | if (dateEdit) { | 556 | if (dateEdit) { | ||
511 | dateEdit->setVisible(item == (int)Schedule::PaymentType::WriteChecque); | 557 | dateEdit->setVisible(item == (int)Schedule::PaymentType::WriteChecque); | ||
512 | 558 | | |||
Context not available. | |||||
521 | 567 | | |||
522 | void KEditScheduleDlg::slotFrequencyChanged(int item) | 568 | void KEditScheduleDlg::slotFrequencyChanged(int item) | ||
523 | { | 569 | { | ||
524 | m_endSeriesEdit->setEnabled(item != (int)Schedule::Occurrence::Once); | 570 | Q_D(KEditScheduleDlg); | ||
525 | bool isEndSeries = m_endSeriesEdit->isChecked(); | 571 | d->ui->m_endSeriesEdit->setEnabled(item != (int)Schedule::Occurrence::Once); | ||
572 | bool isEndSeries = d->ui->m_endSeriesEdit->isChecked(); | ||||
526 | if (isEndSeries) | 573 | if (isEndSeries) | ||
527 | m_endOptionsFrame->setEnabled(item != (int)Schedule::Occurrence::Once); | 574 | d->ui->m_endOptionsFrame->setEnabled(item != (int)Schedule::Occurrence::Once); | ||
528 | switch (item) { | 575 | switch (item) { | ||
529 | case (int)Schedule::Occurrence::Daily: | 576 | case (int)Schedule::Occurrence::Daily: | ||
530 | case (int)Schedule::Occurrence::Weekly: | 577 | case (int)Schedule::Occurrence::Weekly: | ||
531 | m_frequencyNoEdit->setEnabled(true); | 578 | d->ui->m_frequencyNoEdit->setEnabled(true); | ||
532 | m_lastDayInMonthEdit->setEnabled(false); | 579 | d->ui->m_lastDayInMonthEdit->setEnabled(false); | ||
533 | break; | 580 | break; | ||
534 | 581 | | |||
535 | case (int)Schedule::Occurrence::EveryHalfMonth: | 582 | case (int)Schedule::Occurrence::EveryHalfMonth: | ||
536 | case (int)Schedule::Occurrence::Monthly: | 583 | case (int)Schedule::Occurrence::Monthly: | ||
537 | case (int)Schedule::Occurrence::Yearly: | 584 | case (int)Schedule::Occurrence::Yearly: | ||
538 | // Supports Frequency Number | 585 | // Supports Frequency Number | ||
539 | m_frequencyNoEdit->setEnabled(true); | 586 | d->ui->m_frequencyNoEdit->setEnabled(true); | ||
540 | m_lastDayInMonthEdit->setEnabled(true); | 587 | d->ui->m_lastDayInMonthEdit->setEnabled(true); | ||
541 | break; | 588 | break; | ||
542 | 589 | | |||
543 | default: | 590 | default: | ||
544 | // Multiplier is always 1 | 591 | // Multiplier is always 1 | ||
545 | m_frequencyNoEdit->setEnabled(false); | 592 | d->ui->m_frequencyNoEdit->setEnabled(false); | ||
546 | m_frequencyNoEdit->setValue(1); | 593 | d->ui->m_frequencyNoEdit->setValue(1); | ||
547 | m_lastDayInMonthEdit->setEnabled(true); | 594 | d->ui->m_lastDayInMonthEdit->setEnabled(true); | ||
548 | break; | 595 | break; | ||
549 | } | 596 | } | ||
550 | if (isEndSeries && (item != (int)Schedule::Occurrence::Once)) { | 597 | if (isEndSeries && (item != (int)Schedule::Occurrence::Once)) { | ||
Context not available. | |||||
552 | // of remaining transactions | 599 | // of remaining transactions | ||
553 | kMyMoneyDateInput* dateEdit = dynamic_cast<kMyMoneyDateInput*>(d->m_editor->haveWidget("postdate")); | 600 | kMyMoneyDateInput* dateEdit = dynamic_cast<kMyMoneyDateInput*>(d->m_editor->haveWidget("postdate")); | ||
554 | d->m_schedule.setNextDueDate(dateEdit->date()); | 601 | d->m_schedule.setNextDueDate(dateEdit->date()); | ||
555 | d->m_schedule.setOccurrenceMultiplier(m_frequencyNoEdit->value()); | 602 | d->m_schedule.setOccurrenceMultiplier(d->ui->m_frequencyNoEdit->value()); | ||
556 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(item)); | 603 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(item)); | ||
557 | d->m_schedule.setEndDate(m_FinalPaymentEdit->date()); | 604 | d->m_schedule.setEndDate(d->ui->m_FinalPaymentEdit->date()); | ||
558 | updateTransactionsRemaining(); | 605 | d->updateTransactionsRemaining(); | ||
559 | } | 606 | } | ||
560 | } | 607 | } | ||
561 | 608 | | |||
562 | void KEditScheduleDlg::slotOccurrenceMultiplierChanged(int multiplier) | 609 | void KEditScheduleDlg::slotOccurrenceMultiplierChanged(int multiplier) | ||
563 | { | 610 | { | ||
611 | Q_D(KEditScheduleDlg); | ||||
564 | // Make sure the required fields are set | 612 | // Make sure the required fields are set | ||
565 | int oldOccurrenceMultiplier = d->m_schedule.occurrenceMultiplier(); | 613 | auto oldOccurrenceMultiplier = d->m_schedule.occurrenceMultiplier(); | ||
566 | if (multiplier != oldOccurrenceMultiplier) { | 614 | if (multiplier != oldOccurrenceMultiplier) { | ||
567 | if (m_endOptionsFrame->isEnabled()) { | 615 | if (d->ui->m_endOptionsFrame->isEnabled()) { | ||
568 | kMyMoneyDateInput* dateEdit = dynamic_cast<kMyMoneyDateInput*>(d->m_editor->haveWidget("postdate")); | 616 | kMyMoneyDateInput* dateEdit = dynamic_cast<kMyMoneyDateInput*>(d->m_editor->haveWidget("postdate")); | ||
569 | d->m_schedule.setNextDueDate(dateEdit->date()); | 617 | d->m_schedule.setNextDueDate(dateEdit->date()); | ||
570 | d->m_schedule.setOccurrenceMultiplier(multiplier); | 618 | d->m_schedule.setOccurrenceMultiplier(multiplier); | ||
571 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(m_frequencyEdit->currentItem())); | 619 | d->m_schedule.setOccurrencePeriod(static_cast<Schedule::Occurrence>(d->ui->m_frequencyEdit->currentItem())); | ||
572 | d->m_schedule.setEndDate(m_FinalPaymentEdit->date()); | 620 | d->m_schedule.setEndDate(d->ui->m_FinalPaymentEdit->date()); | ||
573 | updateTransactionsRemaining(); | 621 | d->updateTransactionsRemaining(); | ||
574 | } | 622 | } | ||
575 | } | 623 | } | ||
576 | } | 624 | } | ||
577 | 625 | | |||
578 | void KEditScheduleDlg::updateTransactionsRemaining() | | |||
579 | { | | |||
580 | int remain = d->m_schedule.transactionsRemaining(); | | |||
581 | if (remain != m_RemainingEdit->value()) { | | |||
582 | m_RemainingEdit->blockSignals(true); | | |||
583 | m_RemainingEdit->setValue(remain); | | |||
584 | m_RemainingEdit->blockSignals(false); | | |||
585 | } | | |||
586 | } | | |||
587 | | ||||
588 | void KEditScheduleDlg::slotShowHelp() | 626 | void KEditScheduleDlg::slotShowHelp() | ||
589 | { | 627 | { | ||
590 | KHelpClient::invokeHelp("details.schedules.intro"); | 628 | KHelpClient::invokeHelp("details.schedules.intro"); | ||
Context not available. | |||||
592 | 630 | | |||
593 | void KEditScheduleDlg::slotFilterPaymentType(int index) | 631 | void KEditScheduleDlg::slotFilterPaymentType(int index) | ||
594 | { | 632 | { | ||
633 | Q_D(KEditScheduleDlg); | ||||
595 | //save selected item to reload if possible | 634 | //save selected item to reload if possible | ||
596 | int selectedId = m_paymentMethodEdit->itemData(m_paymentMethodEdit->currentIndex(), Qt::UserRole).toInt(); | 635 | auto selectedId = d->ui->m_paymentMethodEdit->itemData(d->ui->m_paymentMethodEdit->currentIndex(), Qt::UserRole).toInt(); | ||
597 | 636 | | |||
598 | //clear and reload the widget with the correct items | 637 | //clear and reload the widget with the correct items | ||
599 | m_paymentMethodEdit->clear(); | 638 | d->ui->m_paymentMethodEdit->clear(); | ||
600 | 639 | | |||
601 | // load option widgets | 640 | // load option widgets | ||
602 | KMyMoneyRegister::Action action = static_cast<KMyMoneyRegister::Action>(index); | 641 | KMyMoneyRegister::Action action = static_cast<KMyMoneyRegister::Action>(index); | ||
603 | if (action != KMyMoneyRegister::ActionWithdrawal) { | 642 | if (action != KMyMoneyRegister::ActionWithdrawal) { | ||
604 | m_paymentMethodEdit->insertItem(i18n("Direct deposit"), (int)Schedule::PaymentType::DirectDeposit); | 643 | d->ui->m_paymentMethodEdit->insertItem(i18n("Direct deposit"), (int)Schedule::PaymentType::DirectDeposit); | ||
605 | m_paymentMethodEdit->insertItem(i18n("Manual deposit"), (int)Schedule::PaymentType::ManualDeposit); | 644 | d->ui->m_paymentMethodEdit->insertItem(i18n("Manual deposit"), (int)Schedule::PaymentType::ManualDeposit); | ||
606 | } | 645 | } | ||
607 | if (action != KMyMoneyRegister::ActionDeposit) { | 646 | if (action != KMyMoneyRegister::ActionDeposit) { | ||
608 | m_paymentMethodEdit->insertItem(i18n("Direct debit"), (int)Schedule::PaymentType::DirectDebit); | 647 | d->ui->m_paymentMethodEdit->insertItem(i18n("Direct debit"), (int)Schedule::PaymentType::DirectDebit); | ||
609 | m_paymentMethodEdit->insertItem(i18n("Write check"), (int)Schedule::PaymentType::WriteChecque); | 648 | d->ui->m_paymentMethodEdit->insertItem(i18n("Write check"), (int)Schedule::PaymentType::WriteChecque); | ||
610 | } | 649 | } | ||
611 | m_paymentMethodEdit->insertItem(i18n("Standing order"), (int)Schedule::PaymentType::StandingOrder); | 650 | d->ui->m_paymentMethodEdit->insertItem(i18n("Standing order"), (int)Schedule::PaymentType::StandingOrder); | ||
612 | m_paymentMethodEdit->insertItem(i18n("Bank transfer"), (int)Schedule::PaymentType::BankTransfer); | 651 | d->ui->m_paymentMethodEdit->insertItem(i18n("Bank transfer"), (int)Schedule::PaymentType::BankTransfer); | ||
613 | m_paymentMethodEdit->insertItem(i18nc("Other payment method", "Other"), (int)Schedule::PaymentType::Other); | 652 | d->ui->m_paymentMethodEdit->insertItem(i18nc("Other payment method", "Other"), (int)Schedule::PaymentType::Other); | ||
614 | 653 | | |||
615 | int newIndex = m_paymentMethodEdit->findData(QVariant(selectedId), Qt::UserRole, Qt::MatchExactly); | 654 | auto newIndex = d->ui->m_paymentMethodEdit->findData(QVariant(selectedId), Qt::UserRole, Qt::MatchExactly); | ||
616 | if (newIndex > -1) { | 655 | if (newIndex > -1) { | ||
617 | m_paymentMethodEdit->setCurrentIndex(newIndex); | 656 | d->ui->m_paymentMethodEdit->setCurrentIndex(newIndex); | ||
618 | } else { | 657 | } else { | ||
619 | m_paymentMethodEdit->setCurrentIndex(0); | 658 | d->ui->m_paymentMethodEdit->setCurrentIndex(0); | ||
620 | } | 659 | } | ||
621 | 660 | | |||
622 | } | 661 | } | ||
Context not available. |