emailuis/nmailui/src/nmviewerheader.cpp
changeset 54 997a02608b3a
parent 53 bf7eb7911fc5
child 56 15bc1d5d6267
equal deleted inserted replaced
53:bf7eb7911fc5 54:997a02608b3a
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description: NMail viewer view header widget implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "nmuiheaders.h"
    19 #include "nmuiheaders.h"
    20 
    20 
    21 static const qreal nmHeaderLineOpacity = 0.4;
    21 static const qreal NmHeaderLineOpacity = 0.4;
    22 
    22 
    23 /*!
    23 /*!
    24     \class NmViewerHeader
    24     \class NmViewerHeader
    25     \brief Mail viewer header area class
    25     \brief Mail viewer header area class
    26 */
    26 */
   117     
   117     
   118     Q_UNUSED(option);
   118     Q_UNUSED(option);
   119     Q_UNUSED(widget);
   119     Q_UNUSED(widget);
   120     if (painter) {
   120     if (painter) {
   121         painter->save();
   121         painter->save();
   122         painter->setOpacity(nmHeaderLineOpacity);
   122         painter->setOpacity(NmHeaderLineOpacity);
   123         QLineF line1( rect().topLeft().x(), rect().bottomRight().y(),
   123         QLineF line1( rect().topLeft().x(), rect().bottomRight().y(),
   124                      rect().bottomRight().x(), rect().bottomRight().y());
   124                      rect().bottomRight().x(), rect().bottomRight().y());
   125         painter->drawLine(line1);
   125         painter->drawLine(line1);
   126         if (mHeaderBox){
   126         if (mHeaderBox){
   127             QRectF headerBoxGeometry = mHeaderBox->geometry();
   127             QRectF headerBoxGeometry = mHeaderBox->geometry();
   158     if (message){
   158     if (message){
   159         mMessage=message;
   159         mMessage=message;
   160         // Set recipients to text edit field as html 
   160         // Set recipients to text edit field as html 
   161         NmAddress sender = mMessage->envelope().sender();      
   161         NmAddress sender = mMessage->envelope().sender();      
   162         if (mRecipientsBox){  
   162         if (mRecipientsBox){  
   163             mRecipientsBox->setHtml(formatRecipientList(addressToDisplayInHtml(sender),
   163             mRecipientsBox->setHtml(formatRecipientList(addressToDisplay(sender),
   164                                     mMessage->envelope().toRecipients(), 
   164                                     mMessage->envelope().toRecipients(), 
   165                                     mMessage->envelope().ccRecipients()));
   165                                     mMessage->envelope().ccRecipients()));
   166         }       
   166         }       
   167     }
   167     }
   168 }
   168 }
   270                 this, SLOT(cursorPositionChanged(int, int)));
   270                 this, SLOT(cursorPositionChanged(int, int)));
   271                 
   271                 
   272         // Set recipients to text edit field as html 
   272         // Set recipients to text edit field as html 
   273         NmAddress sender = mMessage->envelope().sender();               
   273         NmAddress sender = mMessage->envelope().sender();               
   274         if (mMessage) {
   274         if (mMessage) {
   275             mRecipientsBox->setHtml(formatRecipientList(addressToDisplayInHtml(sender),
   275             mRecipientsBox->setHtml(formatRecipientList(addressToDisplay(sender),
   276                                     mMessage->envelope().toRecipients(), 
   276                                     mMessage->envelope().toRecipients(), 
   277                                     mMessage->envelope().ccRecipients()));
   277                                     mMessage->envelope().ccRecipients()));
   278         }
   278         }
   279         mRecipientsBox->setCursorVisibility(Hb::TextCursorHidden);
   279         mRecipientsBox->setCursorVisibility(Hb::TextCursorHidden);
   280         mHeaderBox->setContentWidget(mRecipientsBox);
   280         mHeaderBox->setContentWidget(mRecipientsBox);
   292 {
   292 {
   293     NM_FUNCTION;
   293     NM_FUNCTION;
   294     
   294     
   295     QString result;
   295     QString result;
   296     result.append("<html><body link=\"blue\" topmargin=\"0\" leftmargin=\"0\" marginheight=\"0\"");
   296     result.append("<html><body link=\"blue\" topmargin=\"0\" leftmargin=\"0\" marginheight=\"0\"");
   297     result.append("marginwidth=\"0\" bgcolor=\"white\" text=\"black\">");    
   297     result.append("marginwidth=\"0\">");    
   298     result.append("<font color=\"black\" face=\"");
   298     result.append("<font face=\"");
   299     result.append("Nokia Sans");
   299     result.append("Nokia Sans");
   300     result.append("\"size=\"3\">"); 
   300     result.append("\"size=\"3\">"); 
   301     // Set text in HTML format based on layout direction
   301     // Set text in HTML format based on layout direction
   302     if (qApp->layoutDirection()==Qt::RightToLeft){
   302     if (qApp->layoutDirection()==Qt::RightToLeft){
   303         result.append("<p style=\"margin-right: '0'; margin-left: '0'\" dir=\"rtl\"><b>"); 
   303         result.append("<p style=\"margin-right: '0'; margin-left: '0'\" dir=\"rtl\"><b>"); 
   307         result.append("<br><b>"); 
   307         result.append("<br><b>"); 
   308         result.append(hbTrId("txt_mail_list_to"));
   308         result.append(hbTrId("txt_mail_list_to"));
   309         result.append(" </b>");
   309         result.append(" </b>");
   310         int reciCount = to.count();
   310         int reciCount = to.count();
   311         for (int i=0; i < reciCount; i++) { 
   311         for (int i=0; i < reciCount; i++) { 
   312             result.append(addressToDisplayInHtml(to[i]));
   312             result.append(addressToDisplay(to[i]));
   313             result.append(" ");
   313             result.append(" ");
   314         } 
   314         } 
   315         reciCount = cc.count();
   315         reciCount = cc.count();
   316         if (reciCount) {
   316         if (reciCount) {
   317             result.append("<br><b>");
   317             result.append("<br><b>");
   318             result.append(hbTrId("txt_mail_list_cc"));
   318             result.append(hbTrId("txt_mail_list_cc"));
   319             result.append(" </b>");
   319             result.append(" </b>");
   320             for (int i=0; i < reciCount; i++) {
   320             for (int i=0; i < reciCount; i++) {
   321                 result.append(addressToDisplayInHtml(cc[i]));
   321                 result.append(addressToDisplay(cc[i]));
   322                 result.append(" "); 
   322                 result.append(" "); 
   323             }
   323             }
   324         }   
   324         }   
   325     }
   325     }
   326     else{
   326     else{
   331         result.append("<br><b>"); 
   331         result.append("<br><b>"); 
   332         result.append(hbTrId("txt_mail_list_to"));
   332         result.append(hbTrId("txt_mail_list_to"));
   333         result.append(" </b>");
   333         result.append(" </b>");
   334         int reciCount = to.count();
   334         int reciCount = to.count();
   335         for (int i=0; i < reciCount; i++) { 
   335         for (int i=0; i < reciCount; i++) { 
   336             result.append(addressToDisplayInHtml(to[i]));
   336             result.append(addressToDisplay(to[i]));
   337             result.append("; ");
   337             result.append("; ");
   338         }
   338         }
   339         reciCount = cc.count();
   339         reciCount = cc.count();
   340         if (reciCount) {
   340         if (reciCount) {
   341             result.append("<br><b>");
   341             result.append("<br><b>");
   342             result.append(hbTrId("txt_mail_list_cc"));
   342             result.append(hbTrId("txt_mail_list_cc"));
   343             result.append(" </b>");
   343             result.append(" </b>");
   344             for (int i=0; i < reciCount; i++) {
   344             for (int i=0; i < reciCount; i++) {
   345                 result.append(addressToDisplayInHtml(cc[i]));
   345                 result.append(addressToDisplay(cc[i]));
   346                 result.append("; ");
   346                 result.append("; ");
   347             }
   347             }
   348         }   
   348         }   
   349     } 
   349     } 
   350     result.append("</p></font></body></html>");     
   350     result.append("</p></font></body></html>");     
   353 
   353 
   354 /*!
   354 /*!
   355     Function retursn address string from NmAddress to
   355     Function retursn address string from NmAddress to
   356     be displayed in HTML format
   356     be displayed in HTML format
   357 */
   357 */
   358 QString NmViewerHeader::addressToDisplayInHtml(const NmAddress &addr)
   358 QString NmViewerHeader::addressToDisplay(const NmAddress &addr)
   359 {
   359 {
   360     NM_FUNCTION;
   360     NM_FUNCTION;
   361     
   361     
   362     QString dispName;
   362     QString dispName;
   363     if (addr.displayName().length()!=0){
   363     if (addr.displayName().length()!=0){