videocollection/videocollectionview/src/videolistview.cpp
changeset 62 0e1e938beb1a
parent 59 a76e86df7ccd
child 65 a9d57bd8d7b7
equal deleted inserted replaced
59:a76e86df7ccd 62:0e1e938beb1a
    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.5 %
    18 // Version : %version: 113.1.8 %
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <xqserviceutil.h>
       
    22 #include <qactiongroup.h>
    21 #include <qactiongroup.h>
    23 #include <hbinstance.h>
    22 #include <hbinstance.h>
    24 #include <hbmainwindow.h>
    23 #include <hbmainwindow.h>
    25 #include <hbmessagebox.h>
    24 #include <hbmessagebox.h>
    26 #include <hbstackedwidget.h>
    25 #include <hbstackedwidget.h>
    42 #include "videolistwidget.h"
    41 #include "videolistwidget.h"
    43 #include "videohintwidget.h"
    42 #include "videohintwidget.h"
    44 #include "videolistview.h"
    43 #include "videolistview.h"
    45 #include "videocollectioncommon.h"
    44 #include "videocollectioncommon.h"
    46 #include "videocollectionwrapper.h"
    45 #include "videocollectionwrapper.h"
    47 #include "videosortfilterproxymodel.h"
    46 #include "videoproxymodelgeneric.h"
    48 #include "videocollectionuiloader.h"
    47 #include "videocollectionuiloader.h"
    49 #include "mpxhbvideocommondefs.h"
    48 #include "mpxhbvideocommondefs.h"
    50 #include "videooperatorservice.h"
    49 #include "videooperatorservice.h"
    51 #include "videocollectioncenrepdefs.h"
    50 #include "videocollectioncenrepdefs.h"
    52 #include "videocollectiontrace.h"
    51 #include "videocollectiontrace.h"
   121 	}
   120 	}
   122 	int videoListPhase = VideoCollectionUiLoaderParam::LoadPhasePrimary;
   121 	int videoListPhase = VideoCollectionUiLoaderParam::LoadPhasePrimary;
   123 	int collectionListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
   122 	int collectionListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
   124 	int collectionContentListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
   123 	int collectionContentListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
   125 	VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
   124 	VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
   126     if (XQServiceUtil::isService())
   125     if (mUiUtils.isService())
   127     {
   126     {
   128         INFO("VideoListView::initializeView() initializing service.");
   127         INFO("VideoListView::initializeView() initializing service.");
   129     	if (!mVideoServices)
   128     	if (!mVideoServices)
   130         {
   129         {
   131     	    mVideoServices = VideoServices::instance();
   130     	    mVideoServices = VideoServices::instance();
   606             bar->addActions(mToolbarViewsActionGroup->actions());
   605             bar->addActions(mToolbarViewsActionGroup->actions());
   607         }
   606         }
   608         else if(level == VideoCollectionCommon::ELevelAlbum) 
   607         else if(level == VideoCollectionCommon::ELevelAlbum) 
   609         {
   608         {
   610             bar->addActions(mToolbarCollectionActionGroup->actions());
   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             }
   611         }
   617         }
   612 
   618 
   613         if(mToolbarServiceExtension && (level == VideoCollectionCommon::ELevelCategory 
   619         if(mToolbarServiceExtension && (level == VideoCollectionCommon::ELevelCategory 
   614            || level == VideoCollectionCommon::ELevelVideos))
   620            || level == VideoCollectionCommon::ELevelVideos))
   615         {
   621         {
   736     if(!mCurrentList)
   742     if(!mCurrentList)
   737     {
   743     {
   738         return;
   744         return;
   739     }
   745     }
   740 
   746 
   741     VideoSortFilterProxyModel *model = mCurrentList->getModel();
   747     VideoProxyModelGeneric *model = mCurrentList->getModel();
   742     
   748     
   743     if(!model || (!mModelReady && model->rowCount() == 0))
   749     if(!model || (!mModelReady && model->rowCount() == 0))
   744     {
   750     {
   745         return;
   751         return;
   746     }
   752     }
   772         }
   778         }
   773     }
   779     }
   774 
   780 
   775     if (mToolbarViewsActionGroup && mToolbarCollectionActionGroup && !mVideoServices)
   781     if (mToolbarViewsActionGroup && mToolbarCollectionActionGroup && !mVideoServices)
   776     {
   782     {
       
   783         mToolbarActions[ETBActionAddVideos]->setVisible(true);
   777         if (show)
   784         if (show)
   778         {
   785         {
   779         	mToolbarActions[ETBActionRemoveVideos]->setVisible(false);
   786         	mToolbarActions[ETBActionRemoveVideos]->setVisible(false);
   780         }
   787         }
   781         else if(mToolbarActions[ETBActionRemoveVideos]->isVisible() == false)
   788         else if(mToolbarActions[ETBActionRemoveVideos]->isVisible() == false)
   817 // ---------------------------------------------------------------------------
   824 // ---------------------------------------------------------------------------
   818 //
   825 //
   819 void VideoListView::updateSubLabel()
   826 void VideoListView::updateSubLabel()
   820 {
   827 {
   821 	FUNC_LOG;
   828 	FUNC_LOG;
   822     VideoSortFilterProxyModel *model = 0;
   829     VideoProxyModelGeneric *model = 0;
   823     if(mCurrentList)
   830     if(mCurrentList)
   824     {
   831     {
   825         model = mCurrentList->getModel(); 
   832         model = mCurrentList->getModel(); 
   826     }
   833     }
   827     
   834     
  1094 	    // no list or model, cannot sort
  1101 	    // no list or model, cannot sort
  1095 	    return;
  1102 	    return;
  1096 	}
  1103 	}
  1097 	// sort model
  1104 	// sort model
  1098 	Qt::SortOrder order(Qt::AscendingOrder);
  1105 	Qt::SortOrder order(Qt::AscendingOrder);
  1099 	VideoSortFilterProxyModel *model = mCurrentList->getModel();
  1106 	VideoProxyModelGeneric *model = mCurrentList->getModel();
  1100 	if(model->sortRole() == role && model->sortOrder() == Qt::AscendingOrder)
  1107 	if(model->sortRole() == role && model->sortOrder() == Qt::AscendingOrder)
  1101 	{
  1108 	{
  1102 		order = Qt::DescendingOrder;
  1109 		order = Qt::DescendingOrder;
  1103 	}
  1110 	}
  1104 	model->doSorting(role, order);
  1111 	model->doSorting(role, order);
  1317     {
  1324     {
  1318         showAction(true, DOCML_NAME_CREATE_COLLECTION);
  1325         showAction(true, DOCML_NAME_CREATE_COLLECTION);
  1319     }
  1326     }
  1320     
  1327     
  1321     //  No other actions shown if there's no videos.
  1328     //  No other actions shown if there's no videos.
  1322     VideoSortFilterProxyModel *model = mCurrentList->getModel();
  1329     VideoProxyModelGeneric *model = mCurrentList->getModel();
  1323     if (!model || !model->rowCount())
  1330     if (!model || !model->rowCount())
  1324     {
  1331     {
  1325         return;
  1332         return;
  1326     }
  1333     }
  1327     
  1334     
  1401     showAction(false, DOCML_NAME_SORT_BY_NAME);
  1408     showAction(false, DOCML_NAME_SORT_BY_NAME);
  1402     showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
  1409     showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
  1403     showAction(false, DOCML_NAME_SORT_BY_SIZE);
  1410     showAction(false, DOCML_NAME_SORT_BY_SIZE);
  1404     showAction(false, DOCML_NAME_SORT_MENU);
  1411     showAction(false, DOCML_NAME_SORT_MENU);
  1405     
  1412     
  1406     VideoSortFilterProxyModel *model = mCurrentList->getModel();
  1413     VideoProxyModelGeneric *model = mCurrentList->getModel();
  1407     if (!model || !model->rowCount())
  1414     if (!model || !model->rowCount())
  1408     {
  1415     {
  1409         return;
  1416         return;
  1410     }
  1417     }
  1411     
  1418     
  1480         else 
  1487         else 
  1481         {
  1488         {
  1482             return;
  1489             return;
  1483         }
  1490         }
  1484                 
  1491                 
  1485         VideoSortFilterProxyModel *model = collectionContentWidget->getModel();
  1492         VideoProxyModelGeneric *model = collectionContentWidget->getModel();
  1486         if(!model)
  1493         if(!model)
  1487         {
  1494         {
  1488             // no model for content widget, cannot activate
  1495             // no model for content widget, cannot activate
  1489             return;
  1496             return;
  1490         }
  1497         }
  1510         
  1517         
  1511         // update hint widget for correct content
  1518         // update hint widget for correct content
  1512         mModelReady = model->rowCount() > 0;
  1519         mModelReady = model->rowCount() > 0;
  1513         setHintLevel(VideoHintWidget::Collection);
  1520         setHintLevel(VideoHintWidget::Collection);
  1514 
  1521 
  1515         // update toolbar for albums, default categories don't have one. Neither does services.
  1522         if(mToolbarCollectionActionGroup)
  1516         toolBar()->clearActions();
  1523         {
  1517         if(!mVideoServices && level == VideoCollectionCommon::ELevelAlbum && 
  1524             // update toolbar for albums, default categories don't have one. Neither does services.
  1518            mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections))
  1525             toolBar()->clearActions();
  1519         {
  1526             if(!mVideoServices && level == VideoCollectionCommon::ELevelAlbum && 
  1520             mToolbarActions[ETBActionCollections]->setChecked(false);
  1527                 mToolbarActions.contains(ETBActionCollections))
  1521             toolBar()->addActions(mToolbarCollectionActionGroup->actions());
  1528             {
  1522             setItemVisible(Hb::ToolBarItem, true);
  1529                 mToolbarActions[ETBActionCollections]->setChecked(false);
  1523         }
  1530                 toolBar()->addActions(mToolbarCollectionActionGroup->actions());
  1524         else
  1531                 setItemVisible(Hb::ToolBarItem, true);
  1525         {
  1532             }
  1526             setItemVisible(Hb::ToolBarItem, false);
  1533             else
       
  1534             {
       
  1535                 setItemVisible(Hb::ToolBarItem, false);
       
  1536             }
  1527         }
  1537         }
  1528         // restore animations for collection content widget
  1538         // restore animations for collection content widget
  1529         collectionContentWidget->setEnabledAnimations(animationState);
  1539         collectionContentWidget->setEnabledAnimations(animationState);
  1530     }
  1540     }
  1531     else
  1541     else