videocollection/videocollectionview/src/videolistview.cpp
changeset 63 4707a0db12f6
parent 58 d2b028fd1f7d
child 66 adb51f74b890
equal deleted inserted replaced
58:d2b028fd1f7d 63:4707a0db12f6
    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.1.8 %
    18 // Version : %version: 113.1.13 %
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <qactiongroup.h>
       
    22 #include <hbinstance.h>
    21 #include <hbinstance.h>
    23 #include <hbmainwindow.h>
    22 #include <hbmainwindow.h>
    24 #include <hbmessagebox.h>
       
    25 #include <hbstackedwidget.h>
       
    26 #include <hbstackedlayout.h>
       
    27 #include <hblistwidget.h>
       
    28 #include <hbtoolbar.h>
    23 #include <hbtoolbar.h>
    29 #include <hbaction.h>
    24 #include <hbaction.h>
    30 #include <hbmenu.h>
    25 #include <hbmenu.h>
    31 #include <hbgroupbox.h>
    26 #include <hbgroupbox.h>
    32 #include <hbpushbutton.h>
       
    33 #include <hbinputdialog.h>
       
    34 #include <hbparameterlengthlimiter.h>
    27 #include <hbparameterlengthlimiter.h>
    35 #include <hbtoolbarextension.h>
    28 #include <hbtoolbarextension.h>
       
    29 #include <xqaiwdecl.h>
    36 #include <vcxmyvideosdefs.h>
    30 #include <vcxmyvideosdefs.h>
    37 
    31 
    38 #include "videoservices.h"
    32 #include "videoservices.h"
    39 #include "videolistselectiondialog.h"
       
    40 #include "videocollectionviewutils.h"
    33 #include "videocollectionviewutils.h"
    41 #include "videolistwidget.h"
    34 #include "videolistwidget.h"
    42 #include "videohintwidget.h"
    35 #include "videohintwidget.h"
    43 #include "videolistview.h"
    36 #include "videolistview.h"
       
    37 #include "videolisttoolbar.h"
       
    38 #include "videolistmenu.h"
    44 #include "videocollectioncommon.h"
    39 #include "videocollectioncommon.h"
    45 #include "videocollectionwrapper.h"
    40 #include "videocollectionwrapper.h"
    46 #include "videoproxymodelgeneric.h"
    41 #include "videoproxymodelgeneric.h"
    47 #include "videocollectionuiloader.h"
    42 #include "videocollectionuiloader.h"
    48 #include "mpxhbvideocommondefs.h"
       
    49 #include "videooperatorservice.h"
       
    50 #include "videocollectioncenrepdefs.h"
       
    51 #include "videocollectiontrace.h"
    43 #include "videocollectiontrace.h"
    52 
    44 
    53 // Object names.
    45 // Object names.
    54 const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU      = "vc::ListViewOptionsMenu";
    46 const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU      = "vc::ListViewOptionsMenu";
    55 const char* const LIST_VIEW_OBJECT_NAME_TOOLBAR_EXTENSION = "vc::ListViewToolbarExtension";
       
    56 
    47 
    57 // ---------------------------------------------------------------------------
    48 // ---------------------------------------------------------------------------
    58 // Constructor
    49 // Constructor
    59 // ---------------------------------------------------------------------------
    50 // ---------------------------------------------------------------------------
    60 //
    51 //
    61 VideoListView::VideoListView( VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent ) 
    52 VideoListView::VideoListView( VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent ) 
    62     : HbView( parent )
    53     : HbView(parent)
    63     , mUiUtils( VideoCollectionViewUtils::instance() )
    54     , mUiUtils(VideoCollectionViewUtils::instance())
    64     , mWrapper( VideoCollectionWrapper::instance() )
    55     , mWrapper(VideoCollectionWrapper::instance())
    65     , mUiLoader( uiLoader )
    56     , mUiLoader(uiLoader)
    66     , mModelReady( false )
    57     , mToolbar(0)
    67     , mViewReady( false )
    58     , mMenu(0)
    68     , mHintLevel( VideoHintWidget::AllVideos )
    59     , mModelReady(false)
    69     , mVideoServices( 0 )
    60     , mViewReady(false)
    70     , mCurrentList( 0 )
    61     , mHintLevel(VideoHintWidget::AllVideos)
    71     , mToolbarViewsActionGroup( 0 )
    62     , mVideoServices(0)
    72     , mToolbarCollectionActionGroup( 0 )
    63     , mCurrentList(0)
    73     , mToolbarServiceExtension( 0 )
       
    74 {
    64 {
    75 	FUNC_LOG;
    65 	FUNC_LOG;
    76 }
    66 }
    77 
    67 
    78 // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
    82 VideoListView::~VideoListView()
    72 VideoListView::~VideoListView()
    83 {
    73 {
    84 	FUNC_LOG;
    74 	FUNC_LOG;
    85     
    75     
    86     toolBar()->clearActions();
    76     toolBar()->clearActions();
    87     
       
    88     mToolbarActions.clear();
       
    89     mSortingRoles.clear();
       
    90 
       
    91     delete mToolbarServiceExtension;
       
    92     mToolbarServiceExtension = 0;
       
    93     
    77     
    94     if(mVideoServices)
    78     if(mVideoServices)
    95     {
    79     {
    96     	mVideoServices->decreaseReferenceCount();
    80     	mVideoServices->decreaseReferenceCount();
    97     	mVideoServices = 0;
    81     	mVideoServices = 0;
    98     }
    82     }
    99     
       
   100     QList<VideoOperatorService *>::const_iterator iter = mVideoOperatorServices.constBegin();
       
   101     while(iter != mVideoOperatorServices.constEnd())
       
   102     {
       
   103         delete *iter;
       
   104         iter++;
       
   105     }
       
   106     mVideoOperatorServices.clear();
       
   107 }
    83 }
   108 
    84 
   109 // ---------------------------------------------------------------------------
    85 // ---------------------------------------------------------------------------
   110 // initializeView()
    86 // initializeView()
   111 // ---------------------------------------------------------------------------
    87 // ---------------------------------------------------------------------------
   177     params.append(VideoCollectionUiLoaderParam(
   153     params.append(VideoCollectionUiLoaderParam(
   178         DOCML_NAME_VC_COLLECTIONCONTENTWIDGET,
   154         DOCML_NAME_VC_COLLECTIONCONTENTWIDGET,
   179         DOCML_VIDEOCOLLECTIONVIEW_FILE,
   155         DOCML_VIDEOCOLLECTIONVIEW_FILE,
   180         DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
   156         DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
   181         true,
   157         true,
   182         collectionContentListPhase)); 
   158         collectionContentListPhase));
   183     
   159     
   184     params.append(VideoCollectionUiLoaderParam(
       
   185         DOCML_NAME_OPTIONS_MENU,
       
   186         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   187         true,
       
   188         VideoCollectionUiLoaderParam::LoadPhasePrimary));
       
   189     params.append(VideoCollectionUiLoaderParam(
       
   190         DOCML_NAME_ADD_TO_COLLECTION,
       
   191         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   192         false,
       
   193         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   194     params.append(VideoCollectionUiLoaderParam(
       
   195         DOCML_NAME_CREATE_COLLECTION,
       
   196         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   197         false,
       
   198         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   199     params.append(VideoCollectionUiLoaderParam(
       
   200         DOCML_NAME_DELETE_MULTIPLE,
       
   201         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   202         false,
       
   203         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   204     params.append(VideoCollectionUiLoaderParam(
   160     params.append(VideoCollectionUiLoaderParam(
   205         DOCML_NAME_VC_HEADINGBANNER,
   161         DOCML_NAME_VC_HEADINGBANNER,
   206         DOCML_VIDEOCOLLECTIONVIEW_FILE,
   162         DOCML_VIDEOCOLLECTIONVIEW_FILE,
   207         true,
   163         true,
   208         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   164         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   209     params.append(VideoCollectionUiLoaderParam(
       
   210         DOCML_NAME_SORT_MENU,
       
   211         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   212         true,
       
   213         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   214     params.append(VideoCollectionUiLoaderParam(
       
   215         DOCML_NAME_SORT_BY_DATE,
       
   216         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   217         false,
       
   218         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   219     params.append(VideoCollectionUiLoaderParam(
       
   220         DOCML_NAME_SORT_BY_NAME,
       
   221         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   222         false,
       
   223         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   224     params.append(VideoCollectionUiLoaderParam(
       
   225         DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS,
       
   226         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   227         false,
       
   228         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   229     params.append(VideoCollectionUiLoaderParam(
       
   230         DOCML_NAME_SORT_BY_SIZE,
       
   231         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   232         false,
       
   233         VideoCollectionUiLoaderParam::LoadPhaseSecondary));       
       
   234     params.append(VideoCollectionUiLoaderParam(
   165     params.append(VideoCollectionUiLoaderParam(
   235         DOCML_NAME_DIALOG,
   166         DOCML_NAME_DIALOG,
   236         DOCML_VIDEOSELECTIONDIALOG_FILE,
   167         DOCML_VIDEOSELECTIONDIALOG_FILE,
   237         true,
   168         true,
   238         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   169         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   255         true,
   186         true,
   256         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   187         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   257     mUiLoader->addData(params,
   188     mUiLoader->addData(params,
   258         this,
   189         this,
   259         SLOT(objectReadySlot(QObject*, const QString&)));
   190         SLOT(objectReadySlot(QObject*, const QString&)));
       
   191     params.clear();
       
   192     
       
   193     if(!mMenu)
       
   194     {
       
   195         mMenu = new VideoListMenu(mUiLoader, this);
       
   196         int err = mMenu->initializeMenu();
       
   197         if(err)
       
   198         {
       
   199             cleanup();
       
   200             return -1;
       
   201         }
       
   202     }
       
   203     
   260     mUiLoader->loadPhase(VideoCollectionUiLoaderParam::LoadPhasePrimary);
   204     mUiLoader->loadPhase(VideoCollectionUiLoaderParam::LoadPhasePrimary);
   261     params.clear();
       
   262     
   205     
   263     // fetch current list right away for main views
   206     // fetch current list right away for main views
   264     // for default and user defined collections, currentList 
   207     // for default and user defined collections, currentList 
   265     // will be setted during activation
   208     // will be setted during activation
   266     if(videoListPhase == VideoCollectionUiLoaderParam::LoadPhasePrimary)
   209     if(videoListPhase == VideoCollectionUiLoaderParam::LoadPhasePrimary)
   481 {
   424 {
   482 	FUNC_LOG;
   425 	FUNC_LOG;
   483 }
   426 }
   484 
   427 
   485 // ---------------------------------------------------------------------------
   428 // ---------------------------------------------------------------------------
       
   429 // getCurrentList()
       
   430 // ---------------------------------------------------------------------------
       
   431 //
       
   432 VideoListWidget* VideoListView::getCurrentList()
       
   433 {
       
   434     FUNC_LOG;
       
   435     
       
   436     return mCurrentList;
       
   437 }
       
   438 
       
   439 // ---------------------------------------------------------------------------
   486 // modelReady()
   440 // modelReady()
   487 // ---------------------------------------------------------------------------
   441 // ---------------------------------------------------------------------------
   488 //
   442 //
   489 void VideoListView::modelReady()
   443 void VideoListView::modelReady()
   490 {
   444 {
   511 // ---------------------------------------------------------------------------
   465 // ---------------------------------------------------------------------------
   512 //
   466 //
   513 void VideoListView::cleanup()
   467 void VideoListView::cleanup()
   514 {
   468 {
   515 	FUNC_LOG;
   469 	FUNC_LOG;
   516     delete mToolbarViewsActionGroup;
   470 	
   517     mToolbarViewsActionGroup = 0;
   471 	delete mToolbar;
   518 
   472 	mToolbar = 0;
   519     delete mToolbarCollectionActionGroup;
   473 	
   520     mToolbarCollectionActionGroup = 0;
       
   521     
       
   522     mCurrentList = 0;    
   474     mCurrentList = 0;    
   523 }
   475 }
   524 
   476 
   525 // ---------------------------------------------------------------------------
   477 // ---------------------------------------------------------------------------
   526 // createToolbar()
   478 // createToolbar()
   527 // Creates toolbar, toolbar actions and toolbar icons
   479 // Creates toolbar
   528 // ---------------------------------------------------------------------------
   480 // ---------------------------------------------------------------------------
   529 //
   481 //
   530 int VideoListView::createToolbar()
   482 int VideoListView::createToolbar()
   531 {
   483 {
   532 	FUNC_LOG;
   484 	FUNC_LOG;
   533     
   485     
   534 	// Create actiongroup and add all actions to it. This ensures that only one is
   486 	// creates VideoListToolbar and HbToolbar
   535     // active at certain moment.
   487     if(!mToolbar)
   536     if(!mToolbarViewsActionGroup && !mToolbarCollectionActionGroup)
   488     {
   537     {
   489     	mToolbar = new VideoListToolbar(mUiLoader, this);
   538     	mToolbarViewsActionGroup = new QActionGroup(this);
       
   539         mToolbarCollectionActionGroup = new QActionGroup(this);
       
   540 
       
   541         // create toolbar item actions
       
   542 
       
   543         // All Videos tab
       
   544         mToolbarActions[ETBActionAllVideos] = createAction("qtg_mono_video",
       
   545                 mToolbarViewsActionGroup, SLOT(openAllVideosViewSlot()));
       
   546 
       
   547         // Collections tab
       
   548         mToolbarActions[ETBActionCollections] = createAction("qtg_mono_video_collection",
       
   549                 mToolbarViewsActionGroup, SLOT(openCollectionViewSlot()));
       
   550 
       
   551         if (!mVideoServices)
       
   552         {
       
   553 			// Create services button or toolbar extension depending how many operator 
       
   554             // services are configured.
       
   555             createOperatorServicesToolbar();
       
   556 			
       
   557 			// Add Videos tab
       
   558 			mToolbarActions[ETBActionAddVideos] = 
       
   559 			        createAction("qtg_mono_add_to_video_collection",
       
   560 					mToolbarCollectionActionGroup, SLOT(addVideosToCollectionSlot()));
       
   561 
       
   562 			// Remove Videos tab
       
   563 			mToolbarActions[ETBActionRemoveVideos] = 
       
   564 			        createAction("qtg_mono_remove_from_video_collection",
       
   565 					mToolbarCollectionActionGroup, SLOT(removeVideosFromCollectionSlot()));
       
   566         }
       
   567 
   490 
   568         HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
   491         HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
   569 
   492         
   570         if(   !bar
   493         if(!bar || !mToolbar ||
   571 		   || !mToolbarActions[ETBActionAllVideos]
   494            !connect(
   572            || !mToolbarActions[ETBActionCollections]
   495                 mToolbar, SIGNAL(actionsChanged(QList<QAction*>)), 
   573            || ( !mVideoServices && (!mToolbarActions[ETBActionAddVideos] 
   496                 this, SLOT(toolbarActionsChanged(QList<QAction*>))) ||
   574                                  || !mToolbarActions[ETBActionRemoveVideos])))
   497            !connect(
   575         {
   498                 mToolbar, SIGNAL(toolbarExtensionChanged(HbToolBarExtension*)), 
   576             ERROR(-1, "VideoListView::createToolbar() failed to create all actions or the toolbar.");
   499                 this, SLOT(toolbarExtensionChanged(HbToolBarExtension*))) ||
   577         	delete mToolbarActions[ETBActionAllVideos];
   500            !connect(
   578             delete mToolbarActions[ETBActionCollections];
   501                 mToolbar, SIGNAL(allVideosActionTriggered()), 
   579             delete mToolbarActions[ETBActionAddVideos];
   502                 this, SLOT(openAllVideosViewSlot())) ||
   580             delete mToolbarActions[ETBActionRemoveVideos];
   503            !connect(
   581         	return -1;
   504                 mToolbar, SIGNAL(collectionViewActionTriggered()),
   582         }
   505                 this, SLOT(openCollectionViewSlot())))
   583 
   506         {
   584         // Collection view actions are not checkable
   507             ERROR(-1, "VideoListView::createToolbar() failed to create all the toolbar.");
   585         mToolbarActions[ETBActionAllVideos]->setCheckable(true);
   508             delete mToolbar;
   586         mToolbarActions[ETBActionCollections]->setCheckable(true);
   509             mToolbar = 0;
   587 
   510             return -1;
   588         if(!mVideoServices && mToolbarActions[ETBActionServices])
   511         }
   589         {
   512         
   590         	mToolbarActions[ETBActionServices]->setCheckable(false);
   513         mToolbar->initialize();
   591         }
   514         mToolbar->viewStateChanged(mCurrentList->getLevel(), true, false);
   592         VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
   515         
   593         if(mCurrentList)
   516         // make sure that the hint widget's button is connected, and connected only once.
   594         {
   517         QObject *hintButton =
   595             level = mCurrentList->getLevel();
   518             mUiLoader->findObject<QObject>(
   596         }
   519                 DOCML_NAME_HINT_BUTTON, false);
   597         if(level == VideoCollectionCommon::ELevelCategory)
   520         
   598         {
   521         if(hintButton)
   599             mToolbarActions[ETBActionCollections]->setChecked(true);
   522         {
   600             bar->addActions(mToolbarViewsActionGroup->actions());
   523             connect(hintButton, SIGNAL(clicked(bool)), 
   601         }
   524                 mToolbar, SLOT(openOperatorServiceSlot()), 
   602         else if(level == VideoCollectionCommon::ELevelVideos )
   525                 Qt::UniqueConnection);
   603         {
   526         }
   604             mToolbarActions[ETBActionAllVideos]->setChecked(true);
   527         // note that if hintButton is not found, then it's connected in objectReadySlot.
   605             bar->addActions(mToolbarViewsActionGroup->actions());
       
   606         }
       
   607         else if(level == VideoCollectionCommon::ELevelAlbum) 
       
   608         {
       
   609             bar->addActions(mToolbarCollectionActionGroup->actions());
       
   610             if(!mModelReady)
       
   611             {
       
   612                 // if model not ready yet toolbuttons should not be
       
   613                 // visible, after model responds visibility will be updated
       
   614                 mToolbarActions[ETBActionAddVideos]->setVisible(false);
       
   615                 mToolbarActions[ETBActionRemoveVideos]->setVisible(false);
       
   616             }
       
   617         }
       
   618 
       
   619         if(mToolbarServiceExtension && (level == VideoCollectionCommon::ELevelCategory 
       
   620            || level == VideoCollectionCommon::ELevelVideos))
       
   621         {
       
   622             HbAction *action = bar->addExtension(mToolbarServiceExtension);
       
   623             HbIcon icon("qtg_mono_video_services");
       
   624             action->setIcon(icon);
       
   625         }
       
   626     }
   528     }
   627 
   529 
   628     return 0;
   530     return 0;
   629 }
       
   630 
       
   631 // ---------------------------------------------------------------------------
       
   632 // createOperatorServicesToolbar()
       
   633 // ---------------------------------------------------------------------------
       
   634 //
       
   635 void VideoListView::createOperatorServicesToolbar()
       
   636 {
       
   637     FUNC_LOG;
       
   638     if(mVideoOperatorServices.count() > 0)
       
   639     {
       
   640         return;
       
   641     }
       
   642     
       
   643     // Load services.
       
   644     
       
   645     loadOperatorService(KVideoCollectionViewCenrepServiceItem1Title, KVideoCollectionViewCenrepServiceItem1ToolbarIconPath, 
       
   646             KVideoCollectionViewCenrepServiceItem1Url, KVideoCollectionViewCenrepServiceItem1Uid);
       
   647     
       
   648     loadOperatorService(KVideoCollectionViewCenrepServiceItem2Title, KVideoCollectionViewCenrepServiceItem2ToolbarIconPath, 
       
   649             KVideoCollectionViewCenrepServiceItem2Url, KVideoCollectionViewCenrepServiceItem2Uid);
       
   650 
       
   651     loadOperatorService(KVideoCollectionViewCenrepServiceItem3Title, KVideoCollectionViewCenrepServiceItem3ToolbarIconPath, 
       
   652             KVideoCollectionViewCenrepServiceItem3Url, KVideoCollectionViewCenrepServiceItem3Uid);
       
   653 
       
   654     loadOperatorService(KVideoCollectionViewCenrepServiceItem4Title, KVideoCollectionViewCenrepServiceItem4ToolbarIconPath, 
       
   655             KVideoCollectionViewCenrepServiceItem4Url, KVideoCollectionViewCenrepServiceItem4Uid);
       
   656 
       
   657     loadOperatorService(KVideoCollectionViewCenrepServiceItem5Title, KVideoCollectionViewCenrepServiceItem5ToolbarIconPath, 
       
   658             KVideoCollectionViewCenrepServiceItem5Url, KVideoCollectionViewCenrepServiceItem5Uid);
       
   659 
       
   660     loadOperatorService(KVideoCollectionViewCenrepServiceItem6Title, KVideoCollectionViewCenrepServiceItem6ToolbarIconPath, 
       
   661             KVideoCollectionViewCenrepServiceItem6Url, KVideoCollectionViewCenrepServiceItem6Uid);
       
   662     
       
   663     // Create toolbar extension when there's multiple services.
       
   664     if(mVideoOperatorServices.count() > 1 && !mToolbarServiceExtension)
       
   665     {
       
   666         mToolbarServiceExtension = new HbToolBarExtension();
       
   667         mToolbarServiceExtension->setObjectName(LIST_VIEW_OBJECT_NAME_TOOLBAR_EXTENSION);
       
   668         
       
   669         QList<VideoOperatorService *>::const_iterator iter = mVideoOperatorServices.constBegin();
       
   670         while(iter != mVideoOperatorServices.constEnd())
       
   671         {
       
   672             HbIcon icon((*iter)->iconResource());
       
   673             HbAction *action = mToolbarServiceExtension->addAction(icon, (*iter)->title(), 
       
   674                     (*iter), SLOT(launchService()));
       
   675             action->setObjectName((*iter)->title());
       
   676             iter++;
       
   677         }
       
   678     }
       
   679     
       
   680     // Add toolbar button when there's only one service.
       
   681     if(mVideoOperatorServices.count() == 1)
       
   682     {
       
   683         VideoOperatorService *service = mVideoOperatorServices[0];
       
   684         mToolbarActions[ETBActionServices] = createAction(service->iconResource(),
       
   685                 mToolbarViewsActionGroup, 0 /*do not connect to any slot*/);
       
   686         connect(mToolbarActions[ETBActionServices], SIGNAL(triggered()), service, SLOT(launchService()));
       
   687     }
       
   688 }
       
   689 
       
   690 // ---------------------------------------------------------------------------
       
   691 // loadOperatorService()
       
   692 // ---------------------------------------------------------------------------
       
   693 //
       
   694 void VideoListView::loadOperatorService(int titleKey, int iconKey, int uriKey, int uidKey)
       
   695 {
       
   696     FUNC_LOG;
       
   697     VideoOperatorService *service = new VideoOperatorService();
       
   698     if(service->load(titleKey, iconKey, uriKey, uidKey))
       
   699     {
       
   700         mVideoOperatorServices.append(service);
       
   701     }
       
   702     else
       
   703     {
       
   704         // Load failed, delete service data.
       
   705         delete service;
       
   706     }
       
   707 }
       
   708 
       
   709 // ---------------------------------------------------------------------------
       
   710 // createAction()
       
   711 // ---------------------------------------------------------------------------
       
   712 //
       
   713 HbAction* VideoListView::createAction(QString icon,
       
   714         QActionGroup* actionGroup, const char *slot)
       
   715 {
       
   716 	FUNC_LOG;
       
   717     HbAction* action = new HbAction(actionGroup);
       
   718 
       
   719     HbIcon hbIcon(icon);
       
   720     action->setIcon(hbIcon);
       
   721 
       
   722     if(slot)
       
   723     {
       
   724         if(!connect(action, SIGNAL(triggered()), this, slot)) {
       
   725             // actiongroup deletion deletes this also.
       
   726             // return 0 tells that there was a problem in creation to caller.
       
   727             delete action;
       
   728             return 0;
       
   729         }
       
   730     }
       
   731     
       
   732     return action;
       
   733 }
   531 }
   734 
   532 
   735 // ---------------------------------------------------------------------------
   533 // ---------------------------------------------------------------------------
   736 // showHint
   534 // showHint
   737 // ---------------------------------------------------------------------------
   535 // ---------------------------------------------------------------------------
   776             hintWidget->deactivate();
   574             hintWidget->deactivate();
   777             hintWidget->setButtonShown(true);
   575             hintWidget->setButtonShown(true);
   778         }
   576         }
   779     }
   577     }
   780 
   578 
   781     if (mToolbarViewsActionGroup && mToolbarCollectionActionGroup && !mVideoServices)
   579     mToolbar->viewStateChanged(mCurrentList->getLevel(), show, mModelReady);
   782     {
   580     
   783         mToolbarActions[ETBActionAddVideos]->setVisible(true);
       
   784         if (show)
       
   785         {
       
   786         	mToolbarActions[ETBActionRemoveVideos]->setVisible(false);
       
   787         }
       
   788         else if(mToolbarActions[ETBActionRemoveVideos]->isVisible() == false)
       
   789 		{
       
   790         	mToolbarActions[ETBActionRemoveVideos]->setVisible(true);
       
   791 		}
       
   792     }
       
   793 
       
   794     // prepare sublabel
   581     // prepare sublabel
   795     HbGroupBox *subLabel =
   582     HbGroupBox *subLabel =
   796         mUiLoader->findWidget<HbGroupBox>(
   583         mUiLoader->findWidget<HbGroupBox>(
   797             DOCML_NAME_VC_HEADINGBANNER);
   584             DOCML_NAME_VC_HEADINGBANNER);
   798     if (subLabel)
   585     if (subLabel)
   846 			{
   633 			{
   847 			    // no need to update sublabel if there are no items in videolist
   634 			    // no need to update sublabel if there are no items in videolist
   848 			    // hint widget is shown instead
   635 			    // hint widget is shown instead
   849 			    if (itemCount)
   636 			    if (itemCount)
   850 			    {
   637 			    {
   851 	                subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_videos", itemCount));
   638 	                subLabel->setHeading(hbTrId("txt_videos_subtitle_all_videos_ln", itemCount));
   852 			    }
   639 			    }
   853 			}
   640 			}
   854 			else if (mCurrentList->getLevel() == VideoCollectionCommon::ELevelCategory)
   641 			else if (mCurrentList->getLevel() == VideoCollectionCommon::ELevelCategory)
   855 			{
   642 			{
   856 				subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_collections", itemCount));
   643 				subLabel->setHeading(hbTrId("txt_videos_subtitle_collections_ln", itemCount));
   857 			}
   644 			}
   858 			else
   645 			else
   859 			{
   646 			{
   860 				QString text = HbParameterLengthLimiter(hbTrId("txt_videos_subtitle_1_l2")).arg(mCollectionName).arg(itemCount);
   647 				QString text = HbParameterLengthLimiter(hbTrId("txt_videos_subtitle_1_l2")).arg(mCollectionName).arg(itemCount);
   861 				subLabel->setHeading(text);
   648 				subLabel->setHeading(text);
   862 			}
   649 			}
   863         }
   650         }
   864     }
       
   865 }
       
   866 
       
   867 // ---------------------------------------------------------------------------
       
   868 // showAction()
       
   869 // ---------------------------------------------------------------------------
       
   870 //
       
   871 void VideoListView::showAction(bool show, const QString &name)
       
   872 {
       
   873 	FUNC_LOG;
       
   874     HbAction *action = mUiLoader->findObject<HbAction>(name);
       
   875     if (!action)
       
   876     {
       
   877         // must be menu widget
       
   878         HbMenu *menu = mUiLoader->findWidget<HbMenu>(name);
       
   879         if (menu)
       
   880         {
       
   881             action = menu->menuAction();
       
   882         }
       
   883     }
       
   884 
       
   885     // hide or show action
       
   886     if (action)
       
   887     {
       
   888         action->setVisible(show);
       
   889     }
   651     }
   890 }
   652 }
   891 
   653 
   892 // ---------------------------------------------------------------------------
   654 // ---------------------------------------------------------------------------
   893 // activateMainView()
   655 // activateMainView()
   970    
   732    
   971     if (mVideoServices)
   733     if (mVideoServices)
   972     {       
   734     {       
   973         // TODO: service sorting roles needs to be defined somewhere
   735         // TODO: service sorting roles needs to be defined somewhere
   974         int sortRole = mVideoServices->sortRole();
   736         int sortRole = mVideoServices->sortRole();
   975         if(sortRole == 2)
   737         if(sortRole == XQService::SortTitle)
   976         {
   738         {
   977             sortRole = VideoCollectionCommon::KeyTitle;
   739             sortRole = VideoCollectionCommon::KeyTitle;
   978         }
   740         }
   979         else if(sortRole == 3)
   741         else if(sortRole == XQService::SortSize)
   980         {
   742         {
   981             sortRole = VideoCollectionCommon::KeySizeValue;
   743             sortRole = VideoCollectionCommon::KeySizeValue;
   982         } 
   744         } 
   983         else
   745         else
   984         {
   746         {
  1047         // also update the sublabel immediatelly, as the data is up to date almost always.
   809         // also update the sublabel immediatelly, as the data is up to date almost always.
  1048         updateSubLabel();
   810         updateSubLabel();
  1049     }
   811     }
  1050 }
   812 }
  1051 
   813 
  1052 // ---------------------------------------------------------------------------
       
  1053 // openOperatorServiceSlot()
       
  1054 // ---------------------------------------------------------------------------
       
  1055 //
       
  1056 void VideoListView::openOperatorServiceSlot()
       
  1057 {
       
  1058 	FUNC_LOG;
       
  1059     
       
  1060 	if(mVideoOperatorServices.count() > 0)
       
  1061 	{
       
  1062 	    mVideoOperatorServices[0]->launchService();
       
  1063 	}
       
  1064 }
       
  1065 
       
  1066 // ---------------------------------------------------------------------------
       
  1067 // startSorting()
       
  1068 // ---------------------------------------------------------------------------
       
  1069 //
       
  1070 void VideoListView::startSorting()
       
  1071 {
       
  1072 	FUNC_LOG;
       
  1073     HbMenu *optionsMenu =
       
  1074         mUiLoader->findWidget<HbMenu>(
       
  1075             DOCML_NAME_OPTIONS_MENU);
       
  1076     if (optionsMenu && mCurrentList)
       
  1077     {
       
  1078         // get sorting role from active action
       
  1079         HbAction* action = optionsMenu->activeAction();
       
  1080         HbMenu* sortMenu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_SORT_MENU);
       
  1081         if(action == sortMenu->menuAction()) // make sure that active action is the sort menu. 
       
  1082         {
       
  1083             HbAction* action = sortMenu->activeAction();
       
  1084             if(action)
       
  1085             {
       
  1086                 doSorting(mSortingRoles[action]);
       
  1087             }
       
  1088         }
       
  1089     }
       
  1090 }
       
  1091 
       
  1092 // ---------------------------------------------------------------------------
       
  1093 // doSorting()
       
  1094 // ---------------------------------------------------------------------------
       
  1095 //
       
  1096 void VideoListView::doSorting(int role)
       
  1097 {
       
  1098 	FUNC_LOG;
       
  1099 	if(!mCurrentList || !mCurrentList->getModel())
       
  1100 	{
       
  1101 	    // no list or model, cannot sort
       
  1102 	    return;
       
  1103 	}
       
  1104 	// sort model
       
  1105 	Qt::SortOrder order(Qt::AscendingOrder);
       
  1106 	VideoProxyModelGeneric *model = mCurrentList->getModel();
       
  1107 	if(model->sortRole() == role && model->sortOrder() == Qt::AscendingOrder)
       
  1108 	{
       
  1109 		order = Qt::DescendingOrder;
       
  1110 	}
       
  1111 	model->doSorting(role, order);
       
  1112 	
       
  1113 	// for video related sorting, all videos list and collection content
       
  1114 	// list, sorting orders are same all the time
       
  1115 	VideoListWidget *anotherVideosList = 0;
       
  1116 	VideoCollectionCommon::TCollectionLevels level = mCurrentList->getLevel();
       
  1117 	if (level == VideoCollectionCommon::ELevelDefaultColl ||
       
  1118 	    level == VideoCollectionCommon::ELevelAlbum)
       
  1119 	{
       
  1120 	    anotherVideosList = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_VIDEOLISTWIDGET);
       
  1121 	}
       
  1122 	else if(level == VideoCollectionCommon::ELevelVideos)
       
  1123 	{
       
  1124 	    anotherVideosList = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
       
  1125 	}
       
  1126     if(anotherVideosList && anotherVideosList->getModel())
       
  1127     {
       
  1128         anotherVideosList->getModel()->doSorting(role, order);
       
  1129     }
       
  1130 
       
  1131     // save sorting values only if the application is not started as a service
       
  1132 	if (!mVideoServices)
       
  1133 	{
       
  1134 	    // save sorting values
       
  1135 	    mUiUtils.saveSortingValues(role, order, mCurrentList->getLevel());
       
  1136 	}
       
  1137 }
       
  1138 
       
  1139 // -------------------------------------------------------------------------------------------------
   814 // -------------------------------------------------------------------------------------------------
  1140 // aboutToChangeOrientationSlot()
   815 // aboutToChangeOrientationSlot()
  1141 // hide all items in the window during orientation change
   816 // hide all items in the window during orientation change
  1142 // -------------------------------------------------------------------------------------------------
   817 // -------------------------------------------------------------------------------------------------
  1143 //
   818 //
  1158     // this method is required for changing from to mediawall
   833     // this method is required for changing from to mediawall
  1159     
   834     
  1160     // in landscape we need to hide the title and the toolbar. (also required for the mediawall?)
   835     // in landscape we need to hide the title and the toolbar. (also required for the mediawall?)
  1161     // TODO: how about the feature where the toolbar comes visible if screen is tapped?
   836     // TODO: how about the feature where the toolbar comes visible if screen is tapped?
  1162     this->setItemVisible(Hb::AllItems, orientation == Qt::Vertical);
   837     this->setItemVisible(Hb::AllItems, orientation == Qt::Vertical);
  1163 }
       
  1164 
       
  1165 // -------------------------------------------------------------------------------------------------
       
  1166 // deleteItemsSlot
       
  1167 // -------------------------------------------------------------------------------------------------
       
  1168 //
       
  1169 void VideoListView::deleteItemsSlot()
       
  1170 {
       
  1171 	FUNC_LOG;
       
  1172 
       
  1173     VideoListSelectionDialog *dialog =
       
  1174         mUiLoader->findWidget<VideoListSelectionDialog>(
       
  1175             DOCML_NAME_DIALOG);
       
  1176     if (dialog)
       
  1177     {
       
  1178         TMPXItemId collectionId = mCurrentList->getModel()->getOpenItem();
       
  1179         dialog->setupContent(VideoListSelectionDialog::EDeleteVideos, collectionId); 
       
  1180         dialog->exec();
       
  1181     }
       
  1182 }
       
  1183 
       
  1184 // -------------------------------------------------------------------------------------------------
       
  1185 // createCollectionSlot
       
  1186 // -------------------------------------------------------------------------------------------------
       
  1187 //
       
  1188 void VideoListView::createCollectionSlot()
       
  1189 {
       
  1190 	FUNC_LOG;
       
  1191      
       
  1192     VideoListSelectionDialog *dialog =
       
  1193         mUiLoader->findWidget<VideoListSelectionDialog>(
       
  1194             DOCML_NAME_DIALOG);
       
  1195     if (!dialog)
       
  1196     {
       
  1197         // fatal: no selection dialog
       
  1198         return;
       
  1199     }
       
  1200     
       
  1201     dialog->setupContent(VideoListSelectionDialog::ECreateCollection, TMPXItemId::InvalidId());
       
  1202     dialog->exec();
       
  1203 }
       
  1204 
       
  1205 // -------------------------------------------------------------------------------------------------
       
  1206 // addVideosToCollectionSlot
       
  1207 // -------------------------------------------------------------------------------------------------
       
  1208 //
       
  1209 void VideoListView::addVideosToCollectionSlot()
       
  1210 {
       
  1211 	FUNC_LOG;
       
  1212     if(!mCurrentList || !mCurrentList->getModel())
       
  1213     {
       
  1214         return;
       
  1215     }
       
  1216 
       
  1217     VideoListSelectionDialog *dialog =
       
  1218         mUiLoader->findWidget<VideoListSelectionDialog>(
       
  1219             DOCML_NAME_DIALOG);
       
  1220     if (!dialog)
       
  1221     {
       
  1222         // fatal: no selection dialog
       
  1223         return;
       
  1224     }
       
  1225     if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelAlbum)
       
  1226     {
       
  1227         // album is opened, do not proceed in case it already have same amount
       
  1228         // of videos than all videos view.
       
  1229         VideoListWidget *allVideos = mUiLoader->findWidget<VideoListWidget>(
       
  1230                     DOCML_NAME_VC_VIDEOLISTWIDGET);
       
  1231         if(allVideos && allVideos->getModel())
       
  1232         {
       
  1233             int count = allVideos->getModel()->rowCount();
       
  1234             if(count == mCurrentList->getModel()->rowCount())
       
  1235             {
       
  1236                 if(count)
       
  1237                 {
       
  1238                     QVariant emptyAdditional;
       
  1239                     mUiUtils.showStatusMsgSlot(
       
  1240                             VideoCollectionCommon::statusAllVideosAlreadyInCollection,
       
  1241                             emptyAdditional);
       
  1242                 }
       
  1243                 return;
       
  1244             }  
       
  1245         }
       
  1246     }
       
  1247     TMPXItemId collectionId = mCurrentList->getModel()->getOpenItem();
       
  1248     dialog->setupContent(VideoListSelectionDialog::EAddToCollection, collectionId);
       
  1249     dialog->exec();
       
  1250 }
       
  1251 
       
  1252 // -------------------------------------------------------------------------------------------------
       
  1253 // removeVideosFromCollectionSlot
       
  1254 // -------------------------------------------------------------------------------------------------
       
  1255 //
       
  1256 void VideoListView::removeVideosFromCollectionSlot()
       
  1257 {
       
  1258 	FUNC_LOG;
       
  1259     if(!mCurrentList || !mCurrentList->getModel())
       
  1260     {
       
  1261         return;
       
  1262     }
       
  1263     // not allowed if for some reason current widget 
       
  1264     // is all videos or collection or there are no items
       
  1265     if(mCurrentList->getLevel() < VideoCollectionCommon::ELevelDefaultColl ||
       
  1266        !mCurrentList->getModel()->rowCount())
       
  1267     {
       
  1268         return;
       
  1269     }
       
  1270 
       
  1271     VideoListSelectionDialog *dialog =
       
  1272             mUiLoader->findWidget<VideoListSelectionDialog>(
       
  1273                         DOCML_NAME_DIALOG);
       
  1274     if (!dialog)
       
  1275     {
       
  1276         ERROR(-1, "VideoListView::removeVideosFromCollectionSlot() failed to load selection dialog.");
       
  1277         return;
       
  1278     }
       
  1279     TMPXItemId collectionId = mCurrentList->getModel()->getOpenItem();
       
  1280     if(collectionId != TMPXItemId::InvalidId() && collectionId.iId2 != KVcxMvcMediaTypeVideo)
       
  1281     {
       
  1282         dialog->setupContent(VideoListSelectionDialog::ERemoveFromCollection, collectionId);
       
  1283         dialog->exec();
       
  1284     }
       
  1285 }
       
  1286 
       
  1287 // -------------------------------------------------------------------------------------------------
       
  1288 // aboutToShowMainMenuSlot
       
  1289 // -------------------------------------------------------------------------------------------------
       
  1290 //
       
  1291 void VideoListView::aboutToShowMainMenuSlot()
       
  1292 {
       
  1293     if (mVideoServices &&
       
  1294         mVideoServices->currentService() == VideoServices::EBrowse)
       
  1295     {
       
  1296         prepareBrowseServiceMenu();
       
  1297         return;
       
  1298     }
       
  1299     
       
  1300 	if (!mCurrentList ||
       
  1301 	    !mToolbarViewsActionGroup ||
       
  1302 	    !mToolbarCollectionActionGroup)
       
  1303 	{
       
  1304 		return;
       
  1305 	}
       
  1306 	
       
  1307 	// hide all actions by default
       
  1308     showAction(false, DOCML_NAME_ADD_TO_COLLECTION);
       
  1309     showAction(false, DOCML_NAME_CREATE_COLLECTION);
       
  1310     showAction(false, DOCML_NAME_DELETE_MULTIPLE);
       
  1311     showAction(false, DOCML_NAME_SORT_BY_DATE);
       
  1312     showAction(false, DOCML_NAME_SORT_BY_NAME);
       
  1313     showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
       
  1314     showAction(false, DOCML_NAME_SORT_BY_SIZE);
       
  1315     showAction(false, DOCML_NAME_SORT_MENU);
       
  1316 
       
  1317     HbAction *firstAction = (HbAction*)(toolBar()->actions().first());
       
  1318 
       
  1319     bool isCollectionsView = mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionCollections] &&
       
  1320            firstAction == mToolbarActions[ETBActionAllVideos];
       
  1321     
       
  1322     // Create collection action is shown even when there's no videos. 
       
  1323     if(isCollectionsView && !mVideoServices)
       
  1324     {
       
  1325         showAction(true, DOCML_NAME_CREATE_COLLECTION);
       
  1326     }
       
  1327     
       
  1328     //  No other actions shown if there's no videos.
       
  1329     VideoProxyModelGeneric *model = mCurrentList->getModel();
       
  1330     if (!model || !model->rowCount())
       
  1331     {
       
  1332         return;
       
  1333     }
       
  1334     
       
  1335     // get current sorting values
       
  1336     int role;
       
  1337     Qt::SortOrder order;
       
  1338     model->getSorting(role, order);
       
  1339 
       
  1340     if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionAllVideos] &&
       
  1341        firstAction == mToolbarActions[ETBActionAllVideos])
       
  1342     {
       
  1343         showAction(true, DOCML_NAME_SORT_MENU);
       
  1344         showAction(true, DOCML_NAME_SORT_BY_DATE);
       
  1345         showAction(true, DOCML_NAME_SORT_BY_NAME);
       
  1346         showAction(true, DOCML_NAME_SORT_BY_SIZE);
       
  1347 
       
  1348         HbAction* action = mSortingRoles.key(role);
       
  1349 		if (action)
       
  1350 		{
       
  1351 			action->setChecked(true);
       
  1352 		}
       
  1353 
       
  1354         if (!mVideoServices)
       
  1355         {
       
  1356             showAction(true, DOCML_NAME_ADD_TO_COLLECTION);
       
  1357             showAction(true, DOCML_NAME_DELETE_MULTIPLE);
       
  1358         }
       
  1359     }
       
  1360     else if(isCollectionsView)
       
  1361     {
       
  1362         showAction(true, DOCML_NAME_SORT_MENU);
       
  1363         showAction(true, DOCML_NAME_SORT_BY_NAME);
       
  1364         showAction(true, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
       
  1365     	
       
  1366 		HbAction* action = mSortingRoles.key(role);
       
  1367 		if (action)
       
  1368 		{
       
  1369 			action->setChecked(true);
       
  1370 		}
       
  1371     }
       
  1372     else if(firstAction != mToolbarActions[ETBActionAllVideos])
       
  1373     {
       
  1374         showAction(true, DOCML_NAME_SORT_MENU);
       
  1375         showAction(true, DOCML_NAME_SORT_BY_DATE);
       
  1376         showAction(true, DOCML_NAME_SORT_BY_NAME);
       
  1377         showAction(true, DOCML_NAME_SORT_BY_SIZE);
       
  1378 
       
  1379         HbAction* action = mSortingRoles.key(role);
       
  1380 		if (action)
       
  1381 		{
       
  1382 			action->setChecked(true);
       
  1383 		}
       
  1384 
       
  1385         if (!mVideoServices)
       
  1386         {
       
  1387             showAction(true, DOCML_NAME_DELETE_MULTIPLE);
       
  1388         }
       
  1389     }
       
  1390 }
       
  1391 
       
  1392 // -------------------------------------------------------------------------------------------------
       
  1393 // prepareBrowseServiceMenu
       
  1394 // -------------------------------------------------------------------------------------------------
       
  1395 //
       
  1396 void VideoListView::prepareBrowseServiceMenu()
       
  1397 {
       
  1398     if (!mCurrentList)
       
  1399     {
       
  1400         return;
       
  1401     }
       
  1402     
       
  1403     // hide all actions by default
       
  1404     showAction(false, DOCML_NAME_ADD_TO_COLLECTION);
       
  1405     showAction(false, DOCML_NAME_CREATE_COLLECTION);
       
  1406     showAction(false, DOCML_NAME_DELETE_MULTIPLE);
       
  1407     showAction(false, DOCML_NAME_SORT_BY_DATE);
       
  1408     showAction(false, DOCML_NAME_SORT_BY_NAME);
       
  1409     showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
       
  1410     showAction(false, DOCML_NAME_SORT_BY_SIZE);
       
  1411     showAction(false, DOCML_NAME_SORT_MENU);
       
  1412     
       
  1413     VideoProxyModelGeneric *model = mCurrentList->getModel();
       
  1414     if (!model || !model->rowCount())
       
  1415     {
       
  1416         return;
       
  1417     }
       
  1418     
       
  1419     // show delete action
       
  1420     showAction(true, DOCML_NAME_DELETE_MULTIPLE);
       
  1421     
       
  1422     // show sort actions
       
  1423     showAction(true, DOCML_NAME_SORT_MENU);
       
  1424     showAction(true, DOCML_NAME_SORT_BY_DATE);
       
  1425     showAction(true, DOCML_NAME_SORT_BY_NAME);
       
  1426     showAction(true, DOCML_NAME_SORT_BY_SIZE);
       
  1427     
       
  1428     // set current sort action selected
       
  1429     int role;
       
  1430     Qt::SortOrder order;
       
  1431     model->getSorting(role, order);
       
  1432     HbAction* action = mSortingRoles.key(role);
       
  1433     if (action)
       
  1434     {
       
  1435         action->setChecked(true);
       
  1436     }
       
  1437 }
   838 }
  1438 
   839 
  1439 // -------------------------------------------------------------------------------------------------
   840 // -------------------------------------------------------------------------------------------------
  1440 // handleAsyncStatusSlot
   841 // handleAsyncStatusSlot
  1441 // -------------------------------------------------------------------------------------------------
   842 // -------------------------------------------------------------------------------------------------
  1516         updateSubLabel();
   917         updateSubLabel();
  1517         
   918         
  1518         // update hint widget for correct content
   919         // update hint widget for correct content
  1519         mModelReady = model->rowCount() > 0;
   920         mModelReady = model->rowCount() > 0;
  1520         setHintLevel(VideoHintWidget::Collection);
   921         setHintLevel(VideoHintWidget::Collection);
  1521 
   922         
  1522         if(mToolbarCollectionActionGroup)
   923         if(mToolbar)
  1523         {
   924         {
  1524             // update toolbar for albums, default categories don't have one. Neither does services.
   925             // if toolbar not yet created, it means that we're activating
  1525             toolBar()->clearActions();
   926             // for the startup, toolbar will be updated during modelReady()
  1526             if(!mVideoServices && level == VideoCollectionCommon::ELevelAlbum && 
   927             mToolbar->viewStateChanged(level, false, mModelReady);
  1527                 mToolbarActions.contains(ETBActionCollections))
   928         }
  1528             {
   929         
  1529                 mToolbarActions[ETBActionCollections]->setChecked(false);
       
  1530                 toolBar()->addActions(mToolbarCollectionActionGroup->actions());
       
  1531                 setItemVisible(Hb::ToolBarItem, true);
       
  1532             }
       
  1533             else
       
  1534             {
       
  1535                 setItemVisible(Hb::ToolBarItem, false);
       
  1536             }
       
  1537         }
       
  1538         // restore animations for collection content widget
   930         // restore animations for collection content widget
  1539         collectionContentWidget->setEnabledAnimations(animationState);
   931         collectionContentWidget->setEnabledAnimations(animationState);
  1540     }
   932     }
  1541     else
   933     else
  1542     {
   934     {
  1543         // clear actions to make sure there is no wrong toolbar in case main 
       
  1544         // toolbar actiongroup actiongroup is missing
       
  1545         toolBar()->clearActions();   
       
  1546         // open collection view
   935         // open collection view
  1547         openCollectionViewSlot();        
   936         openCollectionViewSlot();
  1548         // update toolbar
   937         
  1549         if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections))
   938         mToolbar->viewStateChanged(VideoCollectionCommon::ELevelCategory, false, mModelReady);
  1550         {                    
       
  1551             toolBar()->addActions(mToolbarViewsActionGroup->actions());
       
  1552             mToolbarActions[ETBActionCollections]->setChecked(true);
       
  1553             setItemVisible(Hb::ToolBarItem, true);
       
  1554             
       
  1555             if(mToolbarServiceExtension)
       
  1556             {
       
  1557                 HbAction *action = toolBar()->addExtension(mToolbarServiceExtension);
       
  1558                 HbIcon icon("qtg_mono_video_services");
       
  1559                 action->setIcon(icon);
       
  1560             }
       
  1561         }
       
  1562     }	
   939     }	
  1563 	if(!mVideoServices)
   940 	if(!mVideoServices)
  1564 	{
   941 	{
  1565 	    // save / clear collection related activity data
   942 	    // save / clear collection related activity data
  1566 	    VideoCollectionViewUtils::setCollectionActivityData(collectionId, collection);
   943 	    VideoCollectionViewUtils::setCollectionActivityData(collectionId, collection);
  1607             // this widget not yet activated so it's has been created on the second phase
   984             // this widget not yet activated so it's has been created on the second phase
  1608             // safe to call doDelayed right away
   985             // safe to call doDelayed right away
  1609             qobject_cast<VideoListWidget*>(object)->doDelayedsSlot();
   986             qobject_cast<VideoListWidget*>(object)->doDelayedsSlot();
  1610         }        
   987         }        
  1611     }
   988     }
  1612     else if (name.compare(DOCML_NAME_OPTIONS_MENU) == 0)
       
  1613     {
       
  1614         connect(
       
  1615             object, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMainMenuSlot()));
       
  1616     }
       
  1617     else if (name.compare(DOCML_NAME_HINT_BUTTON) == 0)
   989     else if (name.compare(DOCML_NAME_HINT_BUTTON) == 0)
  1618     {
   990     {
  1619         connect(object, SIGNAL(clicked(bool)), this, SLOT(openOperatorServiceSlot()));
   991         connect(object, SIGNAL(clicked(bool)), mToolbar, SLOT(openOperatorServiceSlot()));
  1620     }
   992     }
  1621     else if (name.compare(DOCML_NAME_SORT_BY_DATE) == 0)
   993 }
  1622     {
   994 
  1623         HbAction *action = qobject_cast<HbAction*>(object);
   995 // -------------------------------------------------------------------------------------------------
  1624         if (action)
   996 // toolbarActionsChanged
  1625         {
   997 // -------------------------------------------------------------------------------------------------
  1626         	connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
   998 //
  1627             mSortingRoles[action] = VideoCollectionCommon::KeyDateTime;
   999 void VideoListView::toolbarActionsChanged(QList<QAction*> newActions)
  1628         }
  1000 {
  1629     }
  1001     HbToolBar* bar = toolBar();
  1630     else if (name.compare(DOCML_NAME_SORT_BY_NAME) == 0)
  1002     
  1631     {
  1003     bar->clearActions();
  1632         HbAction *action = qobject_cast<HbAction*>(object);
  1004     
  1633         if (action)
  1005     if(newActions.count() > 0)
  1634         {
  1006     {
  1635         	connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
  1007         bar->addActions(newActions);
  1636             mSortingRoles[action] = VideoCollectionCommon::KeyTitle;
  1008         setItemVisible(Hb::ToolBarItem, true);
  1637         }
  1009     }
  1638     }
  1010     else
  1639     else if (name.compare(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS) == 0)
  1011     {
  1640     {
  1012         setItemVisible(Hb::ToolBarItem, false);
  1641         HbAction *action = qobject_cast<HbAction*>(object);
  1013     }
  1642         if (action)
  1014 }
  1643         {
  1015 
  1644             connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
  1016 // -------------------------------------------------------------------------------------------------
  1645             mSortingRoles[action] = VideoCollectionCommon::KeyNumberOfItems;
  1017 // toolbarExtensionChanged
  1646         }
  1018 // -------------------------------------------------------------------------------------------------
  1647     }
  1019 //
  1648     else if (name.compare(DOCML_NAME_SORT_BY_SIZE) == 0)
  1020 void VideoListView::toolbarExtensionChanged(HbToolBarExtension* newExtension)
  1649     {
  1021 {
  1650         HbAction *action = qobject_cast<HbAction*>(object);
  1022     if(newExtension)
  1651         if (action)
  1023     {
  1652         {
  1024         HbAction *action = toolBar()->addExtension(newExtension);
  1653         	connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
  1025         HbIcon icon("qtg_mono_video_services");
  1654             mSortingRoles[action] = VideoCollectionCommon::KeySizeValue;
  1026         action->setIcon(icon);
  1655         }
  1027     }
  1656     }
       
  1657     else if (name.compare(DOCML_NAME_ADD_TO_COLLECTION) == 0)
       
  1658     {
       
  1659         HbAction *action = qobject_cast<HbAction*>(object);
       
  1660         if (action)
       
  1661         {
       
  1662             connect(action, SIGNAL(triggered()), this, SLOT(addVideosToCollectionSlot()));
       
  1663         }
       
  1664     }
       
  1665     else if (name.compare(DOCML_NAME_CREATE_COLLECTION) == 0)
       
  1666     {
       
  1667         HbAction *action = qobject_cast<HbAction*>(object);
       
  1668         if (action)
       
  1669         {
       
  1670             connect(action, SIGNAL(triggered()), this, SLOT(createCollectionSlot()));
       
  1671         }
       
  1672     }
       
  1673     else if (name.compare(DOCML_NAME_DELETE_MULTIPLE) == 0)
       
  1674     {
       
  1675         HbAction *action = qobject_cast<HbAction*>(object);
       
  1676         if (action)
       
  1677         {
       
  1678             connect(action, SIGNAL(triggered()), this, SLOT(deleteItemsSlot()));
       
  1679         }
       
  1680     }
       
  1681 }
       
  1682 
       
  1683 // Just for testing, remove this
       
  1684 void VideoListView::debugNotImplementedYet()
       
  1685 {
       
  1686 	FUNC_LOG;
       
  1687     HbMessageBox::information(tr("Not implemented yet"));
       
  1688 }
  1028 }
  1689 
  1029 
  1690 // End of file
  1030 // End of file