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

0001 /*
0002     SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef KSYNTAXHIGHLIGHTING_FORMAT_P_H
0008 #define KSYNTAXHIGHLIGHTING_FORMAT_P_H
0009 
0010 #include "textstyledata_p.h"
0011 #include "theme.h"
0012 
0013 #include <QSharedData>
0014 #include <QString>
0015 
0016 QT_BEGIN_NAMESPACE
0017 class QXmlStreamReader;
0018 QT_END_NAMESPACE
0019 
0020 namespace KSyntaxHighlighting
0021 {
0022 class FormatPrivate : public QSharedData
0023 {
0024 public:
0025     FormatPrivate() = default;
0026     static FormatPrivate *detachAndGet(Format &format);
0027 
0028     static std::intptr_t ptrId(const Format &format)
0029     {
0030         return std::intptr_t(format.d.data());
0031     }
0032 
0033     TextStyleData styleOverride(const Theme &theme) const;
0034     void load(QXmlStreamReader &reader);
0035 
0036     using StyleColor = QRgb(TextStyleData::*);
0037     using ThemeColor = QRgb (Theme::*)(Theme::TextStyle) const;
0038     bool hasColor(const Theme &theme, StyleColor styleColor, ThemeColor themeColor) const;
0039     QColor color(const Theme &theme, StyleColor styleColor, ThemeColor themeColor) const;
0040 
0041     QString definitionName;
0042     QString name;
0043     TextStyleData style;
0044     Theme::TextStyle defaultStyle = Theme::Normal;
0045     int id = 0;
0046     bool spellCheck = true;
0047 };
0048 
0049 }
0050 
0051 #endif