messagingapp/msgui/unifiededitor/inc/msgunieditorbodyeditor.h
changeset 76 60a8a215b0ec
equal deleted inserted replaced
73:ecf6a73a9186 76:60a8a215b0ec
       
     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  *
       
    16  */
       
    17 
       
    18 #ifndef MSG_UNIFIED_EDITOR_BODY_EDITOR_H
       
    19 #define MSG_UNIFIED_EDITOR_BODY_EDITOR_H
       
    20 
       
    21 // SYSTEM INCLUDES
       
    22 #include <msgunieditorbasewidget.h>
       
    23 #include <HbTextEdit>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class HbPushButton;
       
    27 class HbFrameItem;
       
    28 class HbTextItem;
       
    29 class UniEditorPluginLoader;
       
    30 class UniEditorPluginInterface;
       
    31 class UniEditorGenUtils;
       
    32 class ConvergedMessage;
       
    33 
       
    34 /**
       
    35  * Custom editor class
       
    36  */
       
    37 class MsgEditor : public HbTextEdit
       
    38 {
       
    39     Q_OBJECT
       
    40     
       
    41 public:    
       
    42     /**
       
    43      * Constructor
       
    44      */
       
    45     MsgEditor(QGraphicsItem *parent = 0);
       
    46     
       
    47 protected:
       
    48     /**
       
    49      * reimplemented from base class.
       
    50      */
       
    51     void inputMethodEvent(QInputMethodEvent *event);
       
    52 };
       
    53 
       
    54 /**
       
    55  * This class is a custom layout widget for Msg Editor.
       
    56  */
       
    57 
       
    58 class MsgUnifiedEditorBodyEditor : public MsgUnifiedEditorBaseWidget
       
    59 {
       
    60     Q_OBJECT
       
    61 
       
    62 public:
       
    63 
       
    64     /**
       
    65      * Constructor
       
    66      */
       
    67     MsgUnifiedEditorBodyEditor(QGraphicsItem *parent = 0);
       
    68 
       
    69     /**
       
    70      * Destructor
       
    71      */
       
    72     virtual ~MsgUnifiedEditorBodyEditor();
       
    73 
       
    74 public:
       
    75     /* Setter/Getter methods */
       
    76 
       
    77     /**
       
    78      * Returns the editor's contents.
       
    79      * @return Editor contents
       
    80      */
       
    81     QString content() const;
       
    82 
       
    83     /**
       
    84      * Set the editor's content.
       
    85      * @param contentText content text to set.
       
    86      */
       
    87     void setContent(const QString &contentText);
       
    88 
       
    89     /**
       
    90      * This function does initialisations needed for character counter
       
    91      */
       
    92     void setEncodingSettingsL();
       
    93     
       
    94     /**
       
    95      * Packs body editor data to ConvergedMessage object.
       
    96      * @param msg. ConvergedMessage object.(out parameter)
       
    97      */
       
    98     void packMessage(ConvergedMessage &msg);
       
    99     
       
   100     /**
       
   101      * Populate data into body editor from ConvergedMessage.
       
   102      * @param msg, ConvergedMessage object.
       
   103      */
       
   104     void populateContent(const ConvergedMessage& msg);
       
   105    
       
   106 signals:
       
   107 
       
   108     /**
       
   109      * Emitted when send button is pressed.
       
   110      */
       
   111     void sendMessage();
       
   112     
       
   113 public slots:
       
   114 
       
   115     /**
       
   116      * Enables/Disables send button based on message rediness for send.
       
   117      */
       
   118     void enableSendButton(bool enable);
       
   119     
       
   120 private slots:
       
   121 
       
   122     /**
       
   123      * Called when editor content is chaged.
       
   124      */
       
   125     void onContentsChanged();
       
   126     
       
   127     /**
       
   128      * called when send button is pressed/released.
       
   129      */  
       
   130     void onPressed();
       
   131     void onReleased();
       
   132 
       
   133 private:
       
   134 
       
   135     /**
       
   136      * Initialization function.
       
   137      */
       
   138     void init();
       
   139     
       
   140 	 /**
       
   141 	  * To update back ground.
       
   142 	  */
       
   143     void updateButtonBackgroundAndColor(const QString& bg,const QString& iconColor);
       
   144 
       
   145 private:
       
   146 
       
   147     /**
       
   148      * Instance of message edit.
       
   149      * Will be deleted automatically by parent.
       
   150      * Own.
       
   151      */
       
   152     MsgEditor *mMsgEditor;
       
   153 
       
   154     /**
       
   155      * Instance of push button.
       
   156      * Will be deleted automatically by parent.
       
   157      * Own.
       
   158      */
       
   159     HbPushButton *mSendButton;
       
   160 
       
   161     /**
       
   162      * Instance of HbTextItem
       
   163      * Will be deleted automatically by parent.
       
   164      * Own.
       
   165      */
       
   166     HbTextItem *mCharCounter;
       
   167 
       
   168     /**
       
   169      * Instance of HbFrameItem
       
   170      * Will be deleted automatically by parent.
       
   171      * Own.
       
   172      */
       
   173     HbFrameItem* mBackgroundItem;
       
   174     
       
   175     /**
       
   176      * Holds char type supported
       
   177      */
       
   178     int mCharSupportType;
       
   179 
       
   180     /**
       
   181      * Instance of UniEditorPluginInterface
       
   182      * Will be deleted automatically by parent.
       
   183      * Own.
       
   184      */
       
   185     UniEditorPluginInterface* mPluginInterface;
       
   186 
       
   187     /**
       
   188      * Instance of UniEditorPluginLoader
       
   189      * Will be deleted when UniEditorPluginInterface object is deleted
       
   190      * Not Own.
       
   191      */
       
   192     UniEditorPluginLoader* mPluginLoader;
       
   193 
       
   194     /**
       
   195      * Instance of UniEditorGenUtils
       
   196      * Own.
       
   197      */
       
   198     UniEditorGenUtils* mEditorUtils;
       
   199 
       
   200 #ifdef UNIEDITOR_UNIT_TEST
       
   201     /**
       
   202      * Unit Testing
       
   203      */
       
   204     friend class TestMsgUnifiedEditorBodyEditor;
       
   205 #endif
       
   206 };
       
   207 
       
   208 #endif // MSG_UNIFIED_EDITOR_BODY_EDITOR_H
       
   209 // EOF