messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp
changeset 51 3507212d340e
parent 41 25fe1fe642e3
child 62 fdbe8253b596
equal deleted inserted replaced
49:2a272ef608c4 51:3507212d340e
    32 
    32 
    33 // LOCAL CONSTANTS
    33 // LOCAL CONSTANTS
    34 #define LOC_OPEN    hbTrId("txt_common_menu_open")
    34 #define LOC_OPEN    hbTrId("txt_common_menu_open")
    35 #define LOC_SAVE    hbTrId("txt_common_menu_save")
    35 #define LOC_SAVE    hbTrId("txt_common_menu_save")
    36 
    36 
    37 const QString PIXMAP_ICON("qtg_small_image");
    37 static const char PIXMAP_ICON[] = "qtg_small_image";
    38 const QString CORRUPTED_PIXMAP_ICON("qtg_large_corrupted");
    38 static const char CORRUPTED_PIXMAP_ICON[] = "qtg_large_corrupted";
    39 const QString VIDEO_MIMETYPE("video");
    39 static const char VIDEO_MIMETYPE[] = "video";
    40 const QString MSG_VIDEO_ICON("qtg_small_video");
    40 
    41 const QString VIDEO_OVERLAY_ICON("qtg_large_video_player");
    41 static const int WIDTH_RATIO = 4;
    42 
    42 static const int HEIGHT_RATIO = 3;
    43 const int WIDTH_RATIO = 4;
       
    44 const int HEIGHT_RATIO = 3;
       
    45 
    43 
    46 //---------------------------------------------------------------
    44 //---------------------------------------------------------------
    47 // UniViewerPixmapWidget::UniViewerPixmapWidget
    45 // UniViewerPixmapWidget::UniViewerPixmapWidget
    48 // @see header file
    46 // @see header file
    49 //---------------------------------------------------------------
    47 //---------------------------------------------------------------
    50 UniViewerPixmapWidget::UniViewerPixmapWidget(QGraphicsItem *parent) :
    48 UniViewerPixmapWidget::UniViewerPixmapWidget(QGraphicsItem *parent) :
    51     HbIconItem(parent), mViewerUtils(0), mThumbnailManager(0)
    49     HbIconItem(parent), mInfo(0), mViewerUtils(0), mThumbnailManager(0)
    52 {
    50 {
    53     this->grabGesture(Qt::TapGesture);
    51     this->grabGesture(Qt::TapGesture);
    54     init();
    52     init();
    55 }
    53 }
    56 
    54 
    58 // UniViewerPixmapWidget::~UniViewerPixmapWidget
    56 // UniViewerPixmapWidget::~UniViewerPixmapWidget
    59 // @see header file
    57 // @see header file
    60 //---------------------------------------------------------------
    58 //---------------------------------------------------------------
    61 UniViewerPixmapWidget::~UniViewerPixmapWidget()
    59 UniViewerPixmapWidget::~UniViewerPixmapWidget()
    62 {
    60 {
    63 }
    61     if (mInfo) {
    64 
    62         delete mInfo;
    65 //---------------------------------------------------------------
    63         mInfo = NULL;
    66 // UniViewerPixmapWidget::setPixmap
    64     }
       
    65 }
       
    66 
       
    67 //---------------------------------------------------------------
       
    68 // UniViewerPixmapWidget::populate
    67 // @see header file
    69 // @see header file
    68 //---------------------------------------------------------------
    70 //---------------------------------------------------------------
    69 void UniViewerPixmapWidget::populate(UniMessageInfo *info)
    71 void UniViewerPixmapWidget::populate(UniMessageInfo *info)
    70 {
    72 {
    71     mMimeType = info->mimetype();
    73     mMimeType = info->mimetype();
    72     mPixmapPath = info->path();
    74     mPixmapPath = info->path();
       
    75 
       
    76     /**
       
    77      * Create a copy of info for video content.
       
    78      * mInfo will be deleted in the destructor.
       
    79      */
    73     if (mMimeType.contains(VIDEO_MIMETYPE)) {
    80     if (mMimeType.contains(VIDEO_MIMETYPE)) {
    74         this->setIcon(MSG_VIDEO_ICON);
    81         mInfo = new UniMessageInfo(*info);
    75         mThumbnailManager->getThumbnail(mPixmapPath);
    82     }
    76         this->ungrabGesture(Qt::TapGesture);
    83 
    77     }
    84     if (info->isProtected()) {
    78     else if (info->isProtected()) {
    85         if (mMimeType.contains(VIDEO_MIMETYPE)) {
    79         this->setIconName(PIXMAP_ICON);
    86             emit thumbnailFound(false, mInfo);
       
    87         }
       
    88         else {
       
    89             this->setIconName(PIXMAP_ICON);
       
    90         }
    80     }
    91     }
    81     else if (info->isCorrupted()) {
    92     else if (info->isCorrupted()) {
    82         this->setIconName(CORRUPTED_PIXMAP_ICON);
    93         if (mMimeType.contains(VIDEO_MIMETYPE)) {
       
    94             emit thumbnailFound(false, mInfo);
       
    95         }
       
    96         else {
       
    97             this->setIconName(CORRUPTED_PIXMAP_ICON);
       
    98         }
    83     }
    99     }
    84     else {
   100     else {
    85         QPixmap pixmap(mPixmapPath);
   101         if (mMimeType.contains(VIDEO_MIMETYPE)) {
    86         this->setIcon(HbIcon(pixmap));
   102             mThumbnailManager->getThumbnail(mPixmapPath);
       
   103             this->ungrabGesture(Qt::TapGesture);
       
   104         }
       
   105         else {
       
   106             QPixmap pixmap(mPixmapPath);
       
   107             this->setIcon(HbIcon(pixmap));
       
   108         }
    87     }
   109     }
    88 }
   110 }
    89 
   111 
    90 //---------------------------------------------------------------
   112 //---------------------------------------------------------------
    91 // UniViewerPixmapWidget::gestureEvent
   113 // UniViewerPixmapWidget::gestureEvent
   172 void UniViewerPixmapWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
   194 void UniViewerPixmapWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
   173 {
   195 {
   174     Q_UNUSED(data)
   196     Q_UNUSED(data)
   175     Q_UNUSED(id)
   197     Q_UNUSED(id)
   176     this->grabGesture(Qt::TapGesture);
   198     this->grabGesture(Qt::TapGesture);
   177     if (!error) {
   199     if (error) {
       
   200         emit thumbnailFound(false, mInfo);
       
   201     }
       
   202     else {
   178         this->setIcon(HbIcon(pixmap));
   203         this->setIcon(HbIcon(pixmap));
   179         this->hide();
   204         this->hide();
   180         emit setOverlayIcon(VIDEO_OVERLAY_ICON);
   205         emit thumbnailFound(true, NULL);
   181     }
   206     }
   182 }
   207 }
   183 
   208 
   184 //---------------------------------------------------------------
   209 //---------------------------------------------------------------
   185 // UniViewerPixmapWidget::init
   210 // UniViewerPixmapWidget::init