|
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: VideoThumbnailFetcher class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __VIDEOTHUMBNAILDATAFETCHER_H__ |
|
19 #define __VIDEOTHUMBNAILDATAFETCHER_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <qobject.h> |
|
23 #include <qicon.h> |
|
24 #include <qlist.h> |
|
25 #include <qhash.h> |
|
26 |
|
27 #include <thumbnailmanager_qt.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 class VideoThumbnailFetcher : public QObject |
|
32 { |
|
33 /** |
|
34 * defined to be able to use signals and slots |
|
35 */ |
|
36 Q_OBJECT |
|
37 |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Default constructor |
|
42 */ |
|
43 VideoThumbnailFetcher(); |
|
44 |
|
45 /** |
|
46 * Desctructor |
|
47 */ |
|
48 ~VideoThumbnailFetcher(); |
|
49 |
|
50 /** |
|
51 * Adds thumbnail fetch to the fetch list. pauseFetching should be called |
|
52 * before adding fetches for performance reasons. After all fetches have |
|
53 * been added, call continueFetching to start the fetch process which passes |
|
54 * the internal data to thumbnail manager. Signal thumbnailReady is emitted |
|
55 * when fetch is complete. |
|
56 * |
|
57 * @param fileName path to the media. |
|
58 * @param internal data identifying the media. |
|
59 * @param priority priority for the fetch. |
|
60 * |
|
61 */ |
|
62 void addFetch(const QString fileName, void *internal, int priority); |
|
63 |
|
64 /** |
|
65 * Empties fetch list. This does not cancel the possible ongoing fetch on |
|
66 * thumbnail manager side. |
|
67 * |
|
68 */ |
|
69 void cancelFetches(); |
|
70 |
|
71 /** |
|
72 * Returns count of the fetches. |
|
73 * |
|
74 */ |
|
75 int fetchCount(); |
|
76 |
|
77 /** |
|
78 * Pauses thumbnail fetching process. This does not pause the possible |
|
79 * ongoing fetch on thumbnail manager side. |
|
80 * |
|
81 */ |
|
82 void pauseFetching(); |
|
83 |
|
84 /** |
|
85 * Continues the fetching process. All fetches added with addFetch are |
|
86 * started without create thumbnail flag. If there's not any of those, |
|
87 * starts creating thumbnails for fetches that have no thumbnail yet. |
|
88 * Signal allThumbnailsFetched is emitted if there's nothing to do. |
|
89 * |
|
90 */ |
|
91 void continueFetching(); |
|
92 |
|
93 /** |
|
94 * Enables or disables the thumbnail creation for videos that do |
|
95 * not have thumbnail already in the database. |
|
96 * |
|
97 * @param enable true enables thumbnail creation, false disables. |
|
98 * |
|
99 */ |
|
100 void enableThumbnailCreation(bool enable); |
|
101 |
|
102 private: |
|
103 |
|
104 class ThumbnailFetchData |
|
105 { |
|
106 public: |
|
107 ThumbnailFetchData() { mInternal = 0; }; |
|
108 QString mFileName; |
|
109 int mPriority; |
|
110 void *mInternal; |
|
111 }; |
|
112 |
|
113 protected: |
|
114 |
|
115 /** |
|
116 * Starts fetching all the thumbnails in fetch list. Create flag is |
|
117 * disabled. Thumbnail manager signals to thumbnailReadySlot. If thumbnail |
|
118 * fetch fails with -1 the fetch is added to thumbnail creation list, |
|
119 * otherwise signal thumbnailReady signal emitted. |
|
120 * |
|
121 */ |
|
122 void startThumbnailFetches(); |
|
123 |
|
124 /** |
|
125 * Starts fetching thumbnail with highest priority from creation list. |
|
126 * Create flag is enabled. Thumbnail manager signals to thumbnailReadySlot, |
|
127 * from there signal thumbnailReady is emitted. |
|
128 * |
|
129 */ |
|
130 void startThumbnailCreation(); |
|
131 |
|
132 signals: |
|
133 |
|
134 /** |
|
135 * Signaled after signal from thumbnail manager has been processed and |
|
136 * thumbnail fetch process is complete. |
|
137 * |
|
138 * @param tnData thumbnail |
|
139 * @param internal internal data to identify the request |
|
140 * @param error possible error code from thumbnail manager ( 0 == ok ) |
|
141 * |
|
142 */ |
|
143 void thumbnailReady(QPixmap tnData, void *internal, int error); |
|
144 |
|
145 /** |
|
146 * Signaled when all the fetches have been done. |
|
147 * |
|
148 */ |
|
149 void allThumbnailsFetched(); |
|
150 |
|
151 private slots: |
|
152 |
|
153 /** |
|
154 * Thumbnail manager signals this slot when thumbnail is ready |
|
155 * for some item. |
|
156 * |
|
157 * @param tnData thumbnail |
|
158 * @param internal internal data to identify the request |
|
159 * @param requestId thumbnail manager request id |
|
160 * @param error: possible error code from thumbnail manager ( 0 == ok ) |
|
161 * |
|
162 */ |
|
163 void thumbnailReadySlot(QPixmap tnData, void *internal, int requestId, int error); |
|
164 |
|
165 private: // Data |
|
166 |
|
167 /** |
|
168 * Thumbnail manager object. |
|
169 */ |
|
170 ThumbnailManager *mThumbnailManager; |
|
171 |
|
172 /** |
|
173 * List containing not started thumbnail fetches. |
|
174 */ |
|
175 QList<ThumbnailFetchData *> mFetchList; |
|
176 |
|
177 /** |
|
178 * Hash containing ongoing thumbnail fetches. |
|
179 * |
|
180 * key is thumbnail request id. |
|
181 * value is thumbnail fetch data. |
|
182 */ |
|
183 QHash<int, ThumbnailFetchData *> mStartedFetchList; |
|
184 |
|
185 /** |
|
186 * List containing thumbnails that have not been created yet. |
|
187 */ |
|
188 QList<ThumbnailFetchData *> mCreationList; |
|
189 |
|
190 /** |
|
191 * Flag indicating if fetching has been paused. |
|
192 */ |
|
193 bool mPaused; |
|
194 |
|
195 /** |
|
196 * Flag indicating if thumbnail creation is enabled. |
|
197 */ |
|
198 bool mTbnCreationEnabled; |
|
199 }; |
|
200 |
|
201 #endif // __VIDEOTHUMBNAILDATAFETCHER_H__ |