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

0001 /*
0002     SPDX-FileCopyrightText: 2016-2020 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 
0007 #ifndef NEWSPLITEDITOR_H
0008 #define NEWSPLITEDITOR_H
0009 
0010 // ----------------------------------------------------------------------------
0011 // QT Includes
0012 
0013 #include <QScopedPointer>
0014 #include <QWidget>
0015 class QAbstractItemModel;
0016 class QWidget;
0017 
0018 // ----------------------------------------------------------------------------
0019 // KDE Includes
0020 
0021 // ----------------------------------------------------------------------------
0022 // Project Includes
0023 
0024 #include "mymoneymoney.h"
0025 #include "tabordereditor.h"
0026 
0027 class MyMoneySecurity;
0028 
0029 class NewSplitEditor : public QWidget, TabOrderEditorInterface
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     /**
0035      * @a accountId is the current account displayed for the transaction
0036      */
0037     explicit NewSplitEditor(QWidget* parent, const MyMoneySecurity& commodity, const QString& accountId = QString());
0038     virtual ~NewSplitEditor();
0039 
0040     /**
0041      * This method returns true if the user pressed the enter button.
0042      * It remains false, in case the user pressed the cancel button.
0043      */
0044     virtual bool accepted() const;
0045 
0046     void setShowValuesInverted(bool inverse);
0047     bool showValuesInverted();
0048 
0049     void setPostDate(const QDate& date);
0050 
0051     void startLoadingSplit();
0052     void finishLoadingSplit();
0053 
0054     void setAmountPlaceHolderText(const QAbstractItemModel* model);
0055     void setReadOnly(bool readOnly);
0056 
0057     // Implement TabOrderEditorInterface methods
0058     void setupUi(QWidget* parent) override;
0059     void storeTabOrder(const QStringList& tabOrder) override;
0060 
0061     /**
0062      * Returns the id of the selected account in the category widget
0063      */
0064     QString accountId() const;
0065     void setAccountId(const QString& id);
0066 
0067     /**
0068      * Returns the contents of the memo widget
0069      */
0070     QString memo() const;
0071     void setMemo(const QString& memo);
0072 
0073     MyMoneyMoney value() const;
0074     void setValue(const MyMoneyMoney& amount);
0075 
0076     MyMoneyMoney shares() const;
0077     void setShares(const MyMoneyMoney& amount);
0078 
0079     QString costCenterId() const;
0080     void setCostCenterId(const QString& id);
0081 
0082     QString number() const;
0083     void setNumber(const QString& id);
0084 
0085     QString payeeId() const;
0086     void setPayeeId(const QString& id);
0087 
0088     QList<QString> tagIdList() const;
0089     void setTagIdList(const QList<QString>& tagIds);
0090 
0091 protected:
0092     void keyPressEvent(QKeyEvent* event) final override;
0093     bool focusNextPrevChild(bool next) override;
0094     bool eventFilter(QObject* o, QEvent* e) override;
0095 
0096 protected Q_SLOTS:
0097     virtual void reject();
0098     virtual void acceptEdit();
0099 
0100 Q_SIGNALS:
0101     void done();
0102     void transactionChanged(const QString&);
0103 
0104 private:
0105     struct Private;
0106     QScopedPointer<Private> d;
0107 };
0108 
0109 #endif // NEWSPLITEDITOR_H
0110