messagingapp/msgui/unifiedviewer/inc/univieweraddresswidget.h
changeset 27 e4592d119491
parent 23 238255e8b033
child 47 5b14749788d7
equal deleted inserted replaced
25:84d9eb65b26f 27:e4592d119491
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description:
    14  * Description: Custom widget derived from HbTextEdit which provides rich text
       
    15  *              processing
    15  *
    16  *
    16  */
    17  */
    17 
       
    18 #ifndef UNI_VIEWER_ADDRESS_WIDGET_H
    18 #ifndef UNI_VIEWER_ADDRESS_WIDGET_H
    19 #define UNI_VIEWER_ADDRESS_WIDGET_H
    19 #define UNI_VIEWER_ADDRESS_WIDGET_H
    20 
    20 
    21 // SYSTEM INCLUDES
    21 #include <HbTextEdit>
    22 #include <HbWidget>
       
    23 
    22 
    24 // USER INCLUDES
    23 #include "unidatamodelplugininterface.h"
    25 #include "convergedmessageaddress.h"
       
    26 
    24 
    27 // FORWARD DECLARATIONS
    25 /**
    28 class QPointF;
    26  * UniViewerAddressWidget provides support for rich text processing
    29 class HbMenu;
    27  */
    30 class UniTextEditor;
    28 class UniViewerAddressWidget : public HbTextEdit
    31 
       
    32 class UniViewerAddressWidget : public HbWidget
       
    33 {
    29 {
    34 Q_OBJECT
    30     Q_OBJECT
    35 
    31     
    36 public:
    32 public:
    37 
       
    38     /**
    33     /**
    39      * Constructor
    34      * Constructor
    40      */
    35      */
    41     explicit UniViewerAddressWidget(QGraphicsItem *parent = 0);
    36     UniViewerAddressWidget(QGraphicsItem * parent = 0);
    42 
    37 
    43     /**
    38     /**
    44      * Destructor
    39      * Destructor
    45      */
    40      */
    46     virtual ~UniViewerAddressWidget();
    41     ~UniViewerAddressWidget();
    47 
    42     
    48     /**
    43     /**
    49      * Populates the addresses and creates the anchors on them.
    44      * Populates the addresses and creates the anchors on them.
    50      * @param label Label of the address like - "From"
    45      * @param label Label of the address like - "From"
    51      * @param address Address string to be populated.
    46      * @param address Address string to be populated.
    52      */
    47      */
    55     /**
    50     /**
    56      * Populates the addresses and creates the anchors on them.
    51      * Populates the addresses and creates the anchors on them.
    57      * @param label Label of the address like - "To", "Cc"
    52      * @param label Label of the address like - "To", "Cc"
    58      * @param addressList List of addresses to be populated.
    53      * @param addressList List of addresses to be populated.
    59      */
    54      */
    60     void populate(const QString &label,
    55     void populate(const QString &label,ConvergedMessageAddressList addressList);
    61                 ConvergedMessageAddressList addressList);
       
    62 
    56 
    63     /**
    57     /**
    64      * Clears the contents of the widget.
    58      * Clears the contents of the widget.
    65      */
    59      */
    66     void clearContent();
    60     void clearContent();
    67 
    61 
       
    62 protected:
       
    63 
       
    64     /**
       
    65      * called when mouse is pressed.
       
    66      */
       
    67     void mousePressEvent(QGraphicsSceneMouseEvent *event);
       
    68 
       
    69     /**
       
    70      * called when mouse is released.
       
    71      */
       
    72     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
       
    73     
       
    74 private:
       
    75     /**
       
    76      * Helper method to highlight find item on tap.
       
    77      * @param highlight, if true highlight else dont.
       
    78      */
       
    79     void highlightText(bool highlight);
       
    80     
       
    81     /**
       
    82      * short tap handler.
       
    83      * @param anchor anchor at cursor position.
       
    84      */
       
    85     void shortTapAction(QString anchor); 
       
    86     
       
    87     /** Helper method to get contact id against phone number or e-mail id.
       
    88      * @param value phone number or email id.
       
    89      * @param fieldName name of field to be matched.
       
    90      * @param fieldType type of field to be matched.
       
    91      */
       
    92     int resolveContactId(const QString& value,
       
    93                          const QString& fieldName, 
       
    94                          const QString& fieldType);
       
    95     
       
    96     
    68 private slots:
    97 private slots:
    69 
    98 
    70     /**
    99     /**
    71      * Handles the aboutToShowContextMenu() signal generated by HbAbstractEdit.
   100       * called when aboutToShowContextMenu signal is emitted.
    72      * @see HbAbstractEdit
   101       */
    73      * @param contextMenu Reference of the context menu.
   102     void aboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos);
    74      * @param pos Position at which the context menu will be displayed.
   103     
       
   104     /**
       
   105      * Called when option menu is closed.
    75      */
   106      */
    76     void handleAboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos);
   107     void menuClosed();
       
   108     
       
   109     //handlers for phone number specific menu items.
       
   110     void openContactInfo();
       
   111     void call();
       
   112     void saveToContacts();
       
   113     void sendMessage();
       
   114     void copyToClipboard();
       
   115     
       
   116     //called after service request is completed.
       
   117     void onServiceRequestCompleted();
       
   118     
       
   119     /**
       
   120      * Slot for handling valid returns from the framework.
       
   121      * 
       
   122      * @param result const QVariant&
       
   123      */
       
   124     void handleOk(const QVariant& result);
       
   125     
       
   126     /**
       
   127      * Slot for handling errors. Error ids are provided as 
       
   128      * 32-bit integers.
       
   129      * @param errorCode qint32
       
   130      */
       
   131     void handleError(int errorCode, const QString& errorMessage);
       
   132     
    77 
   133 
       
   134 signals:
       
   135     /**
       
   136      * this signal is emitted when send message is triggered for a highlighted number.
       
   137      */
       
   138     void sendMessage(const QString& phoneNumber,const QString& alias);
       
   139     
    78 private:
   140 private:
       
   141     //Current cursor position.
       
   142     int mCursorPos;
       
   143     
       
   144     //char formats for highlight.
       
   145     QTextCharFormat mFormatHighlight;
       
   146     QTextCharFormat mFormatNormal;
    79 
   147 
    80     /**
   148     };
    81      * Reference of the editor.
       
    82      * Own
       
    83      */
       
    84     UniTextEditor *mAddress;
       
    85 };
       
    86 
   149 
    87 #endif // UNI_VIEWER_ADDRESS_WIDGET_H
   150 #endif // UNI_VIEWER_ADDRESS_WIDGET_H
    88 // EOF
   151 // EOF