messagingapp/msgui/conversationview/inc/msgconversationview.h
branchRCL_3
changeset 57 ebe688cedc25
equal deleted inserted replaced
54:fa1df4b99609 57:ebe688cedc25
       
     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 chat View for the messaging application.
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef MSG_CONVERSATION_VIEW_H
       
    19 #define MSG_CONVERSATION_VIEW_H
       
    20 
       
    21 // INCLUDES
       
    22 #include "msgbaseview.h"
       
    23 #include "convergedmessage.h"
       
    24 
       
    25 //Forward declarations
       
    26 class HbListView;
       
    27 class HbAbstractViewItem;
       
    28 class MsgSendUtil;
       
    29 class QStandardItemModel;
       
    30 class MsgEditorWidget;
       
    31 class MsgContactCardWidget;
       
    32 class MsgConversationViewItem;
       
    33 class HbStaticVkbHost;
       
    34 class QGraphicsLinearLayout;
       
    35 class HbAction;
       
    36 //Defines
       
    37 #define INVALID_MSG_ID -1
       
    38 
       
    39 /**
       
    40  * This class provides the message chat view for the messaging application.
       
    41  * Data source for this view is the conversation model.
       
    42  */
       
    43 class MsgConversationView : public MsgBaseView
       
    44 {
       
    45 Q_OBJECT
       
    46 
       
    47 public:
       
    48 
       
    49     /**
       
    50      * Constructor
       
    51      */
       
    52     MsgConversationView(MsgContactCardWidget *contactCardWidget,
       
    53         QGraphicsItem *parent = 0);
       
    54 
       
    55     /**
       
    56      * Destructor
       
    57      */
       
    58     ~MsgConversationView();
       
    59 
       
    60 
       
    61     /**
       
    62      * Clear editors
       
    63      * clear message and address editors
       
    64      */
       
    65     void clearEditors();
       
    66 
       
    67     /**
       
    68      * Save the content inside editor to drafts
       
    69      * @return valid message id if save is success
       
    70      * else invalid message id ( i.e. -1 )
       
    71      */
       
    72     int saveContentToDrafts();
       
    73 
       
    74 private slots:
       
    75 
       
    76     /**
       
    77      * Slot is called when menu is about to be shown.
       
    78      * Populates the menu with relevant actions.
       
    79      */
       
    80     void menuAboutToShow();
       
    81     
       
    82 	/**
       
    83      * This slot is called when settings dialog is launched.
       
    84      * @param action selected action (yes or no).
       
    85      */
       
    86     void onDialogSettingsLaunch(HbAction* action);
       
    87     
       
    88 	/**
       
    89      * This slot is called when delete message centre dialog is launched.
       
    90      * @param action selected action (yes or no).
       
    91      */	
       
    92     void onDialogdeleteMsg(HbAction* action);
       
    93 	
       
    94 	/**
       
    95      * This slot is called when download message centre dialog is launched.
       
    96      * @param action selected action (yes or no).
       
    97      */	    
       
    98     void onDialogDownLoadMsg(HbAction* action);
       
    99 	
       
   100 	/**
       
   101      * This slot is called when save tone dialog is launched.
       
   102      * @param action selected action (yes or no).
       
   103      */	
       
   104     void onDialogSaveTone(HbAction* action);
       
   105 
       
   106     /**
       
   107      * This slot is called when the orientation is changed
       
   108      * @param newOrientation orientation
       
   109      */
       
   110     void onOrientationChanged(Qt::Orientation newOrientation);
       
   111 
       
   112     /**
       
   113      * This slot is called when the orientation is about to bechanged
       
   114      */
       
   115     void onOrientationAboutToBeChanged();
       
   116     
       
   117 private:
       
   118 
       
   119     /**
       
   120      * View initialization function.
       
   121      */
       
   122     void setupView();
       
   123 
       
   124     /**
       
   125      * Setup view menu items.
       
   126      */
       
   127     void setupMenu();
       
   128 
       
   129     /**
       
   130      * Triggers model to fetch more conversations.
       
   131      */
       
   132     void fetchMoreConversations();
       
   133 
       
   134     /**
       
   135      * Populates ConvergedMessage for sending.
       
   136      * @param ConvergedMessage to be populated
       
   137      * @see ConvergedMessage::MessageType
       
   138      */
       
   139     void populateForSending(ConvergedMessage &message);
       
   140     
       
   141     /**
       
   142      * Adds context menu entries to context menu
       
   143      * @param HbMenu context menu
       
   144      * @param int sendingstate.
       
   145      * @see ConvergedMessage::MessageType
       
   146      */
       
   147     void setContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   148 	
       
   149     /**
       
   150      * Adds context menu entry to context menu for saving items
       
   151      * @param MsgConversationViewItem* item whose information is needed.
       
   152      * @param HbMenu context menu
       
   153      * @param int sendingstate.
       
   154      * @see ConvergedMessage::MessageType
       
   155      */    
       
   156     void addSaveItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   157     
       
   158     /**
       
   159      * Adds context menu entry to context menu for Opening items
       
   160 	 * @param MsgConversationViewItem* item whose information is needed.
       
   161      * @param HbMenu context menu
       
   162      * @param int sendingstate.
       
   163      * @see ConvergedMessage::MessageType
       
   164      */
       
   165     void addOpenItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   166 
       
   167     /**
       
   168      * Adds context menu entry to context menu for Resending items
       
   169      * @param MsgConversationViewItem* item whose information is needed.
       
   170      * @param HbMenu context menu
       
   171      * @param int sendingstate.
       
   172      * @see ConvergedMessage::MessageType
       
   173      */  
       
   174     void addResendItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   175 
       
   176     /**
       
   177      * Adds context menu entry to context menu for Forwarding items
       
   178 	 * @param MsgConversationViewItem* item whose information is needed.
       
   179      * @param HbMenu context menu
       
   180      * @param int sendingstate.
       
   181      * @see ConvergedMessage::MessageType
       
   182      */
       
   183     void addForwardItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   184 
       
   185     /**
       
   186      * Adds context menu entry to context menu for Deleting items
       
   187 	 * @param MsgConversationViewItem* item whose information is needed.
       
   188      * @param HbMenu context menu
       
   189      * @param int sendingstate.
       
   190      * @see ConvergedMessage::MessageType
       
   191      */
       
   192     void addDeleteItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState);
       
   193 
       
   194     /**
       
   195      * Adds context menu entry to context menu for Downloading items
       
   196      * @param MsgConversationViewItem* item whose information is needed.
       
   197      * @param HbMenu context menu    
       
   198      * @see ConvergedMessage::MessageType
       
   199      */
       
   200     void addDownloadItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu);
       
   201 
       
   202     /**
       
   203      * Launches the BT message display service.
       
   204      * @param index Index of the item activated/touched
       
   205      */
       
   206     void launchBtDisplayService(const QModelIndex & index);
       
   207 
       
   208 public slots:
       
   209     /**
       
   210      * Refreshes all widgets in the conversation view according to latest model
       
   211      * data
       
   212      */
       
   213     void refreshView();
       
   214 
       
   215     /**
       
   216      * This slot is called when the view is successfully added to main window
       
   217      */
       
   218     void onViewReady();
       
   219     
       
   220 private slots:
       
   221 
       
   222     /**
       
   223      * Utility method to scroll the list to show the bottom most item
       
   224      */
       
   225     void scrollToBottom();
       
   226     
       
   227     void onConversationViewEmpty();
       
   228 
       
   229     /**
       
   230      * Handler for long tap of a list item.
       
   231      * @param viewItem  Long tapped view item
       
   232      * @param point X and Y co-ordinates of long tap
       
   233      */
       
   234     void longPressed(HbAbstractViewItem* viewItem, const QPointF& point);
       
   235 
       
   236     /**
       
   237      * Handler for short tap/direct touch of a list item.
       
   238      * @param index index of the item activated/touched
       
   239      */
       
   240     void openItem(const QModelIndex & index);
       
   241 
       
   242     /**
       
   243      * Sends the message
       
   244      */
       
   245     void send();
       
   246 
       
   247     // ----------------------------- View Specific Menu Slots--------------------//
       
   248 
       
   249    
       
   250     /**
       
   251      * Fetch images 
       
   252      */
       
   253     void fetchImages();
       
   254 
       
   255     /**
       
   256      * Fectch conatcts
       
   257      */
       
   258     void fetchContacts();
       
   259 
       
   260     /**
       
   261      * Fectch audio
       
   262      */
       
   263     void fetchAudio();
       
   264 
       
   265     /*
       
   266      * Get the photos and launch editor
       
   267      */
       
   268     void imagesFetched(const QVariant& result );
       
   269     
       
   270     /**
       
   271      * slot to receive fetched contacts for addition
       
   272      */
       
   273     void contactsFetched(const QVariant& value);
       
   274 
       
   275     /**
       
   276      * slot to receive fetched contacts for vcard addition
       
   277      */
       
   278     void contactsFetchedForVCards(const QVariant& value);
       
   279     
       
   280     /*
       
   281      * Adds subject file to editor.
       
   282      */
       
   283     void addSubject();
       
   284 
       
   285 
       
   286     //----------------------Item Specific menu slots ---------------------//
       
   287 
       
   288     /**
       
   289      * Forwards the message
       
   290      */
       
   291     void forwardMessage();
       
   292 
       
   293     /**
       
   294      * Deletes the item
       
   295      */
       
   296     void deleteItem();
       
   297     
       
   298     /**
       
   299      * Resends the item. This is only valid in the failed message case.
       
   300      */
       
   301     void resendMessage();
       
   302 
       
   303     /**
       
   304      * Download the specified message
       
   305      */
       
   306     void downloadMessage();
       
   307 
       
   308     /**
       
   309      * Open the item
       
   310      */
       
   311     void openItem();
       
   312 
       
   313     /**
       
   314      * Set model to the view 
       
   315      */    
       
   316     void populateConversationsView();
       
   317 
       
   318     /**
       
   319      * Save ringing tone
       
   320      */
       
   321     void saveRingingTone();   
       
   322     
       
   323     /**
       
   324      * Launch Editor since sms character limit reached
       
   325      */
       
   326     void handleSmsCharLimitReached();   
       
   327     
       
   328     /**
       
   329      * Hanldes saving of vcard.
       
   330      */
       
   331     void saveVCard();
       
   332     
       
   333     /**
       
   334      * Tells is mms is shared among conversations.
       
   335      * @param messageId, message id.
       
   336      * @return true is shared among conversations.
       
   337      */
       
   338     bool isSharedMessage(qint32 messageId);
       
   339     
       
   340 signals:
       
   341     /**
       
   342      * Signal emitted to inform close the conversation view.
       
   343      * When Conversation view has opened in send mode, after sending
       
   344      * the message, this signal is emitted.
       
   345      */
       
   346     void closeConversationView();
       
   347 
       
   348     /**
       
   349      * Emitted when editor is tapped to reply.
       
   350      */
       
   351     void replyStarted();
       
   352     
       
   353    /**
       
   354     * This signal is emitted when vkb is open/closed.
       
   355     * @param state True if keypad is opened else false.
       
   356     */
       
   357     void vkbOpened(bool state);
       
   358 
       
   359 private slots:
       
   360     /**
       
   361      * Resizes the view when VKB is opened.
       
   362      * This slot is triggered when user taps on the CV editor
       
   363      */
       
   364     void vkbOpened();
       
   365 
       
   366     /**
       
   367      * Resizes the view when VKB is closed.
       
   368      * This slot is triggered when VKB focus is lost.
       
   369      */
       
   370     void vkbClosed();
       
   371     
       
   372 private:
       
   373     /**
       
   374      * launch editor when attachment is inserted
       
   375      * @params data used for launching editor with pre-populated content
       
   376      */
       
   377     void launchUniEditor(const QVariantList& data);
       
   378     
       
   379     /**
       
   380      * Signal emitted when an error is generated.
       
   381      * @param errorCode Error code.
       
   382      * @param errorMessage Error description.
       
   383      */
       
   384     void serviceRequestError(int errorCode, const QString& errorMessage);
       
   385     
       
   386     /**
       
   387      * Activate Input Blocker
       
   388      */
       
   389     void activateInputBlocker();
       
   390 
       
   391     /**
       
   392      * Deactivate Input Blocker
       
   393      */
       
   394     void deactivateInputBlocker();
       
   395     
       
   396     /**
       
   397      * Handle provisioning message
       
   398      * @param msgId message id
       
   399      */
       
   400     void handleProvisoningMsg(int msgId);
       
   401     
       
   402     /**
       
   403      * Handles short tap for vcard.
       
   404      */
       
   405     void handleShortTap();
       
   406     
       
   407     /**
       
   408      * helper method to show long/short tap context menu.
       
   409      */
       
   410     void showContextMenu(HbAbstractViewItem* viewItem,const QPointF& point, int placement);
       
   411 
       
   412 private:
       
   413 
       
   414     /**
       
   415      * List to hold the conversations
       
   416      * Owned
       
   417      */
       
   418     HbListView *mConversationList;
       
   419 
       
   420     /**
       
   421      * Model to facilitate filtering and sorting
       
   422      * Owned
       
   423      */
       
   424     QStandardItemModel *mMessageModel;
       
   425 
       
   426     /**
       
   427      * Instance of messaged editor widget.
       
   428      */
       
   429     MsgEditorWidget *mEditorWidget;
       
   430 
       
   431     /**
       
   432      * Instance of Contact Card widget.
       
   433      */
       
   434     MsgContactCardWidget* mContactCardWidget;
       
   435     
       
   436     /**
       
   437      * Send utils instance
       
   438      */
       
   439     MsgSendUtil *mSendUtil;
       
   440  
       
   441     /**
       
   442      * Instance of the main layout.
       
   443      */
       
   444     QGraphicsLinearLayout *mMainLayout;
       
   445 
       
   446     /*
       
   447      * Instance of VKB 
       
   448      */
       
   449     HbStaticVkbHost* mVkbHost;
       
   450     
       
   451     /**
       
   452      * variable holding the visible model index
       
   453      */
       
   454     QModelIndex mVisibleIndex;
       
   455     
       
   456     /**
       
   457      * Flag is set when model is populated.
       
   458      * @see signal conversationModelPopulated()
       
   459      */
       
   460     bool mModelPopulated;
       
   461     
       
   462     /**
       
   463      * Flag is set when 
       
   464      */
       
   465     bool mViewReady;
       
   466 };
       
   467 
       
   468 #endif // MSG_CONVERSATION_VIEW_H
       
   469 // EOF