messagingapp/msgui/unifiededitor/inc/msgunieditorscrollarea.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: manages scrollable portion of view.
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef MSGUNIEDITORSCROLLAREA_H_
       
    19 #define MSGUNIEDITORSCROLLAREA_H_
       
    20 
       
    21 #include <HbScrollArea>
       
    22 #include "convergedmessageaddress.h"
       
    23 
       
    24 class QGraphicsLinearLayout;
       
    25 class MsgUnifiedEditorAddress;
       
    26 class MsgUnifiedEditorSubject;
       
    27 class MsgUnifiedEditorBody;
       
    28 class MsgUnifiedEditorBaseWidget;
       
    29 class ConvergedMessage;
       
    30 class MsgAttachmentContainer;
       
    31 class MsgUnifiedEditorMonitor;
       
    32 
       
    33 class MsgUnifiedEditorScrollArea : public HbScrollArea
       
    34 {
       
    35     Q_OBJECT
       
    36     
       
    37 public:
       
    38     MsgUnifiedEditorScrollArea(MsgUnifiedEditorMonitor* msgMonitor,QGraphicsItem *parent = 0);
       
    39     ~MsgUnifiedEditorScrollArea();
       
    40     
       
    41     /**
       
    42      * Tells if contacts in "To" "Cc" , "Bcc" field are valid or not
       
    43      */
       
    44     bool contactsValid();
       
    45 
       
    46     /**
       
    47      * First address of "To" field.
       
    48      */
       
    49     ConvergedMessageAddress* currentAddress();
       
    50     
       
    51     /**
       
    52      * Packs the content inside editor into converged message
       
    53      * @param [OUT]msg, converged message to hold editor data
       
    54      * @param isSave, flag to indicate that msg needs to be packed
       
    55      * for saving to draft or not
       
    56      * @return returns error if something fails
       
    57      */
       
    58     int packMessage(ConvergedMessage &msg, bool isSave);
       
    59     
       
    60     /**
       
    61      * add attachments to the editor
       
    62      * @param files list of file paths
       
    63      */
       
    64     void addAttachments(const QStringList files);
       
    65     
       
    66     /**
       
    67      * Checks if vcf file name is already in use or not.
       
    68      */
       
    69     bool fileNameInUse(const QString& fileName);
       
    70     
       
    71     /**
       
    72      * Enables/Disables scrolling based on parameter passed.
       
    73      */
       
    74     void enableScrolling(bool enable);
       
    75     
       
    76     /**
       
    77      * Populate data into various fields from ConvergedMessage.
       
    78      * @param msg, ConvergedMessage object.
       
    79      * @param draftMessage, true if message is opened from drafts.
       
    80      */
       
    81     void populateContent(const ConvergedMessage& msg, bool draftMessage, bool checkForInline);
       
    82     
       
    83 protected:
       
    84     /**
       
    85      * Reimplemented from base class.
       
    86      */
       
    87     virtual bool scrollByAmount(const QPointF &delta);
       
    88     
       
    89 
       
    90     
       
    91 private:
       
    92     void init();
       
    93     void setFocus(MsgUnifiedEditorBaseWidget* item);
       
    94     void formatAddresses(ConvergedMessageAddressList& addresses);
       
    95     
       
    96 signals:
       
    97     //emitted to enable or disable attach submenu options.
       
    98     void enableMenuAction(int action, bool enable);
       
    99     
       
   100 public slots:
       
   101 
       
   102     /**
       
   103      * Posts event to launch key pad.
       
   104      */
       
   105     void postInputPanelEvent();
       
   106     
       
   107     /**
       
   108      * slot to add Cc,Bcc field.
       
   109      */
       
   110     void addCcBcc(bool needFocus = false);
       
   111     
       
   112     /**
       
   113      * slot to add subject field.
       
   114      */
       
   115     void addSubject(bool needFocus = false);
       
   116     
       
   117     /**
       
   118      * slot to change priority.
       
   119      */
       
   120     void changePriority();
       
   121     
       
   122     void setImage(const QString& path, bool draftMessage = false);
       
   123     
       
   124     void setAudio(const QString& filePath);
       
   125     
       
   126 private slots:
       
   127 
       
   128     /**
       
   129      * slot to handle Cc, Bcc group-box's toggle action
       
   130      */
       
   131     void updateOtherRecipientCount(bool state);
       
   132     
       
   133     /**
       
   134      * slot to tell view to remove the attachment's container
       
   135      */
       
   136     void removeAttachmentContainer();
       
   137 
       
   138     /**
       
   139      * add an attachment to the editor
       
   140      * @return addition operation status
       
   141      */
       
   142     int addAttachment(const QString& filepath);
       
   143 
       
   144 
       
   145 private:
       
   146 
       
   147     MsgUnifiedEditorMonitor* mMsgMonitor;
       
   148     QGraphicsLinearLayout* mMainLayout;
       
   149     MsgUnifiedEditorAddress* mToField;
       
   150     MsgUnifiedEditorAddress* mCcField;
       
   151     MsgUnifiedEditorAddress* mBccField;
       
   152     MsgUnifiedEditorSubject* mSubjectField;
       
   153     MsgUnifiedEditorBody* mBody;    
       
   154     MsgAttachmentContainer* mAttachmentContainer;
       
   155     
       
   156     bool mEnableScrolling;
       
   157 #ifdef UNIEDITOR_UNIT_TEST
       
   158     friend class TestMsgUnifiedEditorScrollArea;
       
   159 #endif
       
   160 };
       
   161 
       
   162 #endif /* MSGUNIEDITORSCROLLAREA_H_ */