messagingapp/msgui/unifiededitor/inc/msgunieditorview.h
changeset 76 60a8a215b0ec
parent 62 fdbe8253b596
equal deleted inserted replaced
73:ecf6a73a9186 76:60a8a215b0ec
    16  */
    16  */
    17 
    17 
    18 #ifndef MSG_UNIFIED_EDITOR_VIEW_H
    18 #ifndef MSG_UNIFIED_EDITOR_VIEW_H
    19 #define MSG_UNIFIED_EDITOR_VIEW_H
    19 #define MSG_UNIFIED_EDITOR_VIEW_H
    20 
    20 
    21 #ifdef MSGUI_UNIT_TEST
    21 #ifdef UNIEDITOR_UNIT_TEST
    22  #define UNIFIEDEDITOR_EXPORT
    22  #define UNIFIEDEDITOR_EXPORT
    23 #else
    23 #else
    24  #ifdef UNIFIEDEDITOR_DLL
    24  #ifdef UNIFIEDEDITOR_DLL
    25   #define UNIFIEDEDITOR_EXPORT Q_DECL_EXPORT
    25   #define UNIFIEDEDITOR_EXPORT Q_DECL_EXPORT
    26  #else
    26  #else
    29 #endif
    29 #endif
    30 
    30 
    31 #include "msgbaseview.h"
    31 #include "msgbaseview.h"
    32 #include "convergedmessage.h"
    32 #include "convergedmessage.h"
    33 #include "convergedmessageid.h"
    33 #include "convergedmessageid.h"
    34 
    34 #include <HbStaticVkbHost>
    35 class HbWidget;
    35 
    36 class HbAction;
    36 class HbAction;
    37 class HbGroupBox;
       
    38 class QGraphicsLinearLayout;
    37 class QGraphicsLinearLayout;
    39 class MsgUnifiedEditorSubject;
       
    40 class MsgUnifiedEditorAddress;
       
    41 class MsgUnifiedEditorBody;
       
    42 class MsgUnifiedEditorMonitor;
    38 class MsgUnifiedEditorMonitor;
    43 class MsgAttachmentContainer;
       
    44 class UniEditorPluginLoader;
    39 class UniEditorPluginLoader;
    45 class HbListWidgetItem;
       
    46 class HbAbstractVkbHost;
       
    47 class MsgUnifiedEditorBaseWidget;
    40 class MsgUnifiedEditorBaseWidget;
    48 class HbListWidget;
       
    49 class MsgAudioFetcherDialog;
    41 class MsgAudioFetcherDialog;
    50 
    42 class MsgUnifiedEditorScrollArea;
       
    43 class MsgUnifiedEditorBodyEditor;
       
    44 
       
    45 /**
       
    46  * options in menu.
       
    47  */
       
    48 enum MENU_ACTIONS
       
    49 {
       
    50     PHOTO = 0x00,
       
    51     SOUND = 0x01,
       
    52     VCARD = 0x02,
       
    53     SUBJECT = 0x03,
       
    54     CCBCC = 0x04
       
    55 };
       
    56 
       
    57 /**
       
    58  * Custom vkb host specific to unifiededitor.
       
    59  */
       
    60 class MsgUniEditorVkbHost: public HbStaticVkbHost
       
    61 {
       
    62     Q_OBJECT
       
    63     
       
    64 public:
       
    65     MsgUniEditorVkbHost(HbWidget *target) : HbStaticVkbHost(target){}
       
    66     
       
    67 signals:
       
    68     /**
       
    69      * emitted when focus changes.
       
    70      */
       
    71     void focusChanged();
       
    72     
       
    73 protected:
       
    74     /**
       
    75      * Reimpleted from base class.
       
    76      */
       
    77     void refresh()
       
    78     {
       
    79         emit focusChanged();
       
    80         HbStaticVkbHost::refresh();
       
    81     }
       
    82 };
       
    83 
       
    84 /**
       
    85  * unified editor view class.
       
    86  */
    51 class UNIFIEDEDITOR_EXPORT MsgUnifiedEditorView : public MsgBaseView
    87 class UNIFIEDEDITOR_EXPORT MsgUnifiedEditorView : public MsgBaseView
    52     {
    88     {
    53     Q_OBJECT
    89     Q_OBJECT
    54 
    90 
    55 public:
    91 public:
    73     /**
   109     /**
    74      * Opens the drafts message into editor
   110      * Opens the drafts message into editor
    75      * @param editorData data for editor's usage
   111      * @param editorData data for editor's usage
    76      */
   112      */
    77     void openDraftsMessage(const QVariantList& editorData);
   113     void openDraftsMessage(const QVariantList& editorData);
    78 
       
    79 
   114 
    80     /**
   115     /**
    81      * Saves the content inside editor to save
   116      * Saves the content inside editor to save
    82      */
   117      */
    83     int saveContentToDrafts();
   118     int saveContentToDrafts();
    87      * @param key Key code
   122      * @param key Key code
    88      * @return true if key event handled else false.
   123      * @return true if key event handled else false.
    89      * @see MsgBaseView
   124      * @see MsgBaseView
    90      */
   125      */
    91     bool handleKeyEvent(int key);
   126     bool handleKeyEvent(int key);
    92 
   127     
    93 protected:
       
    94     /**
       
    95      * reimplemented from base class to provide proper geometry for scrolling.
       
    96      */
       
    97     void resizeEvent( QGraphicsSceneResizeEvent * event );
       
    98 
   128 
    99 private:
   129 private:
   100 
   130 
   101     /**
   131     /**
   102      * helper method to add menu.
   132      * helper method to add menu.
   103      */
   133      */
   104     void addMenu();
   134     void addMenu();
   105 
       
   106     /**
       
   107      * helper method to add tool bar.
       
   108      */
       
   109     void addToolBar();
       
   110 
   135 
   111     /**
   136     /**
   112      * Packs the content inside editor into converged message
   137      * Packs the content inside editor into converged message
   113      * @param [OUT]msg, converged message to hold editor data
   138      * @param [OUT]msg, converged message to hold editor data
   114      * @param isSave, flag to indicate that msg needs to be packed
   139      * @param isSave, flag to indicate that msg needs to be packed
   120     /**
   145     /**
   121      * Populate editor with prepopulated msg content
   146      * Populate editor with prepopulated msg content
   122      * @param messageDetails message details
   147      * @param messageDetails message details
   123      * @param draftMessage boolean for specifying draft message
   148      * @param draftMessage boolean for specifying draft message
   124      */
   149      */
   125     void populateContentIntoEditor(
   150     void populateContentIntoEditor(const ConvergedMessage& messageDetails, 
   126         const ConvergedMessage& messageDetails, bool draftMessage = false);
   151                                    bool draftMessage,
       
   152                                    bool checkForInline);
   127     
   153     
   128     /**
   154     /**
   129      * Populate the editor with the message's content
   155      * Populate the editor with the message's content
   130      * for various cases like forward, reply, replyAll
   156      * for various cases like forward, reply, replyAll
   131      * @param messageId, unique id of message in store
   157      * @param messageId, unique id of message in store
   132      * @param messageType, sms or mms
   158      * @param messageType, sms or mms
   133      * @param editorOperation, forward or reply or replyAll etc
   159      * @param editorOperation, forward or reply or replyAll etc
   134      */
   160      */
   135     void fetchMessageFromStore(ConvergedMessageId& messageId,
   161     void fetchMessageFromStore(ConvergedMessageId& messageId,
   136         ConvergedMessage::MessageType messageType,
   162                                ConvergedMessage::MessageType messageType,
   137         int editorOperation);
   163                                int editorOperation);
   138     
   164     
   139     /**
   165     /**
   140      * Create VCards for all the contacts available in the list
   166      * Create VCards for all the contacts available in the list
   141      * @param value list of fetched contacts
   167      * @param value list of fetched contacts
   142      * @param [OUT]filelist list of newly added vcard files
   168      * @param [OUT]filelist list of newly added vcard files
   149      * @param suggestedName suggested file name to use
   175      * @param suggestedName suggested file name to use
   150      * @return fully qualified path of the file in unieditor's temp folder
   176      * @return fully qualified path of the file in unieditor's temp folder
   151      */
   177      */
   152     QString generateFileName(QString& suggestedName);
   178     QString generateFileName(QString& suggestedName);
   153     
   179     
   154     /**
       
   155      * Fetch images 
       
   156      */
       
   157     void fetchImages();
       
   158 
       
   159     /**
       
   160      * Fetch contacts
       
   161      */
       
   162     void fetchContacts();
       
   163 
       
   164     /**
       
   165      * Fetch audio
       
   166      */
       
   167     void fetchAudio();
       
   168 
   180 
   169     /**
   181     /**
   170      * To hide/show chrome.
   182      * To hide/show chrome.
   171      */
   183      */
   172     void hideChrome(bool hide);
   184     void hideChrome(bool hide);
   183     
   195     
   184     /**
   196     /**
   185      * Removes editors temp folder.
   197      * Removes editors temp folder.
   186      */
   198      */
   187     void removeTempFolder();
   199     void removeTempFolder();
   188 
       
   189     /**
       
   190      * Attachment options in TBE
       
   191      * Row number of the TBE actions
       
   192      */
       
   193     enum TBE_AttachOption
       
   194     {
       
   195         TBE_PHOTO = 0x00, TBE_SOUND = 0x01, TBE_VCARD = 0x02
       
   196     };
       
   197 
       
   198     /**
       
   199      * Enable/Disable attachment options for slide-conformance
       
   200      * @param opt, row number of action in TBE
       
   201      * @param isEnabled, true/false
       
   202      */
       
   203     void setAttachOptionEnabled(MsgUnifiedEditorView::TBE_AttachOption opt,
       
   204             bool enable);
       
   205 
       
   206     /**
       
   207      * Addresses are all ok. Now parse not allowed chars away 
       
   208 	 * before giving it to MTM
       
   209 	 * @param addresses, list of ConvergedMessageAddress
       
   210      */
       
   211     void formatAddresses(ConvergedMessageAddressList& addresses);
       
   212     
   200     
   213 private slots:
   201 private slots:
   214 
   202 
   215     /**
   203     /**
   216      * slot to add subject field.
   204      * slot to add subject field.
   217      */
   205      */
   218     void addSubject();
   206     void addSubject(bool needFocus = false);
   219 
   207 
   220     /**
   208     /**
   221      * slot to add Cc,Bcc field.
   209      * slot to add Cc,Bcc field.
   222      */
   210      */
   223     void addCcBcc();
   211     void addCcBcc(bool needFocus = false);
   224 
       
   225     /**
       
   226      * slot to handle Cc, Bcc group-box's toggle action
       
   227      */
       
   228     void updateOtherRecipientCount(bool state);
       
   229 
       
   230     /**
       
   231      * slot to change priority.
       
   232      */
       
   233     void changePriority();
       
   234 
   212 
   235     /**
   213     /**
   236      * slot to current delete message.
   214      * slot to current delete message.
   237      */
   215      */
   238     void deleteMessage();
   216     void deleteMessage();
   251      * slot to send message.
   229      * slot to send message.
   252      */
   230      */
   253     void send();
   231     void send();
   254 	
   232 	
   255     /**
   233     /**
   256      * slot to tell view to remove the attachment's container
       
   257      */
       
   258     void removeAttachmentContainer();
       
   259 
       
   260     /**
       
   261      * add attachments to the editor
   234      * add attachments to the editor
   262      * @param files list of file paths
   235      * @param files list of file paths
   263      */
   236      */
   264     void addAttachments(QStringList files);
   237     void addAttachments(QStringList files);
   265 
       
   266     /**
       
   267      * add an attachment to the editor
       
   268      * @return addition operation status
       
   269      */
       
   270     int addAttachment(const QString& filepath);
       
   271 
       
   272 	/**
       
   273      * called when extention item is clicked.
       
   274      */
       
   275     void handleViewExtnActivated(HbListWidgetItem* item);
       
   276     
   238     
   277     /**
   239     /**
   278      * Signal emitted when an error is generated.
   240      * Signal emitted when an error is generated.
   279      * @param errorCode Error code.
   241      * @param errorCode Error code.
   280      * @param errorMessage Error description.
   242      * @param errorMessage Error description.
   312      * Sets focus to item.
   274      * Sets focus to item.
   313      */
   275      */
   314     void setFocus(MsgUnifiedEditorBaseWidget* item);
   276     void setFocus(MsgUnifiedEditorBaseWidget* item);
   315     
   277     
   316     /**
   278     /**
   317      * Listens to contentChanged signal of various fields.
   279      * Listens to contentChanged signal for various editor fields.
   318      */
   280      */
   319     void onContentChanged();
   281     void onContentChanged();
   320 
   282 
   321 	/**
   283 	/**
   322      * This slot is called when delete message dialog is launched.
   284      * This slot is called when delete message dialog is launched.
   333     /**
   295     /**
   334      * This slot is called when define mms settings dialog is launched.
   296      * This slot is called when define mms settings dialog is launched.
   335      * @param action selected action (yes or no).
   297      * @param action selected action (yes or no).
   336      */
   298      */
   337     void onDialogMmsSettings(HbAction* action);    
   299     void onDialogMmsSettings(HbAction* action);    
   338 	
       
   339 	/**
       
   340      * Enable/Disable send tool button.
       
   341      * @param true/false to enable/disable.
       
   342      */
       
   343      void enableSendButton(bool enable);
       
   344      
       
   345      /**
       
   346       * This slot is triggered when vkb is about to be opened.
       
   347       */
       
   348      void vkbAboutToOpen();
       
   349      
       
   350      /**
       
   351       * This slot is triggered when vkb is about to be closed.
       
   352       */
       
   353      void vkbAboutToClose();
       
   354      
   300      
   355      /** 
   301      /** 
   356       * This slot is called after sound clip is 
   302       * This slot is called after sound clip is 
   357       * selected from audio fetcher dialog    
   303       * selected from audio fetcher dialog    
   358       */
   304       */
   361 	 /**
   307 	 /**
   362       * Check if the reply-path is broken
   308       * Check if the reply-path is broken
   363       * @return bool, true if reply-path constraints are broken
   309       * @return bool, true if reply-path constraints are broken
   364       */
   310       */
   365      bool isReplyPathBroken();
   311      bool isReplyPathBroken();
       
   312      
       
   313      /**
       
   314       * Fetch images 
       
   315       */
       
   316      void fetchImages();
       
   317 
       
   318      /**
       
   319       * Fetch contacts
       
   320       */
       
   321      void fetchContacts();
       
   322 
       
   323      /**
       
   324       * Fetch audio
       
   325       */
       
   326      void fetchAudio();
       
   327      
       
   328      /**
       
   329       * Enable/Disable/removes menu actions.
       
   330       * @param opt, submenu actions.
       
   331       * @param isEnabled, true/false
       
   332       */
       
   333      void enableMenuAction(int action, bool enable);
       
   334      
       
   335      /**
       
   336       * Resets layout when vkb is cosed.
       
   337       */
       
   338      void resetLayout();     
       
   339      
       
   340      /**
       
   341       * Perform layouting when vkb is opened.
       
   342       */
       
   343      void doLayout();
       
   344      
       
   345      /**
       
   346       * Ensures visibility of editor widget in to visible area.
       
   347       */
       
   348      void ensureVisibility();
       
   349      
       
   350      /**
       
   351       * Updates focus widget when editor gains focus.
       
   352       */
       
   353      void focusChanged();
       
   354      
   366     
   355     
   367 private:
   356 private:
   368      
   357      
   369     HbAction* mSubjectAction;
   358      /**
   370     HbAction* mCcBccAction;
   359       * main layout of view.
   371     HbAction* mSendAction;
   360       */
   372     QGraphicsLinearLayout* mMainLayout;
   361     QGraphicsLinearLayout* mMainLayout;
   373     MsgUnifiedEditorSubject* mSubjectField;
       
   374     MsgUnifiedEditorAddress* mToField;
       
   375     MsgUnifiedEditorAddress* mCcField;
       
   376     MsgUnifiedEditorAddress* mBccField;
       
   377     MsgUnifiedEditorBody*   mBody;
       
   378 
       
   379     HbWidget* mContentWidget;
       
   380 
       
   381     MsgUnifiedEditorMonitor* mMsgMonitor;
   362     MsgUnifiedEditorMonitor* mMsgMonitor;
   382     MsgAttachmentContainer* mAttachmentContainer;
       
   383     UniEditorPluginLoader* mPluginLoader;
   363     UniEditorPluginLoader* mPluginLoader;
       
   364     
       
   365     /**
       
   366      * Message id of current opened message.
       
   367      */
   384     ConvergedMessageId mOpenedMessageId;
   368     ConvergedMessageId mOpenedMessageId;
   385     ConvergedMessage::MessageType mmOpenedMessageType;
   369     
       
   370     /**
       
   371      * flag to check if message can be saved to drafts.
       
   372      */
   386 	bool mCanSaveToDrafts;
   373 	bool mCanSaveToDrafts;
   387 	HbAction *mAttachAction;
       
   388     
       
   389 	/**
       
   390 	 * TBE's content widget
       
   391 	 */
       
   392 	HbListWidget* mTBExtnContentWidget;
       
   393 	
   374 	
   394     /**
   375     /**
   395      * Instance of VKB host
   376      * Instance of VKB host
   396      */
   377      */
   397 	HbAbstractVkbHost* mVkbHost;
   378 	MsgUniEditorVkbHost* mVkbHost;
   398 	
   379 	
   399 	/**
   380 	/**
   400 	 * Instance of Audio Fetcher Dialog
   381 	 * Instance of Audio Fetcher Dialog
   401 	 * Need to show when attachment audio selected
   382 	 * Need to show when attachment audio selected
   402 	 */
   383 	 */
   416 
   397 
   417     /**
   398     /**
   418      * Flag to tell if reply-path is available
   399      * Flag to tell if reply-path is available
   419      */
   400      */
   420     bool mReplyPath;	
   401     bool mReplyPath;	
   421 
   402     
   422 	friend class MsgUnifiedEditorMonitor;
   403     /**
       
   404      * Scrollable conatiner.
       
   405      */
       
   406     MsgUnifiedEditorScrollArea* mScrollArea;
       
   407     
       
   408     /**
       
   409      * Body text editor.
       
   410      */
       
   411     MsgUnifiedEditorBodyEditor* mBodyEditor;
       
   412     
       
   413     /**
       
   414      * Various actions.
       
   415      */
       
   416     HbAction* mSubjectAction;
       
   417     HbAction* mCcBccAction;
       
   418     HbAction* mPhotoAction;
       
   419     HbAction* mSoundAction;
       
   420      
       
   421     /**
       
   422      * Widget currently focussed.
       
   423      */
       
   424     QGraphicsWidget* mFocusedWidget;
       
   425     
       
   426     /**
       
   427      * Min height of foucssed widget.
       
   428      */
       
   429     qreal mMinHeight;
       
   430     
       
   431     /**
       
   432      * Max height of focussed widget.
       
   433      */
       
   434     qreal mMaxHeight;
       
   435 	
       
   436 #ifdef UNIEDITOR_UNIT_TEST
       
   437     /**
       
   438      * Unit Testing
       
   439      */
       
   440     friend class TestMsgUnifiedEditorView;
       
   441 #endif
       
   442 	
   423     };
   443     };
   424 
   444 
   425 #endif //MSG_UNIFIED_EDITOR_VIEW_H
   445 #endif //MSG_UNIFIED_EDITOR_VIEW_H