File indexing completed on 2024-04-21 03:57:20

0001 /*
0002     SPDX-FileCopyrightText: 2022 Waqar Ahmed <waqar.17a@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KATECOMPLETIONDELEGATE_H
0008 #define KATECOMPLETIONDELEGATE_H
0009 
0010 // #include "expandingtree/expandingdelegate.h"
0011 #include <QStyledItemDelegate>
0012 #include <QTextLayout>
0013 
0014 class KateCompletionWidget;
0015 class KateCompletionModel;
0016 
0017 class KateCompletionDelegate : public QStyledItemDelegate
0018 {
0019 public:
0020     explicit KateCompletionDelegate(QObject *parent);
0021 
0022     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0023 
0024     QSize basicSizeHint(const QModelIndex &idx) const
0025     {
0026         return QStyledItemDelegate::sizeHint({}, idx);
0027     }
0028 
0029 protected:
0030     static QList<QTextLayout::FormatRange> createHighlighting(const QModelIndex &index);
0031 
0032     QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0033 
0034     // This variable is used by ArgumentHintDelegate to put the text at the top of the item so that
0035     // it isn't hidden by the expanding widget
0036     mutable bool m_alignTop = false;
0037 };
0038 
0039 #endif