File indexing completed on 2024-05-12 04:02:21

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 <KSyntaxHighlighting/Definition>
0012 #include <KSyntaxHighlighting/Theme>
0013 
0014 #include <QObject>
0015 #include <QVariant>
0016 
0017 namespace KSyntaxHighlighting
0018 {
0019 class Repository;
0020 class SyntaxHighlighter;
0021 }
0022 
0023 class KQuickSyntaxHighlighter : public QObject
0024 {
0025     Q_OBJECT
0026 
0027     Q_PROPERTY(QObject *textEdit READ textEdit WRITE setTextEdit NOTIFY textEditChanged)
0028     Q_PROPERTY(QVariant definition READ definition WRITE setDefinition NOTIFY definitionChanged)
0029     Q_PROPERTY(QVariant theme READ theme WRITE setTheme NOTIFY themeChanged)
0030     Q_PROPERTY(KSyntaxHighlighting::Repository *repository READ repository WRITE setRepository NOTIFY repositoryChanged)
0031 
0032 public:
0033     explicit KQuickSyntaxHighlighter(QObject *parent = nullptr);
0034     ~KQuickSyntaxHighlighter() override;
0035 
0036     QObject *textEdit() const;
0037     void setTextEdit(QObject *textEdit);
0038 
0039     QVariant definition() const;
0040     void setDefinition(const QVariant &definition);
0041 
0042     QVariant theme() const;
0043     void setTheme(const QVariant &theme);
0044 
0045     KSyntaxHighlighting::Repository *repository() const;
0046     void setRepository(KSyntaxHighlighting::Repository *repository);
0047 
0048 Q_SIGNALS:
0049     void textEditChanged() const;
0050     void definitionChanged() const;
0051     void themeChanged();
0052     void repositoryChanged();
0053 
0054 private:
0055     KSyntaxHighlighting::Repository *unwrappedRepository() const;
0056 
0057     QObject *m_textEdit;
0058     KSyntaxHighlighting::Definition m_definition;
0059     KSyntaxHighlighting::Theme m_theme;
0060     KSyntaxHighlighting::Repository *m_repository = nullptr;
0061     KSyntaxHighlighting::SyntaxHighlighter *m_highlighter = nullptr;
0062 };
0063 
0064 #endif // KQUICKSYNTAXHIGHLIGHTER_H