messagingapp/msgui/unifiededitor/inc/msgunieditorbody.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: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 <msgunifiededitorbasewidget.h>
       
    22 #include <f32file.h>
       
    23 #include "msgunieditorprocessimageoperation.h"
       
    24 
       
    25 class HbTextEdit;
       
    26 class HbTextItem;
       
    27 class HbFrameItem;
       
    28 class HbIconItem;
       
    29 class HbPushButton;
       
    30 //class HbGestureSceneFilter;
       
    31 class CMsgMediaResolver;
       
    32 class CMsgImageInfo;
       
    33 class MmsConformanceCheck;
       
    34 class UniEditorPluginInterface;
       
    35 class UniEditorPluginLoader;
       
    36 
       
    37 
       
    38 class MsgUnifiedEditorBody : public MsgUnifiedEditorBaseWidget,
       
    39                              public MUniEditorProcessImageOperationObserver
       
    40 {
       
    41     Q_OBJECT
       
    42 
       
    43     Q_PROPERTY(bool hasImage READ hasImage WRITE setImage)
       
    44     Q_PROPERTY(bool hasAudio READ hasAudio WRITE setAudio)
       
    45 public:
       
    46 
       
    47     /**
       
    48      * Constructor
       
    49      */
       
    50     MsgUnifiedEditorBody(QGraphicsItem *parent = 0);
       
    51 
       
    52     /**
       
    53      * Destructor
       
    54      */
       
    55     ~MsgUnifiedEditorBody();
       
    56 
       
    57     /**
       
    58      * Seeker method to return back data to editor's view
       
    59      */
       
    60     QString text();
       
    61 
       
    62     /**
       
    63      * Seeker method to return back data to editor's view
       
    64      */
       
    65     const QStringList mediaContent();
       
    66     
       
    67     /**
       
    68      * get size of body content for MMS size calculations
       
    69      * @return size of body content
       
    70      */
       
    71     int bodySize();
       
    72     
       
    73     /*
       
    74      * Returns value of mUnicode 
       
    75      * @return mUnicode   
       
    76      */
       
    77      bool isUnicode();
       
    78 
       
    79      /*
       
    80       * Disables char counter
       
    81       */
       
    82      void disableCharCounter();
       
    83      
       
    84      /**
       
    85       * To set focus on editable field.
       
    86       */
       
    87      void setFocus();
       
    88 
       
    89      /**
       
    90       * Get to find body already contains an image
       
    91       * @return bool
       
    92       */
       
    93      bool hasImage();
       
    94 
       
    95      /**
       
    96       * Get to find body already contains an audio
       
    97       * @return bool
       
    98       */
       
    99      bool hasAudio();
       
   100 
       
   101 public slots:
       
   102     /**
       
   103      * Called to insert image content in editor.
       
   104      * @param medialist list of absolute paths of media.
       
   105      */
       
   106     void setImage(QString& imagefile);
       
   107 
       
   108     /**
       
   109      * Called to insert audio content in editor.
       
   110      * @param medialist list of absolute paths of media.
       
   111      */
       
   112     void setAudio(QString& audiofile);
       
   113 
       
   114     /**
       
   115      * Called to insert body text in editor.
       
   116      * @param text body text.
       
   117      */
       
   118     void setText(QString& text);
       
   119 
       
   120 signals:
       
   121     /**
       
   122      * Emitted when send button from virtual ITUT is pressed.
       
   123      */
       
   124     void sendMessage();
       
   125 
       
   126     /**
       
   127      * Emitted when msg-body content changes
       
   128      */
       
   129     void contentChanged();
       
   130 
       
   131 public: // from MUniEditorProcessImageOperationObserver
       
   132     
       
   133     /*
       
   134      * @see MUniEditorProcessImageOperationObserver
       
   135      */
       
   136     void EditorOperationEvent( TUniEditorProcessImageOperationEvent aEvent,
       
   137         TFileName aFileName );
       
   138 
       
   139 protected: // from HbWidget
       
   140     
       
   141     /**
       
   142      * Reimplemented from base class to give proper size.
       
   143      * @see HbWidget
       
   144      */
       
   145     QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
       
   146 
       
   147 private slots:
       
   148     /**
       
   149      * called on long press on the media objects
       
   150      */
       
   151     void longPressed(QPointF position);
       
   152 
       
   153     /**
       
   154      * called from the media object's item specific menu
       
   155      */
       
   156     void removeMedia();
       
   157 
       
   158     /**
       
   159      * called from the media object's item specific menu
       
   160      */
       
   161     void openMedia();
       
   162 
       
   163     /**
       
   164      * called from the media object's item specific menu
       
   165      */
       
   166     void viewDetails();
       
   167     
       
   168     /**
       
   169      * handle text changes in body field
       
   170      */
       
   171     void onTextChanged();
       
   172 
       
   173     /**
       
   174      * Service launch complete.
       
   175      */
       
   176     void handleOk(const QVariant& result);
       
   177 
       
   178     /**
       
   179      * Service launch errors.
       
   180      */
       
   181     void handleError(int errorCode, const QString& errorMessage);
       
   182 
       
   183 private:
       
   184 
       
   185     /**
       
   186      * Get to find body already contains an image
       
   187      * @return bool
       
   188      */
       
   189     void setImage(bool image = false);
       
   190 
       
   191     /**
       
   192      * Set that body now contains an audio
       
   193      */
       
   194 	void setAudio(bool audio = false);
       
   195     
       
   196     /**
       
   197      * Get the region (image/audio/video) where longpress happened
       
   198      * @return region
       
   199      */
       
   200     QString getHitRegion(QPointF position);
       
   201 
       
   202     /**
       
   203      * size of the msg
       
   204      */
       
   205     int messageSize();    
       
   206     
       
   207     /**
       
   208      * Handler for set image function 
       
   209      */
       
   210     void handleSetImage();    
       
   211 
       
   212     /**
       
   213      * Starts the resize animation 
       
   214      */
       
   215     void startResizeAnimation();
       
   216 
       
   217     /**
       
   218      * Stops the resize animation 
       
   219      */
       
   220     void stopResizeAnimation();
       
   221 
       
   222 private:
       
   223     /**
       
   224      * Info if message body has image.
       
   225      * true if message body has image else false.
       
   226      */
       
   227     bool mHasImage;
       
   228 
       
   229     /**
       
   230      * Info if message body has audio.
       
   231      * true if message body has audio else false.
       
   232      */
       
   233     bool mHasAudio;
       
   234 
       
   235     /**
       
   236      * editor to in put text.
       
   237      */
       
   238     HbTextEdit* mTextEdit;
       
   239 
       
   240     /**
       
   241      * frame for editor.
       
   242      */
       
   243     HbFrameItem* mEditorFrame;
       
   244 
       
   245     /**
       
   246      * icon item to preview images.
       
   247      */
       
   248     HbIconItem* mIconItem;
       
   249 
       
   250     /**
       
   251      * inline audio item
       
   252      */
       
   253     HbPushButton* mAudioItem;
       
   254 
       
   255 	/**
       
   256 	 * Image file contained inside body
       
   257 	 */
       
   258     QString mImageFile;
       
   259 
       
   260     /**
       
   261      * Saves the original file which has to be used if resize fails
       
   262      */
       
   263     QString mSavedImageFile;
       
   264 
       
   265 	/**
       
   266 	 * Audio file contained inside body
       
   267 	 */
       
   268     QString mAudioFile;
       
   269 
       
   270 	/**
       
   271 	 * Video file contained inside body
       
   272 	 */
       
   273     QString mVideoFile;
       
   274 
       
   275     /**
       
   276      * To setup longpress gesture on media objects
       
   277      */
       
   278     //HbGestureSceneFilter* mGestureFilter;
       
   279 	
       
   280     /**
       
   281      * MMs conformance check utility class
       
   282      */
       
   283     MmsConformanceCheck* mMmsConformanceCheck;
       
   284 	
       
   285     /**
       
   286      * Size of image in body 
       
   287      */
       
   288     int mImageSize;
       
   289     
       
   290     /**
       
   291      * Size of audio in body
       
   292      */
       
   293     int mAudioSize;
       
   294     
       
   295     /**
       
   296      * Size of video in body
       
   297      */
       
   298     int mVideoSize;
       
   299 
       
   300     /**
       
   301      * CUniEditorProcessImageOperation object
       
   302      */
       
   303     CUniEditorProcessImageOperation *mProcessImageOperation;
       
   304 
       
   305     /**
       
   306      * CMsgMediaResolver object
       
   307      */
       
   308     CMsgMediaResolver* mMediaResolver;
       
   309     
       
   310     /**
       
   311      * CMsgImageInfo object
       
   312      */
       
   313     CMsgImageInfo *mImageInfo;    
       
   314     
       
   315     /**
       
   316      * Instance of HbTextItem
       
   317      * Will be deleted automatically by parent.
       
   318      * Own.
       
   319      */
       
   320     HbTextItem *mCharCounter;
       
   321 
       
   322     /**
       
   323      * Instance of HbFrameItem
       
   324      * Will be deleted automatically by parent.
       
   325      * Own.
       
   326      */
       
   327     HbFrameItem* mBackgroundItem;
       
   328     
       
   329     /**
       
   330      * Holds the previous buffer inside msgeditor
       
   331      */
       
   332     QString mPrevBuffer;
       
   333 
       
   334     /**
       
   335      * Holds char type supported
       
   336      */
       
   337     int mCharSupportType;
       
   338 
       
   339     /**
       
   340      * Instance of UniEditorPluginInterface
       
   341      * Will be deleted automatically by parent.
       
   342      * Own.
       
   343      */
       
   344     UniEditorPluginInterface* mPluginInterface;
       
   345 
       
   346     /**
       
   347      * Instance of UniEditorPluginLoader
       
   348      * Will be deleted when UniEditorPluginInterface object is deleted
       
   349      * Not Own.
       
   350      */
       
   351     UniEditorPluginLoader* mPluginLoader;
       
   352 
       
   353     /*
       
   354      * Maintains information if any unicode character has been entered or not
       
   355      */
       
   356     bool mUnicode;
       
   357     
       
   358     /**
       
   359      * Content widget for processing animation.
       
   360      */
       
   361     HbWidget* mProcessingWidget;
       
   362 };
       
   363 
       
   364 #endif //UNIFIED_EDITOR_BODY_H