File indexing completed on 2024-05-12 16:43:44
0001 /* 0002 SPDX-FileCopyrightText: 2000-2002 Michael Edwardes <mte@users.sourceforge.net> 0003 SPDX-FileCopyrightText: 2000-2002 Javier Campos Morales <javi_c@users.sourceforge.net> 0004 SPDX-FileCopyrightText: 2000-2002 Felix Rodriguez <frodriguez@users.sourceforge.net> 0005 SPDX-FileCopyrightText: 2000-2002 John C <thetacoturtle@users.sourceforge.net> 0006 SPDX-FileCopyrightText: 2000-2002 Thomas Baumgart <ipwizard@users.sourceforge.net> 0007 SPDX-FileCopyrightText: 2000-2002 Kevin Tambascio <ktambascio@users.sourceforge.net> 0008 SPDX-FileCopyrightText: 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #ifndef KGLOBALLEDGERVIEW_H 0013 #define KGLOBALLEDGERVIEW_H 0014 0015 // ---------------------------------------------------------------------------- 0016 // QT Includes 0017 0018 // ---------------------------------------------------------------------------- 0019 // KDE Includes 0020 0021 // ---------------------------------------------------------------------------- 0022 // Project Includes 0023 0024 #include "kmymoneyviewbase.h" 0025 #include "mymoneytransaction.h" 0026 #include "mymoneysplit.h" 0027 0028 class MyMoneyAccount; 0029 class MyMoneyReport; 0030 class MyMoneySplit; 0031 class MyMoneyTransaction; 0032 class TransactionEditor; 0033 0034 namespace KMyMoneyRegister { 0035 class SelectedTransactions; 0036 class RegisterItem; 0037 class Transaction; 0038 } 0039 namespace KMyMoneyTransactionForm { 0040 class TransactionForm; 0041 } 0042 namespace eWidgets { 0043 namespace eRegister { 0044 enum class Action; 0045 } 0046 } 0047 namespace eMyMoney { 0048 namespace Schedule { 0049 enum class Occurrence; 0050 } 0051 } 0052 0053 template <class T1, class T2> struct QPair; 0054 template <typename T> class QList; 0055 0056 /** 0057 * @author Thomas Baumgart 0058 */ 0059 class KGlobalLedgerViewPrivate; 0060 class KGlobalLedgerView : public KMyMoneyViewBase 0061 { 0062 Q_OBJECT 0063 public: 0064 explicit KGlobalLedgerView(QWidget *parent = nullptr); 0065 ~KGlobalLedgerView() override; 0066 0067 void executeCustomAction(eView::Action action) override; 0068 void refresh(); 0069 void updateActions(const MyMoneyObject& obj); 0070 void updateLedgerActions(const KMyMoneyRegister::SelectedTransactions& list); 0071 void updateLedgerActionsInternal(); 0072 0073 /** 0074 * This method returns the id of the currently selected account 0075 * or QString() if none is selected. 0076 */ 0077 QString accountId() const; 0078 0079 /** 0080 * Checks if new transactions can be created in the current context 0081 * 0082 * @param tooltip reference to string receiving the tooltip text 0083 * which explains why the modify function is not available (in case 0084 * of returning @c false) 0085 * 0086 * @retval true Yes, view allows to create transactions (tooltip is not changed) 0087 * @retval false No, view does not support creation of transactions (tooltip is updated with message) 0088 */ 0089 bool canCreateTransactions(QString& tooltip) const; 0090 0091 /** 0092 * Checks if a list of transactions can be modified (edit/delete) in the current context 0093 * 0094 * @param list list of selected transactions 0095 * @param tooltip reference to string receiving the tooltip text 0096 * which explains why the modify function is not available (in case 0097 * of returning @c false) 0098 * 0099 * @retval true Yes, view allows to edit/delete transactions (tooltip is not changed) 0100 * @retval false No, view cannot edit/delete transactions (tooltip is updated with message) 0101 */ 0102 bool canModifyTransactions(const KMyMoneyRegister::SelectedTransactions& list, QString& tooltip) const; 0103 0104 bool canDuplicateTransactions(const KMyMoneyRegister::SelectedTransactions& list, QString& tooltip) const; 0105 0106 /** 0107 * Checks if the list of transactions can be edited in the current context 0108 * 0109 * @param list list of selected transactions 0110 * @param tooltip reference to string receiving the tooltip text 0111 * which explains why the edit function is not available (in case 0112 * of returning @c false) 0113 * 0114 * @return @c true if edit operation is possible, @c false if not 0115 */ 0116 bool canEditTransactions(const KMyMoneyRegister::SelectedTransactions& list, QString& tooltip) const; 0117 0118 TransactionEditor* startEdit(const KMyMoneyRegister::SelectedTransactions& list); 0119 0120 /** 0121 * Method to prepare the ledger view to create a new transaction. 0122 * Returns if successful or not. 0123 * 0124 * retval true Empty transaction selected. 0125 * retval false Not successful (e.g. already editing a transaction) 0126 */ 0127 bool selectEmptyTransaction(); 0128 0129 public Q_SLOTS: 0130 /** 0131 * This slot is used to select the correct ledger view type for 0132 * the account specified by @p id in a specific mode. 0133 * 0134 * @param accountId Internal id used for the account to show 0135 * @param transactionId Internal id used for the transaction to select. 0136 * Default is QString() which will select the last 0137 * transaction in the ledger if not the same account 0138 * 0139 * @retval true selection of account referenced by @p id succeeded 0140 * @retval false selection of account failed 0141 */ 0142 void slotSelectAccount(const QString& accountId); 0143 bool slotSelectAccount(const QString& accountId, const QString& transactionId); 0144 0145 /** 0146 * This method is provided for convenience and acts as the method above. 0147 */ 0148 void slotSelectAccount(const MyMoneyObject& acc); 0149 0150 /** 0151 * Switch to reconciliation mode for account @a account. 0152 * If @a account is MyMoneyAccount() (the default), reconciliation mode 0153 * is turned off. 0154 * 0155 * @param account account for which reconciliation mode is activated. 0156 * Default is MyMoneyAccount(). 0157 * @param reconciliationDate date of statement 0158 * @param endingBalance The calculated ending balance for the statement 0159 * Default ist 0. 0160 */ 0161 void slotSetReconcileAccount(const MyMoneyAccount& account, const QDate& reconciliationDate, const MyMoneyMoney& endingBalance); 0162 void slotSetReconcileAccount(const MyMoneyAccount& account, const QDate& reconciliationDate); 0163 void slotSetReconcileAccount(const MyMoneyAccount& account); 0164 void slotSetReconcileAccount(); 0165 void slotShowTransactionMenu(const MyMoneySplit &sp); 0166 0167 /** 0168 * Slot that should be entered after entering all due scheduled transactions 0169 * @param req is requester that made request to enter scheduled transactions 0170 * it's here to avoid reconciliation in case of random entering of scheduled transactions request 0171 */ 0172 void slotContinueReconciliation(); 0173 0174 /** 0175 * Called, whenever the ledger view should pop up and a specific 0176 * transaction in an account should be shown. If @p transaction 0177 * is empty, the last transaction should be selected 0178 * 0179 * @param acc The ID of the account to be shown 0180 * @param transaction The ID of the transaction to be selected 0181 */ 0182 void slotLedgerSelected(const QString& _accId, const QString& transaction); 0183 0184 void slotSelectByObject(const MyMoneyObject& obj, eView::Intent intent) override; 0185 void slotSelectByVariant(const QVariantList& variant, eView::Intent intent) override; 0186 0187 Q_SIGNALS: 0188 /** 0189 * This signal is emitted, when a new report has been generated. A 0190 * 'generated' report is halfway between a default report and a custom 0191 * report. It's created by the system in response to the user's 0192 * request, and it's usually filtered to be a little more specific 0193 * than the usual default reports. 0194 * 0195 * The proper behaviour when getting this signal is to switch to the 0196 * reports view and display the report. But it should NOT be added 0197 * to the data file, unless the user customizes it further. That's 0198 * because the user can always come back to the ledger UI to generate 0199 * the report again. 0200 * 0201 * @param report reference to MyMoneyReport object that contains the report 0202 * details 0203 */ 0204 void reportGenerated(const MyMoneyReport& report); 0205 0206 /** 0207 * This signal is sent out, when the current selected transaction should 0208 * be marked different 0209 */ 0210 void toggleReconciliationFlag(); 0211 0212 protected: 0213 void showEvent(QShowEvent* event) override; 0214 void resizeEvent(QResizeEvent*) override; 0215 0216 /** 0217 * This method handles the focus of the keyboard. When in edit mode 0218 * (m_inEditMode is true) the keyboard focus is handled 0219 * according to the widgets that are referenced in m_tabOrderWidgets. 0220 * If not in edit mode, the base class functionality is provided. 0221 * 0222 * @param next true if forward-tab, false if backward-tab was 0223 * pressed by the user 0224 */ 0225 bool focusNextPrevChild(bool next) override; 0226 0227 bool eventFilter(QObject* o, QEvent* e) override; 0228 0229 private: 0230 Q_DECLARE_PRIVATE(KGlobalLedgerView) 0231 0232 private Q_SLOTS: 0233 0234 void slotTransactionsContextMenuRequested(); 0235 void slotLeaveEditMode(const KMyMoneyRegister::SelectedTransactions& list); 0236 0237 void slotSortOptions(); 0238 void slotToggleTransactionMark(KMyMoneyRegister::Transaction* t); 0239 0240 void slotKeepPostDate(const QDate&); 0241 0242 void slotAboutToSelectItem(KMyMoneyRegister::RegisterItem*, bool&); 0243 0244 void slotUpdateSummaryLine(const KMyMoneyRegister::SelectedTransactions&); 0245 0246 void slotMoveToAccount(const QString& id); 0247 void slotUpdateMoveToAccountMenu(); 0248 void slotObjectDestroyed(QObject* o); 0249 void slotCancelOrEnterTransactions(bool& okToSelect); 0250 void slotNewSchedule(const MyMoneyTransaction& _t, eMyMoney::Schedule::Occurrence occurrence); 0251 void slotNewTransactionForm(eWidgets::eRegister::Action); 0252 0253 void slotNewTransaction(); 0254 void slotEditTransaction(); 0255 void slotDeleteTransaction(); 0256 void slotDuplicateTransaction(bool reverse = false); 0257 void slotEnterTransaction(); 0258 0259 /** 0260 * Accept the selected transactions that are marked as 'imported' and remove the flag 0261 */ 0262 void slotAcceptTransaction(); 0263 void slotCancelTransaction(); 0264 void slotEditSplits(); 0265 0266 /** 0267 * This method takes the selected splits and checks that only one transaction (src) 0268 * has more than one split and all others have only a single one. It then copies the 0269 * splits of the @b src transaction to all others. 0270 */ 0271 void slotCopySplits(); 0272 void slotGoToPayee(); 0273 void slotGoToAccount(); 0274 void slotMatchTransactions(); 0275 void slotCombineTransactions(); 0276 void slotToggleReconciliationFlag(); 0277 void slotMarkCleared(); 0278 void slotMarkReconciled(); 0279 void slotMarkNotReconciled(); 0280 void slotSelectAllTransactions(); 0281 void slotCreateScheduledTransaction(); 0282 void slotAssignNumber(); 0283 void slotCopyTransactionToClipboard(); 0284 0285 /** 0286 * Used to start reconciliation of account @a account. It switches the 0287 * ledger view into reconciliation mode and updates the view. 0288 * 0289 * @param account account which should be reconciled 0290 * @param reconciliationDate the statement date 0291 * @param endingBalance the ending balance entered for this account 0292 * 0293 * @retval true Reconciliation started 0294 * @retval false Account cannot be reconciled 0295 */ 0296 void slotStartReconciliation(); 0297 0298 /** 0299 * Used to finish reconciliation of account @a account. It switches the 0300 * ledger view to normal mode and updates the view. 0301 * 0302 * @param account account which should be reconciled 0303 */ 0304 void slotFinishReconciliation(); 0305 void slotPostponeReconciliation(); 0306 void slotOpenAccount(); 0307 0308 /** 0309 * Brings up a dialog to let the user search for specific transaction(s). It then 0310 * opens a results window to display those transactions. 0311 */ 0312 void slotFindTransaction(); 0313 0314 /** 0315 * Destroys a possibly open the search dialog 0316 */ 0317 void slotCloseSearchDialog(); 0318 0319 void slotStatusMsg(const QString& txt); 0320 void slotStatusProgress(int cnt, int base); 0321 void slotTransactionsSelected(const KMyMoneyRegister::SelectedTransactions& list); 0322 }; 0323 0324 #endif