umbrello: umbrello/dialogs/codetexthighlighter.h Source File

umbrello 2.38.2 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

codetexthighlighter.h
Go to the documentation of this file.
1/*
2 CodeTextHighlighter: Syntax highlighter for the CodeTextEdit widget.
3 SPDX-FileCopyrightText: 2010 Nokia Corporation and /or its subsidiary(-ies) <qt-info@nokia.com>
4 Code based on examples of the Qt Toolkit under BSD license,
5 <http://doc.qt.nokia.com/4.6/richtext-syntaxhighlighter.html>.
6 SPDX-FileCopyrightText: 2010 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
9*/
10
11#ifndef CODETEXTHIGHLIGHTER_H
12#define CODETEXTHIGHLIGHTER_H
13
14#include <QHash>
15#include <QSyntaxHighlighter>
16#include <QTextCharFormat>
17
18class QTextDocument;
19
20 class CodeTextHighlighter : public QSyntaxHighlighter
21{
22 Q_OBJECT
23
24public:
25 explicit CodeTextHighlighter(QTextDocument *parent = 0);
26
27protected:
28 void highlightBlock(const QString &text);
29
30private:
31 QStringList keywords();
32
33 struct HighlightingRule
34 {
35 QRegExp pattern;
36 QTextCharFormat format;
37 };
38 QVector<HighlightingRule> m_highlightingRules;
39
40 QRegExp m_commentStartExpression;
41 QRegExp m_commentEndExpression;
42
43 QTextCharFormat m_keywordFormat;
44 QTextCharFormat m_classFormat;
45 QTextCharFormat m_singleLineCommentFormat;
46 QTextCharFormat m_multiLineCommentFormat;
47 QTextCharFormat m_quotationFormat;
48 QTextCharFormat m_functionFormat;
49};
50
51#endif // CODETEXTHIGHLIGHTER_H
CodeTextHighlighter
Definition: codetexthighlighter.h:21
CodeTextHighlighter::m_functionFormat
QTextCharFormat m_functionFormat
Definition: codetexthighlighter.h:48
CodeTextHighlighter::m_commentStartExpression
QRegExp m_commentStartExpression
Definition: codetexthighlighter.h:40
CodeTextHighlighter::m_singleLineCommentFormat
QTextCharFormat m_singleLineCommentFormat
Definition: codetexthighlighter.h:45
CodeTextHighlighter::m_commentEndExpression
QRegExp m_commentEndExpression
Definition: codetexthighlighter.h:41
CodeTextHighlighter::m_highlightingRules
QVector< HighlightingRule > m_highlightingRules
Definition: codetexthighlighter.h:38
CodeTextHighlighter::m_classFormat
QTextCharFormat m_classFormat
Definition: codetexthighlighter.h:44
CodeTextHighlighter::m_quotationFormat
QTextCharFormat m_quotationFormat
Definition: codetexthighlighter.h:47
CodeTextHighlighter::m_multiLineCommentFormat
QTextCharFormat m_multiLineCommentFormat
Definition: codetexthighlighter.h:46
CodeTextHighlighter::keywords
QStringList keywords()
Definition: codetexthighlighter.cpp:105
CodeTextHighlighter::highlightBlock
void highlightBlock(const QString &text)
Definition: codetexthighlighter.cpp:69
CodeTextHighlighter::m_keywordFormat
QTextCharFormat m_keywordFormat
Definition: codetexthighlighter.h:43
CodeTextHighlighter::HighlightingRule
Definition: codetexthighlighter.h:34
CodeTextHighlighter::HighlightingRule::pattern
QRegExp pattern
Definition: codetexthighlighter.h:35
CodeTextHighlighter::HighlightingRule::format
QTextCharFormat format
Definition: codetexthighlighter.h:36