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