1 /************************************************************************
2 **
3 **  Copyright (C) 2009, 2010, 2011  Strahinja Markovic  <strahinja.markovic@gmail.com>
4 **
5 **  This file is part of Sigil.
6 **
7 **  Sigil is free software: you can redistribute it and/or modify
8 **  it under the terms of the GNU General Public License as published by
9 **  the Free Software Foundation, either version 3 of the License, or
10 **  (at your option) any later version.
11 **
12 **  Sigil is distributed in the hope that it will be useful,
13 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 **  GNU General Public License for more details.
16 **
17 **  You should have received a copy of the GNU General Public License
18 **  along with Sigil.  If not, see <http://www.gnu.org/licenses/>.
19 **
20 *************************************************************************/
21 
22 #pragma once
23 #ifndef XHTMLHIGHLIGHTER2_H
24 #define XHTMLHIGHLIGHTER2_H
25 
26 #include <QtGui/QSyntaxHighlighter>
27 #include <QRegularExpression>
28 
29 #include "Misc/SettingsStore.h"
30 
31 class QTextDocument;
32 
33 class XHTMLHighlighter2 : public QSyntaxHighlighter
34 {
35     Q_OBJECT
36 
37 public:
38 
39     // Constructor
40     XHTMLHighlighter2(bool checkSpelling, QObject *parent = 0);
41 
42     void do_rehighlight();
43 
44     void SetRules();
45 
46 protected:
47 
48     // Overrides the function from QSyntaxHighlighter;
49     // gets called by QTextEditor whenever
50     // a block (line of text) needs to be repainted
51     void highlightBlock(const QString &text);
52 
53 private:
54 
55     void CheckSpelling(const QString &text);
56 
57 
58     ///////////////////////////////
59     // PRIVATE MEMBER VARIABLES
60     ///////////////////////////////
61 
62     QHash<QString, QTextCharFormat> m_Rules;
63 
64     // Determine if spell check should be used on the document.
65     bool m_checkSpelling;
66 
67     SettingsStore::CodeViewAppearance m_codeViewAppearance;
68 };
69 
70 #endif // XHTMLHIGHLIGHTER2_H
71 
72