1/*
2 SPDX-FileCopyrightText: 2012-2018 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATE_COLOR_TREE_WIDGET_H
8#define KATE_COLOR_TREE_WIDGET_H
9
10#include <QTreeWidget>
11
12#include <KSyntaxHighlighting/Theme>
13
14class KateColorItem
15{
16public:
17 KateColorItem(KSyntaxHighlighting::Theme::EditorColorRole _role = KSyntaxHighlighting::Theme::BackgroundColor)
18 : role(_role)
19 {
20 }
21
22 KSyntaxHighlighting::Theme::EditorColorRole role;
23 QString name; // translated name
24 QString category; // translated category for tree view hierarchy
25 QString whatsThis; // what's this info
26 QString key; // untranslated id, used as key to save/load from KConfig
27 QColor color; // user visible color
28 QColor defaultColor; // used when "Default" is clicked
29 bool useDefault = true; // flag whether to use the default color
30};
31
32class KateColorTreeWidget : public QTreeWidget
33{
34 Q_OBJECT
35 friend class KateColorTreeItem;
36 friend class KateColorTreeDelegate;
37
38public:
39 explicit KateColorTreeWidget(QWidget *parent = nullptr);
40
41public:
42 void addColorItem(const KateColorItem &colorItem);
43 void addColorItems(const QList<KateColorItem> &colorItems);
44
45 QList<KateColorItem> colorItems() const;
46
47 QColor findColor(const QString &key) const;
48
49 bool readOnly() const;
50 void setReadOnly(bool readOnly);
51
52public Q_SLOTS:
53 void selectDefaults();
54
55Q_SIGNALS:
56 void changed();
57
58protected:
59 bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) override;
60 void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const override;
61
62private:
63 bool m_readOnly = false;
64};
65
66#endif
67

source code of ktexteditor/src/syntax/katecolortreewidget.h