File indexing completed on 2024-05-12 16:43:54

0001 /*
0002     SPDX-FileCopyrightText: 2016 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 SplitDelegate : public QStyledItemDelegate
0021 {
0022     Q_OBJECT
0023 public:
0024     explicit SplitDelegate(QObject* parent = 0);
0025     virtual ~SplitDelegate();
0026 
0027     void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const final override;
0028     QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const final override;
0029     QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const final override;
0030     void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const final override;
0031     void setEditorData(QWidget* editWidget, const QModelIndex& index) const final override;
0032 
0033     void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const final override;
0034 
0035     /**
0036      * This method returns the row that currently has an editor
0037      * or -1 if no editor is open
0038      */
0039     virtual int editorRow() const;
0040 
0041     void setShowValuesInverted(bool inverse);
0042     bool showValuesInverted();
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 protected Q_SLOTS:
0053     void endEdit();
0054 
0055 Q_SIGNALS:
0056     void sizeHintChanged(const QModelIndex&) const;
0057 
0058 private:
0059     class Private;
0060     Private * const d;
0061 
0062     static QColor m_erroneousColor;
0063     static QColor m_importedColor;
0064 };
0065 
0066 #endif // SPLITDELEGATE_H
0067