File indexing completed on 2024-05-12 15:50:07

0001 /*
0002     SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef REPOSITORYWRAPPER_H
0008 #define REPOSITORYWRAPPER_H
0009 
0010 #include <QObject>
0011 
0012 namespace KSyntaxHighlighting
0013 {
0014 class Definition;
0015 class Repository;
0016 class Theme;
0017 }
0018 
0019 // TODO KF6: merge this into KSyntaxHighlighting::Repository
0020 class RepositoryWrapper : public QObject
0021 {
0022     Q_OBJECT
0023     // TODO KF6: NOTIFY on reload
0024     Q_PROPERTY(QVector<KSyntaxHighlighting::Definition> definitions READ definitions CONSTANT)
0025     Q_PROPERTY(QVector<KSyntaxHighlighting::Theme> themes READ themes CONSTANT)
0026 public:
0027     explicit RepositoryWrapper(QObject *parent = nullptr);
0028 
0029     Q_INVOKABLE KSyntaxHighlighting::Definition definitionForName(const QString &defName) const;
0030     Q_INVOKABLE KSyntaxHighlighting::Definition definitionForFileName(const QString &fileName) const;
0031     Q_INVOKABLE QVector<KSyntaxHighlighting::Definition> definitionsForFileName(const QString &fileName) const;
0032     Q_INVOKABLE KSyntaxHighlighting::Definition definitionForMimeType(const QString &mimeType) const;
0033     Q_INVOKABLE QVector<KSyntaxHighlighting::Definition> definitionsForMimeType(const QString &mimeType) const;
0034     QVector<KSyntaxHighlighting::Definition> definitions() const;
0035 
0036     QVector<KSyntaxHighlighting::Theme> themes() const;
0037     Q_INVOKABLE KSyntaxHighlighting::Theme theme(const QString &themeName) const;
0038     enum DefaultTheme { LightTheme, DarkTheme };
0039     Q_ENUM(DefaultTheme)
0040     Q_INVOKABLE KSyntaxHighlighting::Theme defaultTheme(DefaultTheme t = LightTheme) const;
0041 
0042     KSyntaxHighlighting::Repository *m_repository = nullptr;
0043 };
0044 
0045 #endif // REPOSITORYWRAPPER_H