messagingapp/msgui/conversationview/inc/msgconversationwidget.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:MsgConversationWidget Widget (aka Bubble Widget).
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef MSG_CONVERSATIONWIDGET_H
       
    19 #define MSG_CONVERSATIONWIDGET_H
       
    20 
       
    21 // SYSTEM INCLUDES
       
    22 #include <hbwidget.h>
       
    23 #include <HbIcon>
       
    24 
       
    25 // FORWORD DECLARATIONS
       
    26 class HbFrameItem;
       
    27 class HbIconItem;
       
    28 class HbTextItem;
       
    29 
       
    30 /**
       
    31  * This class represents the custom layouted widget to show
       
    32  * the conversation inside a bubble shape in the conversation view.
       
    33  */
       
    34 class MsgConversationWidget: public HbWidget
       
    35 {
       
    36 Q_OBJECT
       
    37 
       
    38 Q_ENUMS(SendingState)
       
    39 Q_PROPERTY(int priority READ priority WRITE setPriority)
       
    40 Q_PROPERTY(bool hasAttachment READ hasAttachment WRITE setAttachment)
       
    41 Q_PROPERTY(bool hasImage READ hasImage WRITE setImage)
       
    42 Q_PROPERTY(bool hasAudio READ hasAudio WRITE setAudio)
       
    43 Q_PROPERTY(bool hasVideo READ hasVideo WRITE setVideo)
       
    44 Q_PROPERTY(bool isPlayable READ isPlayable WRITE setPlayable)
       
    45 Q_PROPERTY(bool isIncoming READ isIncoming WRITE setIncoming)
       
    46 Q_PROPERTY(bool isMMS READ isMMS WRITE setMMS)
       
    47 Q_PROPERTY(bool isMMSNotification READ isMMSNotification WRITE setMMSNotification)
       
    48 Q_PROPERTY(bool isUnread READ isUnread WRITE setUnread)
       
    49 Q_PROPERTY(SendingState sendingState READ sendingState WRITE setSendingState)
       
    50 Q_PROPERTY(int notificationState READ notificationState WRITE setNotificationState)
       
    51 
       
    52 public:
       
    53 
       
    54     /**
       
    55      * Constructor
       
    56      * @param parent, reference of QGraphicsItem
       
    57      * default set to 0
       
    58      */
       
    59     MsgConversationWidget(QGraphicsItem * parent = 0);
       
    60 
       
    61     /**
       
    62      * Destructor
       
    63      */
       
    64     virtual ~MsgConversationWidget();
       
    65 
       
    66 public:
       
    67 
       
    68     /**
       
    69      * Enum defining Message Sending State
       
    70      * @attention This enum can have values from 0 to 255 only.
       
    71      */
       
    72     enum SendingState
       
    73     {
       
    74         Unknown = 0x00, Sent = 0x01, Sending = 0x02, Pending = 0x03, Failed = 0x04
       
    75     };
       
    76 
       
    77     /**
       
    78      * Set subject for this widget
       
    79      * @param QString
       
    80      */
       
    81     void setSubject(const QString &subject);
       
    82 
       
    83     /**
       
    84      * Set body text for this widget
       
    85      * @param QString
       
    86      */
       
    87     void setBodyText(const QString &bodyText);
       
    88 
       
    89     /**
       
    90      * Set preview icon for this widget
       
    91      * @param HbIcon, preview-icon
       
    92      */
       
    93     void setPreviewIcon(HbIcon& icon);
       
    94 
       
    95     /**
       
    96      * Set priority property
       
    97      * @param priority Set high/low/normal priority
       
    98      * @attention Pass high/low/normal priority to this function.
       
    99      * @see ConvergedMessage::Priority
       
   100      */
       
   101     void setPriority(int priority);
       
   102 
       
   103     /**
       
   104      * Get priority property
       
   105      * @return Returns high/low/normal priority.
       
   106      * @see ConvergedMessage::Priority
       
   107      */
       
   108     int priority();
       
   109 
       
   110     /**
       
   111      * Specify if this widget's message has attachment
       
   112      * @param bool
       
   113      */
       
   114     void setAttachment(bool hasAttachment = true);
       
   115 
       
   116     /**
       
   117      * Get to find if this has attachment
       
   118      * @return bool
       
   119      */
       
   120     bool hasAttachment();
       
   121 
       
   122     /**
       
   123      * Specify if this widget's message has image
       
   124      * @param bool
       
   125      */
       
   126     void setImage(bool image = true);
       
   127 
       
   128     /**
       
   129      * Get to find if this has image file
       
   130      * @return bool
       
   131      */
       
   132     bool hasImage();
       
   133 
       
   134     /**
       
   135      * Specify if this widget's message has audio
       
   136      * @param bool
       
   137      */
       
   138     void setAudio(bool hasAudio = true);
       
   139 
       
   140     /**
       
   141      * Get to find if this has audio file
       
   142      * @return bool
       
   143      */
       
   144     bool hasAudio();
       
   145 
       
   146     /**
       
   147      * Displays audio icon if audio media is present.
       
   148      */
       
   149     void displayAudioIcon(const QString &iconPath = QString());
       
   150 
       
   151     /**
       
   152      * Specify if this widget's message has video
       
   153      * @param bool
       
   154      */
       
   155     void setVideo(bool hasVideo = true);
       
   156 
       
   157     /**
       
   158      * Get to find if this has video file
       
   159      * @return bool
       
   160      */
       
   161     bool hasVideo();
       
   162 
       
   163     /**
       
   164      * Specify if this widget's message has playable content
       
   165      * @param bool
       
   166      */
       
   167     void setPlayable(bool playable = true);
       
   168 
       
   169     /**
       
   170      * Get to find if this has playable content
       
   171      * @return bool
       
   172      */
       
   173     bool isPlayable();
       
   174 
       
   175     /**
       
   176      * Specify if this widget's message is incoming
       
   177      * @param bool
       
   178      */
       
   179     void setIncoming(bool incoming = true);
       
   180 
       
   181     /**
       
   182      * Get to find if this is incoming message
       
   183      * @return bool
       
   184      */
       
   185     bool isIncoming();
       
   186 
       
   187     /**
       
   188      * Specify if this widget's message is unread
       
   189      * @param bool
       
   190      */
       
   191     void setUnread(bool unread = true);
       
   192 
       
   193     /**
       
   194      * Get to find if this is unread message
       
   195      * @return bool
       
   196      */
       
   197     bool isUnread();
       
   198 
       
   199     /**
       
   200      * Set to know if this widget if of type MMS
       
   201      * @return bool
       
   202      */
       
   203     void setMMS(bool isMMS = true);
       
   204 
       
   205     /**
       
   206      * Get to find if this widget is of type MMS
       
   207      * @return bool
       
   208      */
       
   209     bool isMMS();
       
   210 
       
   211     /**
       
   212      * Set to know if this widget if of type MMS Notification
       
   213      * @return bool
       
   214      */
       
   215     void setMMSNotification(bool isMMSNotification = true);
       
   216 
       
   217     /**
       
   218      * Get to find if this widget is of type MMS Notification
       
   219      * @return bool
       
   220      */
       
   221     bool isMMSNotification();
       
   222 
       
   223     /**
       
   224      * Set the sending state.
       
   225      * Maps ConvergedMessage::SendingState to MessageState.
       
   226      * @see ConvergedMessage::SendingState
       
   227      */
       
   228     void setSendingState(int state);
       
   229 
       
   230     /**
       
   231      * Returns the sending state.
       
   232      * @return Returns one of the states from enum SendingState.
       
   233      */
       
   234     SendingState sendingState();
       
   235 
       
   236     /**
       
   237      * Set the notification state.
       
   238      * Maps ConvergedMessage::NotificationState to MessageState.
       
   239      * @see ConvergedMessage::NotificationState
       
   240      */
       
   241     void setNotificationState(int state);
       
   242 
       
   243     /**
       
   244      * Returns the notification state.
       
   245      * @return Returns one of the states from enum NotificationState.
       
   246      */
       
   247     int notificationState();
       
   248 
       
   249     /**
       
   250      * Sets the Timestamp.
       
   251      * @param timeStamp Timestamp to be set.
       
   252      */
       
   253     void setTimeStamp(const QString &timeStamp);
       
   254 
       
   255     /**
       
   256      * Draws the new message frame.
       
   257      */
       
   258     void drawNewItemFrame();
       
   259 
       
   260     /**
       
   261      * Draws the normal/highlighted state bubble frame.
       
   262      */
       
   263     void drawBubbleFrame();
       
   264 
       
   265     /**
       
   266      * Draws the pressed state bubble frame.
       
   267      */
       
   268     void drawPressedBubbleFrame();
       
   269 
       
   270     /**
       
   271      * Function to receive item pressed events.
       
   272      * @see MsgConversationViewItem::pressStateChanged
       
   273      */
       
   274     void pressStateChanged(bool pressed, bool animate);
       
   275 
       
   276 	/**
       
   277      * Function to reset widget items.
       
   278      */
       
   279     void resetProperties();
       
   280 
       
   281     /**
       
   282      * Function to repolish widget.
       
   283      */
       
   284     void repolishWidget();
       
   285 
       
   286 protected:
       
   287     
       
   288     /*
       
   289      * @see HbWidget
       
   290      */
       
   291     virtual void polish(HbStyleParameters &params);
       
   292     
       
   293 private slots:
       
   294 	
       
   295     /*
       
   296      * Handler for orientation changed
       
   297      * @param orientation Qt::Orientation
       
   298      */
       
   299 	void orientationchanged(Qt::Orientation orientation);
       
   300 		
       
   301 private:
       
   302 
       
   303     /**
       
   304      * Initialize the widget.
       
   305      */
       
   306     void init();
       
   307 
       
   308 public:
       
   309 
       
   310     /**
       
   311      * Enum defining MMS Notification's Msg State
       
   312      * These are added here so that notification state 
       
   313      * can be used inside css in future
       
   314      * @attention This enum can have values from 0 to 255 only
       
   315      * Add any new states only at the bottom of this enum
       
   316      */
       
   317     enum NotificationState
       
   318     {
       
   319         NotifUnknown = 0x00,
       
   320         NotifReadyForFetching = 0x01,
       
   321         NotifRetrieving = 0x02,
       
   322         NotifExpired = 0x03,
       
   323         NotifFailed = 0x04,
       
   324     };
       
   325 
       
   326 private:
       
   327 
       
   328     /**
       
   329      * Info if message has attachment.
       
   330      * true if message has attachment else false.
       
   331      */
       
   332     bool mHasAttachment;
       
   333 
       
   334     /**
       
   335      * Info if message has image.
       
   336      * true if message has image else false.
       
   337      */
       
   338     bool mHasImage;
       
   339 
       
   340     /**
       
   341      * Info if message has audio.
       
   342      * true if message has audio else false.
       
   343      */
       
   344     bool mHasAudio;
       
   345 
       
   346     /**
       
   347      * Info if message has video.
       
   348      * true if message has video else false.
       
   349      */
       
   350     bool mHasVideo;
       
   351 
       
   352     /**
       
   353      * Info if message is playable.
       
   354      * true if message is playable else false.
       
   355      */
       
   356     bool mIsPlayable;
       
   357 
       
   358     /**
       
   359      * Info about received or outgoing message.
       
   360      * true if received message else false.
       
   361      */
       
   362     bool mIncoming;
       
   363 
       
   364     /**
       
   365      * Info about message read/unread status.
       
   366      * true if message is unread else false.
       
   367      */
       
   368     bool mUnread;
       
   369 
       
   370     /**
       
   371      * Holds info if this widget is MMS
       
   372      */
       
   373     bool mIsMMS;
       
   374 
       
   375     /**
       
   376      * Holds info if this widget is MMS Notification
       
   377      */
       
   378     bool mIsMMSNotification;
       
   379 
       
   380     /**
       
   381      * Info about message priority.
       
   382      * @attention Stores high/low/normal priority.
       
   383      * @see ConvergedMessage::Priority
       
   384      */
       
   385     int mPriority;
       
   386 
       
   387     /**
       
   388      * Holds sending state information.
       
   389      */
       
   390     MsgConversationWidget::SendingState mSendingState;
       
   391 
       
   392     /**
       
   393      * Holds Notification state information.
       
   394      */
       
   395     int mNotificationState;
       
   396 
       
   397     /**
       
   398      * Graphics Item to hold new message icon.
       
   399      * Owned
       
   400      */
       
   401     HbFrameItem *mNewFrameItem;
       
   402 
       
   403     /**
       
   404      * Graphics Item to hold bubble frame.
       
   405      * Owned
       
   406      */
       
   407     HbFrameItem *mBubbleFrameItem;
       
   408 
       
   409     /**
       
   410      * Graphics Item to hold subject content.
       
   411      * Owned
       
   412      */
       
   413     HbTextItem *mSubjectTextItem;
       
   414 
       
   415     /**
       
   416      * Graphics Item to hold body text content.
       
   417      * Owned
       
   418      */
       
   419     HbTextItem *mBodyTextItem;
       
   420 
       
   421     /**
       
   422      * Graphics Item to hold Time stamp.
       
   423      * Owned
       
   424      */
       
   425     HbTextItem *mTimeStampTextItem;
       
   426 
       
   427     /**
       
   428      * Graphics Item to hold  Icon.
       
   429      * Owned
       
   430      */
       
   431     HbIconItem *mPriorityIconItem;
       
   432 
       
   433     /**
       
   434      * Graphics Item to hold Attachment Icon.
       
   435      * Owned
       
   436      */
       
   437     HbIconItem *mAttachmentIconItem;
       
   438 
       
   439     /**
       
   440      * Graphics Item to hold Audio Icon.
       
   441      * Owned
       
   442      */
       
   443     HbIconItem *mAudioIconItem;
       
   444 
       
   445     /**
       
   446      * Graphics Item to hold Video Icon.
       
   447      * Owned
       
   448      */
       
   449     HbIconItem *mVideoIconItem;
       
   450 
       
   451     /**
       
   452      * Graphics Item to hold Play Icon.
       
   453      * Owned
       
   454      */
       
   455     HbIconItem *mPlayIconItem;
       
   456 
       
   457     /**
       
   458      * Graphics Item to hold Preview thumbnail.
       
   459      * Owned
       
   460      */
       
   461     HbIconItem *mPreviewIconItem;
       
   462 };
       
   463 
       
   464 #endif // MSG_CONVERSATIONWIDGET_H
       
   465 // EOF