File indexing completed on 2024-05-12 16:42:02
0001 /* 0002 SPDX-FileCopyrightText: 2007-2018 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef INVESTTRANSACTIONEDITOR_H 0008 #define INVESTTRANSACTIONEDITOR_H 0009 0010 // ---------------------------------------------------------------------------- 0011 // QT Includes 0012 0013 // ---------------------------------------------------------------------------- 0014 // KDE Includes 0015 0016 // ---------------------------------------------------------------------------- 0017 // Project Includes 0018 0019 #include "transactioneditor.h" 0020 0021 class MyMoneyMoney; 0022 class MyMoneySecurity; 0023 0024 namespace eDialogs { 0025 enum class PriceMode; 0026 } 0027 0028 namespace KMyMoneyRegister { 0029 class InvestTransaction; 0030 } 0031 0032 namespace eMyMoney { 0033 namespace Split { 0034 enum class InvestmentTransactionType; 0035 } 0036 } 0037 0038 class InvestTransactionEditorPrivate; 0039 class InvestTransactionEditor : public TransactionEditor 0040 { 0041 Q_OBJECT 0042 Q_DISABLE_COPY(InvestTransactionEditor) 0043 0044 public: 0045 InvestTransactionEditor(); 0046 explicit InvestTransactionEditor(TransactionEditorContainer* regForm, 0047 KMyMoneyRegister::InvestTransaction* item, 0048 const KMyMoneyRegister::SelectedTransactions& list, 0049 const QDate& lastPostDate); 0050 ~InvestTransactionEditor() override; 0051 0052 /** 0053 * This method returns information about the completeness of the data 0054 * entered. This can be used to control the availability of the 0055 * 'Enter transaction' action. 0056 * 0057 * @retval true if entering the transaction into the engine 0058 * @retval false if not enough information is present to enter the 0059 * transaction into the engine 0060 * 0061 * @param reason will be filled with a string about the reason why the 0062 * completeness is not reached. Empty if the return value 0063 * is @c true. 0064 * 0065 * @sa transactionDataSufficient() 0066 */ 0067 bool isComplete(QString& reason) const override; 0068 0069 QWidget* firstWidget() const override; 0070 0071 bool fixTransactionCommodity(const MyMoneyAccount& /* account */) override; 0072 0073 MyMoneyMoney totalAmount() const; 0074 0075 bool setupPrice(const MyMoneyTransaction& t, MyMoneySplit& split); 0076 0077 /** 0078 * This method creates a transaction based on the contents of the current widgets, 0079 * the splits in m_split in single selection mode or an existing transaction/split 0080 * and the contents of the widgets in multi selection mode. 0081 * 0082 * The split referencing the current account is returned as the first split in the 0083 * transaction's split list. 0084 * 0085 * @param t reference to created transaction 0086 * @param torig the original transaction 0087 * @param sorig the original split 0088 * 0089 * @param skipPriceDialog if @p true the user will not be requested for price information 0090 * (defaults to @p false) 0091 * 0092 * @return @p false if aborted by user, @p true otherwise 0093 * 0094 * @note Usually not used directly. If unsure, use enterTransactions() instead. 0095 */ 0096 bool createTransaction(MyMoneyTransaction& t, 0097 const MyMoneyTransaction& torig, 0098 const MyMoneySplit& sorig, 0099 bool skipPriceDialog = false) override; 0100 0101 eDialogs::PriceMode priceMode() const; 0102 0103 MyMoneySecurity security() const; 0104 0105 QList<MyMoneySplit> feeSplits() const; 0106 QList<MyMoneySplit> interestSplits() const; 0107 0108 protected Q_SLOTS: 0109 void slotCreateSecurity(const QString& name, QString& id); 0110 void slotCreateFeeCategory(const QString& name, QString& id); 0111 void slotCreateInterestCategory(const QString& name, QString& id); 0112 0113 int slotEditInterestSplits(); 0114 int slotEditFeeSplits(); 0115 void slotReloadEditWidgets(); 0116 0117 void slotUpdateActivity(eMyMoney::Split::InvestmentTransactionType); 0118 void slotUpdateSecurity(const QString& stockId); 0119 void slotUpdateInterestCategory(const QString& id); 0120 void slotUpdateFeeCategory(const QString& id); 0121 void slotUpdateTotalAmount(); 0122 void slotTransactionContainerGeometriesUpdated(); 0123 void slotUpdateInvestMemoState(); 0124 0125 protected: 0126 /** 0127 * This method creates all necessary widgets for this transaction editor. 0128 * All signals will be connected to the relevant slots. 0129 */ 0130 void createEditWidgets() override; 0131 0132 /** 0133 * This method (re-)loads the widgets with the transaction information 0134 * contained in @a m_transaction and @a m_split. 0135 * 0136 * @param action preset the edit widgets for @a action if no transaction 0137 * is present 0138 */ 0139 void loadEditWidgets(eWidgets::eRegister::Action action) override; 0140 void loadEditWidgets() override; 0141 0142 void setupFinalWidgets() override; 0143 0144 private: 0145 Q_DECLARE_PRIVATE(InvestTransactionEditor) 0146 }; 0147 0148 #endif // INVESTTRANSACTIONEDITOR_H