KTextEditor

katecolortreewidget.h
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:
18 : role(_role)
19 {
20 }
21
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{
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
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
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
virtual bool event(QEvent *e) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Feb 24 2024 20:00:58 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.