videocollection/tsrc/stubs/src/videocollectionwrapper.cpp
changeset 62 0e1e938beb1a
parent 17 69946d1824c4
equal deleted inserted replaced
59:a76e86df7ccd 62:0e1e938beb1a
    15 * 
    15 * 
    16 */
    16 */
    17 
    17 
    18 #include "videocollectionwrapper.h"
    18 #include "videocollectionwrapper.h"
    19 #include "videocollectionwrapperdata.h"
    19 #include "videocollectionwrapperdata.h"
    20 
    20 /*
    21 bool VideoCollectionWrapperData::mGetModelFails = false;
    21 bool VideoCollectionWrapperData::mGetGenericModelFails = false;
       
    22 bool VideoCollectionWrapperData::mGetAllVideosModelFails = false;
       
    23 bool VideoCollectionWrapperData::mGetCollectionsModelFails = false;
       
    24 bool VideoCollectionWrapperData::mGetCollectionContentModelFails = false;
    22 VideoListDataModel *VideoCollectionWrapperData::mSourceModel = 0;
    25 VideoListDataModel *VideoCollectionWrapperData::mSourceModel = 0;
    23 VideoSortFilterProxyModel *VideoCollectionWrapperData::mAllVideosModel = 0;
    26 QPointer<VideoProxyModelGeneric> VideoCollectionWrapperData::mAllVideosModel = 0;
    24 VideoSortFilterProxyModel *VideoCollectionWrapperData::mCollectionsModel = 0;
    27 QPointer<VideoProxyModelGeneric> VideoCollectionWrapperData::mCollectionsModel = 0;
    25 VideoSortFilterProxyModel *VideoCollectionWrapperData::mCollectionContentModel = 0;
    28 QPointer<VideoProxyModelGeneric> VideoCollectionWrapperData::mCollectionContentModel = 0;
    26 VideoSortFilterProxyModel *VideoCollectionWrapperData::mGenericModel = 0;
    29 QPointer<VideoProxyModelGeneric> VideoCollectionWrapperData::mGenericModel = 0;*/
    27 
    30 
    28 VideoCollectionWrapper &VideoCollectionWrapper::instance()
    31 VideoCollectionWrapper &VideoCollectionWrapper::instance()
    29 {
    32 {
    30     static VideoCollectionWrapper _staticWrapper;
    33     static VideoCollectionWrapper _staticWrapper;
    31     return _staticWrapper;
    34     return _staticWrapper;
    39 VideoCollectionWrapper::~VideoCollectionWrapper()
    42 VideoCollectionWrapper::~VideoCollectionWrapper()
    40 {
    43 {
    41     VideoCollectionWrapperData::reset();
    44     VideoCollectionWrapperData::reset();
    42 }
    45 }
    43 
    46 
    44 VideoSortFilterProxyModel* VideoCollectionWrapper::getModel(VideoCollectionCommon::TModelType type)
    47 VideoProxyModelGeneric* VideoCollectionWrapper::getGenericModel()
    45 {
    48 {
    46     VideoSortFilterProxyModel *model = 0;
    49     VideoProxyModelGeneric *model = 0;
    47     if (!VideoCollectionWrapperData::mGetModelFails)
    50     if (!VideoCollectionWrapperData::mGetGenericModelFails)
    48     {
    51     {
    49         VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel;
    52         VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel;
    50         if (!sourceModel)
    53         if (!sourceModel)
    51         {
    54         {
    52             sourceModel = new VideoListDataModel;
    55             sourceModel = new VideoListDataModel;
    53             if (sourceModel)
    56             sourceModel->initialize();
    54             {
    57             VideoCollectionWrapperData::mSourceModel = sourceModel;
    55                 sourceModel->initialize();
       
    56                 VideoCollectionWrapperData::mSourceModel = sourceModel;
       
    57             }
       
    58         }
    58         }
    59         
    59 
    60         switch (type)
    60         model = VideoCollectionWrapperData::mGenericModel;
       
    61         if(!model && VideoCollectionWrapperData::mSourceModel)
    61         {
    62         {
    62             case VideoCollectionCommon::EModelTypeAllVideos:
    63             model = new VideoProxyModelGeneric();
    63             {
    64             model->initialize(VideoCollectionWrapperData::mSourceModel);
    64                 model = VideoCollectionWrapperData::mAllVideosModel;
    65             VideoCollectionWrapperData::mGenericModel = model;
    65                 if (!model)
    66         }
    66                 {
    67     }
    67                     model = new VideoSortFilterProxyModel(type);
    68     
    68                     if (model)
    69     return model;
    69                     {
    70 }
    70                         model->initialize(sourceModel);
    71 
    71                         VideoCollectionWrapperData::mAllVideosModel = model;
    72 VideoProxyModelGeneric* VideoCollectionWrapper::getAllVideosModel()
    72                     }
    73 {
    73                 }
    74     VideoProxyModelGeneric *model = 0;
    74                 break;
    75     if (!VideoCollectionWrapperData::mGetAllVideosModelFails)
    75             }
    76     {
    76             case VideoCollectionCommon::EModelTypeCollections:
    77         VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel;
    77             {
    78         if (!sourceModel)
    78                 model = VideoCollectionWrapperData::mCollectionsModel;
    79         {
    79                 if (!model)
    80             sourceModel = new VideoListDataModel;
    80                 {
    81             sourceModel->initialize();
    81                     model = new VideoSortFilterProxyModel(type);
    82             VideoCollectionWrapperData::mSourceModel = sourceModel;
    82                     if (model)
    83         }
    83                     {
    84 
    84                         model->initialize(sourceModel);
    85         model = VideoCollectionWrapperData::mAllVideosModel;
    85                         VideoCollectionWrapperData::mCollectionsModel = model;
    86         if (!model)
    86                     }
    87         {
    87                 }
    88             model = new VideoProxyModelAllVideos();
    88                 break;
    89                 model->initialize(VideoCollectionWrapperData::mSourceModel);
    89             }
    90             VideoCollectionWrapperData::mAllVideosModel = model;
    90             case VideoCollectionCommon::EModelTypeCollectionContent:
    91         }
    91             {
    92     }
    92                 model = VideoCollectionWrapperData::mCollectionContentModel;
    93     
    93                 if (!model)
    94     return model;
    94                 {
    95 }
    95                     model = new VideoSortFilterProxyModel(type);
    96 
    96                     if (model)
    97 VideoProxyModelGeneric* VideoCollectionWrapper::getCollectionsModel()
    97                     {
    98 {
    98                         model->initialize(sourceModel);
    99     VideoProxyModelGeneric *model = 0;
    99                         VideoCollectionWrapperData::mCollectionContentModel = model;
   100     if (!VideoCollectionWrapperData::mGetCollectionsModelFails)
   100                     }
   101     {
   101                 }
   102         VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel;
   102                 break;
   103         if (!sourceModel)
   103             }
   104         {
   104             case VideoCollectionCommon::EModelTypeGeneric:
   105             sourceModel = new VideoListDataModel;
   105             {
   106             sourceModel->initialize();
   106                 model = VideoCollectionWrapperData::mGenericModel;
   107             VideoCollectionWrapperData::mSourceModel = sourceModel;
   107                 if (!model)
   108         }
   108                 {
   109 
   109                     model = new VideoSortFilterProxyModel(type);
   110         model = VideoCollectionWrapperData::mCollectionsModel;
   110                     if (model)
   111         if (!model)
   111                     {
   112         {
   112                         model->initialize(sourceModel);
   113             model = new VideoProxyModelCollections();
   113                         VideoCollectionWrapperData::mGenericModel = model;
   114             model->initialize(VideoCollectionWrapperData::mSourceModel);
   114                     }
   115             VideoCollectionWrapperData::mCollectionsModel = model;
   115                 }
   116         }
   116                 break;
   117     }
   117             }
   118     
   118             default:
   119     return model;
   119             {
   120 }
   120                 // invalid model type
   121 
   121                 break;
   122 VideoProxyModelGeneric* VideoCollectionWrapper::getCollectionContentModel()
   122             }
   123 {
       
   124     VideoProxyModelGeneric *model = 0;
       
   125     if (!VideoCollectionWrapperData::mGetCollectionContentModelFails)
       
   126     {
       
   127         VideoListDataModel *sourceModel = VideoCollectionWrapperData::mSourceModel;
       
   128         if (!sourceModel)
       
   129         {
       
   130             sourceModel = new VideoListDataModel;
       
   131             sourceModel->initialize();
       
   132             VideoCollectionWrapperData::mSourceModel = sourceModel;
       
   133         }
       
   134 
       
   135         model = VideoCollectionWrapperData::mCollectionContentModel;
       
   136         if (!model)
       
   137         {
       
   138             model = new VideoProxyModelContent();
       
   139             model->initialize(VideoCollectionWrapperData::mSourceModel);
       
   140             VideoCollectionWrapperData::mCollectionContentModel = model;
   123         }
   141         }
   124     }
   142     }
   125     
   143     
   126     return model;
   144     return model;
   127 }
   145 }