File indexing completed on 2024-03-24 04:00:33
0001 /* 0002 SPDX-FileCopyrightText: 2001-2003 Christoph Cullmann <cullmann@kde.org> 0003 SPDX-FileCopyrightText: 2002, 2003 Anders Lund <anders.lund@lund.tdcadsl.dk> 0004 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org> 0005 SPDX-FileCopyrightText: 2007 Mirko Stocker <me@misto.ch> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef KATESTYLETREEWIDGET_H 0011 #define KATESTYLETREEWIDGET_H 0012 0013 #include <QTreeWidget> 0014 0015 #include "attribute.h" 0016 0017 /** 0018 * QTreeWidget that automatically adds columns for KateStyleListItems and provides a 0019 * popup menu and a slot to edit a style using the keyboard. 0020 * Added by anders, jan 23 2002. 0021 */ 0022 class KateStyleTreeWidget : public QTreeWidget 0023 { 0024 Q_OBJECT 0025 0026 friend class KateStyleListItem; 0027 0028 public: 0029 explicit KateStyleTreeWidget(QWidget *parent = nullptr, bool showUseDefaults = false); 0030 0031 void emitChanged(); 0032 0033 void addItem(QTreeWidgetItem *parent, 0034 const QString &styleName, 0035 KTextEditor::Attribute::Ptr defaultstyle, 0036 KTextEditor::Attribute::Ptr data = KTextEditor::Attribute::Ptr()); 0037 void addItem(const QString &styleName, KTextEditor::Attribute::Ptr defaultstyle, KTextEditor::Attribute::Ptr data = KTextEditor::Attribute::Ptr()); 0038 0039 void resizeColumns(); 0040 0041 bool readOnly() const; 0042 void setReadOnly(bool readOnly); 0043 0044 Q_SIGNALS: 0045 void changed(); 0046 0047 protected: 0048 void contextMenuEvent(QContextMenuEvent *event) override; 0049 void showEvent(QShowEvent *event) override; 0050 bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) override; 0051 0052 private Q_SLOTS: 0053 void changeProperty(); 0054 void unsetColor(); 0055 void updateGroupHeadings(); 0056 0057 private: 0058 bool m_readOnly = false; 0059 }; 0060 0061 #endif