File indexing completed on 2024-05-12 05:07:49

0001 /*
0002     SPDX-FileCopyrightText: 2015-2019 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef NEWTRANSACTIONEDITOR_H
0007 #define NEWTRANSACTIONEDITOR_H
0008 
0009 // ----------------------------------------------------------------------------
0010 // QT Includes
0011 
0012 #include <QFrame>
0013 class QWidget;
0014 
0015 // ----------------------------------------------------------------------------
0016 // Project Includes
0017 
0018 #include "mymoneymoney.h"
0019 #include "mymoneytransaction.h"
0020 #include "tabordereditor.h"
0021 #include "transactioneditorbase.h"
0022 
0023 class MyMoneySchedule;
0024 
0025 class NewTransactionEditor : public TransactionEditorBase, TabOrderEditorInterface
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     explicit NewTransactionEditor(QWidget* parent = nullptr, const QString& accountId = QString());
0031     virtual ~NewTransactionEditor();
0032 
0033     /**
0034      * Returns the currently entered amount
0035      */
0036     MyMoneyMoney transactionAmount() const;
0037 
0038     /**
0039      */
0040     void loadTransaction(const QModelIndex& index) override;
0041     QStringList saveTransaction(const QStringList& selectedJournalEntries) override;
0042 
0043     void setAmountPlaceHolderText(const QAbstractItemModel* model) override;
0044 
0045     MyMoneyTransaction transaction() const;
0046 
0047     void loadSchedule(const MyMoneySchedule& schedule);
0048 
0049     /**
0050      * Reimplemented to suppress some events in certain conditions
0051      */
0052     bool eventFilter(QObject* o, QEvent* e) override;
0053 
0054     void setShowAccountCombo(bool show) const;
0055     void setShowNumberWidget(bool show) const;
0056     void setShowButtons(bool show) const;
0057     void setAccountId(const QString& accountId);
0058 
0059     QDate postDate() const;
0060 
0061     /// overridden for internal reasons
0062     void setReadOnly(bool readOnly) override;
0063 
0064     // Implement TabOrderEditorInterface methods
0065     void setupUi(QWidget* parent) override;
0066     void storeTabOrder(const QStringList& tabOrder) override;
0067 
0068     /**
0069      * This method is used to embed the transaction editor in other dialogs
0070      * e.g. KEditScheduleDlg
0071      */
0072     virtual WidgetHintFrameCollection* widgetHintFrameCollection() const override;
0073 
0074     void setKeepCategoryAmount(bool keepCategoryAmount);
0075 
0076 protected:
0077     bool isTransactionDataValid() const override;
0078 
0079 public Q_SLOTS:
0080     void slotSettingsChanged() override;
0081 
0082 protected Q_SLOTS:
0083     // edit splits directly
0084     virtual void editSplits();
0085 
0086 Q_SIGNALS:
0087     void postDateChanged(const QDate& date);
0088     void categorySelectionChanged();
0089 
0090 private:
0091     class Private;
0092     QScopedPointer<Private> const d;
0093     static QDate  m_lastPostDateUsed;
0094 };
0095 
0096 #endif // NEWTRANSACTIONEDITOR_H
0097