emailuis/nmailui/src/nmmessagelistviewitem.cpp
changeset 57 ae34e1715e21
parent 56 15bc1d5d6267
child 62 a8c646b56683
--- a/emailuis/nmailui/src/nmmessagelistviewitem.cpp	Fri Jul 23 19:09:50 2010 +0300
+++ b/emailuis/nmailui/src/nmmessagelistviewitem.cpp	Thu Aug 05 21:09:09 2010 +0300
@@ -1,96 +1,90 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-*
-*/
+ * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
 
 #include "nmuiheaders.h"
 
 /*!
     \class NmMessageListViewItem
-    \brief list view item for message list view
-*/
+    \brief List view item for message list view.
+ */
 
 static const int NmFolderTypeRole = Qt::UserRole+1; 
 
 /*!
-    Constructor
-*/
-NmMessageListViewItem::NmMessageListViewItem(QGraphicsItem *parent):
-    HbTreeViewItem(parent),
-    mSender(NULL),
-    mSubject(NULL),
-    mTime(NULL),
-    mDividerTitle(NULL),
-    mNewMsgIcon(NULL),
-    mIcon1(NULL),
-    mIcon2(NULL),
-    mPrimarySize(0),
-    mSecondarySize(0)   
+    Constructor.
+ */
+NmMessageListViewItem::NmMessageListViewItem(QGraphicsItem *parent)
+: HbTreeViewItem(parent),
+  mSender(NULL),
+  mSubject(NULL),
+  mTime(NULL),
+  mDividerTitle(NULL),
+  mNewMsgIcon(NULL),
+  mIcon1(NULL),
+  mIcon2(NULL),
+  mPrimarySize(0),
+  mSecondarySize(0)   
 {
-    NM_FUNCTION;
 }
 
 /*!
-    Destruction.
-*/
+    Destructor.
+ */
 NmMessageListViewItem::~NmMessageListViewItem()
 {
-    NM_FUNCTION;
 }
 
 /*!
-*/
+    Create item.
+ */
 HbTreeViewItem *NmMessageListViewItem::createItem()
 {
-    NM_FUNCTION;
-    
     return new NmMessageListViewItem(*this);
 }
 
 /*!
-    boolean value indicating model index availability. Always true since
-    this item prototype is used for both divider and message
-*/
+    Boolean value indicating model index availability. Always true since
+    this item prototype is used for both divider and message.
+ */
 bool NmMessageListViewItem::canSetModelIndex(const QModelIndex &index) const
 {
-    NM_FUNCTION;
-    
     Q_UNUSED(index);
-    // This item class can handle all items in message list
+    // This item class can handle all items in message list.
     return true;
 }
 
 /*!
-    update child items. List calls this function whenever item is needed
+    Update child items. List calls this function whenever item is needed
     to be updated.
-*/
+ */
 void NmMessageListViewItem::updateChildItems()
 {
-    NM_FUNCTION;
-    
     // Get model pointer
     NmMessageListModelItem *msgModelItem = modelIndex().data(
-            Qt::DisplayRole).value<NmMessageListModelItem*>();
+        Qt::DisplayRole).value<NmMessageListModelItem*>();
     // Check whether item is message item or title divider
-    // and set the layout accordingly, dividers not currently used
+    // and set the layout accordingly. Dividers are not currently used.
     if (msgModelItem && msgModelItem->itemType() ==
         NmMessageListModelItem::NmMessageItemMessage){
         NmMessageListModel *model = static_cast<NmMessageListModel*>(msgModelItem->model());
         if (model){
-            // First set item layout
+            // First set item layout.
             createMessageItemLayout();
-            // Set content data to item after layout is created
+            // Set content data to item after layout is created.
             setContentsToMessageItem(msgModelItem->envelope(), model->dividersActive());
         }
     }
@@ -99,67 +93,57 @@
 
 /*!
     Set item layout.
-    Function does not take ownership of model or model item
-*/
+    Function does not take ownership of model or model item.
+ */
 void NmMessageListViewItem::createMessageItemLayout()
-{ 
-    NM_FUNCTION;
-    
+{
     getFontSizes();
-    // Create sender label and set name from widgetml
-    if (!mSender){
+    // Create sender label and set name from widgetml.
+    if (!mSender) {
         mSender = new HbTextItem(this);
         HbStyle::setItemName(mSender, "sender");
         mSender->setObjectName("ListViewItemMessageSender");
-        mSender->setTextWrapping(Hb::TextNoWrap);
     }
-    // Create time label and set name from widgetml
-    if (!mTime){
+    // Create time label and set name from widgetml.
+    if (!mTime) {
         mTime = new HbTextItem(this);
         HbStyle::setItemName(mTime, "time");
         mTime->setObjectName("ListViewItemMessageTime");
     }
-    // Create subject label and set name from widgetml
-    if (!mSubject){
+    // Create subject label and set name from widgetml.
+    if (!mSubject) {
         mSubject = new HbTextItem(this);
         HbStyle::setItemName(mSubject, "subject");
         mSubject->setObjectName("ListViewItemMessageSubject");
-        mSubject->setTextWrapping(Hb::TextNoWrap);
     }
-    // Set new message icon
+    // Set new message icon.
     if (!mNewMsgIcon) {
         mNewMsgIcon = new HbFrameItem(this);
-     }
-    // Create priority icon and set name from widgetml
-    if (!mIcon1){
+    }
+    // Create priority icon and set name from widgetml.
+    if (!mIcon1) {
         mIcon1 = new HbIconItem(this);
         HbStyle::setItemName(mIcon1, "icon1");
-        // According to layout guide, icon alignment is always right
-        mIcon1->setAlignment(Qt::AlignRight);
     }
-    // Create attachment icon and set name from widgetml
-    if (!mIcon2){
+    // Create attachment icon and set name from widgetml.
+    if (!mIcon2) {
         mIcon2 = new HbIconItem(this);
         HbStyle::setItemName(mIcon2, "icon2");
-        // According to layout guide, icon alignment is always right
-        mIcon2->setAlignment(Qt::AlignRight);
     }
     setObjectName("ListViewItemMessage");
 }
 
 /*!
-    set item text label contents, icons, etc.
-    Function does not take ownership of model or model item
+    Set item text label contents, icons, etc.
+    Function does not take ownership of model or model item.
 */
 void NmMessageListViewItem::setContentsToMessageItem(const NmMessageEnvelope &envelope, 
                                                      bool dividersActive)
 {
-    NM_FUNCTION;
-    
-    // member variables are created in previous function
-    // sender
+    // Member variables are created in previous function.
+    // Sender.
     mSender->setText(senderFieldText(envelope));
-    // time
+    // Time.
     HbExtendedLocale locale = HbExtendedLocale::system();
     QDateTime localTime = envelope.sentTime().addSecs(locale.universalTimeOffset());
     QDate sentLocalDate = localTime.date();
@@ -172,14 +156,14 @@
         QString shortDateSpec = r_qtn_date_without_year;
         mTime->setText(locale.format(sentLocalDate, shortDateSpec));
     }
-    // subject 
+    // Subject.
     QString subjectText = envelope.subject();
     if (subjectText.length()) {
         mSubject->setText(subjectText);
     } else {
         mSubject->setText(hbTrId("txt_mail_dblist_val_no_subject"));
     }
-    // priority
+    // Priority.
     bool priorityIs(false);
     mIcon1->hide();
     mIcon2->hide();
@@ -200,7 +184,7 @@
         default:
             break;
     }
-    // attachments
+    // Attachments.
     HbIconItem *attaIcon = (priorityIs ? mIcon2 : mIcon1);
     if (envelope.hasAttachments()) {
         HbIcon &icon = NmIcons::getIcon(NmIcons::NmIconAttachment);
@@ -208,12 +192,11 @@
         attaIcon->setObjectName("ListViewItemMessageIconAttachment");
         attaIcon->show();
     }
-    // message read status
+    // Message read status.
     bool msgReadStatus(envelope.isRead());
     HbFrameDrawer *drawer(NULL);
     HbStyle::setItemName(mNewMsgIcon, "msgicon");
     if (!msgReadStatus) {
-
         setFontsUnread();
         mNewMsgIcon->setObjectName("ListViewItemMessageIconUnread");
         drawer = new HbFrameDrawer("qtg_fr_list_new_item",
@@ -223,10 +206,9 @@
         mNewMsgIcon->setFrameDrawer(drawer);
         mNewMsgIcon->show();
     } else {
-
         setFontsRead();
         mNewMsgIcon->setObjectName("ListViewItemMessageIconRead");
-        drawer = new HbFrameDrawer(); // Create empty drawer
+        drawer = new HbFrameDrawer(); // Create empty drawer.
         drawer->setFillWholeRect(false);
         // Set drawer. Takes ownership of the drawer and deletes previous drawer.
         mNewMsgIcon->setFrameDrawer(drawer);
@@ -235,37 +217,31 @@
 }
 
 /*!
-    setFontsUnread
-*/
+    Set fonts unread.
+ */
 void  NmMessageListViewItem::setFontsUnread()
-{    
-    NM_FUNCTION;
-    
+{
     static QColor colorRole = HbColorScheme::color("qtc_list_item_title_normal");
     HbFontSpec fontSpec(HbFontSpec::Primary);
     setFonts(colorRole, fontSpec);
 }
 
 /*!
-    setFontsRead
-*/
+    Set fonts read.
+ */
 void  NmMessageListViewItem::setFontsRead()
 {
-    NM_FUNCTION;
-    
     static QColor colorRole = HbColorScheme::color("qtc_list_item_content_normal");
     HbFontSpec fontSpec(HbFontSpec::Secondary);
     setFonts(colorRole, fontSpec);
 }
 
 /*!
-    getFontSizes.
-*/
+    Get font sizes.
+ */
 void  NmMessageListViewItem::getFontSizes()
 {
-    NM_FUNCTION;
-    
-    // Get font sizes from style  
+    // Get font sizes from style.
     qreal currentSize;
     bool found = style()->parameter(QString("hb-param-text-height-primary"), currentSize );
     if (found) {
@@ -278,22 +254,18 @@
 }
 
 /*!
-    setFonts.
-*/
+    Set fonts.
+ */
 void  NmMessageListViewItem::setFonts(const QColor &colorRole, 
         HbFontSpec &fontSpec)
 {
-    NM_FUNCTION;
-    
     // Change sizes explicitly since css is overwritten in polish now.    
     if (mSender && mSubject && mTime) {
-        
         if (mPrimarySize) {
             fontSpec.setTextHeight(mPrimarySize);
         }      
         mSender->setFontSpec(fontSpec);
         mSender->setTextColor(colorRole);
-        
         if (mSecondarySize) {
             fontSpec.setTextHeight(mSecondarySize);
         }        
@@ -305,19 +277,17 @@
 }
 
 /*!
-    senderFieldText. Function returns sender field text from
-    envelope based on currently used function
-*/
+    Get sender field text. Function returns sender field text from
+    envelope based on currently used function.
+ */
 QString NmMessageListViewItem::senderFieldText(const NmMessageEnvelope &envelope)
 {
-    NM_FUNCTION;
-    
     QString ret;  
     QVariant folderType = modelIndex().data(
             NmFolderTypeRole).value<QVariant>();
     switch (folderType.toInt()) {
         // Outbox, drafts and sent folder, sender name is 
-        // replaced with first recipient from to/cc list
+        // replaced with first recipient from to/cc list.
         case NmFolderOutbox:
         case NmFolderDrafts:
         case NmFolderSent:
@@ -343,10 +313,9 @@
                     ret += addressToUse.address();                    
                 }               
             }
-            
         }
         break;    
-        // All other folders will show sender display name
+        // All other folders will show sender display name.
         default: 
         {
             QString displayName = envelope.sender().displayName();
@@ -361,4 +330,3 @@
     }
     return ret;
 }
-