videocollection/tsrc/stubs/src/videocollectionwrapper.cpp
branchRCL_3
changeset 56 839377eedc2b
equal deleted inserted replaced
54:315810614048 56:839377eedc2b
       
     1 /*
       
     2 * Copyright (c) 2010 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:   VideoCollectionWrapper class implementation
       
    15 * 
       
    16 */
       
    17 
       
    18 #include "videocollectionwrapper.h"
       
    19 #include "videocollectionwrapperdata.h"
       
    20 
       
    21 bool VideoCollectionWrapperData::mGetModelFails = false;
       
    22 VideoListDataModel *VideoCollectionWrapperData::mSourceModel = 0;
       
    23 VideoSortFilterProxyModel *VideoCollectionWrapperData::mAllVideosModel = 0;
       
    24 VideoSortFilterProxyModel *VideoCollectionWrapperData::mCollectionsModel = 0;
       
    25 VideoSortFilterProxyModel *VideoCollectionWrapperData::mCollectionContentModel = 0;
       
    26 VideoSortFilterProxyModel *VideoCollectionWrapperData::mGenericModel = 0;
       
    27 
       
    28 VideoCollectionWrapper &VideoCollectionWrapper::instance()
       
    29 {
       
    30     static VideoCollectionWrapper _staticWrapper;
       
    31     return _staticWrapper;
       
    32 }
       
    33 
       
    34 VideoCollectionWrapper::VideoCollectionWrapper() 
       
    35 {
       
    36     // nop
       
    37 }
       
    38 
       
    39 VideoCollectionWrapper::~VideoCollectionWrapper()
       
    40 {
       
    41     VideoCollectionWrapperData::reset();
       
    42 }
       
    43 
       
    44 VideoSortFilterProxyModel* VideoCollectionWrapper::getModel(VideoCollectionCommon::TModelType type)
       
    45 {
       
    46     VideoSortFilterProxyModel *model = 0;
       
    47     if (!VideoCollectionWrapperData::mGetModelFails)
       
    48     {
       
    49         VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel;
       
    50         if (!sourceModel)
       
    51         {
       
    52             sourceModel = new VideoListDataModel;
       
    53             if (sourceModel)
       
    54             {
       
    55                 sourceModel->initialize();
       
    56                 VideoCollectionWrapperData::mSourceModel = sourceModel;
       
    57             }
       
    58         }
       
    59         
       
    60         switch (type)
       
    61         {
       
    62             case VideoCollectionCommon::EModelTypeAllVideos:
       
    63             {
       
    64                 model = VideoCollectionWrapperData::mAllVideosModel;
       
    65                 if (!model)
       
    66                 {
       
    67                     model = new VideoSortFilterProxyModel(type);
       
    68                     if (model)
       
    69                     {
       
    70                         model->initialize(sourceModel);
       
    71                         VideoCollectionWrapperData::mAllVideosModel = model;
       
    72                     }
       
    73                 }
       
    74                 break;
       
    75             }
       
    76             case VideoCollectionCommon::EModelTypeCollections:
       
    77             {
       
    78                 model = VideoCollectionWrapperData::mCollectionsModel;
       
    79                 if (!model)
       
    80                 {
       
    81                     model = new VideoSortFilterProxyModel(type);
       
    82                     if (model)
       
    83                     {
       
    84                         model->initialize(sourceModel);
       
    85                         VideoCollectionWrapperData::mCollectionsModel = model;
       
    86                     }
       
    87                 }
       
    88                 break;
       
    89             }
       
    90             case VideoCollectionCommon::EModelTypeCollectionContent:
       
    91             {
       
    92                 model = VideoCollectionWrapperData::mCollectionContentModel;
       
    93                 if (!model)
       
    94                 {
       
    95                     model = new VideoSortFilterProxyModel(type);
       
    96                     if (model)
       
    97                     {
       
    98                         model->initialize(sourceModel);
       
    99                         VideoCollectionWrapperData::mCollectionContentModel = model;
       
   100                     }
       
   101                 }
       
   102                 break;
       
   103             }
       
   104             case VideoCollectionCommon::EModelTypeGeneric:
       
   105             {
       
   106                 model = VideoCollectionWrapperData::mGenericModel;
       
   107                 if (!model)
       
   108                 {
       
   109                     model = new VideoSortFilterProxyModel(type);
       
   110                     if (model)
       
   111                     {
       
   112                         model->initialize(sourceModel);
       
   113                         VideoCollectionWrapperData::mGenericModel = model;
       
   114                     }
       
   115                 }
       
   116                 break;
       
   117             }
       
   118             default:
       
   119             {
       
   120                 // invalid model type
       
   121                 break;
       
   122             }
       
   123         }
       
   124     }
       
   125     
       
   126     return model;
       
   127 }
       
   128 
       
   129 void VideoCollectionWrapper::sendAsyncStatus(int statusCode,
       
   130     QVariant &additional)
       
   131 {
       
   132     Q_UNUSED(statusCode);
       
   133     Q_UNUSED(additional);
       
   134     // not stubbed
       
   135 }
       
   136 
       
   137 // end of file