Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/wizards/newaccountwizard/knewaccountwizard_p.h
Context not available. | |||||
21 | // ---------------------------------------------------------------------------- | 21 | // ---------------------------------------------------------------------------- | ||
---|---|---|---|---|---|
22 | // QT Includes | 22 | // QT Includes | ||
23 | 23 | | |||
24 | #include <QCheckBox> | | |||
25 | #include <QList> | | |||
26 | | ||||
27 | // ---------------------------------------------------------------------------- | 24 | // ---------------------------------------------------------------------------- | ||
28 | // KDE Includes | 25 | // KDE Includes | ||
29 | 26 | | |||
30 | #include <kcombobox.h> | | |||
31 | #include <klineedit.h> | | |||
32 | | ||||
33 | // ---------------------------------------------------------------------------- | 27 | // ---------------------------------------------------------------------------- | ||
34 | // Project Includes | 28 | // Project Includes | ||
35 | 29 | | |||
36 | #include "kmymoneywizardpage.h" | 30 | #include "kmymoneywizard_p.h" | ||
37 | #include <kmymoneywizard.h> | 31 | #include "knewaccountwizard.h" | ||
38 | #include <kmymoneydateinput.h> | 32 | #include "kaccounttypepage.h" | ||
39 | #include <kmymoneycurrencyselector.h> | 33 | #include "mymoneyaccountloan.h" | ||
40 | #include <mymoneyaccount.h> | 34 | #include "mymoneymoney.h" | ||
41 | #include <kmymoneyedit.h> | 35 | #include "mymoneyschedule.h" | ||
42 | #include "accountsproxymodel.h" | 36 | #include "mymoneysecurity.h" | ||
43 | | ||||
44 | #include "ui_kinstitutionpagedecl.h" | | |||
45 | #include "ui_kaccounttypepagedecl.h" | | |||
46 | #include "ui_kbrokeragepagedecl.h" | | |||
47 | #include "ui_kschedulepagedecl.h" | | |||
48 | #include "ui_kgeneralloaninfopagedecl.h" | | |||
49 | #include "ui_kloandetailspagedecl.h" | | |||
50 | #include "ui_kloanpaymentpagedecl.h" | | |||
51 | #include "ui_kloanschedulepagedecl.h" | | |||
52 | #include "ui_kloanpayoutpagedecl.h" | | |||
53 | #include "ui_khierarchypagedecl.h" | | |||
54 | #include "ui_kaccountsummarypagedecl.h" | | |||
55 | | ||||
56 | class Wizard; | | |||
57 | class MyMoneyInstitution; | | |||
58 | 37 | | |||
59 | namespace NewAccountWizard | 38 | namespace NewAccountWizard | ||
60 | { | 39 | { | ||
61 | 40 | class AccountTypePage; | |||
62 | 41 | class InstitutionPage; | |||
63 | class KInstitutionPageDecl : public QWidget, public Ui::KInstitutionPageDecl | 42 | class BrokeragePage; | ||
64 | { | 43 | class CreditCardSchedulePage; | ||
65 | public: | 44 | class GeneralLoanInfoPage; | ||
66 | KInstitutionPageDecl(QWidget *parent) : QWidget(parent) { | 45 | class LoanDetailsPage; | ||
67 | setupUi(this); | 46 | class LoanPaymentPage; | ||
68 | } | 47 | class LoanSchedulePage; | ||
69 | }; | 48 | class LoanPayoutPage; | ||
70 | 49 | class HierarchyPage; | |||
71 | class InstitutionPage : public KInstitutionPageDecl, public WizardPage<Wizard> | 50 | class AccountSummaryPage; | ||
72 | { | 51 | | ||
73 | Q_OBJECT | 52 | class WizardPrivate : public KMyMoneyWizardPrivate | ||
74 | public: | 53 | { | ||
75 | InstitutionPage(Wizard* parent); | 54 | Q_DISABLE_COPY(WizardPrivate) | ||
76 | ~InstitutionPage(); | 55 | | ||
77 | KMyMoneyWizardPage* nextPage(void) const; | 56 | public: | ||
78 | 57 | WizardPrivate(Wizard *qq): | |||
79 | QWidget* initialFocusWidget(void) const { | 58 | KMyMoneyWizardPrivate(qq) | ||
80 | return m_institutionComboBox; | 59 | { | ||
81 | } | 60 | } | ||
82 | 61 | | |||
83 | /** | 62 | ~WizardPrivate() | ||
84 | * Returns the information about an institution if entered by | 63 | { | ||
85 | * the user. If the id field is empty, then he did not enter | 64 | } | ||
86 | * such information. | 65 | | ||
87 | */ | 66 | /** | ||
88 | const MyMoneyInstitution& institution(void) const; | 67 | * This method returns the currently selected currency for the account | ||
89 | | ||||
90 | void selectExistingInstitution(const QString& id); | | |||
91 | | ||||
92 | private slots: | | |||
93 | void slotLoadWidgets(void); | | |||
94 | void slotNewInstitution(void); | | |||
95 | void slotSelectInstitution(int index); | | |||
96 | | ||||
97 | private: | | |||
98 | /// \internal d-pointer class. | | |||
99 | class Private; | | |||
100 | /// \internal d-pointer instance. | | |||
101 | Private* const d; | | |||
102 | }; | | |||
103 | | ||||
104 | | ||||
105 | class KAccountTypePageDecl : public QWidget, public Ui::KAccountTypePageDecl | | |||
106 | { | | |||
107 | public: | | |||
108 | KAccountTypePageDecl(QWidget *parent) : QWidget(parent) { | | |||
109 | setupUi(this); | | |||
110 | } | | |||
111 | }; | | |||
112 | | ||||
113 | class AccountTypePage : public KAccountTypePageDecl, public WizardPage<Wizard> | | |||
114 | { | | |||
115 | Q_OBJECT | | |||
116 | public: | | |||
117 | AccountTypePage(Wizard* parent); | | |||
118 | virtual bool isComplete(void) const; | | |||
119 | KMyMoneyWizardPage* nextPage(void) const; | | |||
120 | | ||||
121 | QWidget* initialFocusWidget(void) const { | | |||
122 | return m_accountName; | | |||
123 | } | | |||
124 | | ||||
125 | eMyMoney::Account accountType(void) const; | | |||
126 | const MyMoneyAccount& parentAccount(void); | | |||
127 | bool allowsParentAccount(void) const; | | |||
128 | const MyMoneySecurity& currency(void) const; | | |||
129 | | ||||
130 | void setAccount(const MyMoneyAccount& acc); | | |||
131 | | ||||
132 | private: | | |||
133 | void hideShowPages(eMyMoney::Account i) const; | | |||
134 | void priceWarning(bool); | | |||
135 | | ||||
136 | private slots: | | |||
137 | void slotUpdateType(int i); | | |||
138 | void slotUpdateCurrency(void); | | |||
139 | void slotUpdateConversionRate(const QString&); | | |||
140 | void slotGetOnlineQuote(void); | | |||
141 | void slotPriceWarning(void); | | |||
142 | | ||||
143 | private: | | |||
144 | bool m_showPriceWarning; | | |||
145 | }; | | |||
146 | | ||||
147 | | ||||
148 | class KBrokeragePageDecl : public QWidget, public Ui::KBrokeragePageDecl | | |||
149 | { | | |||
150 | public: | | |||
151 | KBrokeragePageDecl(QWidget *parent) : QWidget(parent) { | | |||
152 | setupUi(this); | | |||
153 | } | | |||
154 | }; | | |||
155 | | ||||
156 | class BrokeragePage : public KBrokeragePageDecl, public WizardPage<Wizard> | | |||
157 | { | | |||
158 | Q_OBJECT | | |||
159 | public: | | |||
160 | BrokeragePage(Wizard* parent); | | |||
161 | KMyMoneyWizardPage* nextPage(void) const; | | |||
162 | void enterPage(void); | | |||
163 | | ||||
164 | QWidget* initialFocusWidget(void) const { | | |||
165 | return m_createBrokerageButton; | | |||
166 | } | | |||
167 | | ||||
168 | private slots: | | |||
169 | void slotLoadWidgets(void); | | |||
170 | }; | | |||
171 | | ||||
172 | | ||||
173 | class KSchedulePageDecl : public QWidget, public Ui::KSchedulePageDecl | | |||
174 | { | | |||
175 | public: | | |||
176 | KSchedulePageDecl(QWidget *parent) : QWidget(parent) { | | |||
177 | setupUi(this); | | |||
178 | } | | |||
179 | }; | | |||
180 | | ||||
181 | class CreditCardSchedulePage : public KSchedulePageDecl, public WizardPage<Wizard> | | |||
182 | { | | |||
183 | Q_OBJECT | | |||
184 | public: | | |||
185 | CreditCardSchedulePage(Wizard* parent); | | |||
186 | KMyMoneyWizardPage* nextPage(void) const; | | |||
187 | virtual bool isComplete(void) const; | | |||
188 | void enterPage(void); | | |||
189 | | ||||
190 | QWidget* initialFocusWidget(void) const { | | |||
191 | return m_reminderCheckBox; | | |||
192 | } | | |||
193 | | ||||
194 | private slots: | | |||
195 | void slotLoadWidgets(void); | | |||
196 | }; | | |||
197 | | ||||
198 | | ||||
199 | class KGeneralLoanInfoPageDecl : public QWidget, public Ui::KGeneralLoanInfoPageDecl | | |||
200 | { | | |||
201 | public: | | |||
202 | KGeneralLoanInfoPageDecl(QWidget *parent) : QWidget(parent) { | | |||
203 | setupUi(this); | | |||
204 | } | | |||
205 | }; | | |||
206 | | ||||
207 | class GeneralLoanInfoPage : public KGeneralLoanInfoPageDecl, public WizardPage<Wizard> | | |||
208 | { | | |||
209 | Q_OBJECT | | |||
210 | public: | | |||
211 | GeneralLoanInfoPage(Wizard* parent); | | |||
212 | KMyMoneyWizardPage* nextPage(void) const; | | |||
213 | virtual bool isComplete(void) const; | | |||
214 | void enterPage(void); | | |||
215 | const MyMoneyAccount& parentAccount(void); | | |||
216 | | ||||
217 | QWidget* initialFocusWidget(void) const { | | |||
218 | return m_loanDirection; | | |||
219 | } | | |||
220 | | ||||
221 | /** | | |||
222 | * Returns @p true if the user decided to record all payments, @p false otherwise. | | |||
223 | */ | | |||
224 | bool recordAllPayments(void) const; | | |||
225 | | ||||
226 | private slots: | | |||
227 | void slotLoadWidgets(void); | | |||
228 | | ||||
229 | private: | | |||
230 | bool m_firstTime; | | |||
231 | }; | | |||
232 | | ||||
233 | | ||||
234 | class KLoanDetailsPageDecl : public QWidget, public Ui::KLoanDetailsPageDecl | | |||
235 | { | | |||
236 | public: | | |||
237 | KLoanDetailsPageDecl(QWidget *parent) : QWidget(parent) { | | |||
238 | setupUi(this); | | |||
239 | } | | |||
240 | }; | | |||
241 | | ||||
242 | class LoanDetailsPage : public KLoanDetailsPageDecl, public WizardPage<Wizard> | | |||
243 | { | | |||
244 | Q_OBJECT | | |||
245 | public: | | |||
246 | LoanDetailsPage(Wizard* parent); | | |||
247 | void enterPage(void); | | |||
248 | KMyMoneyWizardPage* nextPage(void) const; | | |||
249 | virtual bool isComplete(void) const; | | |||
250 | | ||||
251 | QWidget* initialFocusWidget(void) const { | | |||
252 | return m_paymentDue; | | |||
253 | } | | |||
254 | | ||||
255 | /** | | |||
256 | * This method returns the number of payments depending on | | |||
257 | * the settings of m_termAmount and m_termUnit widgets | | |||
258 | */ | | |||
259 | int term(void) const; | | |||
260 | | ||||
261 | private: | | |||
262 | /** | | |||
263 | * This method is used to update the term widgets | | |||
264 | * according to the length of the given @a term. | | |||
265 | * The term is also converted into a string and returned. | | |||
266 | */ | | |||
267 | QString updateTermWidgets(const double term); | | |||
268 | | ||||
269 | private: | | |||
270 | bool m_needCalculate; | | |||
271 | | ||||
272 | private slots: | | |||
273 | void slotValuesChanged(void); | | |||
274 | void slotCalculate(void); | | |||
275 | }; | | |||
276 | | ||||
277 | | ||||
278 | class KLoanPaymentPageDecl : public QWidget, public Ui::KLoanPaymentPageDecl | | |||
279 | { | | |||
280 | public: | | |||
281 | KLoanPaymentPageDecl(QWidget *parent) : QWidget(parent) { | | |||
282 | setupUi(this); | | |||
283 | } | | |||
284 | }; | | |||
285 | | ||||
286 | class LoanPaymentPage : public KLoanPaymentPageDecl, public WizardPage<Wizard> | | |||
287 | { | | |||
288 | Q_OBJECT | | |||
289 | public: | | |||
290 | LoanPaymentPage(Wizard* parent); | | |||
291 | ~LoanPaymentPage(); | | |||
292 | | ||||
293 | KMyMoneyWizardPage* nextPage(void) const; | | |||
294 | | ||||
295 | void enterPage(void); | | |||
296 | | ||||
297 | /** | | |||
298 | * This method returns the sum of the additional fees | | |||
299 | */ | | |||
300 | MyMoneyMoney additionalFees(void) const; | | |||
301 | | ||||
302 | /** | | |||
303 | * This method returns the base payment, that's principal and interest | | |||
304 | */ | | |||
305 | MyMoneyMoney basePayment(void) const; | | |||
306 | | ||||
307 | /** | | |||
308 | * This method returns the splits that make up the additional fees in @p list. | | |||
309 | * @note The splits may contain assigned ids which the caller must remove before | | |||
310 | * adding the splits to a MyMoneyTransaction object. | | |||
311 | */ | 68 | */ | ||
312 | void additionalFeesSplits(QList<MyMoneySplit>& list); | 69 | const MyMoneySecurity& currency() const | ||
313 | 70 | { | |||
314 | protected slots: | 71 | return m_accountTypePage->currency(); | ||
315 | void slotAdditionalFees(void); | 72 | } | ||
316 | 73 | | |||
317 | protected: | 74 | /** | ||
318 | void updateAmounts(void); | 75 | * This method returns the precision in digits for the selected currency. | ||
319 | 76 | * @sa currency() | |||
320 | private: | | |||
321 | /// \internal d-pointer class. | | |||
322 | class Private; | | |||
323 | /// \internal d-pointer instance. | | |||
324 | Private* const d; | | |||
325 | }; | | |||
326 | | ||||
327 | | ||||
328 | class KLoanSchedulePageDecl : public QWidget, public Ui::KLoanSchedulePageDecl | | |||
329 | { | | |||
330 | public: | | |||
331 | KLoanSchedulePageDecl(QWidget *parent) : QWidget(parent) { | | |||
332 | setupUi(this); | | |||
333 | } | | |||
334 | }; | | |||
335 | | ||||
336 | class LoanSchedulePage : public KLoanSchedulePageDecl, public WizardPage<Wizard> | | |||
337 | { | | |||
338 | Q_OBJECT | | |||
339 | public: | | |||
340 | LoanSchedulePage(Wizard* parent); | | |||
341 | void enterPage(void); | | |||
342 | | ||||
343 | KMyMoneyWizardPage* nextPage(void) const; | | |||
344 | | ||||
345 | /** | | |||
346 | * This method returns the due date of the first payment to be recorded. | | |||
347 | */ | 77 | */ | ||
348 | QDate firstPaymentDueDate(void) const; | 78 | int precision() const | ||
349 | 79 | { | |||
350 | QWidget* initialFocusWidget(void) const { | 80 | return MyMoneyMoney::denomToPrec(currency().smallestAccountFraction()); | ||
351 | return m_interestCategory; | 81 | } | ||
352 | } | 82 | | ||
353 | 83 | InstitutionPage* m_institutionPage; | |||
354 | private slots: | 84 | AccountTypePage* m_accountTypePage; | ||
355 | void slotLoadWidgets(void); | 85 | BrokeragePage* m_brokeragepage; | ||
356 | void slotCreateCategory(const QString& name, QString& id); | 86 | CreditCardSchedulePage* m_schedulePage; | ||
357 | }; | 87 | GeneralLoanInfoPage* m_generalLoanInfoPage; | ||
358 | 88 | LoanDetailsPage* m_loanDetailsPage; | |||
359 | 89 | LoanPaymentPage* m_loanPaymentPage; | |||
360 | class KLoanPayoutPageDecl : public QWidget, public Ui::KLoanPayoutPageDecl | 90 | LoanSchedulePage* m_loanSchedulePage; | ||
361 | { | 91 | LoanPayoutPage* m_loanPayoutPage; | ||
362 | public: | 92 | HierarchyPage* m_hierarchyPage; | ||
363 | KLoanPayoutPageDecl(QWidget *parent) : QWidget(parent) { | 93 | AccountSummaryPage* m_accountSummaryPage; | ||
364 | setupUi(this); | 94 | | ||
365 | } | 95 | MyMoneyAccountLoan m_account; | ||
366 | }; | 96 | MyMoneySchedule m_schedule; | ||
367 | 97 | }; | |||
368 | class LoanPayoutPage : public KLoanPayoutPageDecl, public WizardPage<Wizard> | | |||
369 | { | | |||
370 | Q_OBJECT | | |||
371 | public: | | |||
372 | LoanPayoutPage(Wizard* parent); | | |||
373 | void enterPage(void); | | |||
374 | virtual bool isComplete(void) const; | | |||
375 | | ||||
376 | KMyMoneyWizardPage* nextPage(void) const; | | |||
377 | | ||||
378 | QWidget* initialFocusWidget(void) const { | | |||
379 | return m_noPayoutTransaction; | | |||
380 | } | | |||
381 | | ||||
382 | QString payoutAccountId(void) const; | | |||
383 | | ||||
384 | private slots: | | |||
385 | void slotLoadWidgets(void); | | |||
386 | void slotCreateAssetAccount(void); | | |||
387 | void slotButtonsToggled(void); | | |||
388 | }; | | |||
389 | | ||||
390 | class HierarchyFilterProxyModel : public AccountsProxyModel | | |||
391 | { | | |||
392 | Q_OBJECT | | |||
393 | | ||||
394 | public: | | |||
395 | HierarchyFilterProxyModel(QObject *parent = 0); | | |||
396 | | ||||
397 | protected: | | |||
398 | bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; | | |||
399 | bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const; | | |||
400 | }; | | |||
401 | | ||||
402 | class KHierarchyPageDecl : public QWidget, public Ui::KHierarchyPageDecl | | |||
403 | { | | |||
404 | public: | | |||
405 | KHierarchyPageDecl(QWidget *parent) : QWidget(parent) { | | |||
406 | setupUi(this); | | |||
407 | } | | |||
408 | }; | | |||
409 | | ||||
410 | class HierarchyPage : public KHierarchyPageDecl, public WizardPage<Wizard> | | |||
411 | { | | |||
412 | Q_OBJECT | | |||
413 | | ||||
414 | public: | | |||
415 | HierarchyPage(Wizard* parent); | | |||
416 | void enterPage(void); | | |||
417 | KMyMoneyWizardPage* nextPage(void) const; | | |||
418 | QWidget* initialFocusWidget(void) const { | | |||
419 | return m_parentAccounts; | | |||
420 | } | | |||
421 | const MyMoneyAccount& parentAccount(void); | | |||
422 | | ||||
423 | bool isComplete(void) const; | | |||
424 | | ||||
425 | protected slots: | | |||
426 | void parentAccountChanged(); | | |||
427 | | ||||
428 | private: | | |||
429 | HierarchyFilterProxyModel *m_filterProxyModel; | | |||
430 | MyMoneyAccount m_parentAccount; | | |||
431 | }; | | |||
432 | | ||||
433 | | ||||
434 | class KAccountSummaryPageDecl : public QWidget, public Ui::KAccountSummaryPageDecl | | |||
435 | { | | |||
436 | public: | | |||
437 | KAccountSummaryPageDecl(QWidget *parent) : QWidget(parent) { | | |||
438 | setupUi(this); | | |||
439 | } | | |||
440 | }; | | |||
441 | | ||||
442 | class AccountSummaryPage : public KAccountSummaryPageDecl, public WizardPage<Wizard> | | |||
443 | { | | |||
444 | Q_OBJECT | | |||
445 | public: | | |||
446 | AccountSummaryPage(Wizard* parent); | | |||
447 | void enterPage(void); | | |||
448 | QWidget* initialFocusWidget(void) const { | | |||
449 | return m_dataList; | | |||
450 | } | | |||
451 | }; | | |||
452 | | ||||
453 | } // namespace | 98 | } // namespace | ||
454 | 99 | | |||
455 | #endif | 100 | #endif | ||
Context not available. |