|
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: VideoCollectionWrapper class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __VIDEOCOLLECTIONWRAPPER_H__ |
|
19 #define __VIDEOCOLLECTIONWRAPPER_H__ |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 #include <QObject> |
|
24 #include <qabstractitemmodel.h> |
|
25 #include "videocollectionexport.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class VideoCollectionWrapperPrivate; |
|
29 class VideoSortFilterProxyModel; |
|
30 |
|
31 |
|
32 /** |
|
33 * Class is used as an interface of the video collection QT wrapper. |
|
34 * |
|
35 * Singleton instance is deleted when it's not used anymore by clients. At instantion time |
|
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 * |
|
39 * * Usage: |
|
40 * @code |
|
41 * #include "videocollectionwrapper.h" |
|
42 * #include "videosortfilterproxymodel.h" |
|
43 * |
|
44 * ... |
|
45 * //// |
|
46 * // Getting the instances |
|
47 * //// |
|
48 * VideoCollectionWrapper *wrapper = VideoCollectionWrapper::instance(); |
|
49 * |
|
50 * VideoSortFilterProxyModel *model = wrapper->getModel(); |
|
51 * ... |
|
52 * //// |
|
53 * // Opening collection and start fetching video item data |
|
54 * //// |
|
55 * if(model) |
|
56 * { |
|
57 * mModel->open(VideoListWidget::ELevelVideos); |
|
58 * } |
|
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 * |
|
68 * @endcode |
|
69 * |
|
70 */ |
|
71 class VIDEOCOLLECTION_DLL_EXPORT VideoCollectionWrapper : public QObject |
|
72 { |
|
73 /** |
|
74 * define to be able to use signals and slots |
|
75 */ |
|
76 Q_OBJECT |
|
77 |
|
78 public: // Constructor |
|
79 |
|
80 /** |
|
81 * Returns singleton instance for this class. |
|
82 * |
|
83 * WARNING! Not safe to call this from destructor of another function scope static object! |
|
84 * |
|
85 * @return The singleton instance. |
|
86 */ |
|
87 static VideoCollectionWrapper *instance(); |
|
88 |
|
89 /** |
|
90 * Decreases the reference count, when count reaches zero cleanup is done. |
|
91 * |
|
92 */ |
|
93 void decreaseReferenceCount(); |
|
94 |
|
95 /** |
|
96 * Returns pointer to model |
|
97 * |
|
98 * @return address to model or NULL if fails. |
|
99 */ |
|
100 VideoSortFilterProxyModel* getModel(); |
|
101 |
|
102 /** |
|
103 * Method can be used by client to emit status signal |
|
104 * containing status code from particular async status. |
|
105 * |
|
106 * @param statusCode code of status |
|
107 * |
|
108 * @param additional additional information for the code |
|
109 */ |
|
110 void sendAsyncStatus(int statusCode, QVariant &additional); |
|
111 |
|
112 signals: |
|
113 |
|
114 /** |
|
115 * Signal that can be emitted by the wrapper to indicate status |
|
116 * of some async operation. |
|
117 * |
|
118 * See videocollectioncommon.h for codes |
|
119 * |
|
120 * @param status code of status |
|
121 * |
|
122 * @param additional additional information for the code |
|
123 */ |
|
124 void asyncStatus(int statusCode, QVariant &additional); |
|
125 |
|
126 private: |
|
127 |
|
128 /** |
|
129 * Private contructor. |
|
130 */ |
|
131 VideoCollectionWrapper(); |
|
132 |
|
133 /** |
|
134 * Private destructor. |
|
135 * |
|
136 */ |
|
137 virtual ~VideoCollectionWrapper(); |
|
138 |
|
139 /** |
|
140 * disables copy-constructor and assingment operator |
|
141 */ |
|
142 Q_DISABLE_COPY(VideoCollectionWrapper) |
|
143 |
|
144 private: |
|
145 |
|
146 /** |
|
147 * d -pointer for actual implementation |
|
148 */ |
|
149 VideoCollectionWrapperPrivate *d; |
|
150 |
|
151 /** |
|
152 * Reference count. |
|
153 */ |
|
154 int mReferenceCount; |
|
155 |
|
156 /** |
|
157 * Singleton instance. |
|
158 */ |
|
159 static VideoCollectionWrapper* mInstance; |
|
160 }; |
|
161 |
|
162 #endif // __VIDEOCOLLECTIONWRAPPER_H__ |
|
163 |
|
164 // End of file |