File indexing completed on 2024-05-19 05:08:27
0001 /* 0002 SPDX-FileCopyrightText: 2016-2019 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef SPLITDELEGATE_H 0007 #define SPLITDELEGATE_H 0008 0009 // ---------------------------------------------------------------------------- 0010 // QT Includes 0011 0012 #include <QStyledItemDelegate> 0013 0014 // ---------------------------------------------------------------------------- 0015 // KDE Includes 0016 0017 // ---------------------------------------------------------------------------- 0018 // Project Includes 0019 0020 class MyMoneySecurity; 0021 0022 class SplitDelegate : public QStyledItemDelegate 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit SplitDelegate(QObject* parent = 0); 0027 virtual ~SplitDelegate(); 0028 0029 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const final override; 0030 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const final override; 0031 QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const final override; 0032 void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const final override; 0033 void setEditorData(QWidget* editWidget, const QModelIndex& index) const final override; 0034 0035 void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const final override; 0036 0037 /** 0038 * This method returns the row that currently has an editor 0039 * or -1 if no editor is open 0040 */ 0041 virtual int editorRow() const; 0042 0043 void setShowValuesInverted(bool inverse); 0044 bool showValuesInverted(); 0045 0046 void setCommodity(const MyMoneySecurity& commodity); 0047 void setTransactionPayeeId(const QString& id); 0048 void setReadOnlyMode(bool readOnly); 0049 0050 static void setErroneousColor(const QColor& color); 0051 static void setImportedColor(const QColor& color); 0052 0053 static QColor erroneousColor(); 0054 0055 protected: 0056 bool eventFilter(QObject* o, QEvent* event) final override; 0057 0058 protected Q_SLOTS: 0059 void endEdit(); 0060 0061 private: 0062 class Private; 0063 Private * const d; 0064 0065 static QColor m_erroneousColor; 0066 static QColor m_importedColor; 0067 }; 0068 0069 #endif // SPLITDELEGATE_H 0070