QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsexpressionhighlighter.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsexpressionhighlighter.h - A syntax highlighter for a qgsexpression
3  --------------------------------------
4  Date : 28-Dec-2011
5  Copyright : (C) 2011 by Nathan Woodrow
6  Email : woodrow.nathan at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSEXPRESSIONHIGHLIGHTER_H
17 #define QGSEXPRESSIONHIGHLIGHTER_H
18 
19 #include <QSyntaxHighlighter>
20 
21 #include <QHash>
22 #include <QTextCharFormat>
23 #include <QStringList>
24 #include "qgis_gui.h"
25 
26 class QTextDocument;
27 
32 class GUI_EXPORT QgsExpressionHighlighter : public QSyntaxHighlighter
33 {
34  Q_OBJECT
35 
36  public:
37  QgsExpressionHighlighter( QTextDocument *parent = nullptr );
38  void addFields( const QStringList &fieldList );
39 
40  protected:
41  void highlightBlock( const QString &text ) override;
42 
43  private:
44  struct HighlightingRule
45  {
46  QRegExp pattern;
47  QTextCharFormat format;
48  };
49  QVector<HighlightingRule> highlightingRules;
50 
51  QTextCharFormat columnNameFormat;
52  QTextCharFormat keywordFormat;
53  QTextCharFormat quotationFormat;
54  QTextCharFormat functionFormat;
55 };
56 
57 #endif // QGSEXPRESSIONHIGHLIGHTER_H
QgsExpressionHighlighter
Definition: qgsexpressionhighlighter.h:32