videocollection/videocollectionview/src/videocollectionuiloader.cpp
changeset 24 7d93ee07fb27
parent 20 b9e04db066d4
child 28 c48470be1ba7
equal deleted inserted replaced
20:b9e04db066d4 24:7d93ee07fb27
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 21 %
    18 // Version : %version: 22 %
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <qgraphicswidget.h>
    21 #include <qgraphicswidget.h>
    22 #include <qaction.h>
    22 #include <qaction.h>
    23 #include <qactiongroup.h>
    23 #include <qactiongroup.h>
   197 
   197 
   198 // ---------------------------------------------------------------------------
   198 // ---------------------------------------------------------------------------
   199 // doFindWidget
   199 // doFindWidget
   200 // ---------------------------------------------------------------------------
   200 // ---------------------------------------------------------------------------
   201 //
   201 //
   202 QGraphicsWidget* VideoCollectionUiLoader::doFindWidget(const QString &name)
   202 QGraphicsWidget* VideoCollectionUiLoader::doFindWidget(const QString &name, bool loadIfNotFound)
   203 {
   203 {
   204 	FUNC_LOG;
   204 	FUNC_LOG;
   205     QGraphicsWidget *widget = 0;
   205     QGraphicsWidget *widget = 0;
   206     
   206     
   207     // 1. check from hash
   207     // 1. check from hash
   209     {
   209     {
   210         widget = qobject_cast<QGraphicsWidget*>(mObjects.value(name));
   210         widget = qobject_cast<QGraphicsWidget*>(mObjects.value(name));
   211     }
   211     }
   212 
   212 
   213     // 2. load from document and initialize
   213     // 2. load from document and initialize
   214     else
   214     else if (loadIfNotFound)
   215     {
   215     {
   216         // find object from queue
   216         // find object from queue
   217         int index = indexInQueue(name);
   217         int index = indexInQueue(name);
   218         if (index != -1)
   218         if (index != -1)
   219         {
   219         {
   236 
   236 
   237 // ---------------------------------------------------------------------------
   237 // ---------------------------------------------------------------------------
   238 // doFindObject
   238 // doFindObject
   239 // ---------------------------------------------------------------------------
   239 // ---------------------------------------------------------------------------
   240 //
   240 //
   241 QObject* VideoCollectionUiLoader::doFindObject(const QString &name)
   241 QObject* VideoCollectionUiLoader::doFindObject(const QString &name, bool loadIfNotFound)
   242 {
   242 {
   243 	FUNC_LOG;
   243 	FUNC_LOG;
   244     QObject *object = 0;
   244     QObject *object = 0;
   245     
   245     
   246     // 1. check from hash
   246     // 1. check from hash
   248     {
   248     {
   249         object = mObjects.value(name);
   249         object = mObjects.value(name);
   250     }
   250     }
   251 
   251 
   252     // 2. load from document and initialize
   252     // 2. load from document and initialize
   253     else
   253     else if (loadIfNotFound)
   254     {
   254     {
   255         // find object from queue
   255         // find object from queue
   256         int index = indexInQueue(name);
   256         int index = indexInQueue(name);
   257         if (index != -1)
   257         if (index != -1)
   258         {
   258         {
   371             {
   371             {
   372                 VideoSortFilterProxyModel *model =
   372                 VideoSortFilterProxyModel *model =
   373                     wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos);
   373                     wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos);
   374                 if(model)
   374                 if(model)
   375                 {
   375                 {
   376                     // open and sort model
   376                 	VideoCollectionViewUtils::sortModel(model, true, VideoCollectionCommon::ELevelVideos);
   377                     model->open(VideoCollectionCommon::ELevelVideos);
   377                 	
   378                     VideoCollectionViewUtils::sortModel(model, true, VideoCollectionCommon::ELevelVideos);
       
   379                     
       
   380                     // init widget
   378                     // init widget
   381                     VideoServices *videoServices = 0;
   379                     VideoServices *videoServices = 0;
   382                     if (mIsService)
   380                     if (mIsService)
   383                     {
   381                     {
   384                         videoServices = VideoServices::instance();
   382                         videoServices = VideoServices::instance();
   391         {
   389         {
   392             VideoSortFilterProxyModel *model = wrapper.getModel(
   390             VideoSortFilterProxyModel *model = wrapper.getModel(
   393             		VideoCollectionCommon::EModelTypeCollections);
   391             		VideoCollectionCommon::EModelTypeCollections);
   394             if (model)
   392             if (model)
   395             {
   393             {
   396                 model->open(VideoCollectionCommon::ELevelCategory);
       
   397                 VideoCollectionViewUtils::sortModel(model, true, VideoCollectionCommon::ELevelCategory);
   394                 VideoCollectionViewUtils::sortModel(model, true, VideoCollectionCommon::ELevelCategory);
   398 
   395                 
   399                 // initialize video collection widget
   396                 // initialize video collection widget
   400                 VideoListWidget *videoList =
   397                 VideoListWidget *videoList =
   401                     qobject_cast<VideoListWidget*>(object);
   398                     qobject_cast<VideoListWidget*>(object);
   402                 if (videoList)
   399                 if (videoList)
   403                 {
   400                 {
   415         {
   412         {
   416             VideoSortFilterProxyModel *model = wrapper.getModel(
   413             VideoSortFilterProxyModel *model = wrapper.getModel(
   417             		VideoCollectionCommon::EModelTypeCollectionContent);
   414             		VideoCollectionCommon::EModelTypeCollectionContent);
   418             if (model)
   415             if (model)
   419             {
   416             {
       
   417                 // collection content contains always a list of videos so we use 
       
   418                 // ELevelVideos as target for sorting
       
   419                 VideoCollectionViewUtils::sortModel(model, false, VideoCollectionCommon::ELevelVideos);
       
   420                 
   420                 VideoListWidget *videoList = qobject_cast<VideoListWidget*>(object);
   421                 VideoListWidget *videoList = qobject_cast<VideoListWidget*>(object);
   421                 if (videoList)
   422                 if (videoList)
   422                 {
   423                 {
   423                     // init widget
   424                     // init widget
   424                     VideoServices *videoServices = 0;
   425                     VideoServices *videoServices = 0;