emailuis/nmhswidget/src/nmhswidgetemailrow.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 23 2dc6caa42ec3
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
    29 NmHsWidgetEmailRow::NmHsWidgetEmailRow(QGraphicsItem *parent, Qt::WindowFlags flags)
    29 NmHsWidgetEmailRow::NmHsWidgetEmailRow(QGraphicsItem *parent, Qt::WindowFlags flags)
    30     : HbWidget(parent, flags),
    30     : HbWidget(parent, flags),
    31       mSenderLabel(0),
    31       mSenderLabel(0),
    32       mSubjectLabel(0),
    32       mSubjectLabel(0),
    33       mTimeLabel(0),
    33       mTimeLabel(0),
    34       mNewMailIcon(0)
    34       mNewMailIcon(0),
       
    35       mSeparatorIcon(0),
       
    36       mMessageId(0)
    35 {
    37 {
    36     qDebug() << "NmHsWidgetEmailRow::NmHsWidgetEmailRow IN -->>";
    38     qDebug() << "NmHsWidgetEmailRow::NmHsWidgetEmailRow IN -->>";
    37     
    39     
    38     loadDocML();
    40     loadDocML();
    39     
    41     
    47 {
    49 {
    48     qDebug() << "NmHsWidgetEmailRow::~NmHsWidgetEmailRow IN -->>";
    50     qDebug() << "NmHsWidgetEmailRow::~NmHsWidgetEmailRow IN -->>";
    49 
    51 
    50     qDebug() << "NmHsWidgetEmailRow::~NmHsWidgetEmailRow OUT <<--";
    52     qDebug() << "NmHsWidgetEmailRow::~NmHsWidgetEmailRow OUT <<--";
    51 }
    53 }
    52     
    54 
       
    55 /*!
       
    56     Returns id of message shown
       
    57 */
       
    58 NmId NmHsWidgetEmailRow::messageId()
       
    59 {
       
    60     qDebug() << "NmHsWidgetEmailRow::messageId()";
       
    61     return mMessageId;
       
    62 
       
    63 }
       
    64 
    53 /*!
    65 /*!
    54     Loads layout data and child items from docml file
    66     Loads layout data and child items from docml file
    55 */
    67 */
    56 void NmHsWidgetEmailRow::loadDocML()
    68 void NmHsWidgetEmailRow::loadDocML()
    57 {
    69 {
    71     //find container widget
    83     //find container widget
    72     QGraphicsWidget *container = loader.findWidget(KNmHsWidgetMailRowContainer);
    84     QGraphicsWidget *container = loader.findWidget(KNmHsWidgetMailRowContainer);
    73     Q_ASSERT_X((container != 0), "nmhswidget", "email container not found!");
    85     Q_ASSERT_X((container != 0), "nmhswidget", "email container not found!");
    74     layout->addItem(container);
    86     layout->addItem(container);
    75 
    87 
       
    88     //separator
       
    89     mSeparatorIcon = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailSeparatorIcon));
       
    90     HbIcon separatorIcon("qtg_graf_divider_h_thin"); 
       
    91     mSeparatorIcon->setIcon(separatorIcon);
       
    92     
    76     //child items possible to update
    93     //child items possible to update
    77     mSenderLabel = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowSenderLabel));
    94     mSenderLabel = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowSenderLabel));
    78     mSubjectLabel = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowSubjectLabel));
    95     mSubjectLabel = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowSubjectLabel));
    79     mTimeLabel = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowTimeLabel));
    96     mTimeLabel = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowTimeLabel));
    80 
    97 
    81     //Icons
    98     //Icons
    82     mNewMailIcon = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowNewMailIcon));
    99     mNewMailIcon = static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowNewMailIcon));
       
   100     HbIcon newEmailIcon("qtg_fr_list_new_item_c"); 
       
   101     mNewMailIcon->setIcon(newEmailIcon);
    83     // KNmHsWidgetMailRowLeftIcon is not yet used, because followup information is not shown in client side
   102     // KNmHsWidgetMailRowLeftIcon is not yet used, because followup information is not shown in client side
    84     // and thus it is not wanted to be shown in widget side
   103     // and thus it is not wanted to be shown in widget side
    85     mStatusIcons.append( static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowRightIcon)));
   104     mStatusIcons.append( static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowRightIcon)));
    86     mStatusIcons.append( static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowMiddleIcon)));
   105     mStatusIcons.append( static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowMiddleIcon)));
    87     mStatusIcons.append( static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowLeftIcon)));
   106     mStatusIcons.append( static_cast<HbLabel*>(loader.findWidget(KNmHsWidgetMailRowLeftIcon)));
    99     \param envelope message envelope representing an email
   118     \param envelope message envelope representing an email
   100 */
   119 */
   101 void NmHsWidgetEmailRow::updateMailData( const NmMessageEnvelope& envelope )
   120 void NmHsWidgetEmailRow::updateMailData( const NmMessageEnvelope& envelope )
   102     {
   121     {
   103     qDebug() << "NmHsWidgetEmailRow::updateMailData IN -->>";
   122     qDebug() << "NmHsWidgetEmailRow::updateMailData IN -->>";
       
   123 
   104     //hide all icons, so no previous data is messing with the new
   124     //hide all icons, so no previous data is messing with the new
   105     hideIcons();
   125     hideIcons();
   106     
   126 
       
   127     mMessageId = envelope.id();
   107     //Show sender name if it is available, otherwise show email address
   128     //Show sender name if it is available, otherwise show email address
   108     QString senderDisplayName = envelope.sender().displayName();
   129     QString senderDisplayName = envelope.sender().displayName();
   109     if ( !senderDisplayName.isNull() && !senderDisplayName.isEmpty()  )
   130     if ( !senderDisplayName.isNull() && !senderDisplayName.isEmpty()  )
   110         {
   131         {
   111         mSenderLabel->setPlainText( senderDisplayName );
   132         mSenderLabel->setPlainText( senderDisplayName );
   197     }
   218     }
   198 
   219 
   199     // Here we show icons added to the iconList in the order they have been added.
   220     // Here we show icons added to the iconList in the order they have been added.
   200     for(int count = 0; count<iconList.count(); count++){
   221     for(int count = 0; count<iconList.count(); count++){
   201         mStatusIcons[count]->setIcon(iconList[count]);
   222         mStatusIcons[count]->setIcon(iconList[count]);
   202         mStatusIcons[count]->setAlignment(Qt::AlignRight);
       
   203         mStatusIcons[count]->show();
   223         mStatusIcons[count]->show();
   204     }
   224     }
   205     
   225     
   206     qDebug() << "NmHsWidgetEmailRow::setIconsToWidget OUT <<--";
   226     qDebug() << "NmHsWidgetEmailRow::setIconsToWidget OUT <<--";
   207 }
   227 }