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 // |
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 { |
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 } |
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 |