1/*
2 SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef EXPANDING_WIDGET_MODEL_H
8#define EXPANDING_WIDGET_MODEL_H
9
10#include <QAbstractTableModel>
11#include <QIcon>
12#include <QPointer>
13
14class QTreeView;
15
16/**
17 * Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate
18 */
19// TODO: Merge this into KateCompletionModel
20class ExpandingWidgetModel : public QAbstractItemModel
21{
22public:
23 explicit ExpandingWidgetModel(QWidget *parent);
24 ~ExpandingWidgetModel() override;
25
26 enum ExpandingType { NotExpandable = 0, Expandable, Expanded };
27
28 virtual QTreeView *treeView() const = 0;
29
30 /// Should return true if the given row should be painted like a contained item(as opposed to label-rows etc.)
31 virtual bool indexIsItem(const QModelIndex &index) const = 0;
32
33 /// Does not request data from index, this only returns local data like highlighting for expanded rows and similar
34 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
35
36 /// Returns the match-color for the given index, or zero if match-quality could not be computed.
37 uint matchColor(const QModelIndex &index) const;
38
39protected:
40 /**
41 * @return the context-match quality from 0 to 10 if it could be determined, else -1
42 * */
43 virtual int contextMatchQuality(const QModelIndex &index) const = 0;
44};
45
46/**
47 * Helper-function to merge custom-highlighting variant-lists.
48 *
49 * @param strings A list of strings that should be merged
50 * @param highlights One variant-list for highlighting, as described in the kde header ktextedtor/codecompletionmodel.h
51 * @param gapBetweenStrings How many signs are inserted between 2 strings?
52 * */
53QList<QVariant> mergeCustomHighlighting(QStringList strings, QList<QVariantList> highlights, int gapBetweenStrings = 0);
54#endif
55

source code of ktexteditor/src/completion/expandingtree/expandingwidgetmodel.h