File indexing completed on 2024-04-28 03:57:22
0001 /* 0002 SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef EXPANDING_WIDGET_MODEL_H 0008 #define EXPANDING_WIDGET_MODEL_H 0009 0010 #include <QAbstractTableModel> 0011 #include <QIcon> 0012 #include <QPointer> 0013 0014 class QTreeView; 0015 0016 /** 0017 * Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate 0018 */ 0019 // TODO: Merge this into KateCompletionModel 0020 class ExpandingWidgetModel : public QAbstractItemModel 0021 { 0022 public: 0023 explicit ExpandingWidgetModel(QWidget *parent); 0024 ~ExpandingWidgetModel() override; 0025 0026 enum ExpandingType { NotExpandable = 0, Expandable, Expanded }; 0027 0028 virtual QTreeView *treeView() const = 0; 0029 0030 /// Should return true if the given row should be painted like a contained item(as opposed to label-rows etc.) 0031 virtual bool indexIsItem(const QModelIndex &index) const = 0; 0032 0033 /// Does not request data from index, this only returns local data like highlighting for expanded rows and similar 0034 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0035 0036 /// Returns the match-color for the given index, or zero if match-quality could not be computed. 0037 uint matchColor(const QModelIndex &index) const; 0038 0039 protected: 0040 /** 0041 * @return the context-match quality from 0 to 10 if it could be determined, else -1 0042 * */ 0043 virtual int contextMatchQuality(const QModelIndex &index) const = 0; 0044 }; 0045 0046 /** 0047 * Helper-function to merge custom-highlighting variant-lists. 0048 * 0049 * @param strings A list of strings that should be merged 0050 * @param highlights One variant-list for highlighting, as described in the kde header ktextedtor/codecompletionmodel.h 0051 * @param gapBetweenStrings How many signs are inserted between 2 strings? 0052 * */ 0053 QList<QVariant> mergeCustomHighlighting(QStringList strings, QList<QVariantList> highlights, int gapBetweenStrings = 0); 0054 #endif