messagingapp/msgui/unifiedviewer/src/univiewerdetailswidget.cpp
branchRCL_3
changeset 26 ebe688cedc25
equal deleted inserted replaced
25:fa1df4b99609 26: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: This widget displays subject,timestamp & priority info
       
    15  *
       
    16  */
       
    17 
       
    18 #include "univiewerdetailswidget.h"
       
    19 
       
    20 // SYSTEM INCLUDES
       
    21 #include <HbTextItem>
       
    22 #include <HbIconItem>
       
    23 #include <HbExtendedLocale>
       
    24 #include <QDateTime>
       
    25 #include <QStringBuilder>
       
    26 
       
    27 // USER INCLUDES
       
    28 #include "convergedmessage.h"
       
    29 #include "debugtraces.h"
       
    30 
       
    31 // LOCALIZATION
       
    32 #define LOC_MESSAGE_RESEND hbTrId("txt_common_menu_resend_message")
       
    33 
       
    34 // @see hbi18ndef.h
       
    35 static const char DATE_FORMAT[] = r_qtn_date_usual_with_zero;
       
    36 static const char TIME_FORMAT[] = r_qtn_time_usual_with_zero;
       
    37 
       
    38 const QString MSG_HIGH_PRIORITY_ICON("qtg_small_priority_high");
       
    39 const QString MSG_LOW_PRIORITY_ICON("qtg_small_priority_low");
       
    40 
       
    41 //---------------------------------------------------------------
       
    42 // UniViewerDetailsWidget::UniViewerDetailsWidget
       
    43 // @see header file
       
    44 //---------------------------------------------------------------
       
    45 UniViewerDetailsWidget::UniViewerDetailsWidget(QGraphicsItem *parent) :
       
    46     HbWidget(parent), mSubjectLabel(0), mPriorityIcon(0)
       
    47 {
       
    48     // Permanent items & will not be removed
       
    49     mTime = new HbTextItem(this);
       
    50     HbStyle::setItemName(mTime, "timeLabel");
       
    51 }
       
    52 
       
    53 //---------------------------------------------------------------
       
    54 // UniViewerDetailsWidget::~UniViewerDetailsWidget
       
    55 // @see header file
       
    56 //---------------------------------------------------------------
       
    57 UniViewerDetailsWidget::~UniViewerDetailsWidget()
       
    58 {
       
    59 }
       
    60 
       
    61 //---------------------------------------------------------------
       
    62 //UniViewerDetailsWidget :: setSubject
       
    63 // @see header file
       
    64 //---------------------------------------------------------------
       
    65 void UniViewerDetailsWidget::setSubject(const QString &subject)
       
    66 {
       
    67     if (!mSubjectLabel)
       
    68     {
       
    69         mSubjectLabel = new HbTextItem(this);
       
    70         HbStyle::setItemName(mSubjectLabel, "subjectLabel");
       
    71         mSubjectLabel->setTextWrapping(Hb::TextWrapAnywhere);
       
    72     }
       
    73     mSubjectLabel->setText(subject);
       
    74     this->repolish();
       
    75 }
       
    76 
       
    77 //---------------------------------------------------------------
       
    78 //UniViewerDetailsWidget :: setTimeStamp
       
    79 // @see header file
       
    80 //---------------------------------------------------------------
       
    81 void UniViewerDetailsWidget::setTimeStamp(const QDateTime &aTimeStamp, const int &aSendingState)
       
    82 {
       
    83     HbExtendedLocale locale = HbExtendedLocale::system();
       
    84     QString date = locale.format(aTimeStamp.date(), DATE_FORMAT);
       
    85     QString time = locale.format(aTimeStamp.time(), TIME_FORMAT);
       
    86 
       
    87     if (aSendingState == ConvergedMessage::Resend) {
       
    88         mTime->setText(LOC_MESSAGE_RESEND % time);
       
    89     }
       
    90     else {
       
    91         mTime->setText(date % QChar(' ') % time);
       
    92     }
       
    93 }
       
    94 
       
    95 //---------------------------------------------------------------
       
    96 // UniViewerDetailsWidget::setPriorityIcon
       
    97 // @see header file
       
    98 //---------------------------------------------------------------
       
    99 void UniViewerDetailsWidget::setPriorityIcon(int priority)
       
   100 {
       
   101     if (priority)
       
   102     {
       
   103         if (!mPriorityIcon)
       
   104         {
       
   105             mPriorityIcon = new HbIconItem(this);
       
   106             HbStyle::setItemName(mPriorityIcon, "priorityIcon");
       
   107         }
       
   108         if (ConvergedMessage::Low == priority)
       
   109         {
       
   110             mPriorityIcon->setIcon(HbIcon(MSG_LOW_PRIORITY_ICON));
       
   111         }
       
   112         else if (ConvergedMessage::High == priority)
       
   113         {
       
   114             mPriorityIcon->setIcon(HbIcon(MSG_HIGH_PRIORITY_ICON));
       
   115         }
       
   116         this->repolish();
       
   117     }
       
   118 }
       
   119 
       
   120 //---------------------------------------------------------------
       
   121 //UniViewerDetailsWidget :: clearContent
       
   122 // @see header file
       
   123 //---------------------------------------------------------------
       
   124 void UniViewerDetailsWidget::clearContent()
       
   125 {
       
   126     //Delete the temporary items(subject & priority) &
       
   127     //content on the permanent item
       
   128 
       
   129     if (mSubjectLabel)
       
   130     {
       
   131         mSubjectLabel->setParent(NULL);
       
   132         delete mSubjectLabel;
       
   133         mSubjectLabel = NULL;
       
   134     }
       
   135 
       
   136     if (mPriorityIcon)
       
   137     {
       
   138         mPriorityIcon->setParent(NULL);
       
   139         delete mPriorityIcon;
       
   140         mPriorityIcon = NULL;
       
   141     }
       
   142 
       
   143     mTime->setText(QString());
       
   144 }
       
   145 
       
   146 // EOF