videocollection/videocollectionwrapper/src/videolistdatamodel_p.cpp
changeset 36 8aed59de29f9
parent 35 3738fe97f027
child 37 4eb2df7f7cbe
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    13 *
    13 *
    14 * Description: VideoListDataModelPrivate class implementation
    14 * Description: VideoListDataModelPrivate class implementation
    15 * 
    15 * 
    16 */
    16 */
    17 
    17 
       
    18 // Version : %version: %
       
    19 
    18 // INCLUDE FILES
    20 // INCLUDE FILES
    19 
    21 #include <hbglobal.h>
    20 #include <mpxmediageneraldefs.h>
    22 #include <mpxmediageneraldefs.h>
       
    23 #include <mpxmediavideodefs.h>
    21 #include <thumbnailmanager_qt.h>
    24 #include <thumbnailmanager_qt.h>
    22 #include <mpxmediaarray.h>
    25 #include <mpxmediaarray.h>
    23 #include <mpxmedia.h>
    26 #include <mpxmedia.h>
    24 #include <qvariant.h>
    27 #include <qvariant.h>
       
    28 #include <hbextendedlocale.h>
    25 
    29 
    26 #include "videolistdatamodel.h"
    30 #include "videolistdatamodel.h"
    27 #include "videocollectionclient.h"
    31 #include "videocollectionclient.h"
    28 #include "videodeleteworker.h"
    32 #include "videodeleteworker.h"
    29 
       
    30 #include "videolistdatamodel_p.h"
    33 #include "videolistdatamodel_p.h"
    31 #include "videothumbnaildata.h"
    34 #include "videothumbnaildata.h"
    32 #include "vcxmyvideosdefs.h"
    35 #include "vcxmyvideosdefs.h"
    33 #include "videocollectionutils.h"
    36 #include "videocollectionutils.h"
    34 #include "videocollectioncommon.h"
    37 #include "videocollectioncommon.h"
       
    38 #include "videocollectiontrace.h"
    35 
    39 
    36 /**
    40 /**
    37  * global qHash function required fo creating hash values for TMPXItemId -keys
    41  * global qHash function required fo creating hash values for TMPXItemId -keys
    38  */
    42  */
    39 inline uint qHash(TMPXItemId key) 
    43 inline uint qHash(TMPXItemId key) 
    40 { 
    44 { 
    41     QPair<uint, uint> keyPair(key.iId1, key.iId2); 
    45     QPair<uint, uint> keyPair(key.iId1, key.iId2); 
    42 
       
    43     return qHash(keyPair);
    46     return qHash(keyPair);
    44 }
    47 }
    45 
    48 
    46 // ================= MEMBER FUNCTIONS =======================
    49 // ================= MEMBER FUNCTIONS =======================
    47 //
    50 //
    54 q_ptr(model),
    57 q_ptr(model),
    55 mVideoThumbnailData(0),
    58 mVideoThumbnailData(0),
    56 mInitialized(false),
    59 mInitialized(false),
    57 mCurrentAlbum(TMPXItemId::InvalidId())
    60 mCurrentAlbum(TMPXItemId::InvalidId())
    58 {
    61 {
       
    62 	FUNC_LOG;
    59 }
    63 }
    60 	
    64 	
    61 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    62 // ~VideoListDataModelPrivate
    66 // ~VideoListDataModelPrivate
    63 // -----------------------------------------------------------------------------
    67 // -----------------------------------------------------------------------------
    64 //
    68 //
    65 VideoListDataModelPrivate::~VideoListDataModelPrivate()
    69 VideoListDataModelPrivate::~VideoListDataModelPrivate()
    66 {
    70 {
       
    71 	FUNC_LOG;
    67     QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter = mAlbumData.begin();
    72     QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter = mAlbumData.begin();
    68     while(iter != mAlbumData.end())
    73     while(iter != mAlbumData.end())
    69     {
    74     {
    70         iter->clear();
    75         iter->clear();
    71         ++iter;
    76         ++iter;
    78 // initialize
    83 // initialize
    79 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    80 //
    85 //
    81 int VideoListDataModelPrivate::initialize()
    86 int VideoListDataModelPrivate::initialize()
    82 {
    87 {
       
    88 	FUNC_LOG;
    83     if(mInitialized)
    89     if(mInitialized)
    84     {
    90     {
    85         return 0;
    91         return 0;
    86     }
    92     }
    87     mVideoThumbnailData = &(VideoThumbnailData::instance());
    93     mVideoThumbnailData = &(VideoThumbnailData::instance());
   178 // getVideodurationFromIndex
   184 // getVideodurationFromIndex
   179 // -----------------------------------------------------------------------------
   185 // -----------------------------------------------------------------------------
   180 //
   186 //
   181 quint32 VideoListDataModelPrivate::getVideodurationFromIndex( int index ) const
   187 quint32 VideoListDataModelPrivate::getVideodurationFromIndex( int index ) const
   182 {
   188 {
       
   189     CMPXMedia *media = mMediaData.fromIndex(index);
       
   190     return getVideoDuration(media);
       
   191 }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // getVideodurationFromIndex
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 quint32 VideoListDataModelPrivate::getVideoDuration(CMPXMedia* media) const
       
   198 {
   183     quint32 returnDuration(0);
   199     quint32 returnDuration(0);
   184     float duration(0);
   200     float duration(0);
   185     CMPXMedia *media = mMediaData.fromIndex(index);
       
   186     VideoCollectionUtils::instance().mediaValue<float>(media, KVcxMediaMyVideosDuration, duration );
   201     VideoCollectionUtils::instance().mediaValue<float>(media, KVcxMediaMyVideosDuration, duration );
   187     returnDuration = static_cast<quint32>(duration);
   202     returnDuration = static_cast<quint32>(duration);
   188     return returnDuration;
   203     return returnDuration;
   189 }
   204 }
   190 
   205 
   192 // getVideoDateFromIndex
   207 // getVideoDateFromIndex
   193 // -----------------------------------------------------------------------------
   208 // -----------------------------------------------------------------------------
   194 //
   209 //
   195 QDateTime VideoListDataModelPrivate::getVideoDateFromIndex( int index ) const
   210 QDateTime VideoListDataModelPrivate::getVideoDateFromIndex( int index ) const
   196 {
   211 {
       
   212     return getVideoDate(mMediaData.fromIndex(index));
       
   213 }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // getVideoDate
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 QDateTime VideoListDataModelPrivate::getVideoDate(CMPXMedia* media) const
       
   220 {
   197     QDateTime date;
   221     QDateTime date;
   198     quint64 dateTimeValue;
   222     quint64 dateTimeValue;
   199     if(!VideoCollectionUtils::instance().mediaValue<quint64>(mMediaData.fromIndex(index), KMPXMediaGeneralDate, dateTimeValue)) 
   223     if(!VideoCollectionUtils::instance().mediaValue<quint64>(media, KMPXMediaGeneralDate, dateTimeValue)) 
   200     {
   224     {
   201         return date;
   225         return date;
   202     }
   226     }
   203     TDateTime temp = TTime( dateTimeValue ).DateTime();
   227     TDateTime temp = TTime( dateTimeValue ).DateTime();
   204     date = QDateTime(QDate(temp.Year(), temp.Month()+1, temp.Day()+1), 
   228     date = QDateTime(QDate(temp.Year(), temp.Month()+1, temp.Day()+1), 
   205                        QTime(temp.Hour(), temp.Minute(), temp.Second(), temp.MicroSecond()));
   229                        QTime(temp.Hour(), temp.Minute(), temp.Second(), temp.MicroSecond()));
   206     return date;
   230     return date;
   207 }
   231 }
   208 
   232 
   209 // -----------------------------------------------------------------------------
   233 // -----------------------------------------------------------------------------
   210 // getMetaDataFromIndex
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 QMap<QString, QVariant> VideoListDataModelPrivate::getMetaDataFromIndex(int index) const
       
   214 {
       
   215     using namespace VideoCollectionCommon;
       
   216     QMap<QString, QVariant> map;
       
   217     CMPXMedia *media = mMediaData.fromIndex(index);
       
   218     if(!media) {
       
   219         return map;
       
   220     }
       
   221 
       
   222     // MetaKeyDate
       
   223     QDateTime date = getVideoDateFromIndex(index);
       
   224     if(date.isValid()) {
       
   225         map[MetaKeyDate] = date.date();
       
   226     }
       
   227     
       
   228     //TODO: Localisation
       
   229     // MetaKeyDurationString
       
   230     quint32 dur = getVideodurationFromIndex(index);
       
   231     QString duration = VideoCollectionUtils::instance().prepareLengthString(dur);
       
   232     if(!duration.isNull() && !duration.isEmpty()) {
       
   233         map[MetaKeyDurationString] = duration;
       
   234     }
       
   235     
       
   236     //TODO: Localisation
       
   237     // MetaKeySizeString
       
   238     quint32 s = getVideoSizeFromIndex(index);
       
   239     QString size = VideoCollectionUtils::instance().prepareSizeString(s);
       
   240     if(!size.isNull() && !size.isEmpty()) {
       
   241         map[MetaKeySizeString] = size; 
       
   242     }
       
   243     
       
   244     // MetaKeyStarRating
       
   245     quint8 rating = 0;
       
   246     if(VideoCollectionUtils::instance().mediaValue<quint8>(media, KVcxMediaMyVideosRating, rating)) 
       
   247     {
       
   248         map[MetaKeyStarRating] = rating;
       
   249     }
       
   250     
       
   251     // MetaKeyDRMInfo
       
   252     
       
   253     // MetaKeyServiceURL
       
   254     
       
   255     // MetaKeyDescription
       
   256     QString desc;
       
   257     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralComment, desc)) {
       
   258         map[MetaKeyDescription] = desc;
       
   259     }
       
   260     
       
   261     // MetaKeyModifiedDate
       
   262     quint64 dateTimeValue;
       
   263     if(VideoCollectionUtils::instance().mediaValue<quint64>(media, KVcxMediaMyVideosModifiedDate, dateTimeValue)) {
       
   264         TDateTime temp = TTime( dateTimeValue ).DateTime();
       
   265         QDateTime date = QDateTime(QDate(temp.Year(), temp.Month()+1, temp.Day()), 
       
   266                            QTime(temp.Hour(), temp.Minute(), temp.Second(), temp.MicroSecond()));
       
   267         map[MetaKeyModifiedDate] = date.date();
       
   268     }
       
   269 
       
   270     // MetaKeyShotLocation
       
   271     
       
   272     // MetaKeyAuthor
       
   273     QString author;
       
   274     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KVcxMediaMyVideosAuthor, author)) {
       
   275         map[MetaKeyAuthor] = author;
       
   276     }
       
   277     
       
   278     // MetaKeyCopyright
       
   279     QString copyright;
       
   280     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralCopyright, copyright)) {
       
   281         map[MetaKeyCopyright] = copyright;
       
   282     }
       
   283     
       
   284     // MetaKeyAudioType
       
   285     
       
   286     // MetaKeyLanguageString
       
   287     QString language;
       
   288     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KVcxMediaMyVideosAudioLanguage, language)) {
       
   289         map[MetaKeyLanguageString] = language;
       
   290     }
       
   291     
       
   292     // MetaKeyKeywords
       
   293     
       
   294     // MetaKeyVideoResolutionString
       
   295     
       
   296     // MetaKeyBitRate
       
   297     
       
   298     // MetaKeyFormat
       
   299     QString format;
       
   300     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralMimeType, format)) {
       
   301         map[MetaKeyFormat] = format;
       
   302     }
       
   303     
       
   304     return map;
       
   305 }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // markVideosRemoved
   234 // markVideosRemoved
   309 // -----------------------------------------------------------------------------
   235 // -----------------------------------------------------------------------------
   310 //
   236 //
   311 TMPXItemId VideoListDataModelPrivate::markVideoRemoved(const QModelIndex &itemIndex)
   237 TMPXItemId VideoListDataModelPrivate::markVideoRemoved(const QModelIndex &itemIndex)
   312 {
   238 {
   317 // restoreRemoved
   243 // restoreRemoved
   318 // -----------------------------------------------------------------------------
   244 // -----------------------------------------------------------------------------
   319 //
   245 //
   320 void VideoListDataModelPrivate::restoreRemoved(QList<TMPXItemId> *idList)
   246 void VideoListDataModelPrivate::restoreRemoved(QList<TMPXItemId> *idList)
   321 {
   247 {
       
   248 	FUNC_LOG;
   322     int startIndex = mMediaData.count();
   249     int startIndex = mMediaData.count();
   323     int restored = mMediaData.restoreRemovedItems(idList);
   250     int restored = mMediaData.restoreRemovedItems(idList);
   324     if(restored > 0)
   251     if(restored > 0)
   325     {
   252     {
   326         q_ptr->beginInsertRows(QModelIndex(), startIndex, startIndex + (restored - 1));
   253         q_ptr->beginInsertRows(QModelIndex(), startIndex, startIndex + (restored - 1));
   381 // setAlbumInUse
   308 // setAlbumInUse
   382 // -----------------------------------------------------------------------------
   309 // -----------------------------------------------------------------------------
   383 //
   310 //
   384 void VideoListDataModelPrivate::setAlbumInUse(TMPXItemId albumId)
   311 void VideoListDataModelPrivate::setAlbumInUse(TMPXItemId albumId)
   385 {
   312 {
       
   313 	FUNC_LOG;
   386     mCurrentAlbum = albumId;
   314     mCurrentAlbum = albumId;
   387 }
   315 }
   388 
   316 
   389 // -----------------------------------------------------------------------------
   317 // -----------------------------------------------------------------------------
   390 // removeItemsFromAlbum
   318 // removeItemsFromAlbum
   391 // -----------------------------------------------------------------------------
   319 // -----------------------------------------------------------------------------
   392 //
   320 //
   393 int VideoListDataModelPrivate::removeItemsFromAlbum(TMPXItemId &albumId, 
   321 int VideoListDataModelPrivate::removeItemsFromAlbum(TMPXItemId &albumId, 
   394                                         const QList<TMPXItemId> &items)
   322                                         const QList<TMPXItemId> &items)
   395 {
   323 {
       
   324 	FUNC_LOG;
   396     QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter = mAlbumData.find(albumId);
   325     QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter = mAlbumData.find(albumId);
   397     if(iter == mAlbumData.end())
   326     if(iter == mAlbumData.end())
   398     {
   327     {
   399         return 0;
   328         return 0;
   400     }
   329     }
   429 //
   358 //
   430 void VideoListDataModelPrivate::appendDataToContainerL(
   359 void VideoListDataModelPrivate::appendDataToContainerL(
   431     CMPXMediaArray *videoArray,
   360     CMPXMediaArray *videoArray,
   432     unsigned int startIndex)
   361     unsigned int startIndex)
   433 {
   362 {
       
   363 	FUNC_LOG;
       
   364 	INFO_2("VideoListDataModelPrivate::appendDataToContainerL() array count: %d, start index: %d", videoArray->Count(), startIndex);
       
   365 	
   434     int count = videoArray->Count();
   366     int count = videoArray->Count();
   435     if (!videoArray ||
   367     if (!videoArray ||
   436         startIndex >= count)
   368         startIndex >= count)
   437     {
   369     {
   438         return;
   370         return;
   449         {
   381         {
   450             newMedia = CMPXMedia::NewL(*mediaFromArray);
   382             newMedia = CMPXMedia::NewL(*mediaFromArray);
   451             mMediaData.append(newMedia);
   383             mMediaData.append(newMedia);
   452             newMedia = 0;
   384             newMedia = 0;
   453         }
   385         }
   454     }    
   386     }
   455 }
   387 }
   456 
   388 
   457 // -----------------------------------------------------------------------------
   389 // -----------------------------------------------------------------------------
   458 // isValid
   390 // isValid
   459 // -----------------------------------------------------------------------------
   391 // -----------------------------------------------------------------------------
   489 // -----------------------------------------------------------------------------
   421 // -----------------------------------------------------------------------------
   490 //
   422 //
   491 void VideoListDataModelPrivate::albumDataChangedL(TMPXItemId albumId,
   423 void VideoListDataModelPrivate::albumDataChangedL(TMPXItemId albumId,
   492     CMPXMediaArray *videoArray)
   424     CMPXMediaArray *videoArray)
   493 {
   425 {
       
   426 	FUNC_LOG;
   494     if (!videoArray || albumId == TMPXItemId::InvalidId())
   427     if (!videoArray || albumId == TMPXItemId::InvalidId())
   495     {
   428     {
   496         return;
   429         return;
   497     }
   430     }
   498     QSet<TMPXItemId> items;
   431     QSet<TMPXItemId> items;
   501     mAlbumData.remove(albumId);
   434     mAlbumData.remove(albumId);
   502     
   435     
   503     int videoCount = videoArray->Count();
   436     int videoCount = videoArray->Count();
   504     CMPXMedia *media = 0;
   437     CMPXMedia *media = 0;
   505     TMPXItemId id = TMPXItemId::InvalidId();
   438     TMPXItemId id = TMPXItemId::InvalidId();
   506     QModelIndex index;
       
   507     for (int i = videoCount - 1; i >= 0; i--)
   439     for (int i = videoCount - 1; i >= 0; i--)
   508     {
   440     {
   509         media = videoArray->AtL(i);
   441         media = videoArray->AtL(i);
   510         id = getMediaId(media);
   442         id = getMediaId(media);
   511         if (id != TMPXItemId::InvalidId() && id.iId2 == KVcxMvcMediaTypeVideo)
   443         if (id != TMPXItemId::InvalidId() && id.iId2 == KVcxMvcMediaTypeVideo)
   528 // thumbnailsFetchedSlot
   460 // thumbnailsFetchedSlot
   529 // -----------------------------------------------------------------------------
   461 // -----------------------------------------------------------------------------
   530 //
   462 //
   531 void VideoListDataModelPrivate::thumbnailsFetchedSlot(QList<TMPXItemId> mediaIds)
   463 void VideoListDataModelPrivate::thumbnailsFetchedSlot(QList<TMPXItemId> mediaIds)
   532 {
   464 {
   533     // TODO: find way to optimize dataChanged events 
       
   534     
       
   535     TMPXItemId id;
   465     TMPXItemId id;
   536     QModelIndex rowIndex;
   466     QModelIndex rowIndex;
   537     
   467     
   538     while(!mediaIds.isEmpty())
   468     while(!mediaIds.isEmpty())
   539     {
   469     {
   550 // newVideoListSlot
   480 // newVideoListSlot
   551 // -----------------------------------------------------------------------------
   481 // -----------------------------------------------------------------------------
   552 //
   482 //
   553 void VideoListDataModelPrivate::newVideoListSlot( CMPXMediaArray *newVideoList )
   483 void VideoListDataModelPrivate::newVideoListSlot( CMPXMediaArray *newVideoList )
   554 {
   484 {
       
   485 	FUNC_LOG;
   555     if( !newVideoList )
   486     if( !newVideoList )
   556     {
   487     {
   557         return;
   488         return;
   558     }
   489     }
   559 
   490     
   560     int startIndex = mMediaData.count();
   491     int startIndex = mMediaData.count();
   561 
   492 
   562     TRAP_IGNORE(appendDataToContainerL(newVideoList));
   493     TRAP_IGNORE(appendDataToContainerL(newVideoList));
   563 	
   494 	
   564     int endIndex = mMediaData.count() - 1;
   495     int endIndex = mMediaData.count() - 1;
   575 // appendVideoListSlot
   506 // appendVideoListSlot
   576 // -----------------------------------------------------------------------------
   507 // -----------------------------------------------------------------------------
   577 //
   508 //
   578 void VideoListDataModelPrivate::appendVideoListSlot(CMPXMediaArray* videoList)
   509 void VideoListDataModelPrivate::appendVideoListSlot(CMPXMediaArray* videoList)
   579 {
   510 {
       
   511 	FUNC_LOG;
   580     if(!videoList)
   512     if(!videoList)
   581     {
   513     {
   582         return;
   514         return;
   583     }
   515     }
   584     if(videoList->Count() == 0 || videoList->Count() <= mMediaData.count())
   516     if(videoList->Count() == 0 || videoList->Count() <= mMediaData.count())
   604 // newVideoAvailable
   536 // newVideoAvailable
   605 // -----------------------------------------------------------------------------
   537 // -----------------------------------------------------------------------------
   606 //
   538 //
   607 void VideoListDataModelPrivate::newVideoAvailableSlot(CMPXMedia *newVideo)
   539 void VideoListDataModelPrivate::newVideoAvailableSlot(CMPXMedia *newVideo)
   608 {
   540 {
       
   541 	FUNC_LOG;
   609     if(!newVideo ) 
   542     if(!newVideo ) 
   610     {
   543     {
   611         return;        
   544         return;        
   612     }
   545     }
   613 
   546 
   639 // itemDeletedSlot
   572 // itemDeletedSlot
   640 // -----------------------------------------------------------------------------
   573 // -----------------------------------------------------------------------------
   641 //
   574 //
   642 void VideoListDataModelPrivate::itemDeletedSlot(TMPXItemId itemId)
   575 void VideoListDataModelPrivate::itemDeletedSlot(TMPXItemId itemId)
   643 {
   576 {
       
   577 	FUNC_LOG;
   644 	if(itemId == TMPXItemId::InvalidId())
   578 	if(itemId == TMPXItemId::InvalidId())
   645     {
   579     {
   646         return;
   580         return;
   647     }    
   581     }    
   648 
   582 
   660 // albumRemoved 
   594 // albumRemoved 
   661 // -----------------------------------------------------------------------------
   595 // -----------------------------------------------------------------------------
   662 //
   596 //
   663 void VideoListDataModelPrivate::albumRemoved(TMPXItemId albumId)
   597 void VideoListDataModelPrivate::albumRemoved(TMPXItemId albumId)
   664 {
   598 {
       
   599 	FUNC_LOG;
   665     if (albumId == TMPXItemId::InvalidId() || albumId.iId2 != KVcxMvcMediaTypeAlbum)
   600     if (albumId == TMPXItemId::InvalidId() || albumId.iId2 != KVcxMvcMediaTypeAlbum)
   666     {
   601     {
   667         return;
   602         return;
   668     }
   603     }
   669     
   604     
   703 // videoDeleted
   638 // videoDeleted
   704 // -----------------------------------------------------------------------------
   639 // -----------------------------------------------------------------------------
   705 //
   640 //
   706 void VideoListDataModelPrivate::videoDeleted(TMPXItemId videoId)
   641 void VideoListDataModelPrivate::videoDeleted(TMPXItemId videoId)
   707 {
   642 {
       
   643 	FUNC_LOG;
   708     if(videoId == TMPXItemId::InvalidId())
   644     if(videoId == TMPXItemId::InvalidId())
   709     {
   645     {
   710         return;
   646         return;
   711     }    
   647     }    
   712     // check if provided id is in the deleted -container and remove 
   648     // check if provided id is in the deleted -container and remove 
   724         // removal: in this case we need to indicate UI         
   660         // removal: in this case we need to indicate UI         
   725         int index = mMediaData.indexOfId(videoId);
   661         int index = mMediaData.indexOfId(videoId);
   726         if(index >= 0)
   662         if(index >= 0)
   727         {
   663         {
   728             q_ptr->beginRemoveRows(QModelIndex(), index, index);
   664             q_ptr->beginRemoveRows(QModelIndex(), index, index);
   729             mMediaData.remove(videoId);            
   665             mMediaData.remove(videoId);
   730             q_ptr->endRemoveRows();
   666             q_ptr->endRemoveRows();
   731             emit q_ptr->modelChanged();
   667             emit q_ptr->modelChanged();
   732         }
   668         }
   733     }     
   669     }     
   734 }
   670 }
   737 // videoDeleteCompleted
   673 // videoDeleteCompleted
   738 // -----------------------------------------------------------------------------
   674 // -----------------------------------------------------------------------------
   739 //
   675 //
   740 void VideoListDataModelPrivate::videoDeleteCompletedSlot(int overallCount, QList<TMPXItemId> *failedMediaIds)
   676 void VideoListDataModelPrivate::videoDeleteCompletedSlot(int overallCount, QList<TMPXItemId> *failedMediaIds)
   741 {    
   677 {    
       
   678 	FUNC_LOG;
   742     Q_UNUSED(overallCount);
   679     Q_UNUSED(overallCount);
   743     if(!failedMediaIds)
   680     if(!failedMediaIds)
   744     {
   681     {
   745         // invalid signal received, do nothing
   682         // invalid signal received, do nothing
   746         return;
   683         return;
   761         {
   698         {
   762             status = VideoCollectionCommon::statusMultipleDeleteFail;
   699             status = VideoCollectionCommon::statusMultipleDeleteFail;
   763             data = failedMediaIds->count();
   700             data = failedMediaIds->count();
   764         }  
   701         }  
   765         restoreRemoved(failedMediaIds);
   702         restoreRemoved(failedMediaIds);
   766     }   
   703     }
   767     q_ptr->reportAsyncStatus(status, data);
   704     q_ptr->reportAsyncStatus(status, data);
   768     emit q_ptr->modelChanged();
   705     emit q_ptr->modelChanged();
   769 }
   706 }
   770 
   707 
   771 // -----------------------------------------------------------------------------
   708 // -----------------------------------------------------------------------------
   772 // albumRemoveFailureSlot
   709 // albumRemoveFailureSlot
   773 // -----------------------------------------------------------------------------
   710 // -----------------------------------------------------------------------------
   774 //
   711 //
   775 void VideoListDataModelPrivate::albumRemoveFailureSlot(QList<TMPXItemId> *failedMediaIds)
   712 void VideoListDataModelPrivate::albumRemoveFailureSlot(QList<TMPXItemId> *failedMediaIds)
   776 {
   713 {
       
   714 	FUNC_LOG;
   777     if(!failedMediaIds)
   715     if(!failedMediaIds)
   778     {
   716     {
   779         return;
   717         return;
   780     }
   718     }
   781     int status(VideoCollectionCommon::statusRemoveSucceed);
   719     int status(VideoCollectionCommon::statusRemoveSucceed);
   801 
   739 
   802 // -----------------------------------------------------------------------------
   740 // -----------------------------------------------------------------------------
   803 // VideoDetailsCompleted 
   741 // VideoDetailsCompleted 
   804 // -----------------------------------------------------------------------------
   742 // -----------------------------------------------------------------------------
   805 //
   743 //
   806 void VideoListDataModelPrivate::videoDetailsCompletedSlot(TMPXItemId videoId)
   744 void VideoListDataModelPrivate::videoDetailsCompletedSlot(CMPXMedia* media)
   807 {
   745 {
   808     if(videoId != TMPXItemId::InvalidId())
   746 	FUNC_LOG;
   809     {
   747     if(!media)
   810         emit videoDetailsReady(videoId);
   748     {
   811     }
   749         return;
       
   750     }
       
   751     
       
   752     using namespace VideoCollectionCommon;
       
   753     QMap<QString, QVariant> map;
       
   754 
       
   755     HbExtendedLocale locale = HbExtendedLocale::system();
       
   756     
       
   757     // MetaKeyDate
       
   758     QDateTime date = getVideoDate(media);
       
   759     if(date.isValid()) {
       
   760         map[MetaKeyDate] = locale.format( date.date(), r_qtn_date_usual );
       
   761     }
       
   762     
       
   763     //TODO: Localisation
       
   764     // MetaKeyDurationString
       
   765     quint32 dur = getVideoDuration(media);
       
   766     QString duration = VideoCollectionUtils::instance().prepareLengthString(dur);
       
   767     if(!duration.isNull() && !duration.isEmpty()) {
       
   768         map[MetaKeyDurationString] = duration;
       
   769     }
       
   770     
       
   771     //TODO: Localisation
       
   772     // MetaKeySizeString
       
   773     quint32 s;
       
   774     VideoCollectionUtils::instance().mediaValue<quint32>(media, KMPXMediaGeneralSize, s );
       
   775     QString size = VideoCollectionUtils::instance().prepareSizeString(s);
       
   776     if(!size.isNull() && !size.isEmpty()) {
       
   777         map[MetaKeySizeString] = size; 
       
   778     }
       
   779     
       
   780     // MetaKeyStarRating
       
   781     quint8 rating = 0;
       
   782     if(VideoCollectionUtils::instance().mediaValue<quint8>(media, KVcxMediaMyVideosRating, rating)) 
       
   783     {
       
   784         map[MetaKeyStarRating] = rating;
       
   785     }
       
   786     
       
   787     // MetaKeyDRMInfo
       
   788     
       
   789     // MetaKeyServiceURL
       
   790     
       
   791     // MetaKeyDescription
       
   792     QString desc;
       
   793     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralComment, desc)) {
       
   794         map[MetaKeyDescription] = desc;
       
   795     }
       
   796     
       
   797     // MetaKeyModifiedDate
       
   798     quint64 dateTimeValue;
       
   799     if(VideoCollectionUtils::instance().mediaValue<quint64>(media, KVcxMediaMyVideosModifiedDate, dateTimeValue)) {
       
   800         TDateTime temp = TTime( dateTimeValue ).DateTime();
       
   801         QDateTime date = QDateTime(QDate(temp.Year(), temp.Month()+1, temp.Day()), 
       
   802                            QTime(temp.Hour(), temp.Minute(), temp.Second(), temp.MicroSecond()));
       
   803         map[MetaKeyModifiedDate] = locale.format( date.date(), r_qtn_date_usual );
       
   804     }
       
   805 
       
   806     // MetaKeyShotLocation
       
   807     
       
   808     // MetaKeyAuthor
       
   809     QString author;
       
   810     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KVcxMediaMyVideosAuthor, author)) {
       
   811         map[MetaKeyAuthor] = author;
       
   812     }
       
   813     
       
   814     // MetaKeyCopyright
       
   815     QString copyright;
       
   816     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralCopyright, copyright)) {
       
   817         map[MetaKeyCopyright] = copyright;
       
   818     }
       
   819     
       
   820     // MetaKeyAudioType
       
   821     
       
   822     // MetaKeyLanguageString
       
   823     QString language;
       
   824     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KVcxMediaMyVideosAudioLanguage, language)) {
       
   825         map[MetaKeyLanguageString] = language;
       
   826     }
       
   827     
       
   828     // MetaKeyKeywords
       
   829     
       
   830     // MetaKeyVideoResolutionString
       
   831     quint16 width;
       
   832     quint16 heigth;
       
   833     if(VideoCollectionUtils::instance().mediaValue<quint16>(media, KMPXMediaVideoWidth, width) &&
       
   834        VideoCollectionUtils::instance().mediaValue<quint16>(media, KMPXMediaVideoHeight, heigth)) 
       
   835     {
       
   836         map[MetaKeyVideoResolutionString] = hbTrId("txt_videos_list_l1l2").arg(width).arg(heigth);
       
   837     }
       
   838     
       
   839     // MetaKeyBitRate
       
   840     qint16 bitrate;
       
   841     if(VideoCollectionUtils::instance().mediaValue<qint16>(media, KMPXMediaVideoBitRate, bitrate)) 
       
   842     {
       
   843         const char* loc = "txt_videos_list_l1_kbps";
       
   844         
       
   845         if(bitrate > 999)
       
   846         {
       
   847             loc = "txt_videos_list_l1_mbps";
       
   848             bitrate = (double)bitrate / (double)1000 + 0.5;
       
   849         }
       
   850         
       
   851         map[MetaKeyBitRate] = hbTrId(loc, bitrate);
       
   852     }
       
   853     
       
   854     // MetaKeyFormat
       
   855     QString format;
       
   856     if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralMimeType, format)) {
       
   857         map[MetaKeyFormat] = format;
       
   858     }
       
   859     
       
   860     QVariant variant = QVariant(map);
       
   861     emit videoDetailsReady(variant);
   812 }
   862 }
   813 
   863 
   814 // -----------------------------------------------------------------------------
   864 // -----------------------------------------------------------------------------
   815 // albumListAvailableSlot 
   865 // albumListAvailableSlot 
   816 // -----------------------------------------------------------------------------
   866 // -----------------------------------------------------------------------------
   817 //
   867 //
   818 void VideoListDataModelPrivate::albumListAvailableSlot(TMPXItemId albumId,
   868 void VideoListDataModelPrivate::albumListAvailableSlot(TMPXItemId albumId,
   819     CMPXMediaArray *albumItems)
   869     CMPXMediaArray *albumItems)
   820 {
   870 {
       
   871 	FUNC_LOG;
   821     // currently only one album is kept in memory
   872     // currently only one album is kept in memory
   822     TRAP_IGNORE(albumDataChangedL(albumId, albumItems));
   873     TRAP_IGNORE(albumDataChangedL(albumId, albumItems));
   823 }
   874 }
   824 
   875 
       
   876 // -----------------------------------------------------------------------------
       
   877 // itemModifiedSlot 
       
   878 // -----------------------------------------------------------------------------
       
   879 //
       
   880 void VideoListDataModelPrivate::itemModifiedSlot(const TMPXItemId &itemId)
       
   881 {
       
   882 	FUNC_LOG;
       
   883     int index = mMediaData.indexOfId(itemId);
       
   884     if(index != -1)
       
   885     {
       
   886         QModelIndex rowIndex = q_ptr->index(index, 0);
       
   887         if(rowIndex.isValid())
       
   888         {
       
   889             emit dataChanged(rowIndex, rowIndex);
       
   890             emit q_ptr->itemModified(itemId);
       
   891         }
       
   892     }
       
   893 }
       
   894 
   825 // End of file
   895 // End of file