File indexing completed on 2024-05-12 05:06:06

0001 /*
0002     SPDX-FileCopyrightText: 2003-2017 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-FileCopyrightText: 2016-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KACCOUNTSELECTDLG_H
0008 #define KACCOUNTSELECTDLG_H
0009 
0010 #include "kmm_base_dialogs_export.h"
0011 
0012 // ----------------------------------------------------------------------------
0013 // QT Includes
0014 
0015 #include <QDialog>
0016 
0017 // ----------------------------------------------------------------------------
0018 // KDE Includes
0019 
0020 // ----------------------------------------------------------------------------
0021 // Project Includes
0022 
0023 /**
0024   * @author Thomas Baumgart
0025   */
0026 
0027 class MyMoneyAccount;
0028 class MyMoneyInstitution;
0029 
0030 namespace eDialogs {
0031 enum Category : int;
0032 }
0033 
0034 class KAccountSelectDlgPrivate;
0035 class KMM_BASE_DIALOGS_EXPORT KAccountSelectDlg : public QDialog
0036 {
0037     Q_OBJECT
0038     Q_DISABLE_COPY(KAccountSelectDlg)
0039 
0040 public:
0041     explicit KAccountSelectDlg(const eDialogs::Category type, const QString& purpose, QWidget *parent = nullptr);
0042     ~KAccountSelectDlg();
0043 
0044     /**
0045       * This method is used to setup the descriptive text in the account
0046       * selection dialog box. The @p msg should contain a descriptive
0047       * text about the purpose of the dialog and it's options.
0048       *
0049       * @param msg const reference to QString object containing the text.
0050       */
0051     void setDescription(const QString& msg);
0052 
0053     /**
0054       * This method is used to setup the buddy text of the account
0055       * selection box. the @p msg should contain a short text
0056       * which is placed above the selection box with the account
0057       * names.
0058       *
0059       * @param msg const reference to QString object containing the text.
0060       */
0061     void setHeader(const QString& msg);
0062 
0063     /**
0064       * This method is used to pass information to the account selection
0065       * dialog which will be used as initial selection in the account
0066       * selection combo box and during account creation.
0067       *
0068       * @param account MyMoneyAccount filled with the relevant and available information
0069       * @param id account id to be used.
0070       */
0071     void setAccount(const MyMoneyAccount& account, const QString& id);
0072 
0073     /**
0074       * This method returns the name of the selected account in the combo box.
0075       *
0076       * @return QString containing the id of the selected account
0077       */
0078     QString selectedAccount() const;
0079 
0080     /**
0081       * This method is used to set the mode of the dialog. Two modes
0082       * are supplied: a) select or create and b) create only.
0083       * If @p mode is 0, select or create is selected, otherwise create only
0084       * is selected.
0085       *
0086       * @param mode selected mode
0087       */
0088     void setMode(const int mode);
0089 
0090     /**
0091       * This method allows to control the visibility of the abort button
0092       * in this dialog according to the parameter @p visible.
0093       *
0094       * @param visible @p true shows the abort button, @p false hides it.
0095       */
0096     void showAbortButton(const bool visible);
0097 
0098     /**
0099       * This method is used to determine if the user pressed the 'Skip' or
0100       * the 'Abort' button. The return value is valid only, if the exec()
0101       * function of the dialog returns false.
0102       *
0103       * @retval false Dialog was left using the 'Skip' button
0104       * @retval true Dialog was left using the 'Abort' button
0105       */
0106     bool aborted() const;
0107 
0108     void hideQifEntry();
0109 
0110 public Q_SLOTS:
0111     /**
0112       * Reimplemented from QDialog
0113       */
0114     int exec() override;
0115 
0116 protected Q_SLOTS:
0117     /**
0118       * This slot is used to fire up the new account wizard and preset it
0119       * with the values found in m_account. If an account was created using
0120       * the wizard, this will be the selected account.
0121       */
0122     void slotCreateAccount();
0123 
0124     /**
0125       * This slot is used to react on the abort button
0126       */
0127     void abort();
0128 
0129 Q_SIGNALS:
0130     void createAccount(MyMoneyAccount& account);
0131     void createCategory(MyMoneyAccount& account, const MyMoneyAccount& parent);
0132 
0133 private:
0134     KAccountSelectDlgPrivate * const d_ptr;
0135     Q_DECLARE_PRIVATE(KAccountSelectDlg)
0136 };
0137 
0138 #endif
0139 
0140 // kate: space-indent on; indent-width 2; remove-trailing-space on; remove-trailing-space-save on;