messagingapp/msgui/unifiedviewer/src/univieweraudiowidget.cpp
changeset 51 3507212d340e
parent 37 518b245aa84c
child 62 fdbe8253b596
equal deleted inserted replaced
49:2a272ef608c4 51:3507212d340e
    28 
    28 
    29 // LOCAL CONSTANTS
    29 // LOCAL CONSTANTS
    30 #define LOC_OPEN    hbTrId("txt_common_menu_open")
    30 #define LOC_OPEN    hbTrId("txt_common_menu_open")
    31 #define LOC_SAVE    hbTrId("txt_common_menu_save")
    31 #define LOC_SAVE    hbTrId("txt_common_menu_save")
    32 
    32 
    33 const QString AUDIO_ICON("qtg_mono_audio");
    33 static const char VIDEO_MIMETYPE[] = "video";
    34 const QString CORRUPTED_AUDIO_ICON("qtg_mono_corrupted");
    34 static const char AUDIO_ICON[] = "qtg_mono_audio";
       
    35 static const char VIDEO_ICON[] = "qtg_mono_video";
       
    36 static const char CORRUPTED_AUDIO_ICON[] = "qtg_mono_corrupted";
    35 
    37 
    36 //----------------------------------------------------------------------------
    38 //----------------------------------------------------------------------------
    37 // UniViewerAudioWidget::UniViewerAudioWidget
    39 // UniViewerAudioWidget::UniViewerAudioWidget
    38 // @see header file
    40 // @see header file
    39 //----------------------------------------------------------------------------
    41 //----------------------------------------------------------------------------
    40 UniViewerAudioWidget::UniViewerAudioWidget(QGraphicsItem *parent) :
    42 UniViewerAudioWidget::UniViewerAudioWidget(QGraphicsItem *parent) :
    41     HbPushButton(parent), mViewerUtils(0)
    43     HbPushButton(parent), mViewerUtils(0), mValidMediaDuration(true)
    42 {
    44 {
    43     connect(this, SIGNAL(clicked()), this, SLOT(handleShortTap()));
    45     connect(this, SIGNAL(clicked()), this, SLOT(handleShortTap()));
    44     connect(this, SIGNAL(longPress(QPointF)), this, SLOT(handleLongTap(QPointF)));
    46     connect(this, SIGNAL(longPress(QPointF)), this, SLOT(handleLongTap(QPointF)));
    45 }
    47 }
    46 
    48 
    60 {
    62 {
    61     mMimeType = info->mimetype();
    63     mMimeType = info->mimetype();
    62     mMediaPath = info->path();
    64     mMediaPath = info->path();
    63 
    65 
    64     HbIcon audioIcon;
    66     HbIcon audioIcon;
       
    67 
    65     if (info->isProtected()) {
    68     if (info->isProtected()) {
    66         audioIcon.setIconName(AUDIO_ICON);
    69         if (mMimeType.contains(VIDEO_MIMETYPE)) {
       
    70             audioIcon.setIconName(VIDEO_ICON);
       
    71         }
       
    72         else {
       
    73             audioIcon.setIconName(AUDIO_ICON);
       
    74         }
    67     }
    75     }
    68     else if (info->isCorrupted()) {
    76     else if (info->isCorrupted()) {
    69         audioIcon.setIconName(CORRUPTED_AUDIO_ICON);
    77         audioIcon.setIconName(CORRUPTED_AUDIO_ICON);
    70     }
    78     }
    71     else {
    79     else {
    72         audioIcon.setIconName(AUDIO_ICON);
    80         if (mMimeType.contains(VIDEO_MIMETYPE)) {
       
    81             audioIcon.setIconName(VIDEO_ICON);
       
    82         }
       
    83         else {
       
    84             audioIcon.setIconName(AUDIO_ICON);
       
    85         }
    73     }
    86     }
    74 
    87 
    75     this->setIcon(audioIcon);
    88     this->setIcon(audioIcon);
    76     QFileInfo fileInfo(mMediaPath);
    89     QFileInfo fileInfo(mMediaPath);
    77     this->setText(fileInfo.baseName());
    90     this->setText(fileInfo.baseName());
    78     this->setTextAlignment(Qt::AlignLeft);
    91     this->setTextAlignment(Qt::AlignLeft);
    79     MsgMediaUtil mediaUtil;
    92     MsgMediaUtil mediaUtil;
    80     this->setAdditionalText(mediaUtil.mediaDuration(mMediaPath));
    93     QString mediaDuration(mediaUtil.mediaDuration(mMediaPath));
       
    94     if (mediaDuration.isEmpty()) {
       
    95         mValidMediaDuration = false;
       
    96     }
       
    97     else {
       
    98         mValidMediaDuration = true;
       
    99         this->setAdditionalText(mediaDuration);
       
   100     }
       
   101 }
       
   102 
       
   103 //----------------------------------------------------------------------------
       
   104 // UniViewerAudioWidget::setStretched
       
   105 // @see header file
       
   106 //----------------------------------------------------------------------------
       
   107 void UniViewerAudioWidget::setStretched(bool stretched)
       
   108 {
       
   109     if (mValidMediaDuration) {
       
   110         HbPushButton::setStretched(stretched);
       
   111     }
       
   112     else {
       
   113         HbPushButton::setStretched(true);
       
   114     }
    81 }
   115 }
    82 
   116 
    83 //----------------------------------------------------------------------------
   117 //----------------------------------------------------------------------------
    84 // UniViewerAudioWidget::handleShortTap
   118 // UniViewerAudioWidget::handleShortTap
    85 // @see header file
   119 // @see header file