videocollection/videocollectionview/src/videolistview.cpp
changeset 35 3738fe97f027
parent 34 bbb98528c666
child 36 8aed59de29f9
equal deleted inserted replaced
34:bbb98528c666 35:3738fe97f027
    39 #include "videolistview.h"
    39 #include "videolistview.h"
    40 #include "videocollectioncommon.h"
    40 #include "videocollectioncommon.h"
    41 #include "videocollectionwrapper.h"
    41 #include "videocollectionwrapper.h"
    42 #include "videosortfilterproxymodel.h"
    42 #include "videosortfilterproxymodel.h"
    43 #include "videocollectionuiloader.h"
    43 #include "videocollectionuiloader.h"
       
    44 #include "mpxhbvideocommondefs.h"
    44 
    45 
    45 // remove these
    46 // remove these
    46 #include <QDebug>
    47 #include <QDebug>
    47 
    48 
    48 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    53 HbView(parent),
    54 HbView(parent),
    54 mUiUtils(VideoCollectionViewUtils::instance()),
    55 mUiUtils(VideoCollectionViewUtils::instance()),
    55 mWrapper(VideoCollectionWrapper::instance()),
    56 mWrapper(VideoCollectionWrapper::instance()),
    56 mUiLoader(uiLoader),
    57 mUiLoader(uiLoader),
    57 mIsService(false),
    58 mIsService(false),
       
    59 mHintLoaded(false),
       
    60 mListsLoaded(false),
       
    61 mMultiselectionLoaded(false),
    58 mModelReady(false),
    62 mModelReady(false),
       
    63 mTransitionOngoing(false),
       
    64 mHintLevel(VideoHintWidget::AllVideos),
    59 mVideoServices(0),
    65 mVideoServices(0),
    60 mCurrentList(0),
    66 mCurrentList(0),
    61 mToolbarViewsActionGroup(0),
    67 mToolbarViewsActionGroup(0),
    62 mToolbarCollectionActionGroup(0)
    68 mToolbarCollectionActionGroup(0)
    63 {
    69 {
    69 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    70 //
    76 //
    71 VideoListView::~VideoListView()
    77 VideoListView::~VideoListView()
    72 {
    78 {
    73     qDebug() << "VideoListView::~VideoListView()";
    79     qDebug() << "VideoListView::~VideoListView()";
       
    80     
       
    81     toolBar()->clearActions();
    74     
    82     
    75     mToolbarActions.clear();
    83     mToolbarActions.clear();
    76     mSortingRoles.clear();
    84     mSortingRoles.clear();
    77 
    85 
    78     if(mVideoServices)
    86     if(mVideoServices)
   108         else
   116         else
   109         {
   117         {
   110         	connect(mVideoServices, SIGNAL(titleReady(const QString&)), this, SLOT(titleReadySlot(const QString&)));
   118         	connect(mVideoServices, SIGNAL(titleReady(const QString&)), this, SLOT(titleReadySlot(const QString&)));
   111         }
   119         }
   112 	}
   120 	}
   113     mUiLoader->setIsService(mIsService);
       
   114     
   121     
   115     // start open all videos model
   122     // start open all videos model
   116     VideoSortFilterProxyModel *model =
   123     VideoSortFilterProxyModel *model =
   117         mWrapper.getModel(VideoCollectionWrapper::EAllVideos);
   124         mWrapper.getModel(VideoCollectionWrapper::EAllVideos);
   118     if (model)
   125     if (model)
   126     }
   133     }
   127     
   134     
   128     // start loading widgets
   135     // start loading widgets
   129     QSet<QString> uiItems;
   136     QSet<QString> uiItems;
   130     uiItems.insert(DOCML_NAME_VC_VIDEOLISTWIDGET);
   137     uiItems.insert(DOCML_NAME_VC_VIDEOLISTWIDGET);
       
   138     uiItems.insert(DOCML_NAME_VC_HEADINGBANNER);
   131     uiItems.insert(DOCML_NAME_OPTIONS_MENU);
   139     uiItems.insert(DOCML_NAME_OPTIONS_MENU);
   132     uiItems.insert(DOCML_NAME_ADD_TO_COLLECTION);
   140     if(!mIsService)
   133     uiItems.insert(DOCML_NAME_CREATE_COLLECTION);
   141     {
   134     uiItems.insert(DOCML_NAME_DELETE_MULTIPLE);
   142 		uiItems.insert(DOCML_NAME_ADD_TO_COLLECTION);
   135     uiItems.insert(DOCML_NAME_VC_HEADINGBANNER);
   143 		uiItems.insert(DOCML_NAME_CREATE_COLLECTION);
   136     uiItems.insert(DOCML_NAME_VC_VIDEOHINTWIDGET);
   144 		uiItems.insert(DOCML_NAME_DELETE_MULTIPLE);
   137     uiItems.insert(DOCML_NAME_HINT_BUTTON);
   145     }
   138     uiItems.insert(DOCML_NAME_NO_VIDEOS_LABEL);
       
   139     uiItems.insert(DOCML_NAME_SORT_MENU);
   146     uiItems.insert(DOCML_NAME_SORT_MENU);
   140     uiItems.insert(DOCML_NAME_SORT_BY_DATE);
   147     uiItems.insert(DOCML_NAME_SORT_BY_DATE);
   141     uiItems.insert(DOCML_NAME_SORT_BY_NAME);
   148     uiItems.insert(DOCML_NAME_SORT_BY_NAME);
   142     uiItems.insert(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
   149     uiItems.insert(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
   143     uiItems.insert(DOCML_NAME_SORT_BY_TOTAL_LENGTH);
       
   144     uiItems.insert(DOCML_NAME_SORT_BY_RATING);
   150     uiItems.insert(DOCML_NAME_SORT_BY_RATING);
   145     uiItems.insert(DOCML_NAME_SORT_BY_SIZE);
   151     uiItems.insert(DOCML_NAME_SORT_BY_SIZE);
   146     uiItems.insert(DOCML_NAME_VC_COLLECTIONWIDGET);
       
   147     uiItems.insert(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
       
   148     uiItems.insert(DOCML_NAME_DIALOG);
       
   149     mUiLoader->startLoading(uiItems,
   152     mUiLoader->startLoading(uiItems,
   150         this,
   153         this,
   151         SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
   154         SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
   152         SLOT(objectReadySlot(QObject*, const QString&)));
   155         SLOT(objectReadySlot(QObject*, const QString&)));
   153     uiItems.clear();
   156     uiItems.clear();
   191         {
   194         {
   192         	mCurrentList = videoList;
   195         	mCurrentList = videoList;
   193         }
   196         }
   194         
   197         
   195     	int result = mCurrentList->activate(level);
   198     	int result = mCurrentList->activate(level);
   196         if(result < 0) 
   199         if(result < 0)
   197         {
   200         {
   198             // activate failed, deactivate view so we get rid of dangling connections.
   201             // activate failed, deactivate view so we get rid of dangling connections.
   199             deactivateView();
   202             deactivateView();
   200             return -1;
   203             return -1;
   201         }
   204         }
   236     }
   239     }
   237     
   240     
   238     return 0;
   241     return 0;
   239 }
   242 }
   240 
   243 
       
   244 
       
   245 // ---------------------------------------------------------------------------
       
   246 // loadMultiSelection
       
   247 // ---------------------------------------------------------------------------
       
   248 //
       
   249 void VideoListView::loadMultiSelection()
       
   250 {
       
   251 	if(!mIsService)
       
   252     {
       
   253 		if(!mMultiselectionLoaded)
       
   254 		{
       
   255 			QSet<QString> uiItems;
       
   256 			uiItems.insert(DOCML_NAME_DIALOG);
       
   257 			mUiLoader->startLoading(uiItems,
       
   258 				this,
       
   259 				SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
       
   260 				SLOT(objectReadySlot(QObject*, const QString&)));
       
   261 			uiItems.clear();
       
   262 			mMultiselectionLoaded = true;
       
   263 		}
       
   264     }
       
   265 }
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // loadLists
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 void VideoListView::loadLists(bool doAsync)
       
   272 {
       
   273 	if(!mListsLoaded)
       
   274 	{
       
   275 		QSet<QString> uiItems;
       
   276 		uiItems.insert(DOCML_NAME_VC_COLLECTIONWIDGET);
       
   277 		uiItems.insert(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
       
   278 		mUiLoader->startLoading(uiItems,
       
   279 			this,
       
   280 			SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
       
   281 			SLOT(objectReadySlot(QObject*, const QString&)));
       
   282 		uiItems.clear();
       
   283 
       
   284 		if(!doAsync)
       
   285 		{
       
   286 			VideoListWidget* widget(0);
       
   287 			widget = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONWIDGET);
       
   288 			widget->setVisible(false);
       
   289 			widget = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
       
   290 			widget->setVisible(false);
       
   291 		}
       
   292 	    mListsLoaded = true;
       
   293 	}
       
   294 }
       
   295 
       
   296 // ---------------------------------------------------------------------------
       
   297 // doDelayedsSlot
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 void VideoListView::doDelayedsSlot()
       
   301 {
       
   302 	loadLists(true);
       
   303 	loadMultiSelection();
       
   304 	loadHint(true);
       
   305 	emit doDelayeds();
       
   306 }
       
   307 
   241 // ---------------------------------------------------------------------------
   308 // ---------------------------------------------------------------------------
   242 // modelReadySlot
   309 // modelReadySlot
   243 // ---------------------------------------------------------------------------
   310 // ---------------------------------------------------------------------------
   244 //
   311 //
   245 void VideoListView::modelReadySlot()
   312 void VideoListView::modelReadySlot()
   364         // All Videos tab
   431         // All Videos tab
   365         mToolbarActions[ETBActionAllVideos] = createAction(":/images/qtg_mono_video_all.svg",
   432         mToolbarActions[ETBActionAllVideos] = createAction(":/images/qtg_mono_video_all.svg",
   366                 mToolbarViewsActionGroup, SLOT(openAllVideosViewSlot()));
   433                 mToolbarViewsActionGroup, SLOT(openAllVideosViewSlot()));
   367 
   434 
   368         // Collections tab
   435         // Collections tab
   369         mToolbarActions[ETBActionCollections] = createAction(":/images/qtg_mono_video_collection.svg",
   436         mToolbarActions[ETBActionCollections] = createAction("qtg_mono_video_collection",
   370                 mToolbarViewsActionGroup, SLOT(openCollectionViewSlot()));
   437                 mToolbarViewsActionGroup, SLOT(openCollectionViewSlot()));
   371 
   438 
   372         if (!mIsService)
   439         if (!mIsService)
   373         {
   440         {
   374 			// Services tab
   441 			// Services tab
   375 			mToolbarActions[ETBActionServices] = createAction(":/images/qtg_mono_video_services.svg",
   442 			mToolbarActions[ETBActionServices] = createAction("qtg_mono_ovistore",
   376 					mToolbarViewsActionGroup, SLOT(openServicesViewSlot()));
   443 					mToolbarViewsActionGroup, SLOT(openServicesViewSlot()));
   377 			// Add Videos tab
   444 			// Add Videos tab
   378 			mToolbarActions[ETBActionAddVideos] = createAction(":/images/mono_video_addvideos.svg",
   445 			mToolbarActions[ETBActionAddVideos] = 
       
   446 			        createAction("qtg_mono_add_to_video_collection",
   379 					mToolbarCollectionActionGroup, SLOT(addVideosToCollectionSlot()));
   447 					mToolbarCollectionActionGroup, SLOT(addVideosToCollectionSlot()));
   380 
   448 
   381 			// Remove Videos tab
   449 			// Remove Videos tab
   382 			mToolbarActions[ETBActionRemoveVideos] = createAction(":/images/mono_video_removevideos.svg",
   450 			mToolbarActions[ETBActionRemoveVideos] = 
   383 					mToolbarCollectionActionGroup, SLOT(debugNotImplementedYet()));
   451 			        createAction(":/images/qtg_mono_remove_from_video_collection.svg",
   384         }
   452 					mToolbarCollectionActionGroup, SLOT(removeVideosFromCollectionSlot()));
   385 
   453         }
   386         // Sort by tab
       
   387         mToolbarActions[ETBActionSortVideos] = createAction(":/images/mono_video_sortvideos.svg",
       
   388                 mToolbarCollectionActionGroup, SLOT(openSortByMenuSlot()));
       
   389 
   454 
   390         HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
   455         HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
   391 
   456 
   392         if(   !bar
   457         if(   !bar
   393 		   || !mToolbarActions[ETBActionAllVideos]
   458 		   || !mToolbarActions[ETBActionAllVideos]
   394            || !mToolbarActions[ETBActionCollections]
   459            || !mToolbarActions[ETBActionCollections]
   395 		   || !mToolbarActions[ETBActionSortVideos]
       
   396            || (!mToolbarActions[ETBActionServices]     && !mIsService)
   460            || (!mToolbarActions[ETBActionServices]     && !mIsService)
   397            || (!mToolbarActions[ETBActionAddVideos]    && !mIsService)
   461            || (!mToolbarActions[ETBActionAddVideos]    && !mIsService)
   398            || (!mToolbarActions[ETBActionRemoveVideos] && !mIsService))
   462            || (!mToolbarActions[ETBActionRemoveVideos] && !mIsService))
   399         {
   463         {
   400         	delete mToolbarActions[ETBActionAllVideos];
   464         	delete mToolbarActions[ETBActionAllVideos];
   401             delete mToolbarActions[ETBActionCollections];
   465             delete mToolbarActions[ETBActionCollections];
   402             delete mToolbarActions[ETBActionServices];
   466             delete mToolbarActions[ETBActionServices];
   403             delete mToolbarActions[ETBActionAddVideos];
   467             delete mToolbarActions[ETBActionAddVideos];
   404             delete mToolbarActions[ETBActionRemoveVideos];
   468             delete mToolbarActions[ETBActionRemoveVideos];
   405             delete mToolbarActions[ETBActionSortVideos];
       
   406         	return -1;
   469         	return -1;
   407         }
   470         }
   408 
   471 
   409         // Collection view actions are not checkable
   472         // Collection view actions are not checkable
   410         mToolbarActions[ETBActionAllVideos]->setCheckable(true);
   473         mToolbarActions[ETBActionAllVideos]->setCheckable(true);
   411         mToolbarActions[ETBActionCollections]->setCheckable(true);
   474         mToolbarActions[ETBActionCollections]->setCheckable(true);
   412 
   475 
   413         if (!mIsService)
   476         if (!mIsService)
   414         {
   477         {
   415         	mToolbarActions[ETBActionServices]->setCheckable(true);
   478         	mToolbarActions[ETBActionServices]->setCheckable(false);
   416         }
   479         }
   417 
   480 
   418         // Allvideos is checked at creation phase
   481         // Allvideos is checked at creation phase
   419         mToolbarActions[ETBActionAllVideos]->setChecked(true);
   482         mToolbarActions[ETBActionAllVideos]->setChecked(true);
   420 
   483 
   449 
   512 
   450     return action;
   513     return action;
   451 }
   514 }
   452 
   515 
   453 // ---------------------------------------------------------------------------
   516 // ---------------------------------------------------------------------------
       
   517 // loadHint
       
   518 // ---------------------------------------------------------------------------
       
   519 //
       
   520 void VideoListView::loadHint(bool doAsync)
       
   521 {
       
   522 	if(!mHintLoaded)
       
   523 	{
       
   524 		QSet<QString> uiItems;
       
   525 	    uiItems.insert(DOCML_NAME_VC_VIDEOHINTWIDGET);
       
   526 	    uiItems.insert(DOCML_NAME_HINT_BUTTON);
       
   527 	    uiItems.insert(DOCML_NAME_NO_VIDEOS_LABEL);
       
   528 		mUiLoader->startLoading(uiItems,
       
   529 			this,
       
   530 			SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
       
   531 			SLOT(objectReadySlot(QObject*, const QString&)));
       
   532 		uiItems.clear();
       
   533 
       
   534 		if(!doAsync)
       
   535 		{
       
   536 			HbPushButton* button = mUiLoader->findWidget<HbPushButton>(DOCML_NAME_HINT_BUTTON);
       
   537 		}
       
   538 		mHintLoaded = true;
       
   539 	}
       
   540 }
       
   541 
       
   542 // ---------------------------------------------------------------------------
   454 // showHint
   543 // showHint
   455 // ---------------------------------------------------------------------------
   544 // ---------------------------------------------------------------------------
   456 //
   545 //
   457 void VideoListView::showHint(bool show)
   546 void VideoListView::showHint(bool show)
   458 {
   547 {
   460     {
   549     {
   461         return;
   550         return;
   462     }
   551     }
   463 
   552 
   464     VideoSortFilterProxyModel &model = mCurrentList->getModel();
   553     VideoSortFilterProxyModel &model = mCurrentList->getModel();
       
   554 
       
   555     HbGroupBox *subLabel =
       
   556         mUiLoader->findWidget<HbGroupBox>(DOCML_NAME_VC_HEADINGBANNER);
       
   557 
       
   558     if((!mHintLoaded && !show) || (!mHintLoaded && model.rowCount() != 0))
       
   559     {
       
   560     	if(subLabel)
       
   561     	{
       
   562     		subLabel->show();
       
   563     	}
       
   564     	return;
       
   565     }
       
   566     else if(!mHintLoaded)
       
   567     {
       
   568     	loadHint(false);
       
   569     }
       
   570 
   465     VideoHintWidget *hintWidget =
   571     VideoHintWidget *hintWidget =
   466         mUiLoader->findWidget<VideoHintWidget>(
   572         mUiLoader->findWidget<VideoHintWidget>(
   467             DOCML_NAME_VC_VIDEOHINTWIDGET);
   573             DOCML_NAME_VC_VIDEOHINTWIDGET);
       
   574 
       
   575     if (hintWidget)
       
   576     {
       
   577         hintWidget->setLevel(mHintLevel);
       
   578     }
       
   579 
   468     if (mModelReady &&
   580     if (mModelReady &&
   469         model.rowCount() == 0 &&
   581         model.rowCount() == 0 &&
   470         hintWidget)
   582         hintWidget)
   471     {
   583     {
   472         show ? hintWidget->activate() : hintWidget->deactivate();
   584         show ? hintWidget->activate() : hintWidget->deactivate();
   481     {
   593     {
   482     	if(!mIsService)
   594     	if(!mIsService)
   483     	{
   595     	{
   484     		mToolbarActions[ETBActionRemoveVideos]->setVisible(false);
   596     		mToolbarActions[ETBActionRemoveVideos]->setVisible(false);
   485     	}
   597     	}
   486         mToolbarActions[ETBActionSortVideos]->setVisible(false);
       
   487 
       
   488         if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelDefaultColl) 
   598         if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelDefaultColl) 
   489         {
   599         {
   490         	if(!mIsService)
   600         	if(!mIsService)
   491         	{
   601         	{
   492         		mToolbarActions[ETBActionAddVideos]->setVisible(false);
   602         		mToolbarActions[ETBActionAddVideos]->setVisible(false);
   509 	        if(mToolbarActions[ETBActionAddVideos]->isVisible() == false) 
   619 	        if(mToolbarActions[ETBActionAddVideos]->isVisible() == false) 
   510 	        {
   620 	        {
   511 	            mToolbarActions[ETBActionAddVideos]->setVisible(true);
   621 	            mToolbarActions[ETBActionAddVideos]->setVisible(true);
   512 	        }
   622 	        }
   513     	}
   623     	}
   514         if(mToolbarActions[ETBActionSortVideos]->isVisible() == false) 
       
   515         {
       
   516             mToolbarActions[ETBActionSortVideos]->setVisible(true);
       
   517         }
       
   518         hintWidget->setButtonShown(true);
   624         hintWidget->setButtonShown(true);
   519     }
   625     }
   520     
   626     
   521     HbGroupBox *subLabel =
       
   522         mUiLoader->findWidget<HbGroupBox>(DOCML_NAME_VC_HEADINGBANNER);
       
   523     if (subLabel)
   627     if (subLabel)
   524     {
   628     {
   525         if (show &&
   629         if (show &&
   526             subLabel &&
   630             subLabel->isVisible() &&
   527             mCurrentList->getLevel() == VideoCollectionCommon::ELevelVideos)
   631             mCurrentList->getLevel() == VideoCollectionCommon::ELevelVideos)
   528         {
   632         {
   529             subLabel->hide();
   633             subLabel->hide();
   530         }
   634         }
   531         else
   635         else if (!subLabel->isVisible())
   532         {
   636         {
   533             subLabel->show();
   637             subLabel->show();
   534         }
   638         }
   535     }
   639     }
   536 }
   640 }
   539 // setHintLevel
   643 // setHintLevel
   540 // ---------------------------------------------------------------------------
   644 // ---------------------------------------------------------------------------
   541 //
   645 //
   542 void VideoListView::setHintLevel(VideoHintWidget::HintLevel level)
   646 void VideoListView::setHintLevel(VideoHintWidget::HintLevel level)
   543 {
   647 {
   544     VideoHintWidget *hintWidget =
   648 	mHintLevel = level;
   545         mUiLoader->findWidget<VideoHintWidget>(
       
   546             DOCML_NAME_VC_VIDEOHINTWIDGET);
       
   547     if (hintWidget)
       
   548     {
       
   549         hintWidget->setLevel(level);
       
   550     }
       
   551 }
   649 }
   552 
   650 
   553 // ---------------------------------------------------------------------------
   651 // ---------------------------------------------------------------------------
   554 // updateSubLabel
   652 // updateSubLabel
   555 // ---------------------------------------------------------------------------
   653 // ---------------------------------------------------------------------------
   578                 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
   676                 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
   579         
   677         
   580         HbGroupBox *subLabel = 
   678         HbGroupBox *subLabel = 
   581             mUiLoader->findWidget<HbGroupBox>(
   679             mUiLoader->findWidget<HbGroupBox>(
   582                 DOCML_NAME_VC_HEADINGBANNER);
   680                 DOCML_NAME_VC_HEADINGBANNER);
   583         
   681 
   584         if (mCurrentList == videoListWidget)
   682         if(subLabel)
   585         {
   683         {
   586             subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_videos", itemCount));
   684 			if (mCurrentList == videoListWidget)
   587         }
   685 			{
   588         else if (mCurrentList == collectionWidget)
   686 				subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_videos", itemCount));
   589         {
   687 			}
   590             subLabel->setHeading(hbTrId("txt_videos_subtitle_l1_collections", itemCount));
   688 			else if (mCurrentList == collectionWidget)
   591         }
   689 			{
   592         else if(mCurrentList == collectionContentWidget)
   690 				subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_collections", itemCount));
   593         {
   691 			}
   594             subLabel->setHeading(hbTrId("txt_videos_subtitle_1_l2").arg(mCollectionName).arg(itemCount));
   692 			else if(mCurrentList == collectionContentWidget)
   595         }  
   693 			{
       
   694 				subLabel->setHeading(hbTrId("txt_videos_subtitle_1_l2").arg(mCollectionName).arg(itemCount));
       
   695 			}
       
   696         }
   596     }
   697     }
   597 }
   698 }
   598 
   699 
   599 // ---------------------------------------------------------------------------
   700 // ---------------------------------------------------------------------------
   600 // showAction()
   701 // showAction()
   676 // openAllVideosViewSlot()
   777 // openAllVideosViewSlot()
   677 // ---------------------------------------------------------------------------
   778 // ---------------------------------------------------------------------------
   678 //
   779 //
   679 void VideoListView::openAllVideosViewSlot()
   780 void VideoListView::openAllVideosViewSlot()
   680 {
   781 {
       
   782 	if(!mListsLoaded)
       
   783 	{
       
   784 		loadLists(false);
       
   785 	}
       
   786 
   681     VideoListWidget *videoListWidget =
   787     VideoListWidget *videoListWidget =
   682         mUiLoader->findWidget<VideoListWidget>(
   788         mUiLoader->findWidget<VideoListWidget>(
   683             DOCML_NAME_VC_VIDEOLISTWIDGET);
   789             DOCML_NAME_VC_VIDEOLISTWIDGET);
       
   790     
   684     if (mCurrentList &&
   791     if (mCurrentList &&
   685         videoListWidget &&
   792         videoListWidget &&
   686         mCurrentList != videoListWidget)
   793         mCurrentList != videoListWidget)
   687     {
   794     {
   688         // deactivate old list
   795         // deactivate old list
   704 // openCollectionViewSlot()
   811 // openCollectionViewSlot()
   705 // ---------------------------------------------------------------------------
   812 // ---------------------------------------------------------------------------
   706 //
   813 //
   707 void VideoListView::openCollectionViewSlot()
   814 void VideoListView::openCollectionViewSlot()
   708 {
   815 {
       
   816 	if(!mListsLoaded)
       
   817 	{
       
   818 		loadLists(false);
       
   819 	}
       
   820 
   709     VideoListWidget *collectionWidget =
   821     VideoListWidget *collectionWidget =
   710         mUiLoader->findWidget<VideoListWidget>(
   822         mUiLoader->findWidget<VideoListWidget>(
   711             DOCML_NAME_VC_COLLECTIONWIDGET);
   823             DOCML_NAME_VC_COLLECTIONWIDGET);
       
   824     
   712     if (mCurrentList &&
   825     if (mCurrentList &&
   713         mCurrentList != collectionWidget)
   826         mCurrentList != collectionWidget)
   714     {
   827     {
   715         // deactivate all videos widget
   828         // deactivate all videos widget
   716         mCurrentList->deactivate();
   829         mCurrentList->deactivate();
   776             DOCML_NAME_OPTIONS_MENU);
   889             DOCML_NAME_OPTIONS_MENU);
   777     if (optionsMenu)
   890     if (optionsMenu)
   778     {
   891     {
   779         // get sorting role from active action
   892         // get sorting role from active action
   780         HbAction *action = optionsMenu->activeAction()->menu()->activeAction();
   893         HbAction *action = optionsMenu->activeAction()->menu()->activeAction();
   781         int role = mSortingRoles[action];
   894         if(action)
   782 
   895 		{
   783         // sort model
   896 			doSorting(mSortingRoles[action]);
   784         Qt::SortOrder order(Qt::AscendingOrder);
   897 		}
   785         VideoSortFilterProxyModel &model = mCurrentList->getModel();
   898     }
   786         if(model.sortRole() == role && model.sortOrder() == Qt::AscendingOrder)
   899 }
   787         {
   900 
   788             order = Qt::DescendingOrder;
   901 // ---------------------------------------------------------------------------
   789         }
   902 // doSorting()
   790         model.doSorting(role, order);
   903 // ---------------------------------------------------------------------------
   791 
   904 //
   792         // save sorting values
   905 void VideoListView::doSorting(int role)
   793         mUiUtils.saveSortingValues(role, order);
   906 {
   794     }    
   907 	// sort model
       
   908 	Qt::SortOrder order(Qt::AscendingOrder);
       
   909 	VideoSortFilterProxyModel &model = mCurrentList->getModel();
       
   910 	if(model.sortRole() == role && model.sortOrder() == Qt::AscendingOrder)
       
   911 	{
       
   912 		order = Qt::DescendingOrder;
       
   913 	}
       
   914 	model.doSorting(role, order);
       
   915 
       
   916 	// save sorting values
       
   917 	mUiUtils.saveSortingValues(role, order);
   795 }
   918 }
   796 
   919 
   797 // -------------------------------------------------------------------------------------------------
   920 // -------------------------------------------------------------------------------------------------
   798 // aboutToChangeOrientationSlot()
   921 // aboutToChangeOrientationSlot()
   799 // hide all items in the window during orientation change
   922 // hide all items in the window during orientation change
   826 {
   949 {
   827     if(!mCurrentList)
   950     if(!mCurrentList)
   828     {
   951     {
   829         return;
   952         return;
   830     }
   953     }
       
   954 
       
   955     if(!mMultiselectionLoaded)
       
   956     {
       
   957     	loadMultiSelection();
       
   958     }
       
   959 
   831     VideoListSelectionDialog *dialog =
   960     VideoListSelectionDialog *dialog =
   832         mUiLoader->findWidget<VideoListSelectionDialog>(
   961         mUiLoader->findWidget<VideoListSelectionDialog>(
   833             DOCML_NAME_DIALOG);
   962             DOCML_NAME_DIALOG);
   834     if (dialog)
   963     if (dialog)
   835     {
   964     {
   853     VideoSortFilterProxyModel &model = mCurrentList->getModel();
   982     VideoSortFilterProxyModel &model = mCurrentList->getModel();
   854 
   983 
   855     
   984     
   856     bool ok = false;
   985     bool ok = false;
   857     // query a name for the collection
   986     // query a name for the collection
   858     QString label(tr("Enter name:")); // TODO: localization missing!
   987     QString label(hbTrId("txt_videos_title_enter_name"));
   859     QString text(tr("New collection")); // TODO: localization missing!
   988     QString text(hbTrId("txt_videos_dialog_entry_new_collection"));
   860     text = HbInputDialog::getText(label, text, &ok);
   989     text = HbInputDialog::getText(label, text, &ok);
   861     if (ok && text.length())
   990     if (ok && text.length())
   862     {
   991     {
   863         // resolve collection true name and add new album
   992         // resolve collection true name and add new album
   864         text = model.resolveAlbumName(text);
   993         text = model.resolveAlbumName(text);
   883 {
  1012 {
   884     if(!mCurrentList)
  1013     if(!mCurrentList)
   885     {
  1014     {
   886         return;
  1015         return;
   887     }
  1016     }
   888     
  1017 
       
  1018     if(!mMultiselectionLoaded)
       
  1019     {
       
  1020     	loadMultiSelection();
       
  1021     }
       
  1022 
   889     VideoListSelectionDialog *dialog =
  1023     VideoListSelectionDialog *dialog =
   890         mUiLoader->findWidget<VideoListSelectionDialog>(
  1024         mUiLoader->findWidget<VideoListSelectionDialog>(
   891             DOCML_NAME_DIALOG);
  1025             DOCML_NAME_DIALOG);
   892     if (dialog)
  1026     if (!dialog)
   893     {
  1027     {
   894         if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelAlbum)
  1028         // fatal: no selection dialog
   895         {
  1029         return;
   896             // album is opened, do not proceed in case it already have same amount
  1030     }
   897             // of videos than all videos view.
  1031     if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelAlbum)
   898             VideoListWidget *allVideos = mUiLoader->findWidget<VideoListWidget>(
  1032     {
   899                         DOCML_NAME_VC_VIDEOLISTWIDGET);
  1033         // album is opened, do not proceed in case it already have same amount
   900             if(allVideos)
  1034         // of videos than all videos view.
       
  1035         VideoListWidget *allVideos = mUiLoader->findWidget<VideoListWidget>(
       
  1036                     DOCML_NAME_VC_VIDEOLISTWIDGET);
       
  1037         if(allVideos)
       
  1038         {
       
  1039             int count = allVideos->getModel().rowCount();
       
  1040             if(count == mCurrentList->getModel().rowCount())
   901             {
  1041             {
   902                 if(allVideos->getModel().rowCount() == mCurrentList->getModel().rowCount())
  1042                 if(count)
   903                 {
  1043                 {
   904                     QVariant emptyAdditional;
  1044                     QVariant emptyAdditional;
   905                     mUiUtils.showStatusMsgSlot(
  1045                     mUiUtils.showStatusMsgSlot(
   906                             VideoCollectionCommon::statusAllVideosAlreadyInCollection,
  1046                             VideoCollectionCommon::statusAllVideosAlreadyInCollection,
   907                             emptyAdditional);
  1047                             emptyAdditional);
   908                     return;
  1048                 }
   909                 }  
  1049                 return;
   910             }
  1050             }  
   911         }
  1051         }
   912         TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
  1052     }
   913         dialog->setupContent(VideoListSelectionDialog::EAddToCollection, collectionId);
  1053     TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
       
  1054     dialog->setupContent(VideoListSelectionDialog::EAddToCollection, collectionId);
       
  1055     dialog->exec();
       
  1056 }
       
  1057 
       
  1058 // -------------------------------------------------------------------------------------------------
       
  1059 // removeVideosFromCollectionSlot
       
  1060 // -------------------------------------------------------------------------------------------------
       
  1061 //
       
  1062 void VideoListView::removeVideosFromCollectionSlot()
       
  1063 {
       
  1064     if(!mCurrentList)
       
  1065     {
       
  1066         return;
       
  1067     }
       
  1068     // not allowed if for some reason current widget 
       
  1069     // is all videos or collection or there are no items
       
  1070     if(mCurrentList->getLevel() < VideoCollectionCommon::ELevelDefaultColl ||
       
  1071        !mCurrentList->getModel().rowCount())
       
  1072     {
       
  1073         return;
       
  1074     }
       
  1075 
       
  1076     if(!mMultiselectionLoaded)
       
  1077     {
       
  1078     	loadMultiSelection();
       
  1079     }
       
  1080 
       
  1081     VideoListSelectionDialog *dialog =
       
  1082             mUiLoader->findWidget<VideoListSelectionDialog>(
       
  1083                         DOCML_NAME_DIALOG);
       
  1084     if (!dialog)
       
  1085     {
       
  1086         // fatal: no selection dialog
       
  1087         return;
       
  1088     }
       
  1089     TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
       
  1090     if(collectionId != TMPXItemId::InvalidId() && collectionId.iId2 != KVcxMvcMediaTypeVideo)
       
  1091     {
       
  1092         dialog->setupContent(VideoListSelectionDialog::ERemoveFromCollection, collectionId);
   914         dialog->exec();
  1093         dialog->exec();
   915     }
  1094     }
   916 }
  1095 }
   917 
  1096 
   918 // -------------------------------------------------------------------------------------------------
  1097 // -------------------------------------------------------------------------------------------------
   933     showAction(false, DOCML_NAME_CREATE_COLLECTION);
  1112     showAction(false, DOCML_NAME_CREATE_COLLECTION);
   934     showAction(false, DOCML_NAME_DELETE_MULTIPLE);
  1113     showAction(false, DOCML_NAME_DELETE_MULTIPLE);
   935     showAction(false, DOCML_NAME_SORT_BY_DATE);
  1114     showAction(false, DOCML_NAME_SORT_BY_DATE);
   936     showAction(false, DOCML_NAME_SORT_BY_NAME);
  1115     showAction(false, DOCML_NAME_SORT_BY_NAME);
   937     showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
  1116     showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
   938     showAction(false, DOCML_NAME_SORT_BY_TOTAL_LENGTH);
       
   939     showAction(false, DOCML_NAME_SORT_BY_RATING);
  1117     showAction(false, DOCML_NAME_SORT_BY_RATING);
   940     showAction(false, DOCML_NAME_SORT_BY_SIZE);
  1118     showAction(false, DOCML_NAME_SORT_BY_SIZE);
   941     showAction(false, DOCML_NAME_SORT_MENU);
  1119     showAction(false, DOCML_NAME_SORT_MENU);
   942     
  1120     
   943     VideoSortFilterProxyModel &model = mCurrentList->getModel();
  1121     VideoSortFilterProxyModel &model = mCurrentList->getModel();
   956     if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionAllVideos] &&
  1134     if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionAllVideos] &&
   957        firstAction == mToolbarActions[ETBActionAllVideos])
  1135        firstAction == mToolbarActions[ETBActionAllVideos])
   958     {
  1136     {
   959         showAction(true, DOCML_NAME_SORT_MENU);
  1137         showAction(true, DOCML_NAME_SORT_MENU);
   960         showAction(true, DOCML_NAME_SORT_BY_DATE);
  1138         showAction(true, DOCML_NAME_SORT_BY_DATE);
   961         if (isActionChecked(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS) ||
  1139         if (isActionChecked(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS))
   962             isActionChecked(DOCML_NAME_SORT_BY_TOTAL_LENGTH)) 
       
   963         {
  1140         {
   964             //TODO: when changing between videos and categories, sorting order needs to be changed, if new
  1141             //TODO: when changing between videos and categories, sorting order needs to be changed, if new
   965             //      view does not have the previously active sorting order supported
  1142             //      view does not have the previously active sorting order supported
   966             showAction(true, DOCML_NAME_SORT_BY_DATE);
  1143             showAction(true, DOCML_NAME_SORT_BY_DATE);
   967         }
  1144         }
  1008                 action->setChecked(true);
  1185                 action->setChecked(true);
  1009             }
  1186             }
  1010         }
  1187         }
  1011         
  1188         
  1012         showAction(true, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
  1189         showAction(true, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
  1013         showAction(true, DOCML_NAME_SORT_BY_TOTAL_LENGTH);
       
  1014     }
  1190     }
  1015     else if(firstAction != mToolbarActions[ETBActionAllVideos])
  1191     else if(firstAction != mToolbarActions[ETBActionAllVideos])
  1016     {
  1192     {
  1017         //Add, Remove and Sort by will be launched from toolbar
  1193         showAction(true, DOCML_NAME_SORT_MENU);
       
  1194         showAction(true, DOCML_NAME_SORT_BY_DATE);
       
  1195         if (isActionChecked(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS))
       
  1196         {
       
  1197             //TODO: when changing between videos and categories, sorting order needs to be changed, if new
       
  1198             //      view does not have the previously active sorting order supported
       
  1199             showAction(true, DOCML_NAME_SORT_BY_DATE);
       
  1200         }
       
  1201         else
       
  1202         {
       
  1203             HbAction* action = mSortingRoles.key(role);
       
  1204             if (action)
       
  1205             {
       
  1206                 action->setChecked(true);
       
  1207             }
       
  1208         }
       
  1209 
       
  1210         showAction(true, DOCML_NAME_SORT_BY_NAME);
       
  1211         showAction(true, DOCML_NAME_SORT_BY_SIZE);
       
  1212 
  1018         if (!mIsService)
  1213         if (!mIsService)
  1019         {
  1214         {
  1020             showAction(true, DOCML_NAME_DELETE_MULTIPLE);
  1215             showAction(true, DOCML_NAME_DELETE_MULTIPLE);
  1021         }
  1216         }
  1022     }
  1217     }
  1038 //
  1233 //
  1039 void VideoListView::collectionOpenedSlot(bool collectionOpened,
  1234 void VideoListView::collectionOpenedSlot(bool collectionOpened,
  1040     const QString& collection,
  1235     const QString& collection,
  1041     const QModelIndex &index)
  1236     const QModelIndex &index)
  1042 {
  1237 {
  1043     if(!mToolbarCollectionActionGroup || !mToolbarViewsActionGroup || !mToolbarActions.contains(ETBActionCollections))
  1238 	if(mTransitionOngoing)
  1044     {
  1239 	{
  1045         return;
  1240 		return;
  1046     }
  1241 	}
  1047     
  1242 	else
       
  1243 	{
       
  1244 	    // clear toolbar actions.
       
  1245 	    toolBar()->clearActions();
       
  1246 	}
       
  1247 	
  1048     // update collection specific information
  1248     // update collection specific information
  1049     mCollectionName = collection;
  1249     mCollectionName = collection;
  1050 
  1250 
  1051     HbToolBar* bar = toolBar();
  1251     if(collectionOpened)
  1052     bar->clearActions();
       
  1053 
       
  1054     if (collectionOpened)
       
  1055     {
  1252     {
  1056         if(!index.isValid())
  1253         if(!index.isValid())
  1057         {   
  1254         {   
  1058             return;
  1255             return;
  1059         }
  1256         }
  1060 		
  1257         
  1061         // open album view
  1258         // open album view
  1062         VideoListWidget *collectionContentWidget =
  1259         VideoListWidget *collectionContentWidget =
  1063             mUiLoader->findWidget<VideoListWidget>(
  1260             mUiLoader->findWidget<VideoListWidget>(
  1064                 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
  1261                 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
       
  1262         
  1065         if (mCurrentList &&
  1263         if (mCurrentList &&
  1066             mCurrentList != collectionContentWidget)
  1264             mCurrentList != collectionContentWidget)
  1067         {
  1265         {
  1068             // get item id before deactivating
  1266             // get item id before deactivating
  1069             TMPXItemId itemId = TMPXItemId::InvalidId();
  1267             TMPXItemId itemId = TMPXItemId::InvalidId();
  1075                 itemId.iId2 != KVcxMvcMediaTypeAlbum))
  1273                 itemId.iId2 != KVcxMvcMediaTypeAlbum))
  1076             {
  1274             {
  1077                 return;
  1275                 return;
  1078             }
  1276             }
  1079             
  1277             
  1080             // deactivat current
  1278             // Send level that is opened with the effect.
  1081             mCurrentList->deactivate();
  1279             QVariant nextLevel;
  1082 			
       
  1083             // activate video collection content widget
       
  1084             mCurrentList = collectionContentWidget;
       
  1085             
       
  1086             if(itemId.iId2 ==  KVcxMvcMediaTypeCategory)
  1280             if(itemId.iId2 ==  KVcxMvcMediaTypeCategory)
  1087             {
  1281             {
  1088                 mCurrentList->activate(VideoCollectionCommon::ELevelDefaultColl);
  1282                 nextLevel = QVariant(VideoCollectionCommon::ELevelDefaultColl);
  1089             }
  1283             }
  1090             else if(itemId.iId2 == KVcxMvcMediaTypeAlbum)
  1284             else if(itemId.iId2 == KVcxMvcMediaTypeAlbum)
  1091             {
  1285             {
  1092                 mCurrentList->activate(VideoCollectionCommon::ELevelAlbum);
  1286                 nextLevel = QVariant(VideoCollectionCommon::ELevelAlbum);
  1093             }
  1287             }            
  1094             mCurrentList->getModel().openItem(itemId);
       
  1095             
  1288             
  1096             // update hint widget, but don't show yet
  1289             // Start fetching content.
  1097             setHintLevel(VideoHintWidget::Collection);
  1290             collectionContentWidget->getModel().openItem(itemId);
  1098             showHint(false);
       
  1099             
  1291             
  1100             // update toolbar
  1292             HbEffect::start(collectionContentWidget,
  1101             mToolbarActions[ETBActionCollections]->setChecked(false);
  1293                             EFFECT_SLIDE_IN_TO_LEFT,
  1102             bar->addActions(mToolbarCollectionActionGroup->actions());
  1294                             this,
       
  1295                             "finishCollectionOpenedSlot",
       
  1296                             nextLevel);
       
  1297             
       
  1298             mTransitionOngoing = true;
  1103         }
  1299         }
  1104     }
  1300     }
  1105     else
  1301     else
  1106     {
  1302     {
  1107         // open collection view
  1303         // open categories view.
  1108         openCollectionViewSlot();
  1304         VideoListWidget *collectionContentWidget =
  1109         
  1305             mUiLoader->findWidget<VideoListWidget>(
  1110         // update toolbar
  1306                 DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
  1111         bar->addActions(mToolbarViewsActionGroup->actions());
  1307         
       
  1308         HbEffect::start(collectionContentWidget,
       
  1309                         EFFECT_SLIDE_OUT_TO_LEFT,
       
  1310                         this,
       
  1311                         "finishCollectionClosedSlot");
       
  1312         
       
  1313         mTransitionOngoing = true;
       
  1314     }
       
  1315 }
       
  1316 
       
  1317 // -------------------------------------------------------------------------------------------------
       
  1318 // finishCollectionOpenedSlot
       
  1319 // -------------------------------------------------------------------------------------------------
       
  1320 //
       
  1321 void VideoListView::finishCollectionOpenedSlot(const HbEffect::EffectStatus &status)
       
  1322 {
       
  1323     Q_UNUSED(status);
       
  1324     
       
  1325     mTransitionOngoing = false;
       
  1326     
       
  1327     // deactivat current widget.
       
  1328     mCurrentList->deactivate();
       
  1329     
       
  1330     // activate video collection content widget.
       
  1331     mCurrentList = mUiLoader->findWidget<VideoListWidget>(
       
  1332                     DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
       
  1333 
       
  1334     if(!mCurrentList || !status.userData.isValid())
       
  1335     {
       
  1336         return;
       
  1337     }
       
  1338     
       
  1339     updateSubLabel();
       
  1340 
       
  1341     VideoCollectionCommon::TCollectionLevels level =
       
  1342             static_cast<VideoCollectionCommon::TCollectionLevels>(status.userData.toInt());
       
  1343     mCurrentList->activate(level);
       
  1344     
       
  1345     // update hint widget
       
  1346     setHintLevel(VideoHintWidget::Collection);
       
  1347     showHint();
       
  1348 
       
  1349     // update toolbar for albums, default categories don't have one.
       
  1350     if(level == VideoCollectionCommon::ELevelAlbum && 
       
  1351        mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections))
       
  1352     {
       
  1353         mToolbarActions[ETBActionCollections]->setChecked(false);
       
  1354         toolBar()->addActions(mToolbarCollectionActionGroup->actions());
       
  1355     }
       
  1356 }
       
  1357 
       
  1358 // -------------------------------------------------------------------------------------------------
       
  1359 // finishCollectionClosedSlot
       
  1360 // -------------------------------------------------------------------------------------------------
       
  1361 //
       
  1362 void VideoListView::finishCollectionClosedSlot(const HbEffect::EffectStatus &status)
       
  1363 {
       
  1364     Q_UNUSED(status);
       
  1365     
       
  1366     mTransitionOngoing = false;
       
  1367     
       
  1368     // open collection view
       
  1369     openCollectionViewSlot();
       
  1370     
       
  1371     // update toolbar
       
  1372     if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections))
       
  1373     {
       
  1374         toolBar()->addActions(mToolbarViewsActionGroup->actions());
  1112         mToolbarActions[ETBActionCollections]->setChecked(true);
  1375         mToolbarActions[ETBActionCollections]->setChecked(true);
  1113     }
  1376     }
  1114 }
  1377 }
  1115 
  1378 
  1116 // -------------------------------------------------------------------------------------------------
  1379 // -------------------------------------------------------------------------------------------------
  1117 // openSortByMenuSlot
       
  1118 // -------------------------------------------------------------------------------------------------
       
  1119 //
       
  1120 void VideoListView::openSortByMenuSlot()
       
  1121 {
       
  1122 	if(!mCurrentList)
       
  1123 	{
       
  1124 		return;
       
  1125 	}
       
  1126 	
       
  1127     VideoSortFilterProxyModel &model = mCurrentList->getModel();
       
  1128     if (!model.rowCount(QModelIndex()))
       
  1129     {
       
  1130         // no items, no menu
       
  1131         return;
       
  1132     }
       
  1133     
       
  1134     // hide all actions by default
       
  1135     showAction(false, DOCML_NAME_ADD_TO_COLLECTION);
       
  1136     showAction(false, DOCML_NAME_CREATE_COLLECTION);
       
  1137     showAction(false, DOCML_NAME_DELETE_MULTIPLE);
       
  1138     showAction(false, DOCML_NAME_SORT_BY_DATE);
       
  1139     showAction(false, DOCML_NAME_SORT_BY_NAME);
       
  1140     showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
       
  1141     showAction(false, DOCML_NAME_SORT_BY_TOTAL_LENGTH);
       
  1142     showAction(false, DOCML_NAME_SORT_BY_RATING);
       
  1143     showAction(false, DOCML_NAME_SORT_BY_SIZE);
       
  1144     showAction(false, DOCML_NAME_SORT_MENU);
       
  1145     
       
  1146     // if sort menu found, show all sort items
       
  1147     HbMenu *sortMenu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_SORT_MENU);
       
  1148     if (sortMenu)
       
  1149     {
       
  1150         // show actions
       
  1151         showAction(true, DOCML_NAME_SORT_MENU);
       
  1152         showAction(true, DOCML_NAME_SORT_BY_DATE);
       
  1153         showAction(true, DOCML_NAME_SORT_BY_NAME);
       
  1154         showAction(true, DOCML_NAME_SORT_BY_SIZE);
       
  1155 
       
  1156         // show sort menu
       
  1157         sortMenu->show();
       
  1158         
       
  1159         // execute sort menu
       
  1160         QPointF coords((size()/2).width(), (size()/3).height());
       
  1161         sortMenu->exec(coords);
       
  1162     }
       
  1163 }
       
  1164 
       
  1165 // -------------------------------------------------------------------------------------------------
       
  1166 // widgetReadySlot
  1380 // widgetReadySlot
  1167 // -------------------------------------------------------------------------------------------------
  1381 // -------------------------------------------------------------------------------------------------
  1168 //
  1382 //
  1169 void VideoListView::widgetReadySlot(QGraphicsWidget *widget, const QString &name)
  1383 void VideoListView::widgetReadySlot(QGraphicsWidget *widget, const QString &name)
  1170 {
  1384 {
  1171     if (name.compare(DOCML_NAME_VC_VIDEOLISTWIDGET) == 0)
  1385     if (name.compare(DOCML_NAME_VC_VIDEOLISTWIDGET) == 0)
  1172     {
  1386     {
  1173         connect(widget, SIGNAL(command(int)), this, SIGNAL(command(int)));
  1387         connect(widget, SIGNAL(command(int)), this, SIGNAL(command(int)));
       
  1388         connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
  1174     }
  1389     }
  1175     else if (name.compare(DOCML_NAME_VC_COLLECTIONWIDGET) == 0)
  1390     else if (name.compare(DOCML_NAME_VC_COLLECTIONWIDGET) == 0)
  1176     {
  1391     {
  1177         connect(
  1392         connect(
  1178             widget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)),
  1393             widget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)),
  1179             this, SLOT(collectionOpenedSlot(bool, const QString&, const QModelIndex&)));
  1394             this, SLOT(collectionOpenedSlot(bool, const QString&, const QModelIndex&)));
       
  1395             connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
       
  1396             emit(doDelayeds());
  1180     }
  1397     }
  1181     else if (name.compare(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) == 0)
  1398     else if (name.compare(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) == 0)
  1182     {
  1399     {
  1183         connect(widget, SIGNAL(command(int)), this, SIGNAL(command(int)));
  1400         connect(widget, SIGNAL(command(int)), this, SIGNAL(command(int)));
  1184         connect(
  1401         connect(
  1185             widget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)),
  1402             widget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)),
  1186             this, SLOT(collectionOpenedSlot(bool, const QString&, const QModelIndex&)));
  1403             this, SLOT(collectionOpenedSlot(bool, const QString&, const QModelIndex&)));
       
  1404             connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
       
  1405             emit(doDelayeds());
  1187     }
  1406     }
  1188     else if (name.compare(DOCML_NAME_OPTIONS_MENU) == 0)
  1407     else if (name.compare(DOCML_NAME_OPTIONS_MENU) == 0)
  1189     {
  1408     {
  1190         connect(
  1409         connect(
  1191             widget, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMainMenuSlot()));
  1410             widget, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMainMenuSlot()));
  1228         	// TODO: implement
  1447         	// TODO: implement
  1229             connect(action, SIGNAL(triggered()), this, SLOT(debugNotImplementedYet()));
  1448             connect(action, SIGNAL(triggered()), this, SLOT(debugNotImplementedYet()));
  1230             mSortingRoles[action] = 0;
  1449             mSortingRoles[action] = 0;
  1231         }
  1450         }
  1232     }
  1451     }
  1233     else if (name.compare(DOCML_NAME_SORT_BY_TOTAL_LENGTH) == 0)
  1452     else if (name.compare(DOCML_NAME_SORT_BY_SIZE) == 0)
  1234     {
  1453     {
  1235         HbAction *action = qobject_cast<HbAction*>(object);
  1454         HbAction *action = qobject_cast<HbAction*>(object);
  1236         if (action)
  1455         if (action)
  1237         {
  1456         {
  1238         	// TODO: implement
  1457         	connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
  1239             connect(action, SIGNAL(triggered()), this, SLOT(debugNotImplementedYet()));
  1458             mSortingRoles[action] = VideoCollectionCommon::KeySizeValue;
  1240             mSortingRoles[action] = 0;
  1459         }
  1241         }
  1460     }
  1242     }
  1461     else if (name.compare(DOCML_NAME_ADD_TO_COLLECTION) == 0)
  1243     else if (name.compare(DOCML_NAME_SORT_BY_SIZE) == 0)
       
  1244     {
  1462     {
  1245         HbAction *action = qobject_cast<HbAction*>(object);
  1463         HbAction *action = qobject_cast<HbAction*>(object);
  1246         if (action)
  1464         if (action)
  1247         {
  1465         {
  1248         	connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
  1466             connect(action, SIGNAL(triggered()), this, SLOT(addVideosToCollectionSlot()));
  1249             mSortingRoles[action] = VideoCollectionCommon::KeySizeValue;
  1467         }
  1250         }
  1468     }
  1251     }
  1469     else if (name.compare(DOCML_NAME_CREATE_COLLECTION) == 0)
  1252     else if (name.compare(DOCML_NAME_ADD_TO_COLLECTION) == 0)
       
  1253     {
  1470     {
  1254         HbAction *action = qobject_cast<HbAction*>(object);
  1471         HbAction *action = qobject_cast<HbAction*>(object);
  1255         if (action)
  1472         if (action)
  1256         {
  1473         {
  1257             connect(action, SIGNAL(triggered()), this, SLOT(addVideosToCollectionSlot()));
  1474             connect(action, SIGNAL(triggered()), this, SLOT(createCollectionSlot()));
  1258         }
  1475         }
  1259     }
  1476     }
  1260     else if (name.compare(DOCML_NAME_CREATE_COLLECTION) == 0)
  1477     else if (name.compare(DOCML_NAME_DELETE_MULTIPLE) == 0)
  1261     {
  1478     {
  1262         HbAction *action = qobject_cast<HbAction*>(object);
  1479         HbAction *action = qobject_cast<HbAction*>(object);
  1263         if (action)
  1480         if (action)
  1264         {
  1481         {
  1265             connect(action, SIGNAL(triggered()), this, SLOT(createCollectionSlot()));
       
  1266         }
       
  1267     }
       
  1268     else if (name.compare(DOCML_NAME_DELETE_MULTIPLE) == 0)
       
  1269     {
       
  1270         HbAction *action = qobject_cast<HbAction*>(object);
       
  1271         if (action)
       
  1272         {
       
  1273             connect(action, SIGNAL(triggered()), this, SLOT(deleteItemsSlot()));
  1482             connect(action, SIGNAL(triggered()), this, SLOT(deleteItemsSlot()));
  1274         }
  1483         }
  1275     }
  1484     }
  1276 }
  1485 }
  1277 
  1486