46 #include "videocollectionuiloader.h" |
46 #include "videocollectionuiloader.h" |
47 #include "mpxhbvideocommondefs.h" |
47 #include "mpxhbvideocommondefs.h" |
48 #include "videocollectiontrace.h" |
48 #include "videocollectiontrace.h" |
49 |
49 |
50 // Object names. |
50 // Object names. |
51 const char* const LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION = "vc::ListViewInputDialogCreateCollection"; |
|
52 const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU = "vc::ListViewOptionsMenu"; |
51 const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU = "vc::ListViewOptionsMenu"; |
53 |
52 |
54 // --------------------------------------------------------------------------- |
53 // --------------------------------------------------------------------------- |
55 // Constructor |
54 // Constructor |
56 // --------------------------------------------------------------------------- |
55 // --------------------------------------------------------------------------- |
289 this, SLOT(orientationChangedSlot(Qt::Orientation))) || |
288 this, SLOT(orientationChangedSlot(Qt::Orientation))) || |
290 !connect( |
289 !connect( |
291 &mWrapper, SIGNAL(asyncStatus(int, QVariant&)), |
290 &mWrapper, SIGNAL(asyncStatus(int, QVariant&)), |
292 this, SLOT(handleAsyncStatusSlot(int, QVariant&))) || |
291 this, SLOT(handleAsyncStatusSlot(int, QVariant&))) || |
293 !connect( |
292 !connect( |
294 mCurrentList->getModel().sourceModel(), SIGNAL(modelChanged()), |
293 mCurrentList->getModel()->sourceModel(), SIGNAL(modelChanged()), |
295 this, SLOT(layoutChangedSlot())) || |
294 this, SLOT(layoutChangedSlot())) || |
296 !connect( |
295 !connect( |
297 mCurrentList->getModel().sourceModel(), SIGNAL(modelReady()), |
296 mCurrentList->getModel()->sourceModel(), SIGNAL(modelReady()), |
298 this, SLOT(modelReadySlot()))) |
297 this, SLOT(modelReadySlot()))) |
299 { |
298 { |
300 ERROR(-1, "VideoListView::activateView() failed to connect signals."); |
299 ERROR(-1, "VideoListView::activateView() failed to connect signals."); |
301 // deactivate view so we get rid of dangling connections. |
300 // deactivate view so we get rid of dangling connections. |
302 deactivateView(); |
301 deactivateView(); |
382 if(menu) |
381 if(menu) |
383 { |
382 { |
384 menu->setObjectName(LIST_VIEW_OBJECT_NAME_OPTIONS_MENU); |
383 menu->setObjectName(LIST_VIEW_OBJECT_NAME_OPTIONS_MENU); |
385 menu->hide(); |
384 menu->hide(); |
386 } |
385 } |
387 |
386 |
388 if(mCurrentList && &(mCurrentList->getModel()) && mCurrentList->getModel().sourceModel()) |
387 if(mCurrentList && mCurrentList->getModel() && mCurrentList->getModel()->sourceModel()) |
389 { |
388 { |
390 disconnect(mCurrentList->getModel().sourceModel(), |
389 disconnect(mCurrentList->getModel()->sourceModel(), |
391 SIGNAL(modelChanged()), |
390 SIGNAL(modelChanged()), |
392 this, SLOT(layoutChangedSlot())); |
391 this, SLOT(layoutChangedSlot())); |
393 disconnect(mCurrentList->getModel().sourceModel(), |
392 disconnect(mCurrentList->getModel()->sourceModel(), |
394 SIGNAL(modelReady()), |
393 SIGNAL(modelReady()), |
395 this, SLOT(modelReadySlot())); |
394 this, SLOT(modelReadySlot())); |
396 |
395 |
397 showHint(false); |
396 showHint(false); |
398 } |
397 } |
547 if(!mCurrentList) |
546 if(!mCurrentList) |
548 { |
547 { |
549 return; |
548 return; |
550 } |
549 } |
551 |
550 |
552 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
551 VideoSortFilterProxyModel *model = mCurrentList->getModel(); |
553 |
552 |
554 if(!mModelReady && model.rowCount() == 0) |
553 if(!model || (!mModelReady && model->rowCount() == 0)) |
555 { |
554 { |
556 return; |
555 return; |
557 } |
556 } |
558 |
557 |
559 mModelReady = true; |
558 mModelReady = true; |
560 |
559 |
561 // decide if the hintwidget needs to be shown or not. |
560 // decide if the hintwidget needs to be shown or not. |
562 show = show && model.rowCount() == 0; |
561 show = show && model->rowCount() == 0; |
563 |
562 |
564 // If show is false, then hint widget is fetched only if it exists. If |
563 // If show is false, then hint widget is fetched only if it exists. If |
565 // show is true then hint widget is also created and prepared if it does not exists. |
564 // show is true then hint widget is also created and prepared if it does not exists. |
566 VideoHintWidget *hintWidget = |
565 VideoHintWidget *hintWidget = |
567 mUiLoader->findWidget<VideoHintWidget>( |
566 mUiLoader->findWidget<VideoHintWidget>( |
744 case KVcxMvcCategoryIdCaptured: |
743 case KVcxMvcCategoryIdCaptured: |
745 { |
744 { |
746 VideoListWidget *collectionContentWidget = |
745 VideoListWidget *collectionContentWidget = |
747 mUiLoader->findWidget<VideoListWidget>( |
746 mUiLoader->findWidget<VideoListWidget>( |
748 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET); |
747 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET); |
749 if (collectionContentWidget) |
748 if (collectionContentWidget && collectionContentWidget->getModel()) |
750 { |
749 { |
751 // no need to deactivate since there cannot be previous widget |
750 // no need to deactivate since there cannot be previous widget |
752 mCurrentList = collectionContentWidget; |
751 mCurrentList = collectionContentWidget; |
753 |
752 |
754 // resolve collection name |
753 // resolve collection name |
886 updateSubLabel(); |
885 updateSubLabel(); |
887 } |
886 } |
888 } |
887 } |
889 |
888 |
890 // --------------------------------------------------------------------------- |
889 // --------------------------------------------------------------------------- |
891 // openNewAlbumSlot() |
|
892 // --------------------------------------------------------------------------- |
|
893 // |
|
894 void VideoListView::openNewAlbumSlot(const QModelIndex &parent, |
|
895 int start, |
|
896 int end) |
|
897 { |
|
898 FUNC_LOG; |
|
899 Q_UNUSED(end); |
|
900 if(!mCurrentList) |
|
901 { |
|
902 return; |
|
903 } |
|
904 // invalidate model |
|
905 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
|
906 model.invalidate(); |
|
907 |
|
908 // activate new index |
|
909 QModelIndex index = model.index(start, 0, parent); |
|
910 if (index.isValid()) |
|
911 { |
|
912 // disconnect rowsInserted signal to prevent obsolete slot calls |
|
913 disconnect( &model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), |
|
914 this, SLOT(openNewAlbumSlot(const QModelIndex&, int, int))); |
|
915 |
|
916 mCurrentList->emitActivated(index); |
|
917 } |
|
918 } |
|
919 |
|
920 // --------------------------------------------------------------------------- |
|
921 // openservicesViewSlot() |
890 // openservicesViewSlot() |
922 // --------------------------------------------------------------------------- |
891 // --------------------------------------------------------------------------- |
923 // |
892 // |
924 void VideoListView::openServicesViewSlot() |
893 void VideoListView::openServicesViewSlot() |
925 { |
894 { |
958 // --------------------------------------------------------------------------- |
927 // --------------------------------------------------------------------------- |
959 // |
928 // |
960 void VideoListView::doSorting(int role) |
929 void VideoListView::doSorting(int role) |
961 { |
930 { |
962 FUNC_LOG; |
931 FUNC_LOG; |
|
932 if(!mCurrentList || !mCurrentList->getModel()) |
|
933 { |
|
934 // no list or model, cannot sort |
|
935 return; |
|
936 } |
963 // sort model |
937 // sort model |
964 Qt::SortOrder order(Qt::AscendingOrder); |
938 Qt::SortOrder order(Qt::AscendingOrder); |
965 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
939 VideoSortFilterProxyModel *model = mCurrentList->getModel(); |
966 if(model.sortRole() == role && model.sortOrder() == Qt::AscendingOrder) |
940 if(model->sortRole() == role && model->sortOrder() == Qt::AscendingOrder) |
967 { |
941 { |
968 order = Qt::DescendingOrder; |
942 order = Qt::DescendingOrder; |
969 } |
943 } |
970 model.doSorting(role, order); |
944 model->doSorting(role, order); |
971 |
945 |
972 if (mCurrentList == mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET)) |
946 if (mCurrentList == mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET)) |
973 { |
947 { |
974 mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_VIDEOLISTWIDGET)->getModel().doSorting(role, order); |
948 VideoListWidget *allVideosList = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_VIDEOLISTWIDGET); |
|
949 if(allVideosList && allVideosList->getModel()) |
|
950 { |
|
951 allVideosList->getModel()->doSorting(role, order); |
|
952 } |
975 } |
953 } |
976 |
954 |
977 // save sorting values only if the application is not started as a service |
955 // save sorting values only if the application is not started as a service |
978 if (!mIsService) |
956 if (!mIsService) |
979 { |
957 { |
1036 // ------------------------------------------------------------------------------------------------- |
1010 // ------------------------------------------------------------------------------------------------- |
1037 // |
1011 // |
1038 void VideoListView::createCollectionSlot() |
1012 void VideoListView::createCollectionSlot() |
1039 { |
1013 { |
1040 FUNC_LOG; |
1014 FUNC_LOG; |
1041 if(!mCurrentList) |
1015 |
1042 { |
|
1043 return; |
|
1044 } |
|
1045 |
|
1046 // query a name for the collection |
|
1047 QString label(hbTrId("txt_videos_title_enter_name")); |
|
1048 QString text(hbTrId("txt_videos_dialog_entry_new_collection")); |
|
1049 |
|
1050 HbInputDialog *dialog = new HbInputDialog(); |
|
1051 dialog->setAttribute(Qt::WA_DeleteOnClose); |
|
1052 dialog->setObjectName(LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION); |
|
1053 dialog->setPromptText(label); |
|
1054 dialog->setValue(text); |
|
1055 dialog->open(this, SLOT(createCollectionDialogFinished(HbAction *))); |
|
1056 } |
|
1057 |
|
1058 // ------------------------------------------------------------------------------------------------- |
|
1059 // createCollectionDialogFinished |
|
1060 // ------------------------------------------------------------------------------------------------- |
|
1061 // |
|
1062 void VideoListView::createCollectionDialogFinished(HbAction *action) |
|
1063 { |
|
1064 FUNC_LOG; |
|
1065 |
|
1066 HbInputDialog *dialog = static_cast<HbInputDialog*>(sender()); |
|
1067 |
|
1068 QVariant variant = dialog->value(); |
|
1069 |
|
1070 if(dialog->actions().first() == action && variant.isValid()) |
|
1071 { |
|
1072 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
|
1073 |
|
1074 // resolve collection true name and add new album |
|
1075 QString text = model.resolveAlbumName(variant.toString()); |
|
1076 |
|
1077 if(text.length()) |
|
1078 { |
|
1079 // when collection reports about new collection, we open it right away, |
|
1080 // for that, connect to rowsInserted so that the new album can be opened |
|
1081 if(!connect(&model, SIGNAL(rowsInserted(const QModelIndex&, int, int)), |
|
1082 this, SLOT(openNewAlbumSlot(const QModelIndex&, int, int)))) |
|
1083 { |
|
1084 return; |
|
1085 } |
|
1086 |
|
1087 model.addNewAlbum(text); |
|
1088 } |
|
1089 } |
|
1090 } |
|
1091 |
|
1092 // ------------------------------------------------------------------------------------------------- |
|
1093 // addVideosToCollectionSlot |
|
1094 // ------------------------------------------------------------------------------------------------- |
|
1095 // |
|
1096 void VideoListView::addVideosToCollectionSlot() |
|
1097 { |
|
1098 FUNC_LOG; |
|
1099 if(!mCurrentList) |
|
1100 { |
|
1101 return; |
|
1102 } |
|
1103 |
|
1104 VideoListSelectionDialog *dialog = |
1016 VideoListSelectionDialog *dialog = |
1105 mUiLoader->findWidget<VideoListSelectionDialog>( |
1017 mUiLoader->findWidget<VideoListSelectionDialog>( |
1106 DOCML_NAME_DIALOG); |
1018 DOCML_NAME_DIALOG); |
1107 if (!dialog) |
1019 if (!dialog) |
1108 { |
1020 { |
1109 // fatal: no selection dialog |
1021 // fatal: no selection dialog |
1110 return; |
1022 return; |
1111 } |
1023 } |
|
1024 |
|
1025 dialog->setupContent(VideoListSelectionDialog::ECreateCollection, TMPXItemId::InvalidId()); |
|
1026 dialog->exec(); |
|
1027 } |
|
1028 |
|
1029 // ------------------------------------------------------------------------------------------------- |
|
1030 // addVideosToCollectionSlot |
|
1031 // ------------------------------------------------------------------------------------------------- |
|
1032 // |
|
1033 void VideoListView::addVideosToCollectionSlot() |
|
1034 { |
|
1035 FUNC_LOG; |
|
1036 if(!mCurrentList || !mCurrentList->getModel()) |
|
1037 { |
|
1038 return; |
|
1039 } |
|
1040 |
|
1041 VideoListSelectionDialog *dialog = |
|
1042 mUiLoader->findWidget<VideoListSelectionDialog>( |
|
1043 DOCML_NAME_DIALOG); |
|
1044 if (!dialog) |
|
1045 { |
|
1046 // fatal: no selection dialog |
|
1047 return; |
|
1048 } |
1112 if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelAlbum) |
1049 if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelAlbum) |
1113 { |
1050 { |
1114 // album is opened, do not proceed in case it already have same amount |
1051 // album is opened, do not proceed in case it already have same amount |
1115 // of videos than all videos view. |
1052 // of videos than all videos view. |
1116 VideoListWidget *allVideos = mUiLoader->findWidget<VideoListWidget>( |
1053 VideoListWidget *allVideos = mUiLoader->findWidget<VideoListWidget>( |
1117 DOCML_NAME_VC_VIDEOLISTWIDGET); |
1054 DOCML_NAME_VC_VIDEOLISTWIDGET); |
1118 if(allVideos) |
1055 if(allVideos && allVideos->getModel()) |
1119 { |
1056 { |
1120 int count = allVideos->getModel().rowCount(); |
1057 int count = allVideos->getModel()->rowCount(); |
1121 if(count == mCurrentList->getModel().rowCount()) |
1058 if(count == mCurrentList->getModel()->rowCount()) |
1122 { |
1059 { |
1123 if(count) |
1060 if(count) |
1124 { |
1061 { |
1125 QVariant emptyAdditional; |
1062 QVariant emptyAdditional; |
1126 mUiUtils.showStatusMsgSlot( |
1063 mUiUtils.showStatusMsgSlot( |
1141 // ------------------------------------------------------------------------------------------------- |
1078 // ------------------------------------------------------------------------------------------------- |
1142 // |
1079 // |
1143 void VideoListView::removeVideosFromCollectionSlot() |
1080 void VideoListView::removeVideosFromCollectionSlot() |
1144 { |
1081 { |
1145 FUNC_LOG; |
1082 FUNC_LOG; |
1146 if(!mCurrentList) |
1083 if(!mCurrentList || !mCurrentList->getModel()) |
1147 { |
1084 { |
1148 return; |
1085 return; |
1149 } |
1086 } |
1150 // not allowed if for some reason current widget |
1087 // not allowed if for some reason current widget |
1151 // is all videos or collection or there are no items |
1088 // is all videos or collection or there are no items |
1152 if(mCurrentList->getLevel() < VideoCollectionCommon::ELevelDefaultColl || |
1089 if(mCurrentList->getLevel() < VideoCollectionCommon::ELevelDefaultColl || |
1153 !mCurrentList->getModel().rowCount()) |
1090 !mCurrentList->getModel()->rowCount()) |
1154 { |
1091 { |
1155 return; |
1092 return; |
1156 } |
1093 } |
1157 |
1094 |
1158 VideoListSelectionDialog *dialog = |
1095 VideoListSelectionDialog *dialog = |
1200 showAction(false, DOCML_NAME_SORT_BY_NAME); |
1137 showAction(false, DOCML_NAME_SORT_BY_NAME); |
1201 showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS); |
1138 showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS); |
1202 showAction(false, DOCML_NAME_SORT_BY_SIZE); |
1139 showAction(false, DOCML_NAME_SORT_BY_SIZE); |
1203 showAction(false, DOCML_NAME_SORT_MENU); |
1140 showAction(false, DOCML_NAME_SORT_MENU); |
1204 |
1141 |
1205 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
1142 VideoSortFilterProxyModel *model = mCurrentList->getModel(); |
1206 if (!model.rowCount()) |
1143 if (!model || !model->rowCount()) |
1207 { |
1144 { |
1208 return; |
1145 return; |
1209 } |
1146 } |
1210 |
1147 |
1211 // get current sorting values |
1148 // get current sorting values |
1212 int role; |
1149 int role; |
1213 Qt::SortOrder order; |
1150 Qt::SortOrder order; |
1214 model.getSorting(role, order); |
1151 model->getSorting(role, order); |
1215 |
1152 |
1216 HbAction *firstAction = (HbAction*)(toolBar()->actions().first()); |
1153 HbAction *firstAction = (HbAction*)(toolBar()->actions().first()); |
1217 |
1154 |
1218 if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionAllVideos] && |
1155 if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionAllVideos] && |
1219 firstAction == mToolbarActions[ETBActionAllVideos]) |
1156 firstAction == mToolbarActions[ETBActionAllVideos]) |
1292 showAction(false, DOCML_NAME_SORT_BY_NAME); |
1229 showAction(false, DOCML_NAME_SORT_BY_NAME); |
1293 showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS); |
1230 showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS); |
1294 showAction(false, DOCML_NAME_SORT_BY_SIZE); |
1231 showAction(false, DOCML_NAME_SORT_BY_SIZE); |
1295 showAction(false, DOCML_NAME_SORT_MENU); |
1232 showAction(false, DOCML_NAME_SORT_MENU); |
1296 |
1233 |
1297 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
1234 VideoSortFilterProxyModel *model = mCurrentList->getModel(); |
1298 if (!model.rowCount()) |
1235 if (!model || !model->rowCount()) |
1299 { |
1236 { |
1300 return; |
1237 return; |
1301 } |
1238 } |
1302 |
1239 |
1303 // show delete action |
1240 // show delete action |
1368 collectionContentWidget->setEnabledAnimations(animationState); |
1309 collectionContentWidget->setEnabledAnimations(animationState); |
1369 return; |
1310 return; |
1370 } |
1311 } |
1371 |
1312 |
1372 // get item id before deactivating |
1313 // get item id before deactivating |
1373 TMPXItemId itemId = mCurrentList->getModel().getMediaIdAtIndex(index); |
1314 TMPXItemId itemId = mCurrentList->getModel()->getMediaIdAtIndex(index); |
1374 |
1315 |
1375 // get level from the item to be opened only default |
1316 // get level from the item to be opened only default |
1376 // or user defined collections can be activated here |
1317 // or user defined collections can be activated here |
1377 VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelInvalid; |
1318 VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelInvalid; |
1378 if(itemId.iId2 == KVcxMvcMediaTypeCategory) |
1319 if(itemId.iId2 == KVcxMvcMediaTypeCategory) |
1388 collectionContentWidget->setEnabledAnimations(animationState); |
1329 collectionContentWidget->setEnabledAnimations(animationState); |
1389 return; |
1330 return; |
1390 } |
1331 } |
1391 |
1332 |
1392 // Start fetching content before changing. |
1333 // Start fetching content before changing. |
1393 VideoSortFilterProxyModel &model = collectionContentWidget->getModel(); |
1334 VideoSortFilterProxyModel *model = collectionContentWidget->getModel(); |
1394 model.openItem(itemId); |
1335 if(!model) |
|
1336 { |
|
1337 // no model for content widget, cannot activate |
|
1338 return; |
|
1339 } |
|
1340 model->openItem(itemId); |
1395 |
1341 |
1396 // deactivat current widget. |
1342 // deactivat current widget. |
1397 mCurrentList->deactivate(); |
1343 mCurrentList->deactivate(); |
1398 |
1344 |
1399 // activate video collection content widget and set it as current list. |
1345 // activate video collection content widget and set it as current list. |
1400 mCurrentList = collectionContentWidget; |
1346 mCurrentList = collectionContentWidget; |
1401 mCurrentList->activate(level); |
1347 mCurrentList->activate(level); |
1402 |
1348 |
1403 updateSubLabel(); |
1349 updateSubLabel(); |
1404 |
1350 |
1405 model.invalidate(); |
1351 model->invalidate(); |
1406 |
1352 |
1407 // update hint widget for correct content |
1353 // update hint widget for correct content |
1408 mModelReady = model.rowCount() > 0; |
1354 mModelReady = model->rowCount() > 0; |
1409 setHintLevel(VideoHintWidget::Collection); |
1355 setHintLevel(VideoHintWidget::Collection); |
1410 |
1356 |
1411 // update toolbar for albums, default categories don't have one. |
1357 // update toolbar for albums, default categories don't have one. |
1412 if(level == VideoCollectionCommon::ELevelAlbum && |
1358 if(level == VideoCollectionCommon::ELevelAlbum && |
1413 mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections)) |
1359 mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections)) |