File indexing completed on 2024-05-12 16:42:10
0001 /* 0002 SPDX-FileCopyrightText: 2002 Michael Edwardes <mte@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2002-2011 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 KSPLITTRANSACTIONDLG_H 0009 #define KSPLITTRANSACTIONDLG_H 0010 0011 // ---------------------------------------------------------------------------- 0012 // QT Includes 0013 0014 #include <QDialog> 0015 0016 // ---------------------------------------------------------------------------- 0017 // KDE Includes 0018 0019 // ---------------------------------------------------------------------------- 0020 // Project Includes 0021 0022 class MyMoneyMoney; 0023 class MyMoneySplit; 0024 class MyMoneyTransaction; 0025 class MyMoneyAccount; 0026 class MyMoneyTag; 0027 0028 namespace Ui { 0029 class KSplitCorrectionDlg; 0030 } 0031 0032 class KSplitCorrectionDlg : public QDialog 0033 { 0034 Q_OBJECT 0035 Q_DISABLE_COPY(KSplitCorrectionDlg) 0036 0037 public: 0038 explicit KSplitCorrectionDlg(QWidget *parent = nullptr); 0039 ~KSplitCorrectionDlg(); 0040 0041 Ui::KSplitCorrectionDlg *ui; 0042 }; 0043 0044 /** 0045 * @author Thomas Baumgart 0046 */ 0047 0048 class KSplitTransactionDlgPrivate; 0049 class KSplitTransactionDlg : public QDialog 0050 { 0051 Q_OBJECT 0052 Q_DISABLE_COPY(KSplitTransactionDlg) 0053 0054 public: 0055 explicit KSplitTransactionDlg(const MyMoneyTransaction& t, 0056 const MyMoneySplit& s, 0057 const MyMoneyAccount& acc, 0058 const bool amountValid, 0059 const bool deposit, 0060 const MyMoneyMoney& calculatedValue, 0061 const QMap<QString, MyMoneyMoney>& priceInfo, 0062 QWidget* parent = nullptr); 0063 0064 ~KSplitTransactionDlg(); 0065 0066 /** 0067 * Using this method, an external object can retrieve the result 0068 * of the dialog. 0069 * 0070 * @return MyMoneyTransaction based on the transaction passes during 0071 * the construction of this object and modified using the 0072 * dialog. 0073 */ 0074 MyMoneyTransaction transaction() const; 0075 0076 /** 0077 * This method calculates the difference between the split that references 0078 * the account passed as argument to the constructor of this object and 0079 * all the other splits shown in the register of this dialog. 0080 * 0081 * @return difference as MyMoneyMoney object 0082 */ 0083 MyMoneyMoney diffAmount(); 0084 0085 /** 0086 * This method calculates the sum of the splits shown in the register 0087 * of this dialog. 0088 * 0089 * @return sum of splits as MyMoneyMoney object 0090 */ 0091 MyMoneyMoney splitsValue(); 0092 0093 /** 0094 * Setting @a readOnly to @c true forces the editor into readonly mode. 0095 * It does not allow to save any information, though it is possible to 0096 * change it in the editor. 0097 */ 0098 void setReadOnlyMode(bool readOnly); 0099 0100 public Q_SLOTS: 0101 int exec() override; 0102 0103 protected Q_SLOTS: 0104 void accept() override; 0105 void reject() override; 0106 void slotClearAllSplits(); 0107 void slotClearUnusedSplits(); 0108 void slotSetTransaction(const MyMoneyTransaction& t); 0109 void slotCreateCategory(const QString& txt, QString& id); 0110 void slotCreateTag(const QString &txt, QString &id); 0111 void slotUpdateButtons(); 0112 void slotMergeSplits(); 0113 void slotEditStarted(); 0114 0115 /// used internally to setup the initial size of all widgets 0116 void initSize(); 0117 0118 Q_SIGNALS: 0119 /** 0120 * This signal is sent out, when a new category needs to be created 0121 * Depending on the setting of either a payment or deposit, the parent 0122 * account will be preset to Expense or Income. 0123 * 0124 * @param account reference to account info. Will be filled by called slot 0125 * @param parent reference to parent account 0126 */ 0127 void createCategory(MyMoneyAccount& account, const MyMoneyAccount& parent); 0128 0129 /** 0130 * This signal is sent out, when a new tag needs to be created 0131 * @param txt The name of the tag to be created 0132 * @param id A connected slot should store the id of the created object in this variable 0133 */ 0134 void createTag(const QString& txt, QString& id); 0135 0136 /** 0137 * Signal is emitted, if any of the widgets enters (@a state equals @a true) 0138 * or leaves (@a state equals @a false) object creation mode. 0139 * 0140 * @param state Enter (@a true) or leave (@a false) object creation 0141 */ 0142 void objectCreation(bool state); 0143 0144 private: 0145 KSplitTransactionDlgPrivate * const d_ptr; 0146 Q_DECLARE_PRIVATE(KSplitTransactionDlg) 0147 }; 0148 0149 #endif