messagingapp/msgui/unifiedviewer/inc/unihighlighter.h
branchGCC_SURGE
changeset 47 5b14749788d7
parent 35 a32b19fb291e
parent 44 36f374c67aa8
equal deleted inserted replaced
35:a32b19fb291e 47:5b14749788d7
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: Enables parsing and change font parameters for email/url
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef UNI_HIGHLIGHTER_H
       
    19 #define UNI_HIGHLIGHTER_H
       
    20 
       
    21 #include <QSyntaxHighlighter>
       
    22 #include <QHash>
       
    23 #include <QTextCharFormat>
       
    24 
       
    25 QT_BEGIN_NAMESPACE
       
    26 class QTextDocument;
       
    27 QT_END_NAMESPACE
       
    28 
       
    29 /**
       
    30  * Enables parsing and change font parameters for email/url
       
    31  */
       
    32 class UniHighlighter : public QSyntaxHighlighter
       
    33 {
       
    34 Q_OBJECT
       
    35 
       
    36 public:
       
    37     /*
       
    38      * Constructor
       
    39      */
       
    40     UniHighlighter(QTextDocument *parent = 0);
       
    41 
       
    42 protected:
       
    43     /*
       
    44      * highlightBlock
       
    45      * @see QSyntaxHighlighter
       
    46      */
       
    47     void highlightBlock(const QString &text);
       
    48 
       
    49 private:
       
    50 
       
    51     struct HighlightingRule
       
    52     {
       
    53         QRegExp pattern;
       
    54         QTextCharFormat format;
       
    55     };
       
    56     QVector<HighlightingRule> highlightingRules;
       
    57 
       
    58     QTextCharFormat emailFormat;
       
    59     QTextCharFormat urlFormat;
       
    60 };
       
    61 
       
    62 #endif //UNI_HIGHLIGHTER_H
       
    63 // EOF