messagingapp/msgui/unifiedviewer/inc/univiewertextitem.h
changeset 31 ebfee66fde93
child 34 84197e66a4bd
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     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     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
       
    36     void mousePressEvent(QGraphicsSceneMouseEvent *event);
       
    37 
       
    38 private:
       
    39 
       
    40     /**
       
    41      * Applies find rule and highlights text.
       
    42      */
       
    43     void applyRule();
       
    44 
       
    45     /**
       
    46       * Helper method to add menus.
       
    47       * @param contextMenu menu object.
       
    48       * @param data, anchor at current position.
       
    49       */
       
    50     void addNumberMenu(HbMenu* contextMenu,const QString& data);
       
    51     void addEmailMenu(HbMenu* contextMenu,const QString& data);
       
    52     void addUrlMenu(HbMenu* contextMenu,const QString& data);
       
    53     
       
    54     /**
       
    55      * short tap handler.
       
    56      * @param anchor anchor at cursor position.
       
    57      */
       
    58     void shortTapAction(QString anchor);    
       
    59     
       
    60     /**
       
    61      * Helper method to highlight find item on tap.
       
    62      * @param highlight, if true highlight else dont.
       
    63      */
       
    64     void highlightText(bool highlight);
       
    65 	
       
    66 private slots:
       
    67     /**
       
    68       * called when aboutToShowContextMenu signal is emitted.
       
    69       */
       
    70     void aboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos);
       
    71     
       
    72     /**
       
    73      * Called when option menu is closed.
       
    74      */
       
    75     void menuClosed();
       
    76 
       
    77 
       
    78     //handlers for phone number specific menu items.
       
    79     void call();
       
    80     void sendMessage();    
       
    81 
       
    82     //handlers for e-mail specific menu items.
       
    83     void createEmail();
       
    84 
       
    85     //handlers for url specific menu items.
       
    86     void openLink();
       
    87     void addToBookmarks();
       
    88 
       
    89     //common handlers.
       
    90     void openContactInfo();
       
    91     void saveToContacts();
       
    92     void copyToClipboard();
       
    93     
       
    94     /**
       
    95      * Slot for handling valid returns from the framework.
       
    96      * 
       
    97      * @param result const QVariant&
       
    98      */
       
    99     void handleOk(const QVariant& result);
       
   100     
       
   101     /**
       
   102      * Slot for handling errors. Error ids are provided as 
       
   103      * 32-bit integers.
       
   104      * @param errorCode qint32
       
   105      */
       
   106     void handleError(int errorCode, const QString& errorMessage);
       
   107 
       
   108     //called after service request is completed.
       
   109     void onServiceRequestCompleted();
       
   110     
       
   111 signals:
       
   112     /**
       
   113      * this signal is emitted when send message is triggered for a highlighted number.
       
   114      */
       
   115     void sendMessage(const QString& phoneNumber);
       
   116     
       
   117 
       
   118 private:
       
   119     //map to hold rule and patterns.
       
   120     QMap<QString,QString> mRules;
       
   121 
       
   122     //property to on/off find patterns. default is on.
       
   123     bool mFindOn;
       
   124 
       
   125     //char formats for highlight.
       
   126     QTextCharFormat mFormatHighlight;
       
   127     QTextCharFormat mFormatNormal;
       
   128 
       
   129     //Current cursor position.
       
   130     int mCursorPos;
       
   131 };
       
   132 
       
   133 #endif // UNIVIEWERTEXTITEM_H