|
1 /* |
|
2 * Copyright (c) 2008 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: Videolist content widget |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef VIDEOLISTWIDGET_H |
|
20 #define VIDEOLISTWIDGET_H |
|
21 |
|
22 #include <hbview.h> |
|
23 #include <hblistview.h> |
|
24 #include <qmap.h> |
|
25 #include <mpxitemid.h> |
|
26 #include "videocollectioncommon.h" |
|
27 |
|
28 class VideoSortFilterProxyModel; |
|
29 class VideoServices; |
|
30 class VideoCollectionUiLoader; |
|
31 class HbAction; |
|
32 class HbMenu; |
|
33 class QTimer; |
|
34 class QItemSelection; |
|
35 class VideoServices; |
|
36 |
|
37 /** |
|
38 * Widget for displaying all videos, either using list- or grid view. |
|
39 * Widget contains 2 widgets to be used for different orientation in the stacked layout. |
|
40 * |
|
41 * Depending on the orientation and it's change, corresponding view is set active. |
|
42 * |
|
43 */ |
|
44 class VideoListWidget : public HbListView |
|
45 { |
|
46 Q_OBJECT |
|
47 Q_DISABLE_COPY(VideoListWidget) |
|
48 |
|
49 public: |
|
50 |
|
51 |
|
52 /** |
|
53 * Contructor. |
|
54 * @param uiloader |
|
55 * @param parent parent of this widget |
|
56 */ |
|
57 VideoListWidget(VideoCollectionUiLoader *uiLoader, HbView *parent = 0); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 * |
|
62 */ |
|
63 virtual ~VideoListWidget(); |
|
64 |
|
65 /** |
|
66 * Method creates colleciton wrapper, grid and list views, |
|
67 * layout and activates correct view based on the current orientation |
|
68 * |
|
69 * @param model Model for this list view. |
|
70 * @return int 0 initialization ok, < 0 if fails. |
|
71 */ |
|
72 int initialize(VideoSortFilterProxyModel &model, VideoServices* videoServices = 0); |
|
73 |
|
74 /** |
|
75 * Method enables and displays current active view |
|
76 * |
|
77 * @return int 0 initialization ok, < 0 if fails. |
|
78 */ |
|
79 int activate(); |
|
80 |
|
81 /** |
|
82 * Method enables and displays current active view |
|
83 * |
|
84 * @return int 0 initialization ok, < 0 if fails. |
|
85 */ |
|
86 int activate(VideoCollectionCommon::TCollectionLevels level); |
|
87 |
|
88 /** |
|
89 * Method disables and hides current active view |
|
90 * |
|
91 */ |
|
92 void deactivate(); |
|
93 |
|
94 /** |
|
95 * returns current level provided by activate |
|
96 * |
|
97 * @return TCollectionLevels |
|
98 */ |
|
99 VideoCollectionCommon::TCollectionLevels getLevel(); |
|
100 |
|
101 /** |
|
102 * returns widget's model |
|
103 * |
|
104 * @return VideoSortFilterProxyModel* |
|
105 */ |
|
106 VideoSortFilterProxyModel& getModel(); |
|
107 |
|
108 public: |
|
109 |
|
110 /** |
|
111 * Called by the fw when some item is tapped. Method check that |
|
112 * index is valid and calls open item for collectionwrapper to |
|
113 * open media object throught collection. |
|
114 * |
|
115 * @param midelIndex, item's index |
|
116 */ |
|
117 void emitActivated (const QModelIndex &modelIndex); |
|
118 |
|
119 /** |
|
120 * Overwritten from Abstractitemview. |
|
121 * Sets local selection mode variable value used locally in checks. |
|
122 * If provided value is mode provided by HbAbstractitemview sets |
|
123 * it as view selection mode othervise NoSelection is setted |
|
124 * |
|
125 * @param mode |
|
126 */ |
|
127 void setSelectionMode(int mode); |
|
128 |
|
129 signals: |
|
130 |
|
131 /** |
|
132 * Command signal. |
|
133 * |
|
134 * @param int command id |
|
135 */ |
|
136 void command(int); |
|
137 |
|
138 /** |
|
139 * Signals collection view's state. Used to indicate |
|
140 * view incase some collection item is opened |
|
141 * |
|
142 * @param true if opened, false if closed. |
|
143 * @param optional name string |
|
144 */ |
|
145 void collectionOpened(bool, const QString&, const QModelIndex&); |
|
146 |
|
147 /** |
|
148 * signal is connected to service's itemSelected -slot |
|
149 */ |
|
150 void fileUri(const QString&); |
|
151 |
|
152 protected slots: |
|
153 /** |
|
154 * Signaled by the fw during long press and indicating that popupmenu |
|
155 * concerning particular item is to be opened. |
|
156 * Saves current selected item's index to mCurrentIndex |
|
157 */ |
|
158 void longPressGesture (const QPointF &point); |
|
159 |
|
160 private slots: |
|
161 |
|
162 /** |
|
163 * Signaled for one item deletion. |
|
164 * |
|
165 */ |
|
166 void deleteItemSlot(); |
|
167 |
|
168 /** |
|
169 * Signaled for item rename. |
|
170 * |
|
171 */ |
|
172 void renameSlot(); |
|
173 |
|
174 /** |
|
175 * Signaled to play all items. |
|
176 * |
|
177 */ |
|
178 void playAllSlot(); |
|
179 |
|
180 /** |
|
181 * Signaled to add an item into a collection. |
|
182 * |
|
183 */ |
|
184 void addToCollectionSlot(); |
|
185 |
|
186 /** |
|
187 * Signaled to remove a particular video from collection |
|
188 */ |
|
189 void removeFromCollectionSlot(); |
|
190 |
|
191 /** |
|
192 * Signaled to remove a user created collection. |
|
193 * |
|
194 */ |
|
195 void removeCollectionSlot(); |
|
196 |
|
197 /** |
|
198 * Signaled when details will be selected from the videolist's |
|
199 * context menu. Maps mCurrentIndex to model's source index and |
|
200 * calls collection wrapper to open details |
|
201 * |
|
202 */ |
|
203 void openDetailsSlot(); |
|
204 |
|
205 /** |
|
206 * Signaled when the application has been lauched as a service and |
|
207 * playback is initialized from context menu. |
|
208 * |
|
209 */ |
|
210 void playItemSlot(); |
|
211 |
|
212 /** |
|
213 * slot is connected to view's doDelayeds -signal |
|
214 * |
|
215 */ |
|
216 void doDelayedsSlot(); |
|
217 |
|
218 /** |
|
219 * Signaled when stepping back from collection in collection view |
|
220 * |
|
221 */ |
|
222 void back(); |
|
223 |
|
224 /** |
|
225 * Signaled when view scrolling starts, pauses thumbnail creation. |
|
226 * |
|
227 */ |
|
228 void scrollingStartedSlot(); |
|
229 |
|
230 /** |
|
231 * Signaled when view scrolling ends, initiates thumbnail fetching |
|
232 * at index of first visible item and enables creation of thumbnails. |
|
233 * |
|
234 */ |
|
235 void scrollingEndedSlot(); |
|
236 |
|
237 /** |
|
238 * Signaled when view scroll position changes, initiates timer to |
|
239 * fetch thumbnails at index of first visible item. |
|
240 * |
|
241 * @param newPosition scroll position |
|
242 * |
|
243 */ |
|
244 void scrollPositionChangedSlot(const QPointF &newPosition); |
|
245 |
|
246 /** |
|
247 * Signaled when scroll position timer triggers. Starts fetching thumbnails |
|
248 * for visible items. |
|
249 * |
|
250 */ |
|
251 void scrollPositionTimerSlot(); |
|
252 |
|
253 /** |
|
254 * Fetches thumbnails for the visible items. |
|
255 * |
|
256 */ |
|
257 void fetchThumbnailsForVisibleItems(); |
|
258 |
|
259 // TODO: following can be removed after all implementation ready |
|
260 /** |
|
261 * Slot is connected into item signals that are not yet implemented. |
|
262 * Slot shows "Not yet implemented" note |
|
263 */ |
|
264 void debugNotImplementedYet(); |
|
265 |
|
266 private: |
|
267 |
|
268 enum TContextActionIds |
|
269 { |
|
270 EActionDelete = 1, |
|
271 EActionDetails, |
|
272 EActionRemove, |
|
273 EActionAddToCollection, |
|
274 EActionRemoveCollection, |
|
275 EActionRename, |
|
276 EActionPlay |
|
277 }; |
|
278 |
|
279 /** |
|
280 * Method creates popup menu for list items. |
|
281 * |
|
282 */ |
|
283 void createContextMenu(); |
|
284 |
|
285 /** |
|
286 * Method sets correct popup menu for specific list items. |
|
287 * |
|
288 */ |
|
289 void setContextMenu(); |
|
290 |
|
291 /** |
|
292 * Method connects signals needed by the widget |
|
293 * |
|
294 * @return int 0 if connect ok, < 0 if connect fails |
|
295 */ |
|
296 int connectSignals(); |
|
297 |
|
298 /** |
|
299 * Method disconnects signals needed by the widget |
|
300 * |
|
301 */ |
|
302 void disConnectSignals(); |
|
303 |
|
304 private: |
|
305 |
|
306 /** |
|
307 * Provided model |
|
308 * Not own. |
|
309 */ |
|
310 VideoSortFilterProxyModel *mModel; |
|
311 |
|
312 /** |
|
313 * pointer to videoservices instance |
|
314 */ |
|
315 VideoServices* mVideoServices; |
|
316 |
|
317 /** |
|
318 * map containing pointers to main menu actions |
|
319 */ |
|
320 QMap<TContextActionIds, HbAction*> mContextMenuActions; |
|
321 |
|
322 /** |
|
323 * current level indicating content currently showing: |
|
324 * category or videos |
|
325 */ |
|
326 VideoCollectionCommon::TCollectionLevels mCurrentLevel; |
|
327 |
|
328 /** |
|
329 * True if signals have been connected |
|
330 */ |
|
331 bool mSignalsConnected; |
|
332 |
|
333 /** |
|
334 * Boolean for knowing when the app was started as a service. |
|
335 */ |
|
336 bool mIsService; |
|
337 |
|
338 /** |
|
339 * Navigation softkey action object for back. |
|
340 */ |
|
341 HbAction *mNavKeyBackAction; |
|
342 |
|
343 /** |
|
344 * Navigation softkey action object for quit. |
|
345 */ |
|
346 HbAction *mNavKeyQuitAction; |
|
347 |
|
348 /** |
|
349 * Item sensitive context menu |
|
350 */ |
|
351 HbMenu *mContextMenu; |
|
352 |
|
353 /** |
|
354 * loacal selection mode |
|
355 */ |
|
356 int mSelectionMode; |
|
357 |
|
358 /** |
|
359 * Timer used to report thumbnail fetches class index of |
|
360 * first visible item when view is scrolling. |
|
361 */ |
|
362 QTimer *mScrollPositionTimer; |
|
363 |
|
364 /** |
|
365 * ui loade object, not owned |
|
366 */ |
|
367 VideoCollectionUiLoader *mUiLoader; |
|
368 }; |
|
369 |
|
370 #endif // VIDEOLISTWIDGET_H |