messagingapp/msgui/unifiedviewer/inc/univieweraddresswidget.h
changeset 37 518b245aa84c
parent 23 238255e8b033
child 48 4f501b74aeb1
--- a/messagingapp/msgui/unifiedviewer/inc/univieweraddresswidget.h	Mon May 03 12:29:07 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/inc/univieweraddresswidget.h	Fri Jun 25 15:47:40 2010 +0530
@@ -11,40 +11,35 @@
  *
  * Contributors:
  *
- * Description:
+ * Description: Custom widget derived from HbTextEdit which provides rich text
+ *              processing
  *
  */
-
 #ifndef UNI_VIEWER_ADDRESS_WIDGET_H
 #define UNI_VIEWER_ADDRESS_WIDGET_H
 
-// SYSTEM INCLUDES
-#include <HbWidget>
+#include <HbTextEdit>
 
-// USER INCLUDES
-#include "convergedmessageaddress.h"
+#include "unidatamodelplugininterface.h"
 
-// FORWARD DECLARATIONS
-class QPointF;
-class HbMenu;
-class UniTextEditor;
-
-class UniViewerAddressWidget : public HbWidget
+/**
+ * UniViewerAddressWidget provides support for rich text processing
+ */
+class UniViewerAddressWidget : public HbTextEdit
 {
-Q_OBJECT
-
+    Q_OBJECT
+    
 public:
-
     /**
      * Constructor
      */
-    explicit UniViewerAddressWidget(QGraphicsItem *parent = 0);
+    UniViewerAddressWidget(QGraphicsItem * parent = 0);
 
     /**
      * Destructor
      */
-    virtual ~UniViewerAddressWidget();
-
+    ~UniViewerAddressWidget();
+    
     /**
      * Populates the addresses and creates the anchors on them.
      * @param label Label of the address like - "From"
@@ -57,32 +52,98 @@
      * @param label Label of the address like - "To", "Cc"
      * @param addressList List of addresses to be populated.
      */
-    void populate(const QString &label,
-                ConvergedMessageAddressList addressList);
+    void populate(const QString &label,ConvergedMessageAddressList addressList);
 
     /**
      * Clears the contents of the widget.
      */
     void clearContent();
 
+protected:
+    /**
+     * Gesture event, overridden from base class.
+     */
+    void gestureEvent(QGestureEvent* event);
+    
+private:
+    /**
+     * Helper method to highlight find item on tap.
+     * @param highlight, if true highlight else dont.
+     */
+    void highlightText(bool highlight);
+    
+    /**
+     * short tap handler.
+     * @param anchor anchor at cursor position.
+     */
+    void shortTapAction(QString anchor); 
+    
+    /** Helper method to get contact id against phone number or e-mail id.
+     * @param value phone number or email id.
+     * @param fieldName name of field to be matched.
+     * @param fieldType type of field to be matched.
+     */
+    int resolveContactId(const QString& value,
+                         const QString& fieldName, 
+                         const QString& fieldType);
+    
+    
 private slots:
 
     /**
-     * Handles the aboutToShowContextMenu() signal generated by HbAbstractEdit.
-     * @see HbAbstractEdit
-     * @param contextMenu Reference of the context menu.
-     * @param pos Position at which the context menu will be displayed.
+      * called when aboutToShowContextMenu signal is emitted.
+      */
+    void aboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos);
+    
+    /**
+     * Called when option menu is closed.
+     */
+    void menuClosed();
+    
+    /**
+     * handlers for phone number specific menu items.
+     */
+    void openContactInfo();
+    void call();
+    void saveToContacts();
+    void sendMessage();
+    void copyToClipboard();
+    
+    /**
+     * called after service request is completed.
      */
-    void handleAboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos);
+    void onServiceRequestCompleted();
+    
+    /**
+     * Slot for handling valid returns from the framework.
+     * 
+     * @param result const QVariant&
+     */
+    void handleOk(const QVariant& result);
+    
+    /**
+     * Slot for handling errors. Error ids are provided as 
+     * 32-bit integers.
+     * @param errorCode qint32
+     */
+    void handleError(int errorCode, const QString& errorMessage);
+    
 
+signals:
+    /**
+     * this signal is emitted when send message is triggered for a highlighted number.
+     */
+    void sendMessage(const QString& phoneNumber,const QString& alias);
+    
 private:
+    //Current cursor position.
+    int mCursorPos;
+    
+    //char formats for highlight.
+    QTextCharFormat mFormatHighlight;
+    QTextCharFormat mFormatNormal;
 
-    /**
-     * Reference of the editor.
-     * Own
-     */
-    UniTextEditor *mAddress;
-};
+    };
 
 #endif // UNI_VIEWER_ADDRESS_WIDGET_H
 // EOF