videocollection/videocollectionview/src/videolistview.cpp
changeset 66 adb51f74b890
parent 63 4707a0db12f6
child 67 72c709219fcd
equal deleted inserted replaced
63:4707a0db12f6 66:adb51f74b890
    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.13 %
    18 // Version : %version: 113.1.15 %
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <hbinstance.h>
    21 #include <hbinstance.h>
    22 #include <hbmainwindow.h>
    22 #include <hbmainwindow.h>
    23 #include <hbtoolbar.h>
    23 #include <hbtoolbar.h>
    24 #include <hbaction.h>
    24 #include <hbaction.h>
    25 #include <hbmenu.h>
    25 #include <hbmenu.h>
    26 #include <hbgroupbox.h>
    26 #include <hbgroupbox.h>
    27 #include <hbparameterlengthlimiter.h>
    27 #include <hbparameterlengthlimiter.h>
    28 #include <hbtoolbarextension.h>
    28 #include <hbtoolbarextension.h>
       
    29 #include <hblabel.h> 
    29 #include <xqaiwdecl.h>
    30 #include <xqaiwdecl.h>
    30 #include <vcxmyvideosdefs.h>
    31 #include <vcxmyvideosdefs.h>
    31 
    32 
    32 #include "videoservices.h"
    33 #include "videoservices.h"
    33 #include "videocollectionviewutils.h"
    34 #include "videocollectionviewutils.h"
    34 #include "videolistwidget.h"
    35 #include "videolistwidget.h"
    35 #include "videohintwidget.h"
       
    36 #include "videolistview.h"
    36 #include "videolistview.h"
    37 #include "videolisttoolbar.h"
    37 #include "videolisttoolbar.h"
    38 #include "videolistmenu.h"
    38 #include "videolistmenu.h"
    39 #include "videocollectioncommon.h"
    39 #include "videocollectioncommon.h"
    40 #include "videocollectionwrapper.h"
    40 #include "videocollectionwrapper.h"
    56     , mUiLoader(uiLoader)
    56     , mUiLoader(uiLoader)
    57     , mToolbar(0)
    57     , mToolbar(0)
    58     , mMenu(0)
    58     , mMenu(0)
    59     , mModelReady(false)
    59     , mModelReady(false)
    60     , mViewReady(false)
    60     , mViewReady(false)
    61     , mHintLevel(VideoHintWidget::AllVideos)
       
    62     , mVideoServices(0)
    61     , mVideoServices(0)
    63     , mCurrentList(0)
    62     , mCurrentList(0)
    64 {
    63 {
    65 	FUNC_LOG;
    64 	FUNC_LOG;
    66 }
    65 }
   166         DOCML_NAME_DIALOG,
   165         DOCML_NAME_DIALOG,
   167         DOCML_VIDEOSELECTIONDIALOG_FILE,
   166         DOCML_VIDEOSELECTIONDIALOG_FILE,
   168         true,
   167         true,
   169         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   168         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   170     params.append(VideoCollectionUiLoaderParam(
   169     params.append(VideoCollectionUiLoaderParam(
   171         DOCML_NAME_VC_VIDEOHINTWIDGET,
   170         DOCML_NAME_NO_CONTENT_LABEL,
   172         DOCML_VIDEOCOLLECTIONVIEW_FILE,
   171         DOCML_VIDEOCOLLECTIONVIEW_FILE,
   173         DOCML_VIDEOCOLLECTIONVIEW_SECTION_HINT,
       
   174         true,
       
   175         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   176     params.append(VideoCollectionUiLoaderParam(
       
   177         DOCML_NAME_HINT_BUTTON,
       
   178         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   179         DOCML_VIDEOCOLLECTIONVIEW_SECTION_HINT,
       
   180         true,
       
   181         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
       
   182     params.append(VideoCollectionUiLoaderParam(
       
   183         DOCML_NAME_NO_VIDEOS_LABEL,
       
   184         DOCML_VIDEOCOLLECTIONVIEW_FILE,
       
   185         DOCML_VIDEOCOLLECTIONVIEW_SECTION_HINT,
       
   186         true,
   172         true,
   187         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   173         VideoCollectionUiLoaderParam::LoadPhaseSecondary));
   188     mUiLoader->addData(params,
   174     mUiLoader->addData(params,
   189         this,
   175         this,
   190         SLOT(objectReadySlot(QObject*, const QString&)));
   176         SLOT(objectReadySlot(QObject*, const QString&)));
   510             return -1;
   496             return -1;
   511         }
   497         }
   512         
   498         
   513         mToolbar->initialize();
   499         mToolbar->initialize();
   514         mToolbar->viewStateChanged(mCurrentList->getLevel(), true, false);
   500         mToolbar->viewStateChanged(mCurrentList->getLevel(), true, false);
   515         
       
   516         // make sure that the hint widget's button is connected, and connected only once.
       
   517         QObject *hintButton =
       
   518             mUiLoader->findObject<QObject>(
       
   519                 DOCML_NAME_HINT_BUTTON, false);
       
   520         
       
   521         if(hintButton)
       
   522         {
       
   523             connect(hintButton, SIGNAL(clicked(bool)), 
       
   524                 mToolbar, SLOT(openOperatorServiceSlot()), 
       
   525                 Qt::UniqueConnection);
       
   526         }
       
   527         // note that if hintButton is not found, then it's connected in objectReadySlot.
       
   528     }
   501     }
   529 
   502 
   530     return 0;
   503     return 0;
   531 }
   504 }
   532 
   505 
   549         return;
   522         return;
   550     }
   523     }
   551     
   524     
   552     mModelReady = true;
   525     mModelReady = true;
   553     
   526     
   554     // decide if the hintwidget needs to be shown or not.
   527     // decide if no content label needs to be shown or not.
   555     show = show && model->rowCount() == 0;
   528     show = show && model->rowCount() == 0;
   556     
   529 
   557     // If show is false, then hint widget is fetched only if it exists. If
   530     // set visibility for the label.
   558     // show is true then hint widget is also created and prepared if it does not exists.
   531     HbLabel *noContentLabel =
   559     VideoHintWidget *hintWidget =
   532         mUiLoader->findWidget<HbLabel>(
   560         mUiLoader->findWidget<VideoHintWidget>(
   533             DOCML_NAME_NO_CONTENT_LABEL);
   561             DOCML_NAME_VC_VIDEOHINTWIDGET, show);
   534     if (noContentLabel)
   562     
   535     {
   563     if (hintWidget)
   536         noContentLabel->setVisible(show);
   564     {
       
   565         hintWidget->setLevel(mHintLevel);
       
   566         if (show)
       
   567         {
       
   568             hintWidget->activate();
       
   569             bool showHintBtns = (mCurrentList->getLevel() != VideoCollectionCommon::ELevelDefaultColl); 
       
   570             hintWidget->setButtonShown(showHintBtns);
       
   571         }
       
   572         else
       
   573         {
       
   574             hintWidget->deactivate();
       
   575             hintWidget->setButtonShown(true);
       
   576         }
       
   577     }
   537     }
   578 
   538 
   579     mToolbar->viewStateChanged(mCurrentList->getLevel(), show, mModelReady);
   539     mToolbar->viewStateChanged(mCurrentList->getLevel(), show, mModelReady);
   580     
   540     
   581     // prepare sublabel
   541     // prepare sublabel
   595         }
   555         }
   596     }
   556     }
   597 }
   557 }
   598 
   558 
   599 // ---------------------------------------------------------------------------
   559 // ---------------------------------------------------------------------------
   600 // setHintLevel
       
   601 // ---------------------------------------------------------------------------
       
   602 //
       
   603 void VideoListView::setHintLevel(VideoHintWidget::HintLevel level)
       
   604 {
       
   605 	FUNC_LOG;
       
   606 	mHintLevel = level;
       
   607 }
       
   608 
       
   609 // ---------------------------------------------------------------------------
       
   610 // updateSubLabel
   560 // updateSubLabel
   611 // ---------------------------------------------------------------------------
   561 // ---------------------------------------------------------------------------
   612 //
   562 //
   613 void VideoListView::updateSubLabel()
   563 void VideoListView::updateSubLabel()
   614 {
   564 {
   629 
   579 
   630         if(subLabel && mCurrentList)
   580         if(subLabel && mCurrentList)
   631         {
   581         {
   632 			if (mCurrentList->getLevel() == VideoCollectionCommon::ELevelVideos)
   582 			if (mCurrentList->getLevel() == VideoCollectionCommon::ELevelVideos)
   633 			{
   583 			{
   634 			    // no need to update sublabel if there are no items in videolist
   584 			    // no need to update sublabel if there are no items in videolist.
   635 			    // hint widget is shown instead
   585 			    // no content label is shown instead.
   636 			    if (itemCount)
   586 			    if (itemCount)
   637 			    {
   587 			    {
   638 	                subLabel->setHeading(hbTrId("txt_videos_subtitle_all_videos_ln", itemCount));
   588 	                subLabel->setHeading(hbTrId("txt_videos_subtitle_all_videos_l1", itemCount));
   639 			    }
   589 			    }
   640 			}
   590 			}
   641 			else if (mCurrentList->getLevel() == VideoCollectionCommon::ELevelCategory)
   591 			else if (mCurrentList->getLevel() == VideoCollectionCommon::ELevelCategory)
   642 			{
   592 			{
   643 				subLabel->setHeading(hbTrId("txt_videos_subtitle_collections_ln", itemCount));
   593 				subLabel->setHeading(hbTrId("txt_videos_subtitle_collections_l1", itemCount));
   644 			}
   594 			}
   645 			else
   595 			else
   646 			{
   596 			{
   647 				QString text = HbParameterLengthLimiter(hbTrId("txt_videos_subtitle_1_l2")).arg(mCollectionName).arg(itemCount);
   597 				QString text = HbParameterLengthLimiter(hbTrId("txt_videos_subtitle_1_l2")).arg(mCollectionName).arg(itemCount);
   648 				subLabel->setHeading(text);
   598 				subLabel->setHeading(text);
   772         mCurrentList->deactivate();
   722         mCurrentList->deactivate();
   773         
   723         
   774         // activate all videos list
   724         // activate all videos list
   775         mCurrentList = videoListWidget;
   725         mCurrentList = videoListWidget;
   776         mCurrentList->activate(VideoCollectionCommon::ELevelVideos);
   726         mCurrentList->activate(VideoCollectionCommon::ELevelVideos);
   777 
       
   778         setHintLevel(VideoHintWidget::AllVideos);
       
   779         
   727         
   780         // update the sublabel, as in most cases the data is already up to date.
   728         // update the sublabel, as in most cases the data is already up to date.
   781         updateSubLabel();
   729         updateSubLabel();
   782     }
   730     }
   783 }
   731 }
   914         mCurrentList = collectionContentWidget;
   862         mCurrentList = collectionContentWidget;
   915         mCurrentList->activate(level);
   863         mCurrentList->activate(level);
   916 
   864 
   917         updateSubLabel();
   865         updateSubLabel();
   918         
   866         
   919         // update hint widget for correct content
       
   920         mModelReady = model->rowCount() > 0;
   867         mModelReady = model->rowCount() > 0;
   921         setHintLevel(VideoHintWidget::Collection);
   868 
   922         
       
   923         if(mToolbar)
   869         if(mToolbar)
   924         {
   870         {
   925             // if toolbar not yet created, it means that we're activating
   871             // if toolbar not yet created, it means that we're activating
   926             // for the startup, toolbar will be updated during modelReady()
   872             // for the startup, toolbar will be updated during modelReady()
   927             mToolbar->viewStateChanged(level, false, mModelReady);
   873             mToolbar->viewStateChanged(level, false, mModelReady);
   984             // this widget not yet activated so it's has been created on the second phase
   930             // this widget not yet activated so it's has been created on the second phase
   985             // safe to call doDelayed right away
   931             // safe to call doDelayed right away
   986             qobject_cast<VideoListWidget*>(object)->doDelayedsSlot();
   932             qobject_cast<VideoListWidget*>(object)->doDelayedsSlot();
   987         }        
   933         }        
   988     }
   934     }
   989     else if (name.compare(DOCML_NAME_HINT_BUTTON) == 0)
       
   990     {
       
   991         connect(object, SIGNAL(clicked(bool)), mToolbar, SLOT(openOperatorServiceSlot()));
       
   992     }
       
   993 }
   935 }
   994 
   936 
   995 // -------------------------------------------------------------------------------------------------
   937 // -------------------------------------------------------------------------------------------------
   996 // toolbarActionsChanged
   938 // toolbarActionsChanged
   997 // -------------------------------------------------------------------------------------------------
   939 // -------------------------------------------------------------------------------------------------