| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2001-2003 Christoph Cullmann <cullmann@kde.org> |
| 3 | SPDX-FileCopyrightText: 2002, 2003 Anders Lund <anders.lund@lund.tdcadsl.dk> |
| 4 | SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org> |
| 5 | SPDX-FileCopyrightText: 2007 Mirko Stocker <me@misto.ch> |
| 6 | |
| 7 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 8 | */ |
| 9 | |
| 10 | #ifndef KATESTYLETREEWIDGET_H |
| 11 | #define KATESTYLETREEWIDGET_H |
| 12 | |
| 13 | #include <QTreeWidget> |
| 14 | |
| 15 | #include "attribute.h" |
| 16 | |
| 17 | /** |
| 18 | * QTreeWidget that automatically adds columns for KateStyleListItems and provides a |
| 19 | * popup menu and a slot to edit a style using the keyboard. |
| 20 | * Added by anders, jan 23 2002. |
| 21 | */ |
| 22 | class KateStyleTreeWidget : public QTreeWidget |
| 23 | { |
| 24 | Q_OBJECT |
| 25 | |
| 26 | friend class KateStyleListItem; |
| 27 | |
| 28 | public: |
| 29 | explicit KateStyleTreeWidget(QWidget *parent = nullptr, bool showUseDefaults = false); |
| 30 | |
| 31 | void emitChanged(); |
| 32 | |
| 33 | void addItem(QTreeWidgetItem *parent, |
| 34 | const QString &styleName, |
| 35 | KTextEditor::Attribute::Ptr defaultstyle, |
| 36 | KTextEditor::Attribute::Ptr data = KTextEditor::Attribute::Ptr()); |
| 37 | void addItem(const QString &styleName, KTextEditor::Attribute::Ptr defaultstyle, KTextEditor::Attribute::Ptr data = KTextEditor::Attribute::Ptr()); |
| 38 | |
| 39 | void resizeColumns(); |
| 40 | |
| 41 | bool readOnly() const; |
| 42 | void setReadOnly(bool readOnly); |
| 43 | |
| 44 | Q_SIGNALS: |
| 45 | void changed(); |
| 46 | |
| 47 | protected: |
| 48 | void (QContextMenuEvent *event) override; |
| 49 | void showEvent(QShowEvent *event) override; |
| 50 | bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) override; |
| 51 | |
| 52 | private Q_SLOTS: |
| 53 | void changeProperty(); |
| 54 | void unsetColor(); |
| 55 | void updateGroupHeadings(); |
| 56 | |
| 57 | private: |
| 58 | bool m_readOnly = false; |
| 59 | }; |
| 60 | |
| 61 | #endif |
| 62 | |