File indexing completed on 2024-05-12 16:42:09

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 // ----------------------------------------------------------------------------
0012 // QT Includes
0013 
0014 #include <QDialog>
0015 
0016 // ----------------------------------------------------------------------------
0017 // KDE Headers
0018 
0019 // ----------------------------------------------------------------------------
0020 // Project Includes
0021 
0022 class QString;
0023 class QItemSelection;
0024 
0025 class MyMoneyMoney;
0026 class MyMoneyAccount;
0027 
0028 class KNewAccountDlgPrivate;
0029 class KNewAccountDlg : public QDialog
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     /**
0035       * This is the constructor of the dialog. The parameters define the environment
0036       * in which the dialog will be used. Depending on the environment, certain rules
0037       * apply and will be handled by the dialog.
0038       *
0039       * @param account The original data to be used to create the account. In case
0040       *                of @p isEditing is false, the account id, the parent account id
0041       *                and the list of all child accounts will be cleared.
0042       * @param isEditing If @p false, rules for new account creation apply.
0043       *                  If @p true, rules for account editing apply
0044       * @param categoryEditor If @p false, rules for asset/liability accounts apply.
0045       *                       If @p true, rules for income/expense account apply.
0046       * @param parent Pointer to parent object (passed to QDialog). Default is 0.
0047       * @param title Caption of the object (passed to QDialog). Default is empty string.
0048       */
0049     KNewAccountDlg(const MyMoneyAccount& account, bool isEditing, bool categoryEditor, QWidget *parent, const QString& title);
0050 
0051     /**
0052       * This method returns the edited account object.
0053       */
0054     MyMoneyAccount account();
0055 
0056     /**
0057       * This method returns the parent account of the edited account object.
0058       */
0059     MyMoneyAccount parentAccount() const;
0060 
0061     MyMoneyMoney openingBalance() const;
0062     void setOpeningBalance(const MyMoneyMoney& balance);
0063 
0064     void setOpeningBalanceShown(bool shown);
0065     void setOpeningDateShown(bool shown);
0066 
0067     /**
0068      * This method adds an additional tab pointed to with @a w to the tab widget.
0069      * This tab is usually defined by a plugin (eg. online banking). If @a w is
0070      * zero, this is a NOP. @a name is used as the text to be placed on the tab.
0071      */
0072     void addTab(QWidget* w, const QString& name);
0073 
0074     /**
0075       * Brings up the new category editor and saves the information.
0076       * The dialog will be preset with the name and parent account.
0077       *
0078       * @param account reference of category to be created. The @p name member
0079       *                should be filled by the caller. The object will be filled
0080       *                with additional information during the creation process
0081       *                esp. the @p id member.
0082       * @param parent reference to parent account (defaults to none)
0083       */
0084     static void newCategory(MyMoneyAccount& account, const MyMoneyAccount& parent);
0085 
0086     /**
0087      * This method opens the category editor with the data found in @a account. The
0088      * parent account is preset to @a parent but can be modified. If the user
0089      * acknowledges, the category is created.
0090      */
0091     static void createCategory(MyMoneyAccount& account, const MyMoneyAccount& parent);
0092 
0093 protected Q_SLOTS:
0094     void okClicked();
0095     void slotSelectionChanged(const QItemSelection &current, const QItemSelection &previous);
0096     void slotAccountTypeChanged(int index);
0097     void slotVatChanged(bool);
0098     void slotVatAssignmentChanged(bool);
0099     void slotNewClicked();
0100     void slotCheckFinished();
0101     void slotLoadInstitutions(const QString&);
0102     void slotAdjustMinBalanceAbsoluteEdit(const QString&);
0103     void slotAdjustMinBalanceEarlyEdit(const QString&);
0104     void slotAdjustMaxCreditAbsoluteEdit(const QString&);
0105     void slotAdjustMaxCreditEarlyEdit(const QString&);
0106     void slotCheckCurrency(int index);
0107 
0108 private:
0109     Q_DISABLE_COPY(KNewAccountDlg)
0110     Q_DECLARE_PRIVATE(KNewAccountDlg)
0111     KNewAccountDlgPrivate* d_ptr;
0112 };
0113 
0114 #endif
0115