videocollection/videocollectionview/src/videolistview.cpp
changeset 52 e3cecb93e76a
parent 47 45e72b57a2fd
child 59 a76e86df7ccd
equal deleted inserted replaced
47:45e72b57a2fd 52:e3cecb93e76a
    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: 113 %
    18 // Version : %version: 113.1.5 %
    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>
    30 #include <hbaction.h>
    30 #include <hbaction.h>
    31 #include <hbmenu.h>
    31 #include <hbmenu.h>
    32 #include <hbgroupbox.h>
    32 #include <hbgroupbox.h>
    33 #include <hbpushbutton.h>
    33 #include <hbpushbutton.h>
    34 #include <hbinputdialog.h>
    34 #include <hbinputdialog.h>
       
    35 #include <hbparameterlengthlimiter.h>
       
    36 #include <hbtoolbarextension.h>
    35 #include <vcxmyvideosdefs.h>
    37 #include <vcxmyvideosdefs.h>
    36 
    38 
    37 #include "videoservices.h"
    39 #include "videoservices.h"
    38 #include "videolistselectiondialog.h"
    40 #include "videolistselectiondialog.h"
    39 #include "videocollectionviewutils.h"
    41 #include "videocollectionviewutils.h"
    43 #include "videocollectioncommon.h"
    45 #include "videocollectioncommon.h"
    44 #include "videocollectionwrapper.h"
    46 #include "videocollectionwrapper.h"
    45 #include "videosortfilterproxymodel.h"
    47 #include "videosortfilterproxymodel.h"
    46 #include "videocollectionuiloader.h"
    48 #include "videocollectionuiloader.h"
    47 #include "mpxhbvideocommondefs.h"
    49 #include "mpxhbvideocommondefs.h"
       
    50 #include "videooperatorservice.h"
       
    51 #include "videocollectioncenrepdefs.h"
    48 #include "videocollectiontrace.h"
    52 #include "videocollectiontrace.h"
    49 
    53 
    50 // Object names.
    54 // Object names.
    51 const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU      = "vc::ListViewOptionsMenu";
    55 const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU      = "vc::ListViewOptionsMenu";
       
    56 const char* const LIST_VIEW_OBJECT_NAME_TOOLBAR_EXTENSION = "vc::ListViewToolbarExtension";
    52 
    57 
    53 // ---------------------------------------------------------------------------
    58 // ---------------------------------------------------------------------------
    54 // Constructor
    59 // Constructor
    55 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    56 //
    61 //
    64     , mHintLevel( VideoHintWidget::AllVideos )
    69     , mHintLevel( VideoHintWidget::AllVideos )
    65     , mVideoServices( 0 )
    70     , mVideoServices( 0 )
    66     , mCurrentList( 0 )
    71     , mCurrentList( 0 )
    67     , mToolbarViewsActionGroup( 0 )
    72     , mToolbarViewsActionGroup( 0 )
    68     , mToolbarCollectionActionGroup( 0 )
    73     , mToolbarCollectionActionGroup( 0 )
       
    74     , mToolbarServiceExtension( 0 )
    69 {
    75 {
    70 	FUNC_LOG;
    76 	FUNC_LOG;
    71 }
    77 }
    72 
    78 
    73 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    81     toolBar()->clearActions();
    87     toolBar()->clearActions();
    82     
    88     
    83     mToolbarActions.clear();
    89     mToolbarActions.clear();
    84     mSortingRoles.clear();
    90     mSortingRoles.clear();
    85 
    91 
       
    92     delete mToolbarServiceExtension;
       
    93     mToolbarServiceExtension = 0;
       
    94     
    86     if(mVideoServices)
    95     if(mVideoServices)
    87     {
    96     {
    88     	mVideoServices->decreaseReferenceCount();
    97     	mVideoServices->decreaseReferenceCount();
    89     	mVideoServices = 0;
    98     	mVideoServices = 0;
    90     }
    99     }
       
   100     
       
   101     QList<VideoOperatorService *>::const_iterator iter = mVideoOperatorServices.constBegin();
       
   102     while(iter != mVideoOperatorServices.constEnd())
       
   103     {
       
   104         delete *iter;
       
   105         iter++;
       
   106     }
       
   107     mVideoOperatorServices.clear();
    91 }
   108 }
    92 
   109 
    93 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
    94 // initializeView()
   111 // initializeView()
    95 // ---------------------------------------------------------------------------
   112 // ---------------------------------------------------------------------------
   145     QList<VideoCollectionUiLoaderParam> params;
   162     QList<VideoCollectionUiLoaderParam> params;
   146     
   163     
   147     params.append(VideoCollectionUiLoaderParam(
   164     params.append(VideoCollectionUiLoaderParam(
   148         DOCML_NAME_VC_VIDEOLISTWIDGET,
   165         DOCML_NAME_VC_VIDEOLISTWIDGET,
   149         DOCML_VIDEOCOLLECTIONVIEW_FILE,
   166         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   167         DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
   150         true,
   168         true,
   151         videoListPhase));
   169         videoListPhase));
   152     
   170     
   153     params.append(VideoCollectionUiLoaderParam(
   171     params.append(VideoCollectionUiLoaderParam(
   154         DOCML_NAME_VC_COLLECTIONWIDGET,
   172         DOCML_NAME_VC_COLLECTIONWIDGET,
   255     {
   273     {
   256         mCurrentList = mUiLoader->findWidget<VideoListWidget>(
   274         mCurrentList = mUiLoader->findWidget<VideoListWidget>(
   257                 DOCML_NAME_VC_COLLECTIONWIDGET );
   275                 DOCML_NAME_VC_COLLECTIONWIDGET );
   258     }
   276     }
   259 
   277 
   260 
       
   261     
       
   262     return 0;
   278     return 0;
   263 }
   279 }
   264 
   280 
   265 // ---------------------------------------------------------------------------
   281 // ---------------------------------------------------------------------------
   266 // titleReadySlot()
   282 // titleReadySlot()
   332             !connect(
   348             !connect(
   333                 mCurrentList->getModel()->sourceModel(), SIGNAL(modelChanged()),
   349                 mCurrentList->getModel()->sourceModel(), SIGNAL(modelChanged()),
   334                 this, SLOT(layoutChangedSlot())) ||
   350                 this, SLOT(layoutChangedSlot())) ||
   335             !connect(
   351             !connect(
   336                 mCurrentList->getModel()->sourceModel(), SIGNAL(modelReady()),
   352                 mCurrentList->getModel()->sourceModel(), SIGNAL(modelReady()),
   337                 this, SLOT(modelReadySlot())))
   353                 this, SLOT(modelReadySlot())) ||
       
   354             !connect(
       
   355                 mCurrentList->getModel()->sourceModel(), SIGNAL(albumListReady()),
       
   356                 this, SLOT(albumListReadySlot())))
   338         {
   357         {
   339             ERROR(-1, "VideoListView::activateView() failed to connect signals.");
   358             ERROR(-1, "VideoListView::activateView() failed to connect signals.");
   340             // deactivate view so we get rid of dangling connections.
   359             // deactivate view so we get rid of dangling connections.
   341             deactivateView();
   360             deactivateView();
   342             err = -1;
   361             err = -1;
   370 //
   389 //
   371 void VideoListView::modelReadySlot()
   390 void VideoListView::modelReadySlot()
   372 {
   391 {
   373 	FUNC_LOG;
   392 	FUNC_LOG;
   374 	
   393 	
   375 	// if mModelReady is false, then it means that this is the first time modelReady
   394 	// check that current list is all videos or collection content.
   376 	// signal fires. Signaling that view is ready.
   395 	VideoCollectionCommon::TCollectionLevels level = mCurrentList->getLevel();
   377 	if(!mViewReady)
   396 	if(level != VideoCollectionCommon::ELevelCategory)
   378 	{
   397 	{
   379 	    mViewReady = true;
   398 	    modelReady();
   380 	    emit viewReady();
       
   381 	}
   399 	}
   382 	
   400 }
   383     mModelReady = true;
   401 
   384     
   402 // ---------------------------------------------------------------------------
   385     // since the reset signal arrives after
   403 // albumListReadySlot
   386     // layout changed, need to make sure that
   404 // ---------------------------------------------------------------------------
   387     // view is updated in case needed
   405 //
   388     layoutChangedSlot();
   406 void VideoListView::albumListReadySlot()
       
   407 {
       
   408     FUNC_LOG;
       
   409     
       
   410     // check that current list is category list.
       
   411     VideoCollectionCommon::TCollectionLevels level = mCurrentList->getLevel();
       
   412     if(level == VideoCollectionCommon::ELevelCategory)
       
   413     {
       
   414         modelReady();
       
   415     }
   389 }
   416 }
   390 
   417 
   391 // ---------------------------------------------------------------------------
   418 // ---------------------------------------------------------------------------
   392 // layoutChangedSlot
   419 // layoutChangedSlot
   393 // ---------------------------------------------------------------------------
   420 // ---------------------------------------------------------------------------
   455 {
   482 {
   456 	FUNC_LOG;
   483 	FUNC_LOG;
   457 }
   484 }
   458 
   485 
   459 // ---------------------------------------------------------------------------
   486 // ---------------------------------------------------------------------------
       
   487 // modelReady()
       
   488 // ---------------------------------------------------------------------------
       
   489 //
       
   490 void VideoListView::modelReady()
       
   491 {
       
   492     FUNC_LOG;
       
   493 
       
   494     // if mViewReady is false, then it means that this is the first time 
       
   495     // modelReady or albumListReady signal fires. Signaling that view is ready.
       
   496     if(!mViewReady)
       
   497     {
       
   498         mViewReady = true;
       
   499         emit viewReady();
       
   500     }
       
   501 
       
   502     mModelReady = true;
       
   503     
       
   504     // since the reset signal arrives after
       
   505     // layout changed, need to make sure that
       
   506     // view is updated in case needed
       
   507     layoutChangedSlot();
       
   508 }
       
   509 
       
   510 // ---------------------------------------------------------------------------
   460 // cleanup()
   511 // cleanup()
   461 // ---------------------------------------------------------------------------
   512 // ---------------------------------------------------------------------------
   462 //
   513 //
   463 void VideoListView::cleanup()
   514 void VideoListView::cleanup()
   464 {
   515 {
   498         mToolbarActions[ETBActionCollections] = createAction("qtg_mono_video_collection",
   549         mToolbarActions[ETBActionCollections] = createAction("qtg_mono_video_collection",
   499                 mToolbarViewsActionGroup, SLOT(openCollectionViewSlot()));
   550                 mToolbarViewsActionGroup, SLOT(openCollectionViewSlot()));
   500 
   551 
   501         if (!mVideoServices)
   552         if (!mVideoServices)
   502         {
   553         {
   503 			// Services tab
   554 			// Create services button or toolbar extension depending how many operator 
   504 			mToolbarActions[ETBActionServices] = createAction("qtg_mono_ovistore",
   555             // services are configured.
   505 					mToolbarViewsActionGroup, SLOT(openServicesViewSlot()));
   556             createOperatorServicesToolbar();
       
   557 			
   506 			// Add Videos tab
   558 			// Add Videos tab
   507 			mToolbarActions[ETBActionAddVideos] = 
   559 			mToolbarActions[ETBActionAddVideos] = 
   508 			        createAction("qtg_mono_add_to_video_collection",
   560 			        createAction("qtg_mono_add_to_video_collection",
   509 					mToolbarCollectionActionGroup, SLOT(addVideosToCollectionSlot()));
   561 					mToolbarCollectionActionGroup, SLOT(addVideosToCollectionSlot()));
   510 
   562 
   517         HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
   569         HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
   518 
   570 
   519         if(   !bar
   571         if(   !bar
   520 		   || !mToolbarActions[ETBActionAllVideos]
   572 		   || !mToolbarActions[ETBActionAllVideos]
   521            || !mToolbarActions[ETBActionCollections]
   573            || !mToolbarActions[ETBActionCollections]
   522            || ( !mVideoServices && (!mToolbarActions[ETBActionServices] 
   574            || ( !mVideoServices && (!mToolbarActions[ETBActionAddVideos] 
   523               || !mToolbarActions[ETBActionAddVideos]
   575                                  || !mToolbarActions[ETBActionRemoveVideos])))
   524               || !mToolbarActions[ETBActionRemoveVideos])))
       
   525         {
   576         {
   526             ERROR(-1, "VideoListView::createToolbar() failed to create all actions or the toolbar.");
   577             ERROR(-1, "VideoListView::createToolbar() failed to create all actions or the toolbar.");
   527         	delete mToolbarActions[ETBActionAllVideos];
   578         	delete mToolbarActions[ETBActionAllVideos];
   528             delete mToolbarActions[ETBActionCollections];
   579             delete mToolbarActions[ETBActionCollections];
   529             delete mToolbarActions[ETBActionServices];
       
   530             delete mToolbarActions[ETBActionAddVideos];
   580             delete mToolbarActions[ETBActionAddVideos];
   531             delete mToolbarActions[ETBActionRemoveVideos];
   581             delete mToolbarActions[ETBActionRemoveVideos];
   532         	return -1;
   582         	return -1;
   533         }
   583         }
   534 
   584 
   535         // Collection view actions are not checkable
   585         // Collection view actions are not checkable
   536         mToolbarActions[ETBActionAllVideos]->setCheckable(true);
   586         mToolbarActions[ETBActionAllVideos]->setCheckable(true);
   537         mToolbarActions[ETBActionCollections]->setCheckable(true);
   587         mToolbarActions[ETBActionCollections]->setCheckable(true);
   538 
   588 
   539         if (!mVideoServices)
   589         if(!mVideoServices && mToolbarActions[ETBActionServices])
   540         {
   590         {
   541         	mToolbarActions[ETBActionServices]->setCheckable(false);
   591         	mToolbarActions[ETBActionServices]->setCheckable(false);
   542         }
   592         }
   543         VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
   593         VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
   544         if(mCurrentList)
   594         if(mCurrentList)
   557         }
   607         }
   558         else if(level == VideoCollectionCommon::ELevelAlbum) 
   608         else if(level == VideoCollectionCommon::ELevelAlbum) 
   559         {
   609         {
   560             bar->addActions(mToolbarCollectionActionGroup->actions());
   610             bar->addActions(mToolbarCollectionActionGroup->actions());
   561         }
   611         }
       
   612 
       
   613         if(mToolbarServiceExtension && (level == VideoCollectionCommon::ELevelCategory 
       
   614            || level == VideoCollectionCommon::ELevelVideos))
       
   615         {
       
   616             HbAction *action = bar->addExtension(mToolbarServiceExtension);
       
   617             HbIcon icon("qtg_mono_video_services");
       
   618             action->setIcon(icon);
       
   619         }
       
   620     }
       
   621 
       
   622     return 0;
       
   623 }
       
   624 
       
   625 // ---------------------------------------------------------------------------
       
   626 // createOperatorServicesToolbar()
       
   627 // ---------------------------------------------------------------------------
       
   628 //
       
   629 void VideoListView::createOperatorServicesToolbar()
       
   630 {
       
   631     FUNC_LOG;
       
   632     if(mVideoOperatorServices.count() > 0)
       
   633     {
       
   634         return;
       
   635     }
       
   636     
       
   637     // Load services.
       
   638     
       
   639     loadOperatorService(KVideoCollectionViewCenrepServiceItem1Title, KVideoCollectionViewCenrepServiceItem1ToolbarIconPath, 
       
   640             KVideoCollectionViewCenrepServiceItem1Url, KVideoCollectionViewCenrepServiceItem1Uid);
       
   641     
       
   642     loadOperatorService(KVideoCollectionViewCenrepServiceItem2Title, KVideoCollectionViewCenrepServiceItem2ToolbarIconPath, 
       
   643             KVideoCollectionViewCenrepServiceItem2Url, KVideoCollectionViewCenrepServiceItem2Uid);
       
   644 
       
   645     loadOperatorService(KVideoCollectionViewCenrepServiceItem3Title, KVideoCollectionViewCenrepServiceItem3ToolbarIconPath, 
       
   646             KVideoCollectionViewCenrepServiceItem3Url, KVideoCollectionViewCenrepServiceItem3Uid);
       
   647 
       
   648     loadOperatorService(KVideoCollectionViewCenrepServiceItem4Title, KVideoCollectionViewCenrepServiceItem4ToolbarIconPath, 
       
   649             KVideoCollectionViewCenrepServiceItem4Url, KVideoCollectionViewCenrepServiceItem4Uid);
       
   650 
       
   651     loadOperatorService(KVideoCollectionViewCenrepServiceItem5Title, KVideoCollectionViewCenrepServiceItem5ToolbarIconPath, 
       
   652             KVideoCollectionViewCenrepServiceItem5Url, KVideoCollectionViewCenrepServiceItem5Uid);
       
   653 
       
   654     loadOperatorService(KVideoCollectionViewCenrepServiceItem6Title, KVideoCollectionViewCenrepServiceItem6ToolbarIconPath, 
       
   655             KVideoCollectionViewCenrepServiceItem6Url, KVideoCollectionViewCenrepServiceItem6Uid);
       
   656     
       
   657     // Create toolbar extension when there's multiple services.
       
   658     if(mVideoOperatorServices.count() > 1 && !mToolbarServiceExtension)
       
   659     {
       
   660         mToolbarServiceExtension = new HbToolBarExtension();
       
   661         mToolbarServiceExtension->setObjectName(LIST_VIEW_OBJECT_NAME_TOOLBAR_EXTENSION);
   562         
   662         
   563     }
   663         QList<VideoOperatorService *>::const_iterator iter = mVideoOperatorServices.constBegin();
   564 
   664         while(iter != mVideoOperatorServices.constEnd())
   565     return 0;
   665         {
       
   666             HbIcon icon((*iter)->iconResource());
       
   667             HbAction *action = mToolbarServiceExtension->addAction(icon, (*iter)->title(), 
       
   668                     (*iter), SLOT(launchService()));
       
   669             action->setObjectName((*iter)->title());
       
   670             iter++;
       
   671         }
       
   672     }
       
   673     
       
   674     // Add toolbar button when there's only one service.
       
   675     if(mVideoOperatorServices.count() == 1)
       
   676     {
       
   677         VideoOperatorService *service = mVideoOperatorServices[0];
       
   678         mToolbarActions[ETBActionServices] = createAction(service->iconResource(),
       
   679                 mToolbarViewsActionGroup, 0 /*do not connect to any slot*/);
       
   680         connect(mToolbarActions[ETBActionServices], SIGNAL(triggered()), service, SLOT(launchService()));
       
   681     }
       
   682 }
       
   683 
       
   684 // ---------------------------------------------------------------------------
       
   685 // loadOperatorService()
       
   686 // ---------------------------------------------------------------------------
       
   687 //
       
   688 void VideoListView::loadOperatorService(int titleKey, int iconKey, int uriKey, int uidKey)
       
   689 {
       
   690     FUNC_LOG;
       
   691     VideoOperatorService *service = new VideoOperatorService();
       
   692     if(service->load(titleKey, iconKey, uriKey, uidKey))
       
   693     {
       
   694         mVideoOperatorServices.append(service);
       
   695     }
       
   696     else
       
   697     {
       
   698         // Load failed, delete service data.
       
   699         delete service;
       
   700     }
   566 }
   701 }
   567 
   702 
   568 // ---------------------------------------------------------------------------
   703 // ---------------------------------------------------------------------------
   569 // createAction()
   704 // createAction()
   570 // ---------------------------------------------------------------------------
   705 // ---------------------------------------------------------------------------
   576     HbAction* action = new HbAction(actionGroup);
   711     HbAction* action = new HbAction(actionGroup);
   577 
   712 
   578     HbIcon hbIcon(icon);
   713     HbIcon hbIcon(icon);
   579     action->setIcon(hbIcon);
   714     action->setIcon(hbIcon);
   580 
   715 
   581     if(!connect(action, SIGNAL(triggered()), this, slot)) {
   716     if(slot)
   582         // actiongroup deletion deletes this also.
   717     {
   583         // return 0 tells that there was a problem in creation to caller.
   718         if(!connect(action, SIGNAL(triggered()), this, slot)) {
   584         delete action;
   719             // actiongroup deletion deletes this also.
   585         return 0;
   720             // return 0 tells that there was a problem in creation to caller.
   586     }
   721             delete action;
   587 
   722             return 0;
       
   723         }
       
   724     }
       
   725     
   588     return action;
   726     return action;
   589 }
   727 }
   590 
   728 
   591 // ---------------------------------------------------------------------------
   729 // ---------------------------------------------------------------------------
   592 // showHint
   730 // showHint
   710 			{
   848 			{
   711 				subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_collections", itemCount));
   849 				subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_collections", itemCount));
   712 			}
   850 			}
   713 			else
   851 			else
   714 			{
   852 			{
   715 				subLabel->setHeading(hbTrId("txt_videos_subtitle_1_l2").arg(mCollectionName).arg(itemCount));
   853 				QString text = HbParameterLengthLimiter(hbTrId("txt_videos_subtitle_1_l2")).arg(mCollectionName).arg(itemCount);
       
   854 				subLabel->setHeading(text);
   716 			}
   855 			}
   717         }
   856         }
   718     }
   857     }
   719 }
   858 }
   720 
   859 
   902         updateSubLabel();
  1041         updateSubLabel();
   903     }
  1042     }
   904 }
  1043 }
   905 
  1044 
   906 // ---------------------------------------------------------------------------
  1045 // ---------------------------------------------------------------------------
   907 // openservicesViewSlot()
  1046 // openOperatorServiceSlot()
   908 // ---------------------------------------------------------------------------
  1047 // ---------------------------------------------------------------------------
   909 //
  1048 //
   910 void VideoListView::openServicesViewSlot()
  1049 void VideoListView::openOperatorServiceSlot()
   911 {
  1050 {
   912 	FUNC_LOG;
  1051 	FUNC_LOG;
   913     debugNotImplementedYet();
  1052     
       
  1053 	if(mVideoOperatorServices.count() > 0)
       
  1054 	{
       
  1055 	    mVideoOperatorServices[0]->launchService();
       
  1056 	}
   914 }
  1057 }
   915 
  1058 
   916 // ---------------------------------------------------------------------------
  1059 // ---------------------------------------------------------------------------
   917 // startSorting()
  1060 // startSorting()
   918 // ---------------------------------------------------------------------------
  1061 // ---------------------------------------------------------------------------
  1300 void VideoListView::collectionOpenedSlot(bool openingCollection,
  1443 void VideoListView::collectionOpenedSlot(bool openingCollection,
  1301     const QString& collection,
  1444     const QString& collection,
  1302     const TMPXItemId &collectionId)
  1445     const TMPXItemId &collectionId)
  1303 {
  1446 {
  1304 	FUNC_LOG;
  1447 	FUNC_LOG;
  1305 
  1448  
  1306     // clear toolbar actions.
  1449     // update / clear collection name
  1307     toolBar()->clearActions();
       
  1308 
       
  1309     VideoListWidget *collectionContentWidget =
       
  1310                 mUiLoader->findWidget<VideoListWidget>(
       
  1311                     DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
       
  1312     
       
  1313     if(!collectionContentWidget)
       
  1314     {
       
  1315         return;
       
  1316     }
       
  1317     // update collection specific information
       
  1318 	mCollectionName = collection;
  1450 	mCollectionName = collection;
  1319 	
  1451 
  1320 	// disable collection content animations during widget change        
       
  1321 	HbAbstractItemView::ItemAnimations animationState = collectionContentWidget->enabledAnimations();
       
  1322 	collectionContentWidget->setEnabledAnimations(HbAbstractItemView::None);
       
  1323 	
       
  1324 	if(openingCollection)
  1452 	if(openingCollection)
  1325     {
  1453     {
  1326         // open album view        
  1454 	    VideoListWidget *collectionContentWidget =
  1327         if (collectionId == TMPXItemId::InvalidId() || mCurrentList == collectionContentWidget)
  1455 	                   mUiLoader->findWidget<VideoListWidget>(
  1328         {
  1456 	                       DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
  1329             // no currentlist or currentlist is already collection content -list 
  1457         // open album view, mCurrentList might be NULL at this point        
  1330             collectionContentWidget->setEnabledAnimations(animationState);
  1458         if (!collectionContentWidget || mCurrentList == collectionContentWidget)
       
  1459         {
       
  1460             // collection widget cannot be loaded or 
       
  1461             // currentlist is already collection content -list            
  1331             return;
  1462             return;
  1332         }
  1463         }
  1333                 
  1464                 
  1334         // get level from the item to be opened only default 
  1465         // get level from the item to be opened only default 
  1335         // or user defined collections can be activated here
  1466         // or user defined collections can be activated here
  1342         {
  1473         {
  1343             level = VideoCollectionCommon::ELevelAlbum; 
  1474             level = VideoCollectionCommon::ELevelAlbum; 
  1344         }
  1475         }
  1345         else 
  1476         else 
  1346         {
  1477         {
  1347             collectionContentWidget->setEnabledAnimations(animationState);
       
  1348             return;
  1478             return;
  1349         }
  1479         }
  1350         
  1480                 
  1351         // Start fetching content before changing.
       
  1352         VideoSortFilterProxyModel *model = collectionContentWidget->getModel();
  1481         VideoSortFilterProxyModel *model = collectionContentWidget->getModel();
  1353         if(!model)
  1482         if(!model)
  1354         {
  1483         {
  1355             // no model for content widget, cannot activate
  1484             // no model for content widget, cannot activate
  1356             collectionContentWidget->setEnabledAnimations(animationState);
       
  1357             return;
  1485             return;
  1358         }
  1486         }
       
  1487         
       
  1488         // disable collection content animations during widget change        
       
  1489         HbAbstractItemView::ItemAnimations animationState = collectionContentWidget->enabledAnimations();
       
  1490         collectionContentWidget->setEnabledAnimations(HbAbstractItemView::None);
       
  1491         
       
  1492         // Start fetching content before changing list widget
  1359         model->openItem(collectionId);
  1493         model->openItem(collectionId);
  1360         
  1494         
  1361         // deactivat current widget.
  1495         // deactivat current widget.
  1362         if(mCurrentList)
  1496         if(mCurrentList)
  1363         {
  1497         {
  1367         // activate video collection content widget and set it as current list.
  1501         // activate video collection content widget and set it as current list.
  1368         mCurrentList = collectionContentWidget;
  1502         mCurrentList = collectionContentWidget;
  1369         mCurrentList->activate(level);
  1503         mCurrentList->activate(level);
  1370 
  1504 
  1371         updateSubLabel();
  1505         updateSubLabel();
  1372 
       
  1373         model->invalidate();
       
  1374         
  1506         
  1375         // update hint widget for correct content
  1507         // update hint widget for correct content
  1376         mModelReady = model->rowCount() > 0;
  1508         mModelReady = model->rowCount() > 0;
  1377         setHintLevel(VideoHintWidget::Collection);
  1509         setHintLevel(VideoHintWidget::Collection);
  1378 
  1510 
  1379         // update toolbar for albums, default categories don't have one.
  1511         // update toolbar for albums, default categories don't have one. Neither does services.
  1380         if(level == VideoCollectionCommon::ELevelAlbum && 
  1512         toolBar()->clearActions();
       
  1513         if(!mVideoServices && level == VideoCollectionCommon::ELevelAlbum && 
  1381            mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections))
  1514            mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections))
  1382         {
  1515         {
  1383             mToolbarActions[ETBActionCollections]->setChecked(false);
  1516             mToolbarActions[ETBActionCollections]->setChecked(false);
  1384             toolBar()->addActions(mToolbarCollectionActionGroup->actions());
  1517             toolBar()->addActions(mToolbarCollectionActionGroup->actions());
  1385         }
  1518             setItemVisible(Hb::ToolBarItem, true);
       
  1519         }
       
  1520         else
       
  1521         {
       
  1522             setItemVisible(Hb::ToolBarItem, false);
       
  1523         }
       
  1524         // restore animations for collection content widget
       
  1525         collectionContentWidget->setEnabledAnimations(animationState);
  1386     }
  1526     }
  1387     else
  1527     else
  1388     {
  1528     {
       
  1529         // clear actions to make sure there is no wrong toolbar in case main 
       
  1530         // toolbar actiongroup actiongroup is missing
       
  1531         toolBar()->clearActions();   
  1389         // open collection view
  1532         // open collection view
  1390         openCollectionViewSlot();
  1533         openCollectionViewSlot();        
  1391         
       
  1392         // update toolbar
  1534         // update toolbar
  1393         if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections))
  1535         if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections))
  1394         {
  1536         {                    
  1395             toolBar()->addActions(mToolbarViewsActionGroup->actions());
  1537             toolBar()->addActions(mToolbarViewsActionGroup->actions());
  1396             mToolbarActions[ETBActionCollections]->setChecked(true);
  1538             mToolbarActions[ETBActionCollections]->setChecked(true);
  1397         }
  1539             setItemVisible(Hb::ToolBarItem, true);
  1398     }
  1540             
  1399 	// restore animations for collection content widget
  1541             if(mToolbarServiceExtension)
  1400 	collectionContentWidget->setEnabledAnimations(animationState);
  1542             {
       
  1543                 HbAction *action = toolBar()->addExtension(mToolbarServiceExtension);
       
  1544                 HbIcon icon("qtg_mono_video_services");
       
  1545                 action->setIcon(icon);
       
  1546             }
       
  1547         }
       
  1548     }	
  1401 	if(!mVideoServices)
  1549 	if(!mVideoServices)
  1402 	{
  1550 	{
  1403 	    // save / clear collection related activity data
  1551 	    // save / clear collection related activity data
  1404 	    VideoCollectionViewUtils::setCollectionActivityData(collectionId, collection);
  1552 	    VideoCollectionViewUtils::setCollectionActivityData(collectionId, collection);
  1405 	}
  1553 	}
  1452         connect(
  1600         connect(
  1453             object, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMainMenuSlot()));
  1601             object, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMainMenuSlot()));
  1454     }
  1602     }
  1455     else if (name.compare(DOCML_NAME_HINT_BUTTON) == 0)
  1603     else if (name.compare(DOCML_NAME_HINT_BUTTON) == 0)
  1456     {
  1604     {
  1457         connect(object, SIGNAL(clicked(bool)), this, SLOT(openServicesViewSlot()));
  1605         connect(object, SIGNAL(clicked(bool)), this, SLOT(openOperatorServiceSlot()));
  1458     }
  1606     }
  1459     else if (name.compare(DOCML_NAME_SORT_BY_DATE) == 0)
  1607     else if (name.compare(DOCML_NAME_SORT_BY_DATE) == 0)
  1460     {
  1608     {
  1461         HbAction *action = qobject_cast<HbAction*>(object);
  1609         HbAction *action = qobject_cast<HbAction*>(object);
  1462         if (action)
  1610         if (action)