1 /* 2 * Copyright 2000-2003 Michael Edwardes <mte@users.sourceforge.net> 3 * Copyright 2005-2018 Thomas Baumgart <tbaumgart@kde.org> 4 * Copyright 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef KNEWACCOUNTDLG_H 21 #define KNEWACCOUNTDLG_H 22 23 // ---------------------------------------------------------------------------- 24 // QT Includes 25 26 #include <QDialog> 27 28 // ---------------------------------------------------------------------------- 29 // KDE Headers 30 31 // ---------------------------------------------------------------------------- 32 // Project Includes 33 34 class QString; 35 class QItemSelection; 36 37 class MyMoneyMoney; 38 class MyMoneyAccount; 39 40 class KNewAccountDlgPrivate; 41 class KNewAccountDlg : public QDialog 42 { 43 Q_OBJECT 44 45 public: 46 /** 47 * This is the constructor of the dialog. The parameters define the environment 48 * in which the dialog will be used. Depending on the environment, certain rules 49 * apply and will be handled by the dialog. 50 * 51 * @param account The original data to be used to create the account. In case 52 * of @p isEditing is false, the account id, the parent account id 53 * and the list of all child accounts will be cleared. 54 * @param isEditing If @p false, rules for new account creation apply. 55 * If @p true, rules for account editing apply 56 * @param categoryEditor If @p false, rules for asset/liability accounts apply. 57 * If @p true, rules for income/expense account apply. 58 * @param parent Pointer to parent object (passed to QDialog). Default is 0. 59 * @param title Caption of the object (passed to QDialog). Default is empty string. 60 */ 61 KNewAccountDlg(const MyMoneyAccount& account, bool isEditing, bool categoryEditor, QWidget *parent, const QString& title); 62 63 /** 64 * This method returns the edited account object. 65 */ 66 MyMoneyAccount account(); 67 68 /** 69 * This method returns the parent account of the edited account object. 70 */ 71 MyMoneyAccount parentAccount() const; 72 73 MyMoneyMoney openingBalance() const; 74 void setOpeningBalance(const MyMoneyMoney& balance); 75 76 void setOpeningBalanceShown(bool shown); 77 void setOpeningDateShown(bool shown); 78 79 /** 80 * This method adds an additional tab pointed to with @a w to the tab widget. 81 * This tab is usually defined by a plugin (eg. online banking). If @a w is 82 * zero, this is a NOP. @a name is used as the text to be placed on the tab. 83 */ 84 void addTab(QWidget* w, const QString& name); 85 86 /** 87 * Brings up the new category editor and saves the information. 88 * The dialog will be preset with the name and parent account. 89 * 90 * @param account reference of category to be created. The @p name member 91 * should be filled by the caller. The object will be filled 92 * with additional information during the creation process 93 * esp. the @p id member. 94 * @param parent reference to parent account (defaults to none) 95 */ 96 static void newCategory(MyMoneyAccount& account, const MyMoneyAccount& parent); 97 98 /** 99 * This method opens the category editor with the data found in @a account. The 100 * parent account is preset to @a parent but can be modified. If the user 101 * acknowledges, the category is created. 102 */ 103 static void createCategory(MyMoneyAccount& account, const MyMoneyAccount& parent); 104 105 protected Q_SLOTS: 106 void okClicked(); 107 void slotSelectionChanged(const QItemSelection ¤t, const QItemSelection &previous); 108 void slotAccountTypeChanged(int index); 109 void slotVatChanged(bool); 110 void slotVatAssignmentChanged(bool); 111 void slotNewClicked(); 112 void slotCheckFinished(); 113 void slotLoadInstitutions(const QString&); 114 void slotAdjustMinBalanceAbsoluteEdit(const QString&); 115 void slotAdjustMinBalanceEarlyEdit(const QString&); 116 void slotAdjustMaxCreditAbsoluteEdit(const QString&); 117 void slotAdjustMaxCreditEarlyEdit(const QString&); 118 void slotCheckCurrency(int index); 119 120 private: 121 Q_DISABLE_COPY(KNewAccountDlg) 122 Q_DECLARE_PRIVATE(KNewAccountDlg) 123 KNewAccountDlgPrivate* d_ptr; 124 }; 125 126 #endif 127 128