umbrello: umbrello/dialogs/codetexthighlighter.h Source File

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

codetexthighlighter.h
Go to the documentation of this file.
1 /*
2 CodeTextHighlighter: Syntax highlighter for the CodeTextEdit widget.
3 Copyright 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 Copyright 2010 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License or (at your option) version 3 or any later version
12 accepted by the membership of KDE e.V. (or its successor approved
13 by the membership of KDE e.V.), which shall act as a proxy
14 defined in Section 14 of version 3 of the license.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25 #ifndef CODETEXTHIGHLIGHTER_H
26 #define CODETEXTHIGHLIGHTER_H
27
28 #include <QHash>
29 #include <QSyntaxHighlighter>
30 #include <QTextCharFormat>
31
32 class QTextDocument;
33
34 class CodeTextHighlighter : public QSyntaxHighlighter
35 {
36 Q_OBJECT
37
38 public:
39 explicit CodeTextHighlighter(QTextDocument *parent = 0);
40
41 protected:
42 void highlightBlock(const QString &text);
43
44 private:
45 QStringList keywords();
46
47 struct HighlightingRule
48 {
49 QRegExp pattern;
50 QTextCharFormat format;
51 };
52 QVector<HighlightingRule> m_highlightingRules;
53
54 QRegExp m_commentStartExpression;
55 QRegExp m_commentEndExpression;
56
57 QTextCharFormat m_keywordFormat;
58 QTextCharFormat m_classFormat;
59 QTextCharFormat m_singleLineCommentFormat;
60 QTextCharFormat m_multiLineCommentFormat;
61 QTextCharFormat m_quotationFormat;
62 QTextCharFormat m_functionFormat;
63 };
64
65 #endif // CODETEXTHIGHLIGHTER_H
CodeGenFactory::createObject
CodeGenerator * createObject(Uml::ProgrammingLanguage::Enum pl)
Definition: codegenfactory.cpp:107
codegenfactory.h
Uml::ProgrammingLanguage::Enum
Enum
Definition: basictypes.h:288
CodeTextHighlighter
Definition: codetexthighlighter.h:34
CodeTextHighlighter::m_multiLineCommentFormat
QTextCharFormat m_multiLineCommentFormat
Definition: codetexthighlighter.h:60
CodeTextHighlighter::HighlightingRule::format
QTextCharFormat format
Definition: codetexthighlighter.h:50
CodeTextHighlighter::m_highlightingRules
QVector< HighlightingRule > m_highlightingRules
Definition: codetexthighlighter.h:52
CodeTextHighlighter::m_commentStartExpression
QRegExp m_commentStartExpression
Definition: codetexthighlighter.h:54
CodeTextHighlighter::HighlightingRule::pattern
QRegExp pattern
Definition: codetexthighlighter.h:49
CodeTextHighlighter::keywords
QStringList keywords()
Definition: codetexthighlighter.cpp:119
CodeTextHighlighter::m_commentEndExpression
QRegExp m_commentEndExpression
Definition: codetexthighlighter.h:55
CodeGenerator::reservedKeywords
virtual QStringList reservedKeywords() const
Definition: codegenerator.cpp:806
codetexthighlighter.h
CodeTextHighlighter::CodeTextHighlighter
CodeTextHighlighter(QTextDocument *parent=0)
Definition: codetexthighlighter.cpp:36
CodeTextHighlighter::m_classFormat
QTextCharFormat m_classFormat
Definition: codetexthighlighter.h:58
CodeTextHighlighter::HighlightingRule
Definition: codetexthighlighter.h:47
CodeTextHighlighter::m_functionFormat
QTextCharFormat m_functionFormat
Definition: codetexthighlighter.h:62
CodeTextHighlighter::highlightBlock
void highlightBlock(const QString &text)
Definition: codetexthighlighter.cpp:83
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:269
CodeTextHighlighter::m_singleLineCommentFormat
QTextCharFormat m_singleLineCommentFormat
Definition: codetexthighlighter.h:59
CodeTextHighlighter::m_keywordFormat
QTextCharFormat m_keywordFormat
Definition: codetexthighlighter.h:57
uml.h
CodeTextHighlighter::m_quotationFormat
QTextCharFormat m_quotationFormat
Definition: codetexthighlighter.h:61
codegenerator.h
CodeGenerator
Definition: codegenerator.h:56
UMLApp::activeLanguage
Uml::ProgrammingLanguage::Enum activeLanguage() const
Definition: uml.cpp:2509