videocollection/videocollectionwrapper/src/videothumbnailfetcher.cpp
changeset 36 8aed59de29f9
parent 34 bbb98528c666
child 20 b9e04db066d4
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    13 *
    13 *
    14 * Description: VideoThumbnailFetcher class implementation
    14 * Description: VideoThumbnailFetcher class implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 // Version : %version: %
       
    19 
    18 // INCLUDE FILES
    20 // INCLUDE FILES
    19 
       
    20 #include <qpixmap.h>
    21 #include <qpixmap.h>
    21 #include <thumbnailmanager_qt.h>
    22 #include <thumbnailmanager_qt.h>
    22 
    23 
    23 #include "videothumbnailfetcher.h"
    24 #include "videothumbnailfetcher.h"
       
    25 #include "videocollectiontrace.h"
    24 
    26 
    25 // ================= MEMBER FUNCTIONS =======================
    27 // ================= MEMBER FUNCTIONS =======================
    26 //
    28 //
    27 
    29 
    28 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    29 // VideoThumbnailFetcher::VideoThumbnailFetcher()
    31 // VideoThumbnailFetcher::VideoThumbnailFetcher()
    30 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    31 //
    33 //
    32 VideoThumbnailFetcher::VideoThumbnailFetcher() :
    34 VideoThumbnailFetcher::VideoThumbnailFetcher() 
    33     mThumbnailManager(0),
    35     : mThumbnailManager( 0 )
    34     mPaused(false),
    36     , mPaused( false )
    35     mTbnCreationEnabled(true)
    37     , mTbnCreationEnabled( true )
    36 {
    38 {
       
    39 	FUNC_LOG;
    37     mThumbnailManager = new ThumbnailManager();
    40     mThumbnailManager = new ThumbnailManager();
    38     mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailMedium);
    41     mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailMedium);
    39     mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForPerformance);
    42     mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForPerformance);
    40     mThumbnailManager->setMode(ThumbnailManager::CropToAspectRatio);
    43     mThumbnailManager->setMode(ThumbnailManager::CropToAspectRatio);
    41     
    44     
    47 // VideoThumbnailFetcher::~VideoThumbnailFetcher()
    50 // VideoThumbnailFetcher::~VideoThumbnailFetcher()
    48 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    49 //
    52 //
    50 VideoThumbnailFetcher::~VideoThumbnailFetcher()
    53 VideoThumbnailFetcher::~VideoThumbnailFetcher()
    51 {
    54 {
       
    55 	FUNC_LOG;
    52     cancelFetches();
    56     cancelFetches();
    53 
    57 
    54     disconnect(mThumbnailManager, SIGNAL(thumbnailReady( QPixmap , void * , int , int )),
    58     disconnect(mThumbnailManager, SIGNAL(thumbnailReady( QPixmap , void * , int , int )),
    55                 this, SLOT(thumbnailReadySlot( QPixmap , void * , int , int )));
    59                 this, SLOT(thumbnailReadySlot( QPixmap , void * , int , int )));
    56     
    60     
    75 // VideoThumbnailFetcher::continueFetching()
    79 // VideoThumbnailFetcher::continueFetching()
    76 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    77 //
    81 //
    78 void VideoThumbnailFetcher::continueFetching()
    82 void VideoThumbnailFetcher::continueFetching()
    79 {
    83 {
       
    84 	FUNC_LOG;
    80     mPaused = false;
    85     mPaused = false;
    81     
    86     
    82     // First fetch all thumbnails that have been created already, next
    87     // First fetch all thumbnails that have been created already, next
    83     // start thumbnail creation for one thumbnail at a time. 
    88     // start thumbnail creation for one thumbnail at a time. 
    84     if(!mFetchList.isEmpty())
    89     if(!mFetchList.isEmpty())
   101 // VideoThumbnailFetcher::startThumbnailFetches()
   106 // VideoThumbnailFetcher::startThumbnailFetches()
   102 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   103 //
   108 //
   104 void VideoThumbnailFetcher::startThumbnailFetches()
   109 void VideoThumbnailFetcher::startThumbnailFetches()
   105 {
   110 {
       
   111 	FUNC_LOG;
   106     if(!mThumbnailManager)
   112     if(!mThumbnailManager)
       
   113     {
   107         return;
   114         return;
       
   115     }
   108     
   116     
   109     // Only fetch those thumbnails that are already been created.
   117     // Only fetch those thumbnails that are already been created.
   110     mThumbnailManager->setMode(ThumbnailManager::DoNotCreate);
   118     mThumbnailManager->setMode(ThumbnailManager::DoNotCreate);
   111     
   119     
   112     // Push all from thumbnail manager.
   120     // Push all from thumbnail manager.
   135 // VideoThumbnailFetcher::startThumbnailCreation()
   143 // VideoThumbnailFetcher::startThumbnailCreation()
   136 // -----------------------------------------------------------------------------
   144 // -----------------------------------------------------------------------------
   137 //
   145 //
   138 void VideoThumbnailFetcher::startThumbnailCreation()
   146 void VideoThumbnailFetcher::startThumbnailCreation()
   139 {
   147 {
       
   148 	FUNC_LOG;
   140     if(!mThumbnailManager || !mTbnCreationEnabled)
   149     if(!mThumbnailManager || !mTbnCreationEnabled)
       
   150     {
   141         return;
   151         return;
       
   152     }
   142     
   153     
   143     mThumbnailManager->setMode(ThumbnailManager::CropToAspectRatio);
   154     mThumbnailManager->setMode(ThumbnailManager::CropToAspectRatio);
   144     
   155     
   145     // Do nothing if list is empty. 
   156     // Do nothing if list is empty. 
   146     if(mCreationList.isEmpty())
   157     if(mCreationList.isEmpty())
       
   158     {
   147         return;
   159         return;
       
   160     }
   148     
   161     
   149     // Find fetch with highest priority. 
   162     // Find fetch with highest priority. 
   150     int highestPriority = 0;
   163     int highestPriority = 0;
   151     int indexWithHighestPriority = 0;
   164     int indexWithHighestPriority = 0;
   152     
   165     
   183 // VideoThumbnailFetcher::pauseFetching()
   196 // VideoThumbnailFetcher::pauseFetching()
   184 // -----------------------------------------------------------------------------
   197 // -----------------------------------------------------------------------------
   185 //
   198 //
   186 void VideoThumbnailFetcher::pauseFetching()
   199 void VideoThumbnailFetcher::pauseFetching()
   187 {
   200 {
       
   201 	FUNC_LOG;
   188     mPaused = true;
   202     mPaused = true;
   189 }
   203 }
   190 
   204 
   191 // -----------------------------------------------------------------------------
   205 // -----------------------------------------------------------------------------
   192 // VideoThumbnailFetcher::cancelFetches()
   206 // VideoThumbnailFetcher::cancelFetches()
   193 // -----------------------------------------------------------------------------
   207 // -----------------------------------------------------------------------------
   194 //
   208 //
   195 void VideoThumbnailFetcher::cancelFetches()
   209 void VideoThumbnailFetcher::cancelFetches()
   196 {
   210 {
       
   211 	FUNC_LOG;
   197     // Clear list of started fetches, thumbnail manager has the internal 
   212     // Clear list of started fetches, thumbnail manager has the internal 
   198     // pointer.
   213     // pointer.
   199     QList<int> keys = mStartedFetchList.keys();
   214     QList<int> keys = mStartedFetchList.keys();
   200     for(int i = 0; i < keys.count(); i++ )
   215     for(int i = 0; i < keys.count(); i++ )
   201     {
   216     {
   226 // VideoThumbnailFetcher::enableThumbnailCreation()
   241 // VideoThumbnailFetcher::enableThumbnailCreation()
   227 // -----------------------------------------------------------------------------
   242 // -----------------------------------------------------------------------------
   228 //
   243 //
   229 void VideoThumbnailFetcher::enableThumbnailCreation(bool enable)
   244 void VideoThumbnailFetcher::enableThumbnailCreation(bool enable)
   230 {
   245 {
       
   246 	FUNC_LOG;
   231     mTbnCreationEnabled = enable;
   247     mTbnCreationEnabled = enable;
   232 }
   248 }
   233 
   249 
   234 // -----------------------------------------------------------------------------
   250 // -----------------------------------------------------------------------------
   235 // VideoThumbnailFetcher::thumbnailReadySlot()
   251 // VideoThumbnailFetcher::thumbnailReadySlot()
   255     {
   271     {
   256         // Report that thumbnail was fetched.
   272         // Report that thumbnail was fetched.
   257         emit thumbnailReady(tnData, internal, error);
   273         emit thumbnailReady(tnData, internal, error);
   258         
   274         
   259         if(mStartedFetchList.contains(requestId))
   275         if(mStartedFetchList.contains(requestId))
       
   276         {
   260             delete mStartedFetchList.take(requestId);
   277             delete mStartedFetchList.take(requestId);
       
   278         }
   261     }
   279     }
   262     
   280     
   263     // Continue the fetching process.
   281     // Continue the fetching process.
   264     if(!mPaused && mStartedFetchList.isEmpty())
   282     if(!mPaused && mStartedFetchList.isEmpty())
       
   283     {
   265         continueFetching();
   284         continueFetching();
       
   285     }
   266 }
   286 }
   267 
   287 
   268 // End of file.
   288 // End of file.