videocollection/videocollectionwrapper/src/videocollectionwrapper_p.cpp
changeset 15 cf5481c2bc0b
child 17 69946d1824c4
equal deleted inserted replaced
2:dec420019252 15:cf5481c2bc0b
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: VideoCollectionWrapperPrivate class implementation
       
    15 * 
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include <qapplication.h>
       
    21 #include <qabstractitemmodel.h>
       
    22 #include <vcxmyvideosdefs.h>
       
    23 #include "videocollectionwrapper.h"
       
    24 #include "videocollectionwrapper_p.h"
       
    25 #include "videolistdatamodel.h"
       
    26 #include "videosortfilterproxymodel.h"
       
    27 #include "videocollectionclient.h"
       
    28 #include "videocollectioncommon.h"
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 //
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate()
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate() : 
       
    38 mAllVideosModel(0),
       
    39 mCollectionsModel(0),
       
    40 mGenericModel(0),
       
    41 mSourceModel(0)
       
    42 {
       
    43     // NOP 
       
    44 }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // VideoCollectionWrapperPrivate::~VideoCollectionWrapperPrivate()
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 VideoCollectionWrapperPrivate::~VideoCollectionWrapperPrivate()
       
    51 {
       
    52     // NOP here
       
    53 }
       
    54 
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // VideoCollectionWrapperPrivate::getModel()
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 VideoSortFilterProxyModel* VideoCollectionWrapperPrivate::getModel(int &type)
       
    61 {
       
    62     
       
    63     VideoSortFilterProxyModel *model = 0;
       
    64     if(!mSourceModel)
       
    65     {
       
    66         mSourceModel = new VideoListDataModel();
       
    67         if(!mSourceModel || mSourceModel->initialize() < 0 || 
       
    68             !connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuitSlot())) )
       
    69         {
       
    70             return 0;
       
    71         }
       
    72     }
       
    73     bool needsInitialization = false;
       
    74     if(type == VideoCollectionWrapper::EAllVideos)
       
    75     {
       
    76         if(!mAllVideosModel)
       
    77         {
       
    78             mAllVideosModel = new VideoSortFilterProxyModel(type); 
       
    79             needsInitialization = true;
       
    80         }
       
    81         model = mAllVideosModel;
       
    82     }
       
    83     else if(type == VideoCollectionWrapper::ECollections)
       
    84     {
       
    85         if(!mCollectionsModel)
       
    86         {
       
    87             mCollectionsModel = new VideoSortFilterProxyModel(type);
       
    88             needsInitialization = true;
       
    89         }
       
    90         model = mCollectionsModel;
       
    91     }
       
    92     else if(type == VideoCollectionWrapper::ECollectionContent)
       
    93     {
       
    94         if(!mCollectionContentModel)
       
    95         {
       
    96             mCollectionContentModel = new VideoSortFilterProxyModel(type);
       
    97 			needsInitialization = true;   
       
    98         }
       
    99         model = mCollectionContentModel;
       
   100     }
       
   101     else if(type == VideoCollectionWrapper::EGeneric)
       
   102     {
       
   103         if(!mGenericModel)
       
   104         {
       
   105             mGenericModel = new VideoSortFilterProxyModel(type);
       
   106             needsInitialization = true;
       
   107         }
       
   108         model = mGenericModel;
       
   109     }
       
   110     
       
   111     if(needsInitialization)
       
   112     {        
       
   113         if(model && model->initialize(mSourceModel) < 0 )
       
   114         {
       
   115             delete model;
       
   116             return 0;
       
   117         }
       
   118         if (!connect(model, SIGNAL(shortDetailsReady(TMPXItemId)), mSourceModel, SIGNAL(shortDetailsReady(TMPXItemId))))
       
   119         {
       
   120         	delete model;
       
   121         	return 0;
       
   122         }
       
   123     }   
       
   124     return model;
       
   125 }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // VideoCollectionWrapperPrivate::aboutToQuitSlot()
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 void VideoCollectionWrapperPrivate::aboutToQuitSlot()
       
   132 {    
       
   133     if(!mSourceModel.isNull())
       
   134     {
       
   135         delete mSourceModel;
       
   136     }
       
   137 }
       
   138 
       
   139 // End of file