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 ONLINEBALANCEDELEGATE_H
0007 #define ONLINEBALANCEDELEGATE_H
0008 
0009 // ----------------------------------------------------------------------------
0010 // QT Includes
0011 
0012 class QColor;
0013 
0014 // ----------------------------------------------------------------------------
0015 // KDE Includes
0016 
0017 // ----------------------------------------------------------------------------
0018 // Project Includes
0019 
0020 #include "mymoneyenums.h"
0021 #include "kmmstyleditemdelegate.h"
0022 
0023 class LedgerView;
0024 class MyMoneyMoney;
0025 
0026 class OnlineBalanceDelegate : public KMMStyledItemDelegate
0027 {
0028     Q_OBJECT
0029 public:
0030     explicit OnlineBalanceDelegate(LedgerView* parent = 0);
0031     virtual ~OnlineBalanceDelegate();
0032 
0033     void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const final override;
0034     QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const final override;
0035 
0036     void setOnlineBalance(const QDate& date, const MyMoneyMoney& amount, int fraction = 0);
0037 
0038     /**
0039      * Which data (@a role) shall be displayed in the detail column
0040      * when only a single line is shown. The default is the payee.
0041      */
0042     void setSingleLineRole(eMyMoney::Model::Roles role);
0043 
0044     static void setErroneousColor(const QColor& color);
0045     static void setImportedColor(const QColor& color);
0046 
0047     static QColor erroneousColor();
0048 
0049 protected:
0050     bool eventFilter(QObject* o, QEvent* event) final override;
0051 
0052 private:
0053     class Private;
0054     Private * const d;
0055 
0056     static QColor m_erroneousColor;
0057     static QColor m_importedColor;
0058     static QColor m_separatorColor;
0059 };
0060 
0061 #endif // ONLINEBALANCEDELEGATE_H
0062