13 * |
13 * |
14 * Description: Videolist view class source code |
14 * Description: Videolist view class source code |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // Version : %version: 101 % |
18 // Version : %version: 106 % |
19 |
19 |
20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include <xqserviceutil.h> |
21 #include <xqserviceutil.h> |
22 #include <qactiongroup.h> |
22 #include <qactiongroup.h> |
23 #include <hbinstance.h> |
23 #include <hbinstance.h> |
45 #include "videosortfilterproxymodel.h" |
45 #include "videosortfilterproxymodel.h" |
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. |
|
51 const char* const LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION = "vc::ListViewInputDialogCreateCollection"; |
|
52 const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU = "vc::ListViewOptionsMenu"; |
|
53 |
50 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
51 // Constructor |
55 // Constructor |
52 // --------------------------------------------------------------------------- |
56 // --------------------------------------------------------------------------- |
53 // |
57 // |
54 VideoListView::VideoListView( VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent ) |
58 VideoListView::VideoListView( VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent ) |
56 , mUiUtils( VideoCollectionViewUtils::instance() ) |
60 , mUiUtils( VideoCollectionViewUtils::instance() ) |
57 , mWrapper( VideoCollectionWrapper::instance() ) |
61 , mWrapper( VideoCollectionWrapper::instance() ) |
58 , mUiLoader( uiLoader ) |
62 , mUiLoader( uiLoader ) |
59 , mIsService( false ) |
63 , mIsService( false ) |
60 , mModelReady( false ) |
64 , mModelReady( false ) |
|
65 , mViewReady( false ) |
61 , mHintLevel( VideoHintWidget::AllVideos ) |
66 , mHintLevel( VideoHintWidget::AllVideos ) |
62 , mVideoServices( 0 ) |
67 , mVideoServices( 0 ) |
63 , mCurrentList( 0 ) |
68 , mCurrentList( 0 ) |
64 , mToolbarViewsActionGroup( 0 ) |
69 , mToolbarViewsActionGroup( 0 ) |
65 , mToolbarCollectionActionGroup( 0 ) |
70 , mToolbarCollectionActionGroup( 0 ) |
320 // --------------------------------------------------------------------------- |
326 // --------------------------------------------------------------------------- |
321 // |
327 // |
322 void VideoListView::layoutChangedSlot() |
328 void VideoListView::layoutChangedSlot() |
323 { |
329 { |
324 FUNC_LOG; |
330 FUNC_LOG; |
|
331 // Note that showHint should be executed before updateSubLabel as it |
|
332 // can modify the mModelReady flag. |
|
333 showHint(); |
325 updateSubLabel(); |
334 updateSubLabel(); |
326 |
|
327 if(mModelReady) |
|
328 { |
|
329 showHint(); |
|
330 } |
|
331 } |
335 } |
332 |
336 |
333 // --------------------------------------------------------------------------- |
337 // --------------------------------------------------------------------------- |
334 // deactivateView() |
338 // deactivateView() |
335 // --------------------------------------------------------------------------- |
339 // --------------------------------------------------------------------------- |
349 |
353 |
350 disconnect(&mWrapper, SIGNAL(asyncStatus(int, QVariant&)), |
354 disconnect(&mWrapper, SIGNAL(asyncStatus(int, QVariant&)), |
351 this, SLOT(handleAsyncStatusSlot(int, QVariant&))); |
355 this, SLOT(handleAsyncStatusSlot(int, QVariant&))); |
352 |
356 |
353 HbMenu *menu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_OPTIONS_MENU); |
357 HbMenu *menu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_OPTIONS_MENU); |
354 if (menu) |
358 if(menu) |
355 { |
359 { |
|
360 menu->setObjectName(LIST_VIEW_OBJECT_NAME_OPTIONS_MENU); |
356 menu->hide(); |
361 menu->hide(); |
357 } |
362 } |
358 |
363 |
359 if(mCurrentList && &(mCurrentList->getModel()) && mCurrentList->getModel().sourceModel()) |
364 if(mCurrentList && &(mCurrentList->getModel()) && mCurrentList->getModel().sourceModel()) |
360 { |
365 { |
405 // --------------------------------------------------------------------------- |
410 // --------------------------------------------------------------------------- |
406 // |
411 // |
407 int VideoListView::createToolbar() |
412 int VideoListView::createToolbar() |
408 { |
413 { |
409 FUNC_LOG; |
414 FUNC_LOG; |
410 // Create actiongroup and add all actions to it. This ensures that only one is |
415 |
|
416 // Create actiongroup and add all actions to it. This ensures that only one is |
411 // active at certain moment. |
417 // active at certain moment. |
412 |
|
413 if(!mToolbarViewsActionGroup && !mToolbarCollectionActionGroup) |
418 if(!mToolbarViewsActionGroup && !mToolbarCollectionActionGroup) |
414 { |
419 { |
415 mToolbarViewsActionGroup = new QActionGroup(this); |
420 mToolbarViewsActionGroup = new QActionGroup(this); |
416 mToolbarCollectionActionGroup = new QActionGroup(this); |
421 mToolbarCollectionActionGroup = new QActionGroup(this); |
417 |
422 |
418 // create toolbar item actions |
423 // create toolbar item actions |
419 |
424 |
420 // All Videos tab |
425 // All Videos tab |
421 mToolbarActions[ETBActionAllVideos] = createAction(":/images/qtg_mono_video_all.svg", |
426 mToolbarActions[ETBActionAllVideos] = createAction("qtg_mono_video", |
422 mToolbarViewsActionGroup, SLOT(openAllVideosViewSlot())); |
427 mToolbarViewsActionGroup, SLOT(openAllVideosViewSlot())); |
423 |
428 |
424 // Collections tab |
429 // Collections tab |
425 mToolbarActions[ETBActionCollections] = createAction("qtg_mono_video_collection", |
430 mToolbarActions[ETBActionCollections] = createAction("qtg_mono_video_collection", |
426 mToolbarViewsActionGroup, SLOT(openCollectionViewSlot())); |
431 mToolbarViewsActionGroup, SLOT(openCollectionViewSlot())); |
512 return; |
517 return; |
513 } |
518 } |
514 |
519 |
515 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
520 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
516 |
521 |
517 // prepare hint widget |
522 if(!mModelReady && model.rowCount() == 0) |
|
523 { |
|
524 return; |
|
525 } |
|
526 |
|
527 mModelReady = true; |
|
528 |
|
529 // decide if the hintwidget needs to be shown or not. |
|
530 show = show && model.rowCount() == 0; |
|
531 |
|
532 // If show is false, then hint widget is fetched only if it exists. If |
|
533 // show is true then hint widget is also created and prepared if it does not exists. |
518 VideoHintWidget *hintWidget = |
534 VideoHintWidget *hintWidget = |
519 mUiLoader->findWidget<VideoHintWidget>( |
535 mUiLoader->findWidget<VideoHintWidget>( |
520 DOCML_NAME_VC_VIDEOHINTWIDGET); |
536 DOCML_NAME_VC_VIDEOHINTWIDGET, show); |
|
537 |
521 if (hintWidget) |
538 if (hintWidget) |
522 { |
539 { |
523 hintWidget->setLevel(mHintLevel); |
540 hintWidget->setLevel(mHintLevel); |
524 if (mModelReady && |
541 if (show) |
525 model.rowCount() == 0) |
542 { |
526 { |
543 hintWidget->activate(); |
527 show ? hintWidget->activate() : hintWidget->deactivate(); |
|
528 } |
|
529 else |
|
530 { |
|
531 show = false; |
|
532 hintWidget->deactivate(); |
|
533 } |
|
534 if(show) |
|
535 { |
|
536 bool showHintBtns = (mCurrentList->getLevel() != VideoCollectionCommon::ELevelDefaultColl); |
544 bool showHintBtns = (mCurrentList->getLevel() != VideoCollectionCommon::ELevelDefaultColl); |
537 hintWidget->setButtonShown(showHintBtns); |
545 hintWidget->setButtonShown(showHintBtns); |
538 } |
546 } |
539 else |
547 else |
540 { |
548 { |
|
549 hintWidget->deactivate(); |
541 hintWidget->setButtonShown(true); |
550 hintWidget->setButtonShown(true); |
542 } |
551 } |
543 } |
552 } |
544 |
553 |
545 if (mToolbarViewsActionGroup && mToolbarCollectionActionGroup && !mIsService) |
554 if (mToolbarViewsActionGroup && mToolbarCollectionActionGroup && !mIsService) |
821 |
830 |
822 // activate all videos list |
831 // activate all videos list |
823 mCurrentList = videoListWidget; |
832 mCurrentList = videoListWidget; |
824 mCurrentList->activate(VideoCollectionCommon::ELevelVideos); |
833 mCurrentList->activate(VideoCollectionCommon::ELevelVideos); |
825 |
834 |
826 // since collection is not to be opened at this point, |
|
827 // we do not receive lauoutChanged for updating the hind -widget |
|
828 // if needed, need to show it here is needed |
|
829 setHintLevel(VideoHintWidget::AllVideos); |
835 setHintLevel(VideoHintWidget::AllVideos); |
830 showHint(); |
836 |
|
837 // update the sublabel, as in most cases the data is already up to date. |
|
838 updateSubLabel(); |
831 } |
839 } |
832 } |
840 } |
833 |
841 |
834 // --------------------------------------------------------------------------- |
842 // --------------------------------------------------------------------------- |
835 // openCollectionViewSlot() |
843 // openCollectionViewSlot() |
852 mCurrentList = collectionWidget; |
860 mCurrentList = collectionWidget; |
853 mCurrentList->activate(VideoCollectionCommon::ELevelCategory); |
861 mCurrentList->activate(VideoCollectionCommon::ELevelCategory); |
854 |
862 |
855 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
863 VideoSortFilterProxyModel &model = mCurrentList->getModel(); |
856 |
864 |
857 VideoCollectionViewUtils::sortModel(&model, false, mCurrentList->getLevel()); |
865 // the collection view is not empty, so we should hide the hint in advance. |
858 |
|
859 // the collection view is not empty, so we can hide the hint in advance. |
|
860 showHint(false); |
866 showHint(false); |
|
867 |
|
868 // also update the sublabel immediatelly, as the data is up to date almost always. |
|
869 updateSubLabel(); |
861 } |
870 } |
862 } |
871 } |
863 |
872 |
864 // --------------------------------------------------------------------------- |
873 // --------------------------------------------------------------------------- |
865 // openNewAlbumSlot() |
874 // openNewAlbumSlot() |
1021 QString label(hbTrId("txt_videos_title_enter_name")); |
1030 QString label(hbTrId("txt_videos_title_enter_name")); |
1022 QString text(hbTrId("txt_videos_dialog_entry_new_collection")); |
1031 QString text(hbTrId("txt_videos_dialog_entry_new_collection")); |
1023 |
1032 |
1024 HbInputDialog *dialog = new HbInputDialog(); |
1033 HbInputDialog *dialog = new HbInputDialog(); |
1025 dialog->setAttribute(Qt::WA_DeleteOnClose); |
1034 dialog->setAttribute(Qt::WA_DeleteOnClose); |
1026 dialog->getText(label, this, SLOT(createCollectionDialogFinished(HbAction *)), text); |
1035 dialog->setObjectName(LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION); |
|
1036 dialog->setPromptText(label); |
|
1037 dialog->setValue(text); |
|
1038 dialog->open(this, SLOT(createCollectionDialogFinished(HbAction *))); |
1027 } |
1039 } |
1028 |
1040 |
1029 // ------------------------------------------------------------------------------------------------- |
1041 // ------------------------------------------------------------------------------------------------- |
1030 // createCollectionDialogFinished |
1042 // createCollectionDialogFinished |
1031 // ------------------------------------------------------------------------------------------------- |
1043 // ------------------------------------------------------------------------------------------------- |
1032 // |
1044 // |
1033 void VideoListView::createCollectionDialogFinished(HbAction *action) |
1045 void VideoListView::createCollectionDialogFinished(HbAction *action) |
1034 { |
1046 { |
1035 FUNC_LOG; |
1047 FUNC_LOG; |
1036 Q_UNUSED(action); |
|
1037 |
1048 |
1038 HbInputDialog *dialog = static_cast<HbInputDialog*>(sender()); |
1049 HbInputDialog *dialog = static_cast<HbInputDialog*>(sender()); |
1039 |
1050 |
1040 QVariant variant = dialog->value(); |
1051 QVariant variant = dialog->value(); |
1041 |
1052 |
1360 collectionContentWidget->setEnabledAnimations(animationState); |
1371 collectionContentWidget->setEnabledAnimations(animationState); |
1361 return; |
1372 return; |
1362 } |
1373 } |
1363 |
1374 |
1364 // Start fetching content before changing. |
1375 // Start fetching content before changing. |
1365 collectionContentWidget->getModel().openItem(itemId); |
1376 VideoSortFilterProxyModel &model = collectionContentWidget->getModel(); |
|
1377 model.openItem(itemId); |
1366 |
1378 |
1367 // deactivat current widget. |
1379 // deactivat current widget. |
1368 mCurrentList->deactivate(); |
1380 mCurrentList->deactivate(); |
1369 |
1381 |
1370 // activate video collection content widget and set it as current list. |
1382 // activate video collection content widget and set it as current list. |
1371 mCurrentList = collectionContentWidget; |
1383 mCurrentList = collectionContentWidget; |
1372 mCurrentList->activate(level); |
1384 mCurrentList->activate(level); |
1373 |
1385 |
1374 updateSubLabel(); |
1386 updateSubLabel(); |
1375 |
1387 |
1376 // setup correct sorting, collection content contains always a list of videos so we use |
1388 model.invalidate(); |
1377 // ELevelVideos as target for sorting |
|
1378 VideoCollectionViewUtils::sortModel(&mCurrentList->getModel(), false, VideoCollectionCommon::ELevelVideos); |
|
1379 mCurrentList->getModel().invalidate(); |
|
1380 |
1389 |
1381 // update hint widget for correct content |
1390 // update hint widget for correct content |
|
1391 mModelReady = model.rowCount() > 0; |
1382 setHintLevel(VideoHintWidget::Collection); |
1392 setHintLevel(VideoHintWidget::Collection); |
1383 showHint(); |
|
1384 |
1393 |
1385 // update toolbar for albums, default categories don't have one. |
1394 // update toolbar for albums, default categories don't have one. |
1386 if(level == VideoCollectionCommon::ELevelAlbum && |
1395 if(level == VideoCollectionCommon::ELevelAlbum && |
1387 mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections)) |
1396 mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections)) |
1388 { |
1397 { |
1402 mToolbarActions[ETBActionCollections]->setChecked(true); |
1411 mToolbarActions[ETBActionCollections]->setChecked(true); |
1403 } |
1412 } |
1404 } |
1413 } |
1405 // restore animations for collection content widget |
1414 // restore animations for collection content widget |
1406 collectionContentWidget->setEnabledAnimations(animationState); |
1415 collectionContentWidget->setEnabledAnimations(animationState); |
1407 |
|
1408 } |
1416 } |
1409 |
1417 |
1410 // ------------------------------------------------------------------------------------------------- |
1418 // ------------------------------------------------------------------------------------------------- |
1411 // objectReadySlot |
1419 // objectReadySlot |
1412 // ------------------------------------------------------------------------------------------------- |
1420 // ------------------------------------------------------------------------------------------------- |