16 */ |
16 */ |
17 |
17 |
18 #include "videocollectiontrace.h" |
18 #include "videocollectiontrace.h" |
19 #include "videolistwidget.h" |
19 #include "videolistwidget.h" |
20 |
20 |
21 #include <xqserviceutil.h> |
|
22 #include <qcoreapplication.h> |
21 #include <qcoreapplication.h> |
23 #include <qtimer.h> |
22 #include <qtimer.h> |
24 #include <hbscrollbar.h> |
23 #include <hbscrollbar.h> |
25 #include <xqserviceutil.h> |
24 #include <xqserviceutil.h> |
26 #include <hbmenu.h> |
25 #include <hbmenu.h> |
35 |
34 |
36 #include "videocollectionviewutils.h" |
35 #include "videocollectionviewutils.h" |
37 #include "videocollectionuiloader.h" |
36 #include "videocollectionuiloader.h" |
38 #include "videolistselectiondialog.h" |
37 #include "videolistselectiondialog.h" |
39 #include "videothumbnaildata.h" |
38 #include "videothumbnaildata.h" |
40 #include "videosortfilterproxymodel.h" |
39 #include "videoproxymodelgeneric.h" |
41 #include "videocollectioncommon.h" |
40 #include "videocollectioncommon.h" |
42 #include "mpxhbvideocommondefs.h" |
41 #include "mpxhbvideocommondefs.h" |
43 |
42 |
44 // Object names. |
43 // Object names. |
45 const char* const LIST_WIDGET_OBJECT_NAME_CONTEXT_MENU = "vc:ListWidgetContextMenu"; |
44 const char* const LIST_WIDGET_OBJECT_NAME_CONTEXT_MENU = "vc:ListWidgetContextMenu"; |
46 const char* const LIST_WIDGET_OBJECT_NAME_DELETE_VIDEO = "vc:ListWidgetMessageBoxDeleteVideo"; |
45 const char* const LIST_WIDGET_OBJECT_NAME_DELETE_VIDEO = "vc:ListWidgetMessageBoxDeleteVideo"; |
47 const char* const LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO = "vc:ListWidgetInputDialogRenameVideo"; |
46 const char* const LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO = "vc:ListWidgetInputDialogRenameVideo"; |
|
47 const char* const LIST_WIDGET_OBJECT_NAME_RENAME_ALBUM = "vc:ListWidgetInputDialogRenameAlbum"; |
48 const char* const LIST_WIDGET_OBJECT_NAME_REMOVE_COLLECTION = "vc:ListWidgetMessageBoxRemoveCollection"; |
48 const char* const LIST_WIDGET_OBJECT_NAME_REMOVE_COLLECTION = "vc:ListWidgetMessageBoxRemoveCollection"; |
49 const char* const LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK = "vc:ListWidgetNavKeyBack"; |
49 const char* const LIST_WIDGET_OBJECT_NAME_NAV_KEY_BACK = "vc:ListWidgetNavKeyBack"; |
50 const char* const LIST_WIDGET_OBJECT_NAME_NAV_KEY_QUIT = "vc:ListWidgetNavKeyQuit"; |
50 const char* const LIST_WIDGET_OBJECT_NAME_NAV_KEY_QUIT = "vc:ListWidgetNavKeyQuit"; |
51 const char* const LIST_WIDGET_OBJECT_NAME_ACTION_ATTACH = "vc:ListWidgetActionAttach"; |
51 const char* const LIST_WIDGET_OBJECT_NAME_ACTION_ATTACH = "vc:ListWidgetActionAttach"; |
52 const char* const LIST_WIDGET_OBJECT_NAME_ACTION_PLAY = "vc:ListWidgetActionPlay"; |
52 const char* const LIST_WIDGET_OBJECT_NAME_ACTION_PLAY = "vc:ListWidgetActionPlay"; |
106 |
106 |
107 // --------------------------------------------------------------------------- |
107 // --------------------------------------------------------------------------- |
108 // initialize |
108 // initialize |
109 // --------------------------------------------------------------------------- |
109 // --------------------------------------------------------------------------- |
110 // |
110 // |
111 int VideoListWidget::initialize(VideoSortFilterProxyModel &model, |
111 int VideoListWidget::initialize(VideoProxyModelGeneric &model, |
112 bool isService, |
112 bool isService, |
113 VideoCollectionCommon::TCollectionLevels level) |
113 VideoCollectionCommon::TCollectionLevels level) |
114 { |
114 { |
115 FUNC_LOG_ADDR(this); |
115 FUNC_LOG_ADDR(this); |
116 mModel = &model; |
116 mModel = &model; |
189 if (connectSignals() < 0) |
189 if (connectSignals() < 0) |
190 { |
190 { |
191 ERROR_1(-1, "VideoListWidget::activate() [0x%x]: connecting signals failed.", this); |
191 ERROR_1(-1, "VideoListWidget::activate() [0x%x]: connecting signals failed.", this); |
192 return -1; |
192 return -1; |
193 } |
193 } |
194 |
194 |
|
195 // Enable thumbnail background fetching. |
|
196 VideoThumbnailData::instance().enableBackgroundFetching(true); |
|
197 fetchThumbnailsForVisibleItems(); |
|
198 |
195 // open model to the current level in case not in album or category |
199 // open model to the current level in case not in album or category |
196 if (level != VideoCollectionCommon::ELevelAlbum && |
200 if (level != VideoCollectionCommon::ELevelAlbum && |
197 level != VideoCollectionCommon::ELevelDefaultColl) |
201 level != VideoCollectionCommon::ELevelDefaultColl) |
198 { |
202 { |
199 mModel->open(level); |
203 mModel->open(level); |
200 } |
204 } |
201 |
|
202 // Enable thumbnail background fetching. |
|
203 VideoThumbnailData &thumbnailData = VideoThumbnailData::instance(); |
|
204 thumbnailData.enableBackgroundFetching(true); |
|
205 fetchThumbnailsForVisibleItems(); |
|
206 |
205 |
207 return 0; |
206 return 0; |
208 } |
207 } |
209 |
208 |
210 // --------------------------------------------------------------------------- |
209 // --------------------------------------------------------------------------- |
220 } |
219 } |
221 |
220 |
222 setVisible(false); |
221 setVisible(false); |
223 disConnectSignals(); |
222 disConnectSignals(); |
224 |
223 |
225 // Free allocated memory for list thumbnails and disable background fetching. |
224 // Disable background thumbnail fetching. |
226 VideoThumbnailData &thumbnailData = VideoThumbnailData::instance(); |
225 VideoThumbnailData::instance().enableBackgroundFetching(false); |
227 thumbnailData.enableBackgroundFetching(false); |
|
228 thumbnailData.freeThumbnailData(); |
|
229 } |
226 } |
230 |
227 |
231 // --------------------------------------------------------------------------- |
228 // --------------------------------------------------------------------------- |
232 // getLevel |
229 // getLevel |
233 // --------------------------------------------------------------------------- |
230 // --------------------------------------------------------------------------- |
796 return; |
797 return; |
797 } |
798 } |
798 |
799 |
799 QModelIndex index = currentIndex(); |
800 QModelIndex index = currentIndex(); |
800 QVariant variant = mModel->data(index, VideoCollectionCommon::KeyTitle); |
801 QVariant variant = mModel->data(index, VideoCollectionCommon::KeyTitle); |
801 |
802 |
802 if(variant.isValid()) |
803 if(variant.isValid()) |
803 { |
804 { |
804 QString label(hbTrId("txt_videos_title_enter_name")); |
805 QString label; |
805 QString albumName = variant.toString(); |
806 const char* objectName = 0; |
806 |
807 QString currentName = variant.toString(); |
807 HbInputDialog *dialog = new HbInputDialog(); |
808 |
808 dialog->setAttribute(Qt::WA_DeleteOnClose); |
809 TMPXItemId mpxId = mModel->getMediaIdAtIndex(index); |
809 dialog->setObjectName(LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO); |
810 if(mpxId.iId2 == KVcxMvcMediaTypeAlbum) |
810 dialog->setPromptText(label); |
811 { |
811 dialog->setValue(albumName); |
812 label = hbTrId("txt_videos_title_enter_name"); |
812 dialog->open(this, SLOT(renameDialogFinished(HbAction *))); |
813 objectName = LIST_WIDGET_OBJECT_NAME_RENAME_ALBUM; |
|
814 } |
|
815 else if(mpxId.iId2 == KVcxMvcMediaTypeVideo) |
|
816 { |
|
817 label = hbTrId("txt_videos_dialog_video_name"); |
|
818 objectName = LIST_WIDGET_OBJECT_NAME_RENAME_VIDEO; |
|
819 } |
|
820 |
|
821 if(!label.isEmpty()) |
|
822 { |
|
823 HbInputDialog *dialog = new HbInputDialog(); |
|
824 dialog->setAttribute(Qt::WA_DeleteOnClose); |
|
825 dialog->setObjectName(objectName); |
|
826 dialog->setPromptText(label); |
|
827 dialog->setValue(currentName); |
|
828 dialog->open(this, SLOT(renameDialogFinished(HbAction *))); |
|
829 } |
813 } |
830 } |
814 } |
831 } |
815 |
832 |
816 // ------------------------------------------------------------------------------------------------- |
833 // ------------------------------------------------------------------------------------------------- |
817 // renameDialogFinished |
834 // renameDialogFinished |
826 { |
843 { |
827 return; |
844 return; |
828 } |
845 } |
829 QModelIndex index = currentIndex(); |
846 QModelIndex index = currentIndex(); |
830 TMPXItemId itemId = mModel->getMediaIdAtIndex(index); |
847 TMPXItemId itemId = mModel->getMediaIdAtIndex(index); |
|
848 |
831 QVariant newNameVariant = dialog->value(); |
849 QVariant newNameVariant = dialog->value(); |
832 QVariant oldNameVariant = mModel->data(index, VideoCollectionCommon::KeyTitle); |
850 QVariant oldNameVariant = mModel->data(index, VideoCollectionCommon::KeyTitle); |
833 if(!newNameVariant.isValid() || !oldNameVariant.isValid()) |
851 if(!newNameVariant.isValid() || !oldNameVariant.isValid()) |
834 { |
852 { |
835 // invalid data at index |
853 // invalid data at index |
836 return; |
854 return; |
837 } |
855 } |
838 QString newAlbumName = newNameVariant.toString().trimmed(); |
856 |
839 QString oldAlbumName = oldNameVariant.toString(); |
857 QString newName = newNameVariant.toString().trimmed(); |
840 if(!newAlbumName.length() || newAlbumName == oldAlbumName) |
858 QString oldName = oldNameVariant.toString(); |
|
859 if(!newName.length() || newName == oldName) |
841 { |
860 { |
842 // no new name provided or name has not changed |
861 // no new name provided or name has not changed |
843 return; |
862 return; |
844 } |
863 } |
845 if(itemId.iId2 == KVcxMvcMediaTypeAlbum) |
864 if(itemId.iId2 == KVcxMvcMediaTypeAlbum) |
846 { |
865 { |
847 // for album, we need to make sure name is unique |
866 // for album, we need to make sure name is unique |
848 newAlbumName = mModel->resolveAlbumName(newAlbumName); |
867 newName = mModel->resolveAlbumName(newName); |
849 } |
868 } |
850 mModel->renameItem(itemId, newAlbumName); |
869 mModel->renameItem(itemId, newName); |
851 } |
870 } |
852 |
871 |
853 // --------------------------------------------------------------------------- |
872 // --------------------------------------------------------------------------- |
854 // addToCollectionSlot |
873 // addToCollectionSlot |
855 // --------------------------------------------------------------------------- |
874 // --------------------------------------------------------------------------- |