messagingapp/msgui/unifiedviewer/src/univiewerattachmentwidget.cpp
changeset 43 35b64624a9e7
parent 34 84197e66a4bd
child 70 a15d9966050f
equal deleted inserted replaced
34:84197e66a4bd 43:35b64624a9e7
    29 #include <QFileInfo>
    29 #include <QFileInfo>
    30 #include <QTimer>
    30 #include <QTimer>
    31 
    31 
    32 // USER INCLUDES
    32 // USER INCLUDES
    33 #include "univiewerutils.h"
    33 #include "univiewerutils.h"
       
    34 #include "unidatamodelplugininterface.h"
    34 
    35 
    35 // LOCAL CONSTANTS
    36 // LOCAL CONSTANTS
    36 #define LOC_OPEN hbTrId("txt_common_menu_open")
    37 #define LOC_OPEN hbTrId("txt_common_menu_open")
    37 #define LOC_SAVE hbTrId("txt_common_menu_save")
    38 #define LOC_SAVE hbTrId("txt_common_menu_save")
    38 #define LOC_SAVE_TO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
    39 #define LOC_SAVE_TO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
    39 
    40 
    40 const QString BG_FRAME_NORMAL("qtg_fr_list_normal");
    41 const QString BG_FRAME_NORMAL("qtg_fr_list_normal");
    41 const QString BG_FRAME_PRESSED("qtg_fr_list_pressed");
    42 const QString BG_FRAME_PRESSED("qtg_fr_list_pressed");
    42 const QString ATTACHMENT_ICON("qtg_small_attachment");
    43 const QString ATTACHMENT_ICON("qtg_small_attachment");
       
    44 const QString CORRUPTED_ATTACH_ICON("qtg_small_corrupted");
    43 const QString VCARD_MIMETYPE("text/X-vCard");
    45 const QString VCARD_MIMETYPE("text/X-vCard");
    44 
    46 
    45 const int KILOBYTE = 1024;
    47 const int KILOBYTE = 1024;
    46 
    48 
    47 //----------------------------------------------------------------------------
    49 //----------------------------------------------------------------------------
    81 
    83 
    82 //----------------------------------------------------------------------------
    84 //----------------------------------------------------------------------------
    83 // UniViewerAttachmentWidget::populate
    85 // UniViewerAttachmentWidget::populate
    84 // @see header file
    86 // @see header file
    85 //----------------------------------------------------------------------------
    87 //----------------------------------------------------------------------------
    86 void UniViewerAttachmentWidget::populate(const QString &mimeType, const QString &filePath)
    88 void UniViewerAttachmentWidget::populate(UniMessageInfo *info)
    87 {
    89 {
    88     mMimeType = mimeType;
    90     mMimeType = info->mimetype();
    89     mMediaPath = filePath;
    91     mMediaPath = info->path();
    90 
    92 
    91     mMediaIcon->setIconName(ATTACHMENT_ICON);
    93     QString attachIcon;
    92 
    94     if (info->isProtected()) {
    93     QFileInfo fileInfo(filePath);
    95         attachIcon = ATTACHMENT_ICON;
       
    96     }
       
    97     else if (info->isCorrupted()) {
       
    98         attachIcon = CORRUPTED_ATTACH_ICON;
       
    99     }
       
   100     else {
       
   101         attachIcon = ATTACHMENT_ICON;
       
   102     }
       
   103 
       
   104     mMediaIcon->setIconName(attachIcon);
       
   105     QFileInfo fileInfo(mMediaPath);
    94     mName->setText(fileInfo.fileName());
   106     mName->setText(fileInfo.fileName());
    95 
   107 
    96     QString sizeString('B');
   108     QString sizeString('B');
    97     int fileSize = fileInfo.size();
   109     int fileSize = fileInfo.size();
    98     if (fileSize > KILOBYTE) {
   110     if (fileSize > KILOBYTE) {