messagingapp/msgui/unifiededitor/inc/msgunieditorbody.h
changeset 23 238255e8b033
child 25 84d9eb65b26f
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
       
     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:message body. to enter text and show media inserted.
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef UNIFIED_EDITOR_BODY_H
       
    19 #define UNIFIED_EDITOR_BODY_H
       
    20 
       
    21 #include <hbwidget.h>
       
    22 #include <f32file.h>
       
    23 #include "msgunieditorprocessimageoperation.h"
       
    24 
       
    25 class HbTextEdit;
       
    26 class HbFrameItem;
       
    27 class HbIconItem;
       
    28 class HbPushButton;
       
    29 class HbGestureSceneFilter;
       
    30 class CMsgMediaResolver;
       
    31 class CMsgImageInfo;
       
    32 class MmsInsertCheckOperation;
       
    33 
       
    34 
       
    35 class MsgUnifiedEditorBody : public HbWidget,public MUniEditorProcessImageOperationObserver
       
    36 {
       
    37     Q_OBJECT
       
    38 
       
    39     Q_PROPERTY(bool hasImage READ hasImage WRITE setImage)
       
    40     Q_PROPERTY(bool hasAudio READ hasAudio WRITE setAudio)
       
    41 public:
       
    42 
       
    43     /**
       
    44      * Constructor
       
    45      */
       
    46     MsgUnifiedEditorBody(const QString& pluginPath, QGraphicsItem *parent = 0);
       
    47 
       
    48     /**
       
    49      * Destructor
       
    50      */
       
    51     ~MsgUnifiedEditorBody();
       
    52 
       
    53     /**
       
    54      * Seeker method to return back data to editor's view
       
    55      */
       
    56     QString text();
       
    57 
       
    58     /**
       
    59      * Seeker method to return back data to editor's view
       
    60      */
       
    61     const QStringList mediaContent();
       
    62 
       
    63 public slots:
       
    64     /**
       
    65      * Called to insert image content in editor.
       
    66      * @param medialist list of absolute paths of media.
       
    67      */
       
    68     void setImage(QString& imagefile);
       
    69 
       
    70     /**
       
    71      * Called to insert audio content in editor.
       
    72      * @param medialist list of absolute paths of media.
       
    73      */
       
    74     void setAudio(QString& audiofile);
       
    75 
       
    76     /**
       
    77      * Called to insert video content in editor.
       
    78      * @param medialist list of absolute paths of media.
       
    79      */
       
    80     void setVideo(QString& videofile);
       
    81 
       
    82     /**
       
    83      * Called to insert body text in editor.
       
    84      * @param text body text.
       
    85      */
       
    86     void setText(QString& text);
       
    87 
       
    88 signals:
       
    89     /**
       
    90      * Emitted when send button from virtual ITUT is pressed.
       
    91      */
       
    92     void sendMessage();
       
    93 
       
    94     /**
       
    95      * Emitted when MMS content is added or removed
       
    96      */
       
    97     void mmContentAdded(bool isAdded);
       
    98 
       
    99     /**
       
   100      * Emitted when msg body size changes
       
   101      */
       
   102     void sizeChanged(int aSize);
       
   103 
       
   104 public: // from MUniEditorProcessImageOperationObserver
       
   105     
       
   106     /*
       
   107      * @see MUniEditorProcessImageOperationObserver
       
   108      */
       
   109     void EditorOperationEvent( TUniEditorProcessImageOperationEvent aEvent,
       
   110         TFileName aFileName );
       
   111 
       
   112 protected: // from HbWidget
       
   113     
       
   114     /**
       
   115      * Reimplemented from base class to give proper size.
       
   116      * @see HbWidget
       
   117      */
       
   118     QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
       
   119 
       
   120 private slots:
       
   121     /**
       
   122      * called on long press on the media objects
       
   123      */
       
   124     void longPressed(QPointF position);
       
   125 
       
   126     /**
       
   127      * called from the media object's item specific menu
       
   128      */
       
   129     void removeMedia();
       
   130 
       
   131     /**
       
   132      * called from the media object's item specific menu
       
   133      */
       
   134     void openMedia();
       
   135 
       
   136     /**
       
   137      * called from the media object's item specific menu
       
   138      */
       
   139     void viewDetails();
       
   140     
       
   141     /**
       
   142      * handle text changes in body field
       
   143      */
       
   144     void onTextChanged();
       
   145 
       
   146 private:
       
   147     /**
       
   148      * Get to find body already contains an image
       
   149      * @return bool
       
   150      */
       
   151     bool hasImage();
       
   152 
       
   153     /**
       
   154      * Get to find body already contains an image
       
   155      * @return bool
       
   156      */
       
   157     void setImage(bool image = false);
       
   158 
       
   159     /**
       
   160      * Get to find body already contains an audio
       
   161      * @return bool
       
   162      */
       
   163     bool hasAudio();
       
   164 
       
   165     /**
       
   166      * Set that body now contains an audio
       
   167      */
       
   168 	void setAudio(bool audio = false);
       
   169     
       
   170     /**
       
   171      * Get the region (image/audio/video) where longpress happened
       
   172      * @return region
       
   173      */
       
   174     QString getHitRegion(QPointF position);
       
   175 
       
   176     /**
       
   177      * get size of body content for MMS size calculations
       
   178      * @return size of body content
       
   179      */
       
   180     int bodySize();
       
   181 
       
   182     /**
       
   183      * size of the msg
       
   184      */
       
   185     int messageSize();    
       
   186     
       
   187     /**
       
   188      * Handler for set image function 
       
   189      */
       
   190     void handleSetImage();    
       
   191 
       
   192     /**
       
   193      * Starts the resize animation 
       
   194      */
       
   195     void startResizeAnimation();
       
   196 
       
   197     /**
       
   198      * Stops the resize animation 
       
   199      */
       
   200     void stopResizeAnimation();
       
   201 
       
   202 private:
       
   203     /**
       
   204      * Info if message body has image.
       
   205      * true if message body has image else false.
       
   206      */
       
   207     bool mHasImage;
       
   208 
       
   209     /**
       
   210      * Info if message body has audio.
       
   211      * true if message body has audio else false.
       
   212      */
       
   213     bool mHasAudio;
       
   214 
       
   215     /**
       
   216      * editor to in put text.
       
   217      */
       
   218     HbTextEdit* mTextEdit;
       
   219 
       
   220     /**
       
   221      * frame for editor.
       
   222      */
       
   223     HbFrameItem* mEditorFrame;
       
   224 
       
   225     /**
       
   226      * icon item to preview images.
       
   227      */
       
   228     HbIconItem* mIconItem;
       
   229 
       
   230     /**
       
   231      * inline audio item
       
   232      */
       
   233     HbPushButton* mAudioItem;
       
   234 
       
   235     /**
       
   236      * string to hold plug in path.
       
   237      */
       
   238     QString mPluginPath;
       
   239 
       
   240 	/**
       
   241 	 * Image file contained inside body
       
   242 	 */
       
   243     QString mImageFile;
       
   244 
       
   245     /**
       
   246      * Saves the original file which has to be used if resize fails
       
   247      */
       
   248     QString mSavedImageFile;
       
   249 
       
   250 	/**
       
   251 	 * Audio file contained inside body
       
   252 	 */
       
   253     QString mAudioFile;
       
   254 
       
   255 	/**
       
   256 	 * Video file contained inside body
       
   257 	 */
       
   258     QString mVideoFile;
       
   259 
       
   260     /**
       
   261      * To setup longpress gesture on media objects
       
   262      */
       
   263     HbGestureSceneFilter* mGestureFilter;
       
   264 	
       
   265     /**
       
   266      * MMs insert check utility class
       
   267      */
       
   268     MmsInsertCheckOperation* mMmsInsertCheckOp;
       
   269 	
       
   270     /**
       
   271      * Size of image in body 
       
   272      */
       
   273     int mImageSize;
       
   274     
       
   275     /**
       
   276      * Size of audio in body
       
   277      */
       
   278     int mAudioSize;
       
   279     
       
   280     /**
       
   281      * Size of video in body
       
   282      */
       
   283     int mVideoSize;
       
   284 
       
   285     /**
       
   286      * Rfs object
       
   287      */
       
   288     RFs mfs;
       
   289 
       
   290     /**
       
   291      * CUniEditorProcessImageOperation object
       
   292      */
       
   293     CUniEditorProcessImageOperation *mProcessImageOperation;
       
   294 
       
   295     /**
       
   296      * CMsgMediaResolver object
       
   297      */
       
   298     CMsgMediaResolver* mMediaResolver;
       
   299     
       
   300     /**
       
   301      * CMsgImageInfo object
       
   302      */
       
   303     CMsgImageInfo *mImageInfo;    
       
   304 };
       
   305 
       
   306 #endif //UNIFIED_EDITOR_BODY_H