messagingapp/msgui/unifiedviewer/inc/univiewertextitem.h
branchRCL_3
changeset 26 ebe688cedc25
equal deleted inserted replaced
25:fa1df4b99609 26:ebe688cedc25
       
     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:
       
    15  * Message body preview class.
       
    16  * has in built logic for finding phone number, email, url.
       
    17  *
       
    18  */
       
    19 
       
    20 #ifndef UNIVIEWERTEXTITEM_H
       
    21 #define UNIVIEWERTEXTITEM_H
       
    22 
       
    23 #include <HbTextEdit>
       
    24 
       
    25 class UniViewerTextItem : public HbTextEdit
       
    26 {
       
    27     Q_OBJECT
       
    28 public:
       
    29     UniViewerTextItem(QGraphicsItem* parent=0);
       
    30     ~UniViewerTextItem();
       
    31     void setFindOn(bool on = true);
       
    32     void setText(const QString& text);
       
    33 
       
    34 protected:
       
    35     /**
       
    36      * Gesture event, overridden from base class.
       
    37      */
       
    38     void gestureEvent(QGestureEvent* event);
       
    39 
       
    40 private:
       
    41 
       
    42     /**
       
    43      * Applies find rule and highlights text.
       
    44      */
       
    45     void applyRule();
       
    46 
       
    47     /**
       
    48       * Helper method to add menus.
       
    49       * @param contextMenu menu object.
       
    50       * @param data, anchor at current position.
       
    51       */
       
    52     void addNumberMenu(HbMenu* contextMenu,const QString& data);
       
    53     void addEmailMenu(HbMenu* contextMenu,const QString& data);
       
    54     void addUrlMenu(HbMenu* contextMenu,const QString& data);
       
    55     
       
    56     /**
       
    57      * short tap handler.
       
    58      * @param anchor anchor at cursor position.
       
    59      * @param pos tapping position
       
    60      */
       
    61     void handleShortTap(QString anchor,const QPointF& pos);    
       
    62     
       
    63     /**
       
    64      * Helper method to highlight find item on tap.
       
    65      * @param highlight, if true highlight else dont.
       
    66      */
       
    67     void highlightText(bool highlight);
       
    68 	
       
    69 private slots:
       
    70     /**
       
    71       * called when aboutToShowContextMenu signal is emitted.
       
    72       */
       
    73     void aboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos);
       
    74     
       
    75     /**
       
    76      * Called when option menu is closed.
       
    77      */
       
    78     void menuClosed();
       
    79 
       
    80 
       
    81     /**
       
    82      * handlers for phone number specific menu items.
       
    83      */
       
    84     void call();
       
    85     void sendMessage();    
       
    86 
       
    87     /**
       
    88      * handlers for e-mail specific menu items.
       
    89      */
       
    90     void createEmail();
       
    91 
       
    92     /**
       
    93      * handlers for url specific menu items.
       
    94      */
       
    95     void openLink();
       
    96     void addToBookmarks();
       
    97 
       
    98     /**
       
    99      * common handlers.
       
   100      */
       
   101     void openContactInfo();
       
   102     void saveToContacts();
       
   103     void copyToClipboard();
       
   104     
       
   105     /**
       
   106      * Slot for handling valid returns from the framework.
       
   107      * 
       
   108      * @param result const QVariant&
       
   109      */
       
   110     void handleOk(const QVariant& result);
       
   111     
       
   112     /**
       
   113      * Slot for handling errors. Error ids are provided as 
       
   114      * 32-bit integers.
       
   115      * @param errorCode qint32
       
   116      */
       
   117     void handleError(int errorCode, const QString& errorMessage);
       
   118 
       
   119     /**
       
   120      * called after service request is completed.
       
   121      */
       
   122     void onServiceRequestCompleted();
       
   123     
       
   124 signals:
       
   125     /**
       
   126      * this signal is emitted when send message is triggered for a highlighted number.
       
   127      */
       
   128     void sendMessage(const QString& phoneNumber);
       
   129     
       
   130 
       
   131 private:
       
   132     //map to hold rule and patterns.
       
   133     QMap<QString,QString> mRules;
       
   134 
       
   135     //property to on/off find patterns. default is on.
       
   136     bool mFindOn;
       
   137 
       
   138     //char formats for highlight.
       
   139     QTextCharFormat mFormatHighlight;
       
   140     QTextCharFormat mFormatNormal;
       
   141 
       
   142     //Current cursor position.
       
   143     int mCursorPos;
       
   144 };
       
   145 
       
   146 #endif // UNIVIEWERTEXTITEM_H