53 * been added, call continueFetching to start the fetch process which passes |
53 * been added, call continueFetching to start the fetch process which passes |
54 * the internal data to thumbnail manager. Signal thumbnailReady is emitted |
54 * the internal data to thumbnail manager. Signal thumbnailReady is emitted |
55 * when fetch is complete. |
55 * when fetch is complete. |
56 * |
56 * |
57 * @param fileName path to the media. |
57 * @param fileName path to the media. |
58 * @param internal data identifying the media. |
58 * @param mediaId mpx id for the media. |
59 * @param priority priority for the fetch. |
59 * @param priority priority for the fetch. |
60 * |
60 * |
61 */ |
61 */ |
62 void addFetch(const QString fileName, void *internal, int priority); |
62 void addFetch(const QString fileName, const TMPXItemId &mediaId, int priority); |
63 |
63 |
64 /** |
64 /** |
65 * Empties fetch list. This does not cancel the possible ongoing fetch on |
65 * Empties fetch list. This does not cancel the possible ongoing fetch on |
66 * thumbnail manager side. |
66 * thumbnail manager side. |
67 * |
67 * |
84 /** |
84 /** |
85 * Continues the fetching process. All fetches added with addFetch are |
85 * Continues the fetching process. All fetches added with addFetch are |
86 * started without create thumbnail flag. If there's not any of those, |
86 * started without create thumbnail flag. If there's not any of those, |
87 * starts creating thumbnails for fetches that have no thumbnail yet. |
87 * starts creating thumbnails for fetches that have no thumbnail yet. |
88 * Signal allThumbnailsFetched is emitted if there's nothing to do. |
88 * Signal allThumbnailsFetched is emitted if there's nothing to do. |
89 * |
89 * |
90 */ |
90 * @param cancelOngoingFetches if true then all ongoing thumbnail fetches |
91 void continueFetching(); |
91 * will be canceled. |
|
92 * |
|
93 */ |
|
94 void continueFetching(bool cancelOngoingFetches); |
92 |
95 |
93 /** |
96 /** |
94 * Enables or disables the thumbnail creation for videos that do |
97 * Enables or disables the thumbnail creation for videos that do |
95 * not have thumbnail already in the database. |
98 * not have thumbnail already in the database. |
96 * |
99 * |
102 private: |
105 private: |
103 |
106 |
104 class ThumbnailFetchData |
107 class ThumbnailFetchData |
105 { |
108 { |
106 public: |
109 public: |
107 ThumbnailFetchData() { mInternal = 0; }; |
|
108 QString mFileName; |
110 QString mFileName; |
109 int mPriority; |
111 int mPriority; |
110 void *mInternal; |
112 TMPXItemId mMediaId; |
|
113 int mRequestId; |
111 }; |
114 }; |
112 |
115 |
113 protected: |
116 protected: |
114 |
117 |
115 /** |
118 /** |
116 * Starts fetching all the thumbnails in fetch list. Create flag is |
119 * Starts fetching all the thumbnails in fetch list. Create flag is |
117 * disabled. Thumbnail manager signals to thumbnailReadySlot. If thumbnail |
120 * disabled. Thumbnail manager signals to thumbnailReadySlot. If thumbnail |
118 * fetch fails with -1 the fetch is added to thumbnail creation list, |
121 * fetch fails with -1 the fetch is added to thumbnail creation list, |
119 * otherwise signal thumbnailReady signal emitted. |
122 * otherwise signal thumbnailReady signal emitted. |
120 * |
123 * |
121 */ |
124 * @param cancelOngoingFetches if true then all ongoing thumbnail fetches |
122 void startThumbnailFetches(); |
125 * will be canceled. |
|
126 * |
|
127 */ |
|
128 void startThumbnailFetches(bool cancelOngoingFetches); |
123 |
129 |
124 /** |
130 /** |
125 * Starts fetching thumbnail with highest priority from creation list. |
131 * Starts fetching thumbnail with highest priority from creation list. |
126 * Create flag is enabled. Thumbnail manager signals to thumbnailReadySlot, |
132 * Create flag is enabled. Thumbnail manager signals to thumbnailReadySlot, |
127 * from there signal thumbnailReady is emitted. |
133 * from there signal thumbnailReady is emitted. |
134 /** |
140 /** |
135 * Signaled after signal from thumbnail manager has been processed and |
141 * Signaled after signal from thumbnail manager has been processed and |
136 * thumbnail fetch process is complete. |
142 * thumbnail fetch process is complete. |
137 * |
143 * |
138 * @param tnData thumbnail |
144 * @param tnData thumbnail |
139 * @param internal internal data to identify the request |
145 * @param mediaId mpx id for the media. |
140 * @param error possible error code from thumbnail manager ( 0 == ok ) |
146 * @param error possible error code from thumbnail manager ( 0 == ok ) |
141 * |
147 * |
142 */ |
148 */ |
143 void thumbnailReady(QPixmap tnData, void *internal, int error); |
149 void thumbnailReady(QPixmap tnData, const TMPXItemId &mediaId, int error); |
144 |
150 |
145 /** |
151 /** |
146 * Signaled when all the fetches have been done. |
152 * Signaled when all the fetches have been done. |
147 * |
153 * |
148 */ |
154 */ |
165 private: // Data |
171 private: // Data |
166 |
172 |
167 /** |
173 /** |
168 * Thumbnail manager object. |
174 * Thumbnail manager object. |
169 */ |
175 */ |
170 ThumbnailManager *mThumbnailManager; |
176 ThumbnailManager *mThumbnailManager; |
171 |
177 |
172 /** |
178 /** |
173 * List containing not started thumbnail fetches. |
179 * List containing not started thumbnail fetches. |
174 */ |
180 * |
175 QList<ThumbnailFetchData *> mFetchList; |
181 * key is mpx id. |
|
182 * value is thumbnail fetch data. |
|
183 */ |
|
184 QHash<TMPXItemId, ThumbnailFetchData *> mFetchList; |
176 |
185 |
177 /** |
186 /** |
178 * Hash containing ongoing thumbnail fetches. |
187 * Hash containing ongoing thumbnail fetches. |
179 * |
188 * |
180 * key is thumbnail request id. |
189 * key is mpx id. |
181 * value is thumbnail fetch data. |
190 * value is thumbnail fetch data. |
182 */ |
191 */ |
183 QHash<int, ThumbnailFetchData *> mStartedFetchList; |
192 QHash<TMPXItemId, ThumbnailFetchData *> mStartedFetchList; |
184 |
193 |
185 /** |
194 /** |
186 * List containing thumbnails that have not been created yet. |
195 * List containing thumbnails that have not been created yet. |
187 */ |
196 */ |
188 QList<ThumbnailFetchData *> mCreationList; |
197 QList<ThumbnailFetchData *> mCreationList; |
189 |
198 |
190 /** |
199 /** |
191 * Flag indicating if fetching has been paused. |
200 * Flag indicating if fetching has been paused. |
192 */ |
201 */ |
193 bool mPaused; |
202 bool mPaused; |
194 |
203 |
195 /** |
204 /** |
196 * Flag indicating if thumbnail creation is enabled. |
205 * Flag indicating if thumbnail creation is enabled. |
197 */ |
206 */ |
198 bool mTbnCreationEnabled; |
207 bool mTbnCreationEnabled; |
199 }; |
208 }; |
200 |
209 |
201 #endif // __VIDEOTHUMBNAILDATAFETCHER_H__ |
210 #endif // __VIDEOTHUMBNAILDATAFETCHER_H__ |