|
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: VideoListDataModelPrivate class definition* |
|
15 */ |
|
16 |
|
17 #ifndef __VIDEOLISTDATAMODEL_P_H__ |
|
18 #define __VIDEOLISTDATAMODEL_P_H__ |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 #include <QObject> |
|
23 #include <qicon.h> |
|
24 #include <qdatetime.h> |
|
25 #include <qhash.h> |
|
26 #include <qset.h> |
|
27 #include <qabstractitemmodel.h> |
|
28 #include <e32const.h> |
|
29 #include <mpxitemid.h> |
|
30 #include "videodatasignalreceiver.h" |
|
31 #include "videodatacontainer.h" |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class VideoListDataModel; |
|
35 class CMPXMediaArray; |
|
36 class CMPXMedia; |
|
37 class VideoThumbnailData; |
|
38 |
|
39 class VideoListDataModelPrivate : public VideoDataSignalReceiver |
|
40 { |
|
41 /** |
|
42 * define to be able to use signals and slots |
|
43 */ |
|
44 Q_OBJECT |
|
45 |
|
46 /** |
|
47 * disable copy-constructor and assignment operator |
|
48 */ |
|
49 Q_DISABLE_COPY(VideoListDataModelPrivate) |
|
50 |
|
51 /** |
|
52 * we're friend of the actual model object |
|
53 */ |
|
54 friend class VideoListDataModel; |
|
55 |
|
56 public: // Constructor |
|
57 |
|
58 /** |
|
59 * Default constructor |
|
60 */ |
|
61 VideoListDataModelPrivate(VideoListDataModel *model); |
|
62 |
|
63 /** |
|
64 * Destructor |
|
65 */ |
|
66 ~VideoListDataModelPrivate(); |
|
67 |
|
68 /** |
|
69 * Method initializes class members: |
|
70 * Creates thumbnail data -object and connect it's signals. |
|
71 * |
|
72 * - VideoThumbnailData: thumbnailsFetched |
|
73 * ---> VideoListData: thumbnailsFetchedSlot |
|
74 * |
|
75 * @return int, 0 if ok. |
|
76 */ |
|
77 int initialize(); |
|
78 |
|
79 private slots: |
|
80 |
|
81 /** |
|
82 * This slot is connected to VideoThumbnailData::thumbnailsFetched -signal |
|
83 * to get notified when thumbnail(s) for some particular item(s) is ready. |
|
84 * |
|
85 * The indexes of the items are checked and videoDataChanged signal is emitted. |
|
86 * |
|
87 * @param mediaIds: media ids of the items |
|
88 * |
|
89 */ |
|
90 void thumbnailsFetchedSlot(QList<TMPXItemId> &mediaIds); |
|
91 |
|
92 private slots: //slots from VideoDataSignalReceiver |
|
93 |
|
94 /** |
|
95 * Signaled by the collection client when there is new video list available. |
|
96 * Method emits videosInserted -signal. |
|
97 * |
|
98 * @param newVideoList: new list of videos |
|
99 * |
|
100 */ |
|
101 void newVideoListSlot(CMPXMediaArray *newVideoList); |
|
102 |
|
103 /** |
|
104 * Signaled by the collection client when there are new videos appended |
|
105 * into the existing videolist. |
|
106 * Checks if medias at provided array does not exist at the existing |
|
107 * array and appends them if they do not. |
|
108 * |
|
109 * @param videoList: list of videos provided for appending |
|
110 */ |
|
111 void appendVideoListSlot(CMPXMediaArray* videoList); |
|
112 |
|
113 /** |
|
114 * Signaled by the collection client when new videodata is fetched. |
|
115 * Given object is inserted into correct position in the |
|
116 * media array and videosInserted -signal is emitted |
|
117 * |
|
118 * @param aVideo data of the new video. |
|
119 */ |
|
120 void newVideoAvailableSlot(CMPXMedia *newVideo); |
|
121 |
|
122 /** |
|
123 * Signaled by the collection client when |
|
124 * item removal has detected. |
|
125 * |
|
126 * @param itemId id of the removed item |
|
127 */ |
|
128 void itemDeletedSlot(TMPXItemId &itemId); |
|
129 |
|
130 /** |
|
131 * Signaled by the collection client video deletion request |
|
132 * has completed |
|
133 * |
|
134 * @param overallCount count of ALL videos in this delete procedure |
|
135 * @param failedMediaIds list of item ids that failed to be removed. |
|
136 */ |
|
137 void videoDeleteCompletedSlot(int overallCount, QList<TMPXItemId> *failedMediaIds); |
|
138 |
|
139 |
|
140 /** |
|
141 * Signaled when album remove command is completed and some albums were not removed. |
|
142 * |
|
143 * @param failedMediaIds media-array containing failed medias |
|
144 */ |
|
145 void albumRemoveFailureSlot(QList<TMPXItemId> *failedMediaIds); |
|
146 |
|
147 /** |
|
148 * Signaled by the collection client when video details fetching |
|
149 * has completed. |
|
150 * |
|
151 */ |
|
152 void videoDetailsCompletedSlot(CMPXMedia* media); |
|
153 |
|
154 /** |
|
155 * Signalled when album items are recieved. |
|
156 * |
|
157 * @param albumId, Album which items are received. |
|
158 * @param albumItems, Items belonging to the current album. |
|
159 */ |
|
160 void albumListAvailableSlot(TMPXItemId &albumId, CMPXMediaArray *albumItems); |
|
161 |
|
162 /** |
|
163 * Signalled when item has been mofidied. |
|
164 * |
|
165 * @param itemId, item that has been modified. |
|
166 */ |
|
167 void itemModifiedSlot(const TMPXItemId &itemId); |
|
168 |
|
169 /** |
|
170 * Signalled when video list is complete. |
|
171 */ |
|
172 void videoListCompleteSlot(); |
|
173 |
|
174 /** |
|
175 * Signalled when album list is complete. |
|
176 */ |
|
177 void albumListCompleteSlot(); |
|
178 |
|
179 public: // services |
|
180 |
|
181 /** |
|
182 * Returns video count |
|
183 * |
|
184 * @return int count of videos |
|
185 */ |
|
186 int getVideoCount(); |
|
187 |
|
188 /** |
|
189 * Returns the MPX media item id (TMPXItemId.id1) |
|
190 * from the given index. |
|
191 * |
|
192 * @param index: item position where client wants the id from |
|
193 * |
|
194 * @return TMPXItemId item id or invalid TMPXItemId if id not found at that index |
|
195 */ |
|
196 const TMPXItemId& getMediaIdFromIndex(const int &index) const; |
|
197 |
|
198 /** |
|
199 * Returns name of the video from the given index. |
|
200 * If there is no item at that index, empty string is returned. |
|
201 * |
|
202 * @param index: item position where client wants the name from |
|
203 * |
|
204 * @return QString name of the item |
|
205 */ |
|
206 const QString getVideoNameFromIndex(const int &index) const; |
|
207 |
|
208 /** |
|
209 * Returns the thumbnail of the item from given index. |
|
210 * If there is no item at that index or thumbnail is not yet fetched, |
|
211 * default thumbnail is returned. |
|
212 * |
|
213 * @param index: item position where client wants the tn from |
|
214 * |
|
215 * @return QIcon thumbnail of the item |
|
216 */ |
|
217 const QIcon* getVideoThumbnailFromIndex(const int &index) const; |
|
218 |
|
219 /** |
|
220 * Returns the value for item count attribute from given index. |
|
221 * If there is no item at that index, 0 is returned. |
|
222 * |
|
223 * @param index: item position where client wants the count from |
|
224 * |
|
225 * @return guint32 size in bytes |
|
226 */ |
|
227 quint32 getCategoryVideoCountFromIndex(const int &index ) const; |
|
228 |
|
229 /** |
|
230 * Returns the size of the video from given index. |
|
231 * If there is no item at that index, 0 is returned |
|
232 * |
|
233 * @param index: item position where client wants the size from |
|
234 * |
|
235 * @return guint32 size in bytes |
|
236 */ |
|
237 quint32 getVideoSizeFromIndex(const int &index) const; |
|
238 |
|
239 /** |
|
240 * Returns the age profile of the video from given index |
|
241 * If there is no item at that index, 0 is returned |
|
242 * |
|
243 * @param index: item position where client wants the size from |
|
244 * |
|
245 * @return quint32 age profile in bytes |
|
246 */ |
|
247 quint32 getVideoAgeProfileFromIndex(const int &index) const; |
|
248 |
|
249 /** |
|
250 * Returns the duration of the video from given index. |
|
251 * If there is no item at that index, 0 is returned |
|
252 * |
|
253 * @param index: item position where client wants the duration from |
|
254 * |
|
255 * @return guint32 duration |
|
256 */ |
|
257 quint32 getVideodurationFromIndex(const int &index) const; |
|
258 |
|
259 /** |
|
260 * Returns the duration of the video from given media. |
|
261 * |
|
262 * @param media The video media object. |
|
263 * |
|
264 * @return guint32 duration |
|
265 */ |
|
266 quint32 getVideoDuration(CMPXMedia* media) const; |
|
267 |
|
268 /** |
|
269 * Returns the creation/download date of the video. |
|
270 * |
|
271 * @param index: item position where client wants the date from. |
|
272 * |
|
273 * @return QDate date |
|
274 */ |
|
275 QDateTime getVideoDateFromIndex(const int &index) const; |
|
276 |
|
277 /** |
|
278 * Returns the creation/download date of the video |
|
279 * |
|
280 * @param media The video media object. |
|
281 */ |
|
282 QDateTime getVideoDate(CMPXMedia* media) const; |
|
283 |
|
284 /** |
|
285 * marks videos to be removed: it's id and index are saved to |
|
286 * remove buffer in data container |
|
287 * |
|
288 * @param itemIndex: index of item to be removed |
|
289 * @return TMPXItemId: id of the item marked |
|
290 * |
|
291 */ |
|
292 const TMPXItemId markVideoRemoved(const QModelIndex &itemIndex); |
|
293 |
|
294 /** |
|
295 * Removes provided ids from the remove -list |
|
296 * and restores them into actual container in case |
|
297 * our current collection level is correct. |
|
298 * |
|
299 */ |
|
300 void restoreRemoved(QList<TMPXItemId> *idList); |
|
301 |
|
302 /** |
|
303 * Returns the file path of the video. |
|
304 * |
|
305 * @param index: item position where client wants the file path from. |
|
306 */ |
|
307 const QString getFilePathFromIndex(const int &index) const; |
|
308 |
|
309 /** |
|
310 * Returns the file path of the video. |
|
311 * |
|
312 * @param mediaId: id for the item |
|
313 */ |
|
314 const QString getFilePathForId(const TMPXItemId &mediaId); |
|
315 |
|
316 /** |
|
317 * Checks if the specified item belongs to currently open album. |
|
318 * |
|
319 * @albumId, Album where the item is to be checked. |
|
320 * @param itemId, Item to be checked. |
|
321 * @return true if item belongs to the album. |
|
322 */ |
|
323 bool belongsToAlbum(const TMPXItemId &itemId, TMPXItemId albumId = TMPXItemId::InvalidId()) const; |
|
324 |
|
325 /** |
|
326 * Set album in use. |
|
327 * |
|
328 * @param albumId, Album to set in use. |
|
329 * @return None. |
|
330 */ |
|
331 void setAlbumInUse(const TMPXItemId &albumId); |
|
332 |
|
333 /** |
|
334 * removes provided items from album provided |
|
335 * |
|
336 * @param albumId album from where to remove |
|
337 * @param items to remove |
|
338 * |
|
339 * @return count of item removed; |
|
340 */ |
|
341 int removeItemsFromAlbum(const TMPXItemId &albumId, const QList<TMPXItemId> &items); |
|
342 |
|
343 private: // private methods |
|
344 |
|
345 /** |
|
346 * private default constructor definition |
|
347 */ |
|
348 VideoListDataModelPrivate(); |
|
349 |
|
350 /** |
|
351 * Method clears map containing media objects |
|
352 */ |
|
353 void clearVideoData(); |
|
354 |
|
355 /** |
|
356 * Method used to parse media id from given object. |
|
357 * Id id data is not available or given object is null. |
|
358 * method returns -1. |
|
359 * The id is CMPXMedia's TMPXItemId.iId1 |
|
360 * |
|
361 * @param media: where to get id from |
|
362 * |
|
363 * @return TMPXItemId: id of the item |
|
364 */ |
|
365 TMPXItemId getMediaId(const CMPXMedia *media ) const; |
|
366 |
|
367 /** |
|
368 * Leaving helper method for appending data from media array into |
|
369 * data container for reducing amount of TRAPs. |
|
370 * |
|
371 * Leaves if CMPXMedia object creation fails. |
|
372 * |
|
373 * @param videoArray array from where to take data |
|
374 * @param startIndex startindex from where start appending. |
|
375 * |
|
376 */ |
|
377 void appendDataToContainerL(CMPXMediaArray *videoArray, unsigned int startIndex = 0); |
|
378 |
|
379 /** |
|
380 * Check that a media item is valid. |
|
381 * |
|
382 * @param itemId, Item to be checked. |
|
383 * @return true if valid. |
|
384 */ |
|
385 bool isValid(const CMPXMedia &media, const TMPXItemId &itemId) const; |
|
386 |
|
387 /** |
|
388 * Album data changed, resets album data from array provided |
|
389 * |
|
390 * @param albumId id of album |
|
391 * @param videoarray array of videos in album |
|
392 */ |
|
393 void albumDataChangedL(TMPXItemId &albumId, CMPXMediaArray *videoArray); |
|
394 |
|
395 /** |
|
396 * Called when an album has been removed. |
|
397 * |
|
398 * @param albumId, Album which items are received. |
|
399 */ |
|
400 void albumRemoved(TMPXItemId &albumId); |
|
401 |
|
402 /** |
|
403 * Called when a video has been removed. |
|
404 * |
|
405 * @param videoId id of the removed video |
|
406 */ |
|
407 void videoDeleted(TMPXItemId &videoId); |
|
408 |
|
409 private: |
|
410 |
|
411 /** |
|
412 * Pointer to the public class |
|
413 * Not own. |
|
414 */ |
|
415 VideoListDataModel *q_ptr; |
|
416 |
|
417 /** |
|
418 * media object container |
|
419 */ |
|
420 VideoDataContainer mMediaData; |
|
421 |
|
422 /** |
|
423 * Thumbnail handler object, not owned |
|
424 */ |
|
425 VideoThumbnailData *mVideoThumbnailData; |
|
426 |
|
427 /** |
|
428 * Object is initialized. |
|
429 */ |
|
430 bool mInitialized; |
|
431 |
|
432 /** |
|
433 * "wrapped" album container, contains item ids belongint into a particular album |
|
434 * or category |
|
435 */ |
|
436 QHash<TMPXItemId, QSet<TMPXItemId> > mAlbumData; |
|
437 |
|
438 /** |
|
439 * currently open album |
|
440 */ |
|
441 TMPXItemId mCurrentAlbum; |
|
442 }; |
|
443 |
|
444 #endif // __VIDEOLISTDATAMODEL_P_H__ |
|
445 |
|
446 // End of file |