videocollection/videocollectionwrapper/src/videocollectionwrapper_p.cpp
changeset 62 0e1e938beb1a
parent 46 adbe7d5ba2f5
equal deleted inserted replaced
59:a76e86df7ccd 62:0e1e938beb1a
    13 *
    13 *
    14 * Description: VideoCollectionWrapperPrivate class implementation
    14 * Description: VideoCollectionWrapperPrivate class implementation
    15 * 
    15 * 
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 27 %
    18 // Version : %version: 30 %
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <qapplication.h>
    21 #include <qapplication.h>
    22 #include <qabstractitemmodel.h>
    22 #include <qabstractitemmodel.h>
    23 #include <vcxmyvideosdefs.h>
    23 #include <vcxmyvideosdefs.h>
    24 
    24 
    25 #include "videocollectionwrapper.h"
    25 #include "videocollectionwrapper.h"
    26 #include "videocollectionwrapper_p.h"
    26 #include "videocollectionwrapper_p.h"
    27 #include "videolistdatamodel.h"
    27 #include "videolistdatamodel.h"
    28 #include "videosortfilterproxymodel.h"
    28 #include "videoproxymodelgeneric.h"
       
    29 #include "videoproxymodelallvideos.h"
       
    30 #include "videoproxymodelcollections.h"
       
    31 #include "videoproxymodelcontent.h"
    29 #include "videocollectionclient.h"
    32 #include "videocollectionclient.h"
    30 #include "videocollectioncommon.h"
    33 #include "videocollectioncommon.h"
    31 #include "videocollectiontrace.h"
    34 #include "videocollectiontrace.h"
    32 
    35 
    33 // ================= MEMBER FUNCTIONS =======================
    36 // ================= MEMBER FUNCTIONS =======================
    35 
    38 
    36 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    37 // VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate()
    40 // VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate()
    38 // -----------------------------------------------------------------------------
    41 // -----------------------------------------------------------------------------
    39 //
    42 //
    40 VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate() 
    43 VideoCollectionWrapperPrivate::VideoCollectionWrapperPrivate() :
    41     : mAllVideosModel( 0 )
    44     mGenericModel( 0 ),
    42     , mCollectionsModel( 0 )
    45     mAllVideosModel( 0 ),
    43     , mCollectionContentModel( 0 )
    46     mCollectionsModel( 0 ),
    44     , mGenericModel( 0 )
    47     mCollectionContentModel( 0 ),
    45     , mSourceModel( 0 )
    48     mSourceModel( 0 ),
    46     , mAboutToClose( false )
    49     mAboutToClose( false )
    47 {
    50 {
    48 	FUNC_LOG;
    51 	FUNC_LOG;
    49     // NOP 
    52     // NOP 
    50 }
    53 }
    51 
    54 
    56 VideoCollectionWrapperPrivate::~VideoCollectionWrapperPrivate()
    59 VideoCollectionWrapperPrivate::~VideoCollectionWrapperPrivate()
    57 {
    60 {
    58 	FUNC_LOG;
    61 	FUNC_LOG;
    59 }
    62 }
    60 
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // VideoCollectionWrapperPrivate::getGenericModel()
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 VideoProxyModelGeneric* VideoCollectionWrapperPrivate::getGenericModel()
       
    69 {
       
    70     FUNC_LOG;
       
    71     if(!mGenericModel)
       
    72     {
       
    73         mGenericModel = initProxyModelModel<VideoProxyModelGeneric>();
       
    74     }
       
    75     return mGenericModel;
       
    76 }
    61 
    77 
    62 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    63 // VideoCollectionWrapperPrivate::getModel()
    79 // VideoCollectionWrapperPrivate::getAllVideosModel()
    64 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    65 //
    81 //
    66 VideoSortFilterProxyModel* VideoCollectionWrapperPrivate::getModel(VideoCollectionCommon::TModelType &type)
    82 VideoProxyModelGeneric* VideoCollectionWrapperPrivate::getAllVideosModel()
    67 {
    83 {
    68 	FUNC_LOG;
    84     FUNC_LOG;
    69     INFO_1("VideoCollectionWrapperPrivate::getModel() type: %d", type);
    85     if(!mAllVideosModel)
    70 	
       
    71     if(mAboutToClose)
       
    72     {
    86     {
    73         return 0;
    87         mAllVideosModel = initProxyModelModel<VideoProxyModelAllVideos>();
    74     }
    88     }
       
    89     return mAllVideosModel;
       
    90 }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // VideoCollectionWrapperPrivate::getCollectionsModel()
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 VideoProxyModelGeneric* VideoCollectionWrapperPrivate::getCollectionsModel()
       
    97 {
       
    98     FUNC_LOG;
       
    99     if(!mCollectionsModel)
       
   100     {
       
   101         mCollectionsModel = initProxyModelModel<VideoProxyModelCollections>();
       
   102     }
       
   103     return mCollectionsModel;    
       
   104 }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // VideoCollectionWrapperPrivate::getCollectionContentModel()
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 VideoProxyModelGeneric* VideoCollectionWrapperPrivate::getCollectionContentModel()
       
   111 {
       
   112     FUNC_LOG;
       
   113     if(!mCollectionContentModel)
       
   114     {
       
   115         mCollectionContentModel = initProxyModelModel<VideoProxyModelContent>();
       
   116     }
       
   117     return mCollectionContentModel;
       
   118 }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // VideoCollectionWrapperPrivate::initSourceModel()
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 bool VideoCollectionWrapperPrivate::initSourceModel()
       
   125 {
       
   126     FUNC_LOG;
    75     
   127     
    76     VideoSortFilterProxyModel *model = 0;
       
    77     if(!mSourceModel)
   128     if(!mSourceModel)
    78     {
   129     {
    79         mSourceModel = new VideoListDataModel();
   130         mSourceModel = new VideoListDataModel();
    80         if(!mSourceModel || mSourceModel->initialize() < 0 || 
   131         if(mSourceModel->initialize() < 0 || 
    81             !connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuitSlot())) )
   132             !connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuitSlot())) )
    82         {
   133         {
    83             ERROR(-1, "VideoCollectionWrapperPrivate::getModel() sourceModel setup failed.");
   134             delete mSourceModel;
    84             return 0;
   135             mSourceModel = 0;
       
   136             ERROR(-1, "VideoCollectionWrapperPrivate::initSourceModel() sourceModel setup failed.");
       
   137             return false;
    85         }
   138         }
    86     }
   139     }
    87     bool needsInitialization = false;
   140     return true;
    88     if(type == VideoCollectionCommon::EModelTypeAllVideos)
       
    89     {
       
    90         if(!mAllVideosModel)
       
    91         {
       
    92             mAllVideosModel = new VideoSortFilterProxyModel(type);
       
    93             needsInitialization = true;
       
    94         }
       
    95         model = mAllVideosModel;
       
    96     }
       
    97     else if(type == VideoCollectionCommon::EModelTypeCollections)
       
    98     {
       
    99         if(!mCollectionsModel)
       
   100         {
       
   101             mCollectionsModel = new VideoSortFilterProxyModel(type);
       
   102             needsInitialization = true;
       
   103         }
       
   104         model = mCollectionsModel;
       
   105     }
       
   106     else if(type == VideoCollectionCommon::EModelTypeCollectionContent)
       
   107     {
       
   108         if(!mCollectionContentModel)
       
   109         {
       
   110             mCollectionContentModel = new VideoSortFilterProxyModel(type);
       
   111 			needsInitialization = true;   
       
   112         }
       
   113         model = mCollectionContentModel;
       
   114     }
       
   115     else if(type == VideoCollectionCommon::EModelTypeGeneric)
       
   116     {
       
   117         if(!mGenericModel)
       
   118         {
       
   119             mGenericModel = new VideoSortFilterProxyModel(type);
       
   120             needsInitialization = true;
       
   121         }
       
   122         model = mGenericModel;
       
   123     }
       
   124     
       
   125     if(needsInitialization)
       
   126     {        
       
   127         if(model && model->initialize(mSourceModel) < 0)
       
   128         {
       
   129             ERROR(-1, "VideoCollectionWrapperPrivate::getModel() no model or init failed.");
       
   130             delete model;
       
   131             return 0;
       
   132         }
       
   133         if(!connect(model, SIGNAL(shortDetailsReady(TMPXItemId)), mSourceModel, SIGNAL(shortDetailsReady(TMPXItemId))))
       
   134         {
       
   135         	delete model;
       
   136         	return 0;
       
   137         }
       
   138     }   
       
   139     return model;
       
   140 }
   141 }
   141 
   142 
   142 // -----------------------------------------------------------------------------
   143 // -----------------------------------------------------------------------------
   143 // VideoCollectionWrapperPrivate::aboutToQuitSlot()
   144 // VideoCollectionWrapperPrivate::aboutToQuitSlot()
   144 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------