File indexing completed on 2024-05-12 15:50:07
0001 /* 0002 SPDX-FileCopyrightText: 2018 Eike Hein <hein@kde.org> 0003 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> 0004 0005 SPDX-License-Identifier: MIT 0006 */ 0007 0008 #ifndef KQUICKSYNTAXHIGHLIGHTER_H 0009 #define KQUICKSYNTAXHIGHLIGHTER_H 0010 0011 #include "repositorywrapper.h" 0012 0013 #include <KSyntaxHighlighting/Definition> 0014 #include <KSyntaxHighlighting/Theme> 0015 0016 #include <QObject> 0017 #include <QVariant> 0018 0019 namespace KSyntaxHighlighting 0020 { 0021 class Repository; 0022 class SyntaxHighlighter; 0023 } 0024 0025 class KQuickSyntaxHighlighter : public QObject 0026 { 0027 Q_OBJECT 0028 0029 Q_PROPERTY(QObject *textEdit READ textEdit WRITE setTextEdit NOTIFY textEditChanged) 0030 Q_PROPERTY(QVariant definition READ definition WRITE setDefinition NOTIFY definitionChanged) 0031 Q_PROPERTY(QVariant theme READ theme WRITE setTheme NOTIFY themeChanged) 0032 Q_PROPERTY(RepositoryWrapper *repository READ repository WRITE setRepository NOTIFY repositoryChanged) 0033 0034 public: 0035 explicit KQuickSyntaxHighlighter(QObject *parent = nullptr); 0036 ~KQuickSyntaxHighlighter() override; 0037 0038 QObject *textEdit() const; 0039 void setTextEdit(QObject *textEdit); 0040 0041 QVariant definition() const; 0042 void setDefinition(const QVariant &definition); 0043 0044 QVariant theme() const; 0045 void setTheme(const QVariant &theme); 0046 0047 RepositoryWrapper *repository() const; 0048 void setRepository(RepositoryWrapper *repository); 0049 0050 Q_SIGNALS: 0051 void textEditChanged() const; 0052 void definitionChanged() const; 0053 void themeChanged(); 0054 void repositoryChanged(); 0055 0056 private: 0057 KSyntaxHighlighting::Repository *unwrappedRepository() const; 0058 0059 QObject *m_textEdit; 0060 KSyntaxHighlighting::Definition m_definition; 0061 KSyntaxHighlighting::Theme m_theme; 0062 RepositoryWrapper *m_repository = nullptr; 0063 KSyntaxHighlighting::SyntaxHighlighter *m_highlighter = nullptr; 0064 }; 0065 0066 #endif // KQUICKSYNTAXHIGHLIGHTER_H