File indexing completed on 2024-05-19 05:06:52

0001 /*
0002     SPDX-FileCopyrightText: 2000-2003 Michael Edwardes <mte@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2005-2018 Thomas Baumgart <tbaumgart@kde.org>
0004     SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef KNEWACCOUNTDLG_H
0009 #define KNEWACCOUNTDLG_H
0010 
0011 #include "kmm_base_dialogs_export.h"
0012 
0013 // ----------------------------------------------------------------------------
0014 // QT Includes
0015 
0016 #include <QDialog>
0017 
0018 // ----------------------------------------------------------------------------
0019 // KDE Headers
0020 
0021 // ----------------------------------------------------------------------------
0022 // Project Includes
0023 
0024 class QString;
0025 class QItemSelection;
0026 
0027 class MyMoneyMoney;
0028 class MyMoneyAccount;
0029 
0030 class KNewAccountDlgPrivate;
0031 class KMM_BASE_DIALOGS_EXPORT KNewAccountDlg : public QDialog
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     /**
0037       * This is the constructor of the dialog. The parameters define the environment
0038       * in which the dialog will be used. Depending on the environment, certain rules
0039       * apply and will be handled by the dialog.
0040       *
0041       * @param account The original data to be used to create the account. In case
0042       *                of @p isEditing is false, the account id, the parent account id
0043       *                and the list of all child accounts will be cleared.
0044       * @param isEditing If @p false, rules for new account creation apply.
0045       *                  If @p true, rules for account editing apply
0046       * @param categoryEditor If @p false, rules for asset/liability accounts apply.
0047       *                       If @p true, rules for income/expense account apply.
0048       * @param parent Pointer to parent object (passed to QDialog). Default is 0.
0049       * @param title Caption of the object (passed to QDialog). Default is empty string.
0050       */
0051     KNewAccountDlg(const MyMoneyAccount& account, bool isEditing, bool categoryEditor, QWidget *parent, const QString& title);
0052 
0053     /**
0054       * This method returns the edited account object.
0055       */
0056     MyMoneyAccount account();
0057 
0058     /**
0059       * This method returns the parent account of the edited account object.
0060       */
0061     MyMoneyAccount parentAccount() const;
0062 
0063     MyMoneyMoney openingBalance() const;
0064     void setOpeningBalance(const MyMoneyMoney& balance);
0065 
0066     void setOpeningBalanceShown(bool shown);
0067     void setOpeningDateShown(bool shown);
0068 
0069     /**
0070      * This method adds an additional tab pointed to with @a w to the tab widget.
0071      * This tab is usually defined by a plugin (eg. online banking). If @a w is
0072      * zero, this is a NOP. @a name is used as the text to be placed on the tab.
0073      */
0074     void addTab(QWidget* w, const QString& name);
0075 
0076     /**
0077      * Brings up the new category editor and saves the information.
0078      * The dialog will be preset with the name and parent account.
0079      * In contrast to the createCategory() method, this method asks
0080      * the user if he really wants to create the object.
0081      *
0082      * @param account reference of category to be created. The @p name member
0083      *                should be filled by the caller. The object will be filled
0084      *                with additional information during the creation process
0085      *                esp. the @p id member.
0086      * @param parent reference to parent account (defaults to none)
0087      */
0088     static void newCategory(MyMoneyAccount& account, const MyMoneyAccount& parent);
0089 
0090     /**
0091      * Brings up the new account editor and saves the information.
0092      * The dialog will be preset with the name and parent account.
0093      * In contrast to the createAccount() method, this method asks
0094      * the user if he really wants to create the object.
0095      *
0096      * @param account reference of account to be created. The @p name member
0097      *                should be filled by the caller. The object will be filled
0098      *                with additional information during the creation process
0099      *                esp. the @p id member.
0100      * @param parent reference to parent account (defaults to none)
0101      */
0102     static void newAccount(MyMoneyAccount& account, const MyMoneyAccount& parent);
0103 
0104     /**
0105      * This method opens the category editor with the data found in @a account. The
0106      * parent account is preset to @a parent but can be modified. If the user
0107      * acknowledges, the category is created.
0108      */
0109     static void createCategory(MyMoneyAccount& account, const MyMoneyAccount& parent);
0110 
0111     /**
0112      * This method opens the account editor with the data found in @a account. The
0113      * parent account is preset to @a parent but can be modified. If the user
0114      * acknowledges, the account is created.
0115      */
0116     static void createAccount(MyMoneyAccount& account, const MyMoneyAccount& parent);
0117 
0118 protected Q_SLOTS:
0119     void okClicked();
0120     void slotSelectionChanged(const QItemSelection &current, const QItemSelection &previous);
0121     void slotAccountTypeChanged(int index);
0122     void slotVatChanged(bool);
0123     void slotVatAssignmentChanged(bool);
0124     void slotNewClicked();
0125     void slotCheckFinished();
0126     void slotLoadInstitutions(const QString&);
0127     void slotAdjustMinBalanceAbsoluteEdit();
0128     void slotAdjustMinBalanceEarlyEdit();
0129     void slotAdjustMaxCreditAbsoluteEdit();
0130     void slotAdjustMaxCreditEarlyEdit();
0131     void slotCheckCurrency(int index);
0132 
0133 private:
0134     Q_DISABLE_COPY(KNewAccountDlg)
0135     Q_DECLARE_PRIVATE(KNewAccountDlg)
0136     KNewAccountDlgPrivate* d_ptr;
0137 };
0138 
0139 #endif
0140