1/*
2 SPDX-FileCopyrightText: 2022 Waqar Ahmed <waqar.17a@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATECOMPLETIONDELEGATE_H
8#define KATECOMPLETIONDELEGATE_H
9
10// #include "expandingtree/expandingdelegate.h"
11#include <QStyledItemDelegate>
12#include <QTextLayout>
13
14class KateCompletionWidget;
15class KateCompletionModel;
16
17class KateCompletionDelegate : public QStyledItemDelegate
18{
19public:
20 explicit KateCompletionDelegate(QObject *parent);
21
22 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
23
24 QSize basicSizeHint(const QModelIndex &idx) const
25 {
26 return QStyledItemDelegate::sizeHint(option: {}, index: idx);
27 }
28
29protected:
30 static QList<QTextLayout::FormatRange> createHighlighting(const QModelIndex &index);
31
32 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
33
34 // This variable is used by ArgumentHintDelegate to put the text at the top of the item so that
35 // it isn't hidden by the expanding widget
36 mutable bool m_alignTop = false;
37};
38
39#endif
40

source code of ktexteditor/src/completion/katecompletiondelegate.h