13 * |
13 * |
14 * Description: VideoListDataModelPrivate class implementation |
14 * Description: VideoListDataModelPrivate class implementation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // Version : %version: 38.1.2 % |
18 // Version : %version: 38.1.6 % |
19 |
19 |
20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include <hbglobal.h> |
21 #include <hbglobal.h> |
22 #include <mpxmediageneraldefs.h> |
22 #include <mpxmediageneraldefs.h> |
23 #include <mpxmediavideodefs.h> |
23 #include <mpxmediavideodefs.h> |
24 #include <thumbnailmanager_qt.h> |
24 #include <thumbnailmanager_qt.h> |
25 #include <mpxmediaarray.h> |
25 #include <mpxmediaarray.h> |
26 #include <mpxmedia.h> |
26 #include <mpxmedia.h> |
27 #include <qvariant.h> |
27 #include <qvariant.h> |
28 #include <hbextendedlocale.h> |
28 #include <hbextendedlocale.h> |
|
29 #include <qfileinfo.h> |
29 |
30 |
30 #include "videolistdatamodel.h" |
31 #include "videolistdatamodel.h" |
31 #include "videocollectionclient.h" |
32 #include "videocollectionclient.h" |
32 #include "videodeleteworker.h" |
33 #include "videodeleteworker.h" |
33 #include "videolistdatamodel_p.h" |
34 #include "videolistdatamodel_p.h" |
89 if(mInitialized) |
90 if(mInitialized) |
90 { |
91 { |
91 return 0; |
92 return 0; |
92 } |
93 } |
93 mVideoThumbnailData = &(VideoThumbnailData::instance()); |
94 mVideoThumbnailData = &(VideoThumbnailData::instance()); |
94 if(!connect( mVideoThumbnailData, SIGNAL(thumbnailsFetched( QList<TMPXItemId> )), |
95 if(!connect( mVideoThumbnailData, SIGNAL(thumbnailsFetched( QList<TMPXItemId>& )), |
95 this, SLOT(thumbnailsFetchedSlot( QList<TMPXItemId> )))) |
96 this, SLOT(thumbnailsFetchedSlot( QList<TMPXItemId>& )))) |
96 { |
97 { |
97 return -1; |
98 return -1; |
98 } |
99 } |
99 |
100 |
100 mInitialized = true; |
101 mInitialized = true; |
112 |
113 |
113 // ----------------------------------------------------------------------------- |
114 // ----------------------------------------------------------------------------- |
114 // getMediaIdFromIndex |
115 // getMediaIdFromIndex |
115 // ----------------------------------------------------------------------------- |
116 // ----------------------------------------------------------------------------- |
116 // |
117 // |
117 TMPXItemId VideoListDataModelPrivate::getMediaIdFromIndex( int index ) const |
118 const TMPXItemId& VideoListDataModelPrivate::getMediaIdFromIndex(const int &index ) const |
118 { |
119 { |
119 return mMediaData.idFromIndex(index); |
120 return mMediaData.idFromIndex(index); |
120 } |
121 } |
121 |
122 |
122 // ----------------------------------------------------------------------------- |
123 // ----------------------------------------------------------------------------- |
123 // getVideoNameFromIndex |
124 // getVideoNameFromIndex |
124 // ----------------------------------------------------------------------------- |
125 // ----------------------------------------------------------------------------- |
125 // |
126 // |
126 const QString VideoListDataModelPrivate::getVideoNameFromIndex( int index ) const |
127 const QString VideoListDataModelPrivate::getVideoNameFromIndex(const int &index ) const |
127 { |
128 { |
128 QString txt; |
129 QString txt; |
129 CMPXMedia* media = mMediaData.fromIndex(index); |
130 CMPXMedia* media = mMediaData.fromIndex(index); |
130 VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, txt ); |
131 VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, txt ); |
131 return txt; |
132 return txt; |
133 |
134 |
134 // ----------------------------------------------------------------------------- |
135 // ----------------------------------------------------------------------------- |
135 // getVideoThumbnailFromIndex |
136 // getVideoThumbnailFromIndex |
136 // ----------------------------------------------------------------------------- |
137 // ----------------------------------------------------------------------------- |
137 // |
138 // |
138 const QIcon* VideoListDataModelPrivate::getVideoThumbnailFromIndex( int index ) const |
139 const QIcon* VideoListDataModelPrivate::getVideoThumbnailFromIndex(const int &index ) const |
139 { |
140 { |
140 if(mVideoThumbnailData) |
141 if(mVideoThumbnailData) |
141 { |
142 { |
142 return mVideoThumbnailData->getThumbnail( mMediaData.idFromIndex(index) ); |
143 return mVideoThumbnailData->getThumbnail( mMediaData.idFromIndex(index) ); |
143 } |
144 } |
146 |
147 |
147 // ----------------------------------------------------------------------------- |
148 // ----------------------------------------------------------------------------- |
148 // getCategoryVideoCountFromIndex |
149 // getCategoryVideoCountFromIndex |
149 // ----------------------------------------------------------------------------- |
150 // ----------------------------------------------------------------------------- |
150 // |
151 // |
151 quint32 VideoListDataModelPrivate::getCategoryVideoCountFromIndex( int index ) const |
152 quint32 VideoListDataModelPrivate::getCategoryVideoCountFromIndex(const int &index ) const |
152 { |
153 { |
153 quint32 count(0); |
154 quint32 count(0); |
154 CMPXMedia *media = mMediaData.fromIndex(index); |
155 CMPXMedia *media = mMediaData.fromIndex(index); |
155 VideoCollectionUtils::instance().mediaValue<quint32>(media, KVcxMediaMyVideosCategoryItemCount, count ); |
156 VideoCollectionUtils::instance().mediaValue<quint32>(media, KVcxMediaMyVideosCategoryItemCount, count ); |
156 return count; |
157 return count; |
158 |
159 |
159 // ----------------------------------------------------------------------------- |
160 // ----------------------------------------------------------------------------- |
160 // getVideoSizeFromIndex |
161 // getVideoSizeFromIndex |
161 // ----------------------------------------------------------------------------- |
162 // ----------------------------------------------------------------------------- |
162 // |
163 // |
163 quint32 VideoListDataModelPrivate::getVideoSizeFromIndex( int index ) const |
164 quint32 VideoListDataModelPrivate::getVideoSizeFromIndex(const int &index ) const |
164 { |
165 { |
165 quint32 size(0); |
166 quint32 size(0); |
166 CMPXMedia *media = mMediaData.fromIndex(index); |
167 CMPXMedia *media = mMediaData.fromIndex(index); |
167 VideoCollectionUtils::instance().mediaValue<quint32>(media, KMPXMediaGeneralSize, size ); |
168 VideoCollectionUtils::instance().mediaValue<quint32>(media, KMPXMediaGeneralSize, size ); |
168 return size; |
169 return size; |
170 |
171 |
171 // ----------------------------------------------------------------------------- |
172 // ----------------------------------------------------------------------------- |
172 // getVideoAgeProfileFromIndex |
173 // getVideoAgeProfileFromIndex |
173 // --------------------------------------------------------------------------- |
174 // --------------------------------------------------------------------------- |
174 // |
175 // |
175 quint32 VideoListDataModelPrivate::getVideoAgeProfileFromIndex( int index ) const |
176 quint32 VideoListDataModelPrivate::getVideoAgeProfileFromIndex(const int &index ) const |
176 { |
177 { |
177 quint32 ageProfile(0); |
178 quint32 ageProfile(0); |
178 CMPXMedia *media = mMediaData.fromIndex(index); |
179 CMPXMedia *media = mMediaData.fromIndex(index); |
179 VideoCollectionUtils::instance().mediaValue<quint32>(media, KVcxMediaMyVideosAgeProfile, ageProfile ); |
180 VideoCollectionUtils::instance().mediaValue<quint32>(media, KVcxMediaMyVideosAgeProfile, ageProfile ); |
180 return ageProfile; |
181 return ageProfile; |
182 |
183 |
183 // ----------------------------------------------------------------------------- |
184 // ----------------------------------------------------------------------------- |
184 // getVideodurationFromIndex |
185 // getVideodurationFromIndex |
185 // ----------------------------------------------------------------------------- |
186 // ----------------------------------------------------------------------------- |
186 // |
187 // |
187 quint32 VideoListDataModelPrivate::getVideodurationFromIndex( int index ) const |
188 quint32 VideoListDataModelPrivate::getVideodurationFromIndex(const int &index ) const |
188 { |
189 { |
189 CMPXMedia *media = mMediaData.fromIndex(index); |
190 CMPXMedia *media = mMediaData.fromIndex(index); |
190 return getVideoDuration(media); |
191 return getVideoDuration(media); |
191 } |
192 } |
192 |
193 |
205 |
206 |
206 // ----------------------------------------------------------------------------- |
207 // ----------------------------------------------------------------------------- |
207 // getVideoDateFromIndex |
208 // getVideoDateFromIndex |
208 // ----------------------------------------------------------------------------- |
209 // ----------------------------------------------------------------------------- |
209 // |
210 // |
210 QDateTime VideoListDataModelPrivate::getVideoDateFromIndex( int index ) const |
211 QDateTime VideoListDataModelPrivate::getVideoDateFromIndex(const int &index ) const |
211 { |
212 { |
212 return getVideoDate(mMediaData.fromIndex(index)); |
213 return getVideoDate(mMediaData.fromIndex(index)); |
213 } |
214 } |
214 |
215 |
215 // ----------------------------------------------------------------------------- |
216 // ----------------------------------------------------------------------------- |
232 |
233 |
233 // ----------------------------------------------------------------------------- |
234 // ----------------------------------------------------------------------------- |
234 // markVideosRemoved |
235 // markVideosRemoved |
235 // ----------------------------------------------------------------------------- |
236 // ----------------------------------------------------------------------------- |
236 // |
237 // |
237 TMPXItemId VideoListDataModelPrivate::markVideoRemoved(const QModelIndex &itemIndex) |
238 const TMPXItemId VideoListDataModelPrivate::markVideoRemoved(const QModelIndex &itemIndex) |
238 { |
239 { |
239 return mMediaData.markItemRemoved(itemIndex.row()); |
240 return mMediaData.markItemRemoved(itemIndex.row()); |
240 } |
241 } |
241 |
242 |
242 // ----------------------------------------------------------------------------- |
243 // ----------------------------------------------------------------------------- |
257 |
258 |
258 // ----------------------------------------------------------------------------- |
259 // ----------------------------------------------------------------------------- |
259 // getFilePathFromIndex |
260 // getFilePathFromIndex |
260 // ----------------------------------------------------------------------------- |
261 // ----------------------------------------------------------------------------- |
261 // |
262 // |
262 const QString VideoListDataModelPrivate::getFilePathFromIndex(int index) const |
263 const QString VideoListDataModelPrivate::getFilePathFromIndex(const int &index) const |
263 { |
264 { |
264 QString filePath; |
265 QString filePath; |
265 VideoCollectionUtils::instance().mediaValue<QString>(mMediaData.fromIndex(index), |
266 VideoCollectionUtils::instance().mediaValue<QString>(mMediaData.fromIndex(index), |
266 KMPXMediaGeneralUri, filePath ); |
267 KMPXMediaGeneralUri, filePath ); |
267 return filePath; |
268 return filePath; |
269 |
270 |
270 // ----------------------------------------------------------------------------- |
271 // ----------------------------------------------------------------------------- |
271 // getFilePathForId |
272 // getFilePathForId |
272 // ----------------------------------------------------------------------------- |
273 // ----------------------------------------------------------------------------- |
273 // |
274 // |
274 const QString VideoListDataModelPrivate::getFilePathForId(TMPXItemId mediaId) const |
275 const QString VideoListDataModelPrivate::getFilePathForId(const TMPXItemId &mediaId) |
275 { |
276 { |
276 QString filePath; |
277 QString filePath; |
277 int index = mMediaData.indexOfId(mediaId); |
278 int index = mMediaData.indexOfId(mediaId); |
278 VideoCollectionUtils::instance().mediaValue<QString>(mMediaData.fromIndex(index), |
279 VideoCollectionUtils::instance().mediaValue<QString>(mMediaData.fromIndex(index), |
279 KMPXMediaGeneralUri, filePath ); |
280 KMPXMediaGeneralUri, filePath ); |
306 |
307 |
307 // ----------------------------------------------------------------------------- |
308 // ----------------------------------------------------------------------------- |
308 // setAlbumInUse |
309 // setAlbumInUse |
309 // ----------------------------------------------------------------------------- |
310 // ----------------------------------------------------------------------------- |
310 // |
311 // |
311 void VideoListDataModelPrivate::setAlbumInUse(TMPXItemId albumId) |
312 void VideoListDataModelPrivate::setAlbumInUse(const TMPXItemId &albumId) |
312 { |
313 { |
313 FUNC_LOG; |
314 FUNC_LOG; |
314 mCurrentAlbum = albumId; |
315 mCurrentAlbum = albumId; |
315 } |
316 } |
316 |
317 |
317 // ----------------------------------------------------------------------------- |
318 // ----------------------------------------------------------------------------- |
318 // removeItemsFromAlbum |
319 // removeItemsFromAlbum |
319 // ----------------------------------------------------------------------------- |
320 // ----------------------------------------------------------------------------- |
320 // |
321 // |
321 int VideoListDataModelPrivate::removeItemsFromAlbum(TMPXItemId &albumId, |
322 int VideoListDataModelPrivate::removeItemsFromAlbum(const TMPXItemId &albumId, |
322 const QList<TMPXItemId> &items) |
323 const QList<TMPXItemId> &items) |
323 { |
324 { |
324 FUNC_LOG; |
325 FUNC_LOG; |
325 QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter = mAlbumData.find(albumId); |
326 QHash<TMPXItemId, QSet<TMPXItemId> >::iterator iter = mAlbumData.find(albumId); |
326 if(iter == mAlbumData.end()) |
327 if(iter == mAlbumData.end()) |
420 |
421 |
421 // ----------------------------------------------------------------------------- |
422 // ----------------------------------------------------------------------------- |
422 // albumDataChangedL |
423 // albumDataChangedL |
423 // ----------------------------------------------------------------------------- |
424 // ----------------------------------------------------------------------------- |
424 // |
425 // |
425 void VideoListDataModelPrivate::albumDataChangedL(TMPXItemId albumId, |
426 void VideoListDataModelPrivate::albumDataChangedL(TMPXItemId &albumId, |
426 CMPXMediaArray *videoArray) |
427 CMPXMediaArray *videoArray) |
427 { |
428 { |
428 FUNC_LOG; |
429 FUNC_LOG; |
429 if (!videoArray || albumId == TMPXItemId::InvalidId()) |
430 if (!videoArray || albumId == TMPXItemId::InvalidId()) |
430 { |
431 { |
465 |
466 |
466 // ----------------------------------------------------------------------------- |
467 // ----------------------------------------------------------------------------- |
467 // thumbnailsFetchedSlot |
468 // thumbnailsFetchedSlot |
468 // ----------------------------------------------------------------------------- |
469 // ----------------------------------------------------------------------------- |
469 // |
470 // |
470 void VideoListDataModelPrivate::thumbnailsFetchedSlot(QList<TMPXItemId> mediaIds) |
471 void VideoListDataModelPrivate::thumbnailsFetchedSlot(QList<TMPXItemId> &mediaIds) |
471 { |
472 { |
472 TMPXItemId id; |
473 TMPXItemId id; |
473 QModelIndex rowIndex; |
474 QModelIndex rowIndex; |
474 |
475 |
475 while(!mediaIds.isEmpty()) |
476 while(!mediaIds.isEmpty()) |
476 { |
477 { |
477 id = mediaIds.takeFirst(); |
478 id = mediaIds.takeFirst(); |
478 rowIndex = q_ptr->index(mMediaData.indexOfId(id), 0); |
479 rowIndex = q_ptr->index(mMediaData.indexOfId(id), 0); |
479 if(rowIndex.isValid()) |
480 if(rowIndex.isValid()) |
480 { |
481 { |
481 emit dataChanged( rowIndex, rowIndex); |
482 emit q_ptr->dataChanged( rowIndex, rowIndex); |
482 } |
483 } |
483 } |
484 } |
484 } |
485 } |
485 |
486 |
486 // ----------------------------------------------------------------------------- |
487 // ----------------------------------------------------------------------------- |
598 |
599 |
599 // ----------------------------------------------------------------------------- |
600 // ----------------------------------------------------------------------------- |
600 // albumRemoved |
601 // albumRemoved |
601 // ----------------------------------------------------------------------------- |
602 // ----------------------------------------------------------------------------- |
602 // |
603 // |
603 void VideoListDataModelPrivate::albumRemoved(TMPXItemId albumId) |
604 void VideoListDataModelPrivate::albumRemoved(TMPXItemId &albumId) |
604 { |
605 { |
605 FUNC_LOG; |
606 FUNC_LOG; |
606 if (albumId == TMPXItemId::InvalidId() || albumId.iId2 != KVcxMvcMediaTypeAlbum) |
607 if (albumId == TMPXItemId::InvalidId() || albumId.iId2 != KVcxMvcMediaTypeAlbum) |
607 { |
608 { |
608 return; |
609 return; |
691 int status(VideoCollectionCommon::statusDeleteSucceed); |
692 int status(VideoCollectionCommon::statusDeleteSucceed); |
692 QVariant data; |
693 QVariant data; |
693 if(failedMediaIds->count() > 0) |
694 if(failedMediaIds->count() > 0) |
694 { |
695 { |
695 QString nameOfFirstFailed(""); |
696 QString nameOfFirstFailed(""); |
696 CMPXMedia *media = mMediaData.getRemovedMedia( TMPXItemId(failedMediaIds->at(0))); |
697 CMPXMedia *media = mMediaData.getRemovedMedia(failedMediaIds->first()); |
697 VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, nameOfFirstFailed ); |
698 VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, nameOfFirstFailed ); |
698 if(failedMediaIds->count() == 1) |
699 if(failedMediaIds->count() == 1) |
699 { |
700 { |
700 status = VideoCollectionCommon::statusSingleDeleteFail; |
701 status = VideoCollectionCommon::statusSingleDeleteFail; |
701 data = nameOfFirstFailed; |
702 data = nameOfFirstFailed; |
725 int status(VideoCollectionCommon::statusRemoveSucceed); |
726 int status(VideoCollectionCommon::statusRemoveSucceed); |
726 QVariant data; |
727 QVariant data; |
727 if(failedMediaIds->count() > 0) |
728 if(failedMediaIds->count() > 0) |
728 { |
729 { |
729 QString nameOfFirstFailed(""); |
730 QString nameOfFirstFailed(""); |
730 CMPXMedia *media = mMediaData.getRemovedMedia( TMPXItemId(failedMediaIds->at(0))); |
731 CMPXMedia *media = mMediaData.getRemovedMedia(failedMediaIds->first()); |
731 VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, nameOfFirstFailed ); |
732 VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, nameOfFirstFailed ); |
732 if(failedMediaIds->count() == 1) |
733 if(failedMediaIds->count() == 1) |
733 { |
734 { |
734 status = VideoCollectionCommon::statusSingleRemoveFail; |
735 status = VideoCollectionCommon::statusSingleRemoveFail; |
735 data = nameOfFirstFailed; |
736 data = nameOfFirstFailed; |
859 QString format; |
860 QString format; |
860 if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralMimeType, format)) { |
861 if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralMimeType, format)) { |
861 map[MetaKeyFormat] = format; |
862 map[MetaKeyFormat] = format; |
862 } |
863 } |
863 |
864 |
|
865 // MetaKeyFileName and MetaKeyFilePath |
|
866 QString fileName; |
|
867 if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralUri, fileName)) { |
|
868 |
|
869 QFileInfo fInfo(fileName); |
|
870 if(fInfo.isFile()) |
|
871 { |
|
872 map[MetaKeyFileName] = fInfo.fileName(); |
|
873 map[MetaKeyFilePath] = fInfo.absolutePath(); |
|
874 } |
|
875 } |
|
876 |
|
877 // Metakey video title |
|
878 QString videoTitle; |
|
879 if(VideoCollectionUtils::instance().mediaValue<QString>(media, KMPXMediaGeneralTitle, videoTitle)) { |
|
880 map[MetaKeyVideoTitle] = videoTitle; |
|
881 } |
|
882 |
|
883 |
864 QVariant variant = QVariant(map); |
884 QVariant variant = QVariant(map); |
865 emit videoDetailsReady(variant); |
885 emit q_ptr->fullVideoDetailsReady(variant); |
866 } |
886 } |
867 |
887 |
868 // ----------------------------------------------------------------------------- |
888 // ----------------------------------------------------------------------------- |
869 // albumListAvailableSlot |
889 // albumListAvailableSlot |
870 // ----------------------------------------------------------------------------- |
890 // ----------------------------------------------------------------------------- |
871 // |
891 // |
872 void VideoListDataModelPrivate::albumListAvailableSlot(TMPXItemId albumId, |
892 void VideoListDataModelPrivate::albumListAvailableSlot(TMPXItemId &albumId, |
873 CMPXMediaArray *albumItems) |
893 CMPXMediaArray *albumItems) |
874 { |
894 { |
875 FUNC_LOG; |
895 FUNC_LOG; |
876 // currently only one album is kept in memory |
896 // currently only one album is kept in memory |
877 TRAP_IGNORE(albumDataChangedL(albumId, albumItems)); |
897 TRAP_IGNORE(albumDataChangedL(albumId, albumItems)); |
887 int index = mMediaData.indexOfId(itemId); |
907 int index = mMediaData.indexOfId(itemId); |
888 if(index != -1) |
908 if(index != -1) |
889 { |
909 { |
890 QModelIndex rowIndex = q_ptr->index(index, 0); |
910 QModelIndex rowIndex = q_ptr->index(index, 0); |
891 if(rowIndex.isValid()) |
911 if(rowIndex.isValid()) |
892 { |
912 { |
893 emit dataChanged(rowIndex, rowIndex); |
913 emit q_ptr->dataChanged(rowIndex, rowIndex); |
894 emit q_ptr->itemModified(itemId); |
914 emit q_ptr->modelChanged(); |
895 } |
915 } |
896 } |
916 } |
897 } |
917 } |
898 |
918 |
899 // ----------------------------------------------------------------------------- |
919 // ----------------------------------------------------------------------------- |
900 // listCompleteSlot |
920 // videoListCompleteSlot |
901 // ----------------------------------------------------------------------------- |
921 // ----------------------------------------------------------------------------- |
902 // |
922 // |
903 void VideoListDataModelPrivate::listCompleteSlot() |
923 void VideoListDataModelPrivate::videoListCompleteSlot() |
904 { |
924 { |
905 emit q_ptr->modelReady(); |
925 emit q_ptr->modelReady(); |
906 } |
926 } |
907 |
927 |
|
928 // ----------------------------------------------------------------------------- |
|
929 // albumListCompleteSlot |
|
930 // ----------------------------------------------------------------------------- |
|
931 // |
|
932 void VideoListDataModelPrivate::albumListCompleteSlot() |
|
933 { |
|
934 emit q_ptr->albumListReady(); |
|
935 } |
|
936 |
908 // End of file |
937 // End of file |