30
|
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: VideoThumbnailDataPrivate class definition
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef __VIDEOTHUMBNAILDATAPRIVATE_H__
|
|
19 |
#define __VIDEOTHUMBNAILDATAPRIVATE_H__
|
|
20 |
|
|
21 |
// INCLUDES
|
37
|
22 |
#include <qobject.h>
|
|
23 |
#include <qpointer.h>
|
|
24 |
#include <qcache.h>
|
|
25 |
#include <qicon.h>
|
|
26 |
#include <qset.h>
|
|
27 |
#include <qlist.h>
|
|
28 |
#include <qhash.h>
|
30
|
29 |
#include <e32const.h>
|
|
30 |
#include <mpxitemid.h>
|
|
31 |
|
|
32 |
// FORWARD DECLARATIONS
|
|
33 |
class VideoCollectionWrapper;
|
58
|
34 |
class VideoProxyModelGeneric;
|
30
|
35 |
class QModelIndex;
|
|
36 |
class QTimer;
|
34
|
37 |
class VideoThumbnailFetcher;
|
35
|
38 |
class HbIcon;
|
30
|
39 |
|
|
40 |
class VideoThumbnailDataPrivate : public QObject
|
|
41 |
{
|
|
42 |
/**
|
|
43 |
* defined to be able to use signals and slots
|
|
44 |
*/
|
|
45 |
Q_OBJECT
|
|
46 |
|
|
47 |
public:
|
34
|
48 |
|
30
|
49 |
/**
|
|
50 |
* Default constructor
|
|
51 |
*/
|
|
52 |
VideoThumbnailDataPrivate();
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Destructor
|
|
56 |
*/
|
|
57 |
virtual ~VideoThumbnailDataPrivate();
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Method returns a pointer to video's thumbnail.
|
|
61 |
*
|
|
62 |
* If thumbnail fetching is ongoing or not yet started, pointer to default thumbnail
|
|
63 |
* is returned.
|
|
64 |
*
|
|
65 |
* @param mediaId media id for which to get thumbnail
|
|
66 |
* @param tnData reference to thumbnail data where data is ocpied
|
|
67 |
*
|
|
68 |
* @return QIcon* thumbnail pointer
|
|
69 |
*
|
|
70 |
*/
|
50
|
71 |
const QIcon* getThumbnail(const TMPXItemId &mediaId);
|
30
|
72 |
|
|
73 |
/**
|
34
|
74 |
* Method removes thumbnail data from the icon cache.
|
30
|
75 |
*
|
|
76 |
* @param mediaId id for media whose thumbnail is to be removed
|
|
77 |
*
|
|
78 |
* @return bool: true if item removed correctly, false if not.
|
|
79 |
*
|
|
80 |
*/
|
50
|
81 |
bool removeThumbnail(const TMPXItemId &mediaId);
|
30
|
82 |
|
|
83 |
/**
|
|
84 |
* Starts background thumbnail fetching from the given fetch index.
|
|
85 |
*
|
34
|
86 |
* @param model model of the items for the fetching.
|
30
|
87 |
* @param fetchIndex index where to start the background thumbnail fetching.
|
|
88 |
*/
|
58
|
89 |
void startBackgroundFetching(VideoProxyModelGeneric *model, int fetchIndex);
|
30
|
90 |
|
|
91 |
/**
|
|
92 |
* Enables or disables thumbnail background fetching.
|
|
93 |
*
|
|
94 |
* @param enable true enables and false disables thumbnail background fetching.
|
|
95 |
*/
|
|
96 |
void enableBackgroundFetching(bool enable);
|
34
|
97 |
|
|
98 |
/**
|
|
99 |
* Enables or disables thumbnail creation. Default is enabled. Thumbnails
|
|
100 |
* that have been already generated are fetched still.
|
|
101 |
*
|
|
102 |
* @param enable true enables and false disables thumbnail creation.
|
|
103 |
*/
|
|
104 |
void enableThumbnailCreation(bool enable);
|
|
105 |
|
30
|
106 |
/**
|
50
|
107 |
* Returns if background fetching is enabled.
|
|
108 |
*
|
|
109 |
* @return bool: true if background fetching is enabled, otherwise false.
|
|
110 |
*/
|
|
111 |
bool backgroundFetchingEnabled();
|
|
112 |
|
|
113 |
/**
|
30
|
114 |
* Frees allocated data for thumbnails and cancels ongoing fetches.
|
|
115 |
*/
|
|
116 |
void freeThumbnailData();
|
|
117 |
|
|
118 |
protected:
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Method creates member objects and connects signals.
|
|
122 |
*
|
|
123 |
* @return int 0 initialization ok, -1 initialization failed
|
|
124 |
*
|
|
125 |
*/
|
|
126 |
int initialize();
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Cleanup internal data. This must be called before UI environment is destroyed.
|
|
130 |
*/
|
|
131 |
void cleanup();
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Connects the signals.
|
|
135 |
*
|
|
136 |
* @return int 0 connecting ok, -1 connecting failed.
|
|
137 |
*/
|
|
138 |
int connectSignals();
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Disconnects the signals.
|
|
142 |
*
|
|
143 |
*/
|
|
144 |
void disconnectSignals();
|
|
145 |
|
|
146 |
/**
|
34
|
147 |
* Starts fetching thumbnails for medias in the model defined by the indexes
|
|
148 |
* parameter. Priority for the thumbnails is ascending starting from the
|
|
149 |
* defined priority.
|
|
150 |
*
|
|
151 |
* param @indexes indexes of the medias in the model
|
|
152 |
* param @priority starting priority for the thumbnails
|
|
153 |
*
|
|
154 |
* @return int count of fetches started or -1 in case of error.
|
|
155 |
*/
|
|
156 |
int startFetchingThumbnails(const QList<QModelIndex> &indexes, int priority);
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Method starts fetching thumbnail for the video specified by given mediaId
|
|
160 |
* Media IDs are used as a key identification in the thumbnail map where data is
|
|
161 |
* collected.
|
|
162 |
*
|
|
163 |
* @param mediaId media id for which to start fetching thumbnail
|
|
164 |
* @param priority priority for the fetch
|
|
165 |
*
|
|
166 |
* @return int: thumbnail id or -1 if fetch starting fails.
|
|
167 |
*
|
|
168 |
*/
|
50
|
169 |
int startFetchingThumbnail(const TMPXItemId &mediaId, int priority);
|
34
|
170 |
|
|
171 |
/**
|
30
|
172 |
* Appends indexes in the source model to the list between start and end.
|
|
173 |
*
|
|
174 |
* @param indexes list of indexes
|
|
175 |
* @param startIndex start index
|
|
176 |
* @param endIndex end index
|
|
177 |
*/
|
50
|
178 |
void getModelIndexes(QList<QModelIndex> &indexes, int &startIndex, int &endIndex);
|
30
|
179 |
|
|
180 |
/**
|
|
181 |
* Method returns default thumbnail data.
|
|
182 |
*
|
|
183 |
* @param mediaId media id for which to get thumbnail
|
|
184 |
*
|
|
185 |
* @return QIcon: reference to default thumbnail data
|
|
186 |
*
|
|
187 |
*/
|
50
|
188 |
const QIcon* defaultThumbnail(const TMPXItemId &mediaId);
|
38
|
189 |
|
|
190 |
/**
|
|
191 |
* Loads icon from file or resource, the icon is scaled to size of the
|
|
192 |
* video list view thumbnail.
|
|
193 |
*
|
|
194 |
* @param iconName name of the file or resource.
|
|
195 |
*
|
58
|
196 |
* @return QIcon the icon load from resource or file.
|
38
|
197 |
*
|
|
198 |
*/
|
58
|
199 |
QIcon *loadIcon(QString iconName);
|
30
|
200 |
|
|
201 |
/**
|
|
202 |
* Starts timer that continues the background thumbnail fetching at timeout.
|
|
203 |
*/
|
|
204 |
void continueBackgroundFetch();
|
|
205 |
|
|
206 |
signals:
|
|
207 |
|
|
208 |
/**
|
|
209 |
* This signal is emitted from thumbnailReadySlot, when
|
|
210 |
*
|
|
211 |
* @param mediaIds: media ids of the videos whose thumbnail is ready.
|
|
212 |
*
|
|
213 |
*/
|
50
|
214 |
void thumbnailsFetched(QList<TMPXItemId>& mediaIds);
|
30
|
215 |
|
|
216 |
private slots:
|
|
217 |
|
|
218 |
/**
|
34
|
219 |
* Thumbnail fetcher signals this slot when thumbnail is ready
|
|
220 |
* for some item. Thumbnail data is saved to icon cache.
|
30
|
221 |
*
|
|
222 |
* @param tnData: thumbnail
|
37
|
223 |
* @param mediaId: pointer to the media id used in emitted signal
|
30
|
224 |
* @param error: possible error code from thumbnail manager ( 0 == ok )
|
|
225 |
*
|
|
226 |
*/
|
37
|
227 |
void thumbnailReadySlot(QPixmap tnData, const TMPXItemId &mediaId, int error);
|
30
|
228 |
|
|
229 |
/**
|
|
230 |
* Fetches thumbnails around of mCurrentFetchIndex in batches of THUMBNAIL_BACKGROUND_FETCH_AMOUNT.
|
|
231 |
* The fetch index is set by startFetchingThumbnails which also resets
|
|
232 |
* mCurrentBackgroundFetchCount. Maximum of THUMBNAIL_MAX_BACKGROUND_FETCH thumbnails are
|
|
233 |
* fetched between the count resets.
|
|
234 |
*
|
|
235 |
*/
|
|
236 |
void doBackgroundFetching();
|
|
237 |
|
|
238 |
/**
|
|
239 |
* Signaled when UI environment is about to be destroyed. Thumbnails must be cleaned before that.
|
|
240 |
*
|
|
241 |
*/
|
|
242 |
void aboutToQuitSlot();
|
|
243 |
|
|
244 |
/**
|
|
245 |
* Emits thumbnailReady signals for list of thumbnails.
|
|
246 |
*
|
|
247 |
*/
|
|
248 |
void reportThumbnailsReadySlot();
|
34
|
249 |
|
|
250 |
/**
|
|
251 |
* Thumbnail fetcher signals this when all thumbnails have been fetched.
|
|
252 |
*/
|
|
253 |
void allThumbnailsFetchedSlot();
|
30
|
254 |
|
|
255 |
private: // Data
|
|
256 |
|
58
|
257 |
VideoThumbnailFetcher *mThumbnailFetcher;
|
34
|
258 |
|
30
|
259 |
/**
|
35
|
260 |
* Local cache for thumbnail data:
|
30
|
261 |
* - key is the video's media id
|
|
262 |
* - data is the actual thumbnail data.
|
|
263 |
* If thumbnail data is not yet fetched, QIcon is default thumbnail.
|
|
264 |
*/
|
58
|
265 |
QCache<TMPXItemId, QIcon> mThumbnailData;
|
30
|
266 |
|
|
267 |
/**
|
35
|
268 |
* Local hash for default thumbnails.
|
|
269 |
* - key is mpx item id defining default tn type
|
58
|
270 |
* - data is the actual thumbnail data.
|
30
|
271 |
*/
|
58
|
272 |
QHash<TMPXItemId, QIcon *> mDefaultThumbnails;
|
30
|
273 |
|
|
274 |
/**
|
34
|
275 |
* Current model, set at call to startBackgroundFetching.
|
30
|
276 |
*/
|
58
|
277 |
QPointer<VideoProxyModelGeneric> mCurrentModel;
|
34
|
278 |
|
30
|
279 |
/**
|
|
280 |
* Current index for background thumbnail fetching.
|
|
281 |
*/
|
|
282 |
int mCurrentFetchIndex;
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Current count of background thumbnails fetched around the fetch index.
|
|
286 |
*/
|
|
287 |
int mCurrentBackgroundFetchCount;
|
|
288 |
|
|
289 |
/**
|
|
290 |
* Timer for background fetching.
|
|
291 |
*/
|
|
292 |
QTimer *mBgFetchTimer;
|
|
293 |
|
|
294 |
/**
|
|
295 |
* Timer for thumbnail ready signaling.
|
|
296 |
*/
|
|
297 |
QTimer *mTbnReportTimer;
|
|
298 |
|
|
299 |
/**
|
|
300 |
* List of media ids for thumbnails that are ready.
|
|
301 |
*/
|
|
302 |
QList<TMPXItemId> mReadyThumbnailMediaIds;
|
|
303 |
|
|
304 |
/**
|
|
305 |
* Flag for signal connections.
|
|
306 |
*/
|
|
307 |
bool mSignalsConnected;
|
|
308 |
|
|
309 |
/**
|
|
310 |
* Indicates if background thumbnail fetching is enabled.
|
|
311 |
*/
|
|
312 |
bool mBackgroundFetchingEnabled;
|
|
313 |
};
|
|
314 |
|
|
315 |
#endif // __VIDEOTHUMBNAILDATAPRIVATE_H__
|
|
316 |
|
|
317 |
// End of file
|