Quantum GIS API Documentation  1.8
src/gui/qgsexpressionhighlighter.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     qgsexpressionhighlighter.h - A syntax highlighter for a qgsexpression
00003      --------------------------------------
00004     Date                 :  28-Dec-2011
00005     Copyright            : (C) 2011 by Nathan Woodrow
00006     Email                : woodrow.nathan at gmail dot com
00007  ***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 
00016 #ifndef QGSEXPRESSIONHIGHLIGHTER_H
00017 #define QGSEXPRESSIONHIGHLIGHTER_H
00018 
00019 #include "qgsfield.h"
00020 #include <QSyntaxHighlighter>
00021 
00022 #include <QHash>
00023 #include <QTextCharFormat>
00024 #include <QStringList>
00025 
00026 class QTextDocument;
00027 
00028 class QgsExpressionHighlighter : QSyntaxHighlighter
00029 {
00030     Q_OBJECT
00031 
00032   public:
00033     QgsExpressionHighlighter( QTextDocument *parent = 0 );
00034     void addFields( QStringList fieldList );
00035 
00036   protected:
00037     void highlightBlock( const QString &text );
00038 
00039   private:
00040     struct HighlightingRule
00041     {
00042       QRegExp pattern;
00043       QTextCharFormat format;
00044     };
00045     QVector<HighlightingRule> highlightingRules;
00046 
00047     QTextCharFormat columnNameFormat;
00048     QTextCharFormat keywordFormat;
00049     QTextCharFormat quotationFormat;
00050     QTextCharFormat functionFormat;
00051 };
00052 
00053 #endif // QGSEXPRESSIONHIGHLIGHTER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines