videocollection/videocollectionwrapper/inc/videocollectionwrapper.h
changeset 36 8aed59de29f9
parent 34 bbb98528c666
child 40 13331705e488
equal deleted inserted replaced
35:3738fe97f027 36:8aed59de29f9
    20 
    20 
    21 
    21 
    22 // INCLUDES
    22 // INCLUDES
    23 #include <QObject>
    23 #include <QObject>
    24 #include <qabstractitemmodel.h>
    24 #include <qabstractitemmodel.h>
       
    25 #include "videocollectioncommon.h"
    25 #include "videocollectionexport.h"
    26 #include "videocollectionexport.h"
    26 
    27 
    27 // FORWARD DECLARATIONS
    28 // FORWARD DECLARATIONS
    28 class VideoCollectionWrapperPrivate;
    29 class VideoCollectionWrapperPrivate;
    29 class VideoSortFilterProxyModel;
    30 class VideoSortFilterProxyModel;
    30 
    31 
    31 
    32 
    32 /**
    33 /**
    33  * Class is used as an interface of the video collection QT wrapper.
    34  * Class is used as an interface of the video collection QT wrapper.
    34  * 
    35  * 
    35  * Singleton instance is deleted when it's not used anymore by clients. At instantion time  
    36  * Singleton instance is deleted when application ends
    36  * reference count is incremented. Client must call decreaseReferenceCount when it doesn't 
       
    37  * need the instance anymore. When reference count is 0 the instance is destroyed.
       
    38  * 
    37  * 
    39  * * Usage:
    38  * * Usage:
    40  *  @code
    39  *  @code
       
    40  *  #include "videocollectioncommon.h"
    41  *  #include "videocollectionwrapper.h"
    41  *  #include "videocollectionwrapper.h"
    42  *  #include "videosortfilterproxymodel.h"
    42  *  #include "videosortfilterproxymodel.h"
    43  *  
    43  *  
    44  *  ...
    44  *  ...
    45  *  ////
    45  *  ////
    46  *  // Getting the instances
    46  *  // Getting the instances
    47  *  ////
    47  *  ////
    48  *  VideoCollectionWrapper *wrapper = VideoCollectionWrapper::instance();
    48  *  VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
    49  * 
    49  *  // getting all videos model
    50  *  VideoSortFilterProxyModel *model = wrapper->getModel();
    50  *  VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionCommon::EModelTypeAllVideos);
    51  *  ...
    51  *  ...
    52  *  ////
    52  *  ////
    53  *  // Opening collection and start fetching video item data
    53  *  // Opening collection and start fetching video item data
    54  *  ////
    54  *  ////
    55  *  if(model)
    55  *  if(model)
    56  *  {
    56  *  {
    57  *      mModel->open(VideoListWidget::ELevelVideos);
    57  *      mModel.open(VideoCollectionCommon::ELevelVideos);
    58  *  }
    58  *  }
    59  *  // see model documentation for the open funtionality
    59  *  // see model documentation for the open funtionality
    60  *
       
    61  *  /////
       
    62  *  // Instance is not used anymore. 
       
    63  *  // Wrapper owns the model, so client should not deallocate it
       
    64  *  /////
       
    65  *  wrapper->decreaseReferenceCount();
       
    66  *  wrapper = 0; // Don't use before new instantion.
       
    67  * 
    60  * 
    68  *  @endcode
    61  *  @endcode
    69  * 
    62  * 
    70  */
    63  */
    71 class VIDEOCOLLECTION_DLL_EXPORT VideoCollectionWrapper : public QObject         
    64 class VIDEOCOLLECTION_DLL_EXPORT VideoCollectionWrapper : public QObject         
    74      * define to be able to use signals and slots
    67      * define to be able to use signals and slots
    75      */
    68      */
    76     Q_OBJECT
    69     Q_OBJECT
    77     
    70     
    78 public: // Constructor
    71 public: // Constructor
    79     
       
    80     enum TModelType
       
    81     {
       
    82         EAllVideos,
       
    83         ECollections,
       
    84         ECollectionContent,
       
    85         EGeneric
       
    86     };
       
    87     
    72     
    88     /**
    73     /**
    89      * Returns singleton instance for this class.
    74      * Returns singleton instance for this class.
    90      * 
    75      * 
    91      * WARNING! Not safe to call this from destructor of another function scope static object!
    76      * WARNING! Not safe to call this from destructor of another function scope static object!
    99      * 
    84      * 
   100      * @param type of the model
    85      * @param type of the model
   101      * 
    86      * 
   102      * @return address to model or NULL if fails.
    87      * @return address to model or NULL if fails.
   103      */    
    88      */    
   104     VideoSortFilterProxyModel* getModel(int type);
    89     VideoSortFilterProxyModel* getModel(VideoCollectionCommon::TModelType type);
   105 
    90 
   106     /**
    91     /**
   107      * Method can be used by client to emit status signal
    92      * Method can be used by client to emit status signal
   108      * containing status code from particular async status.
    93      * containing status code from particular async status.
   109      * 
    94      *