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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
34
|
18 |
#include <qgraphicswidget.h>
|
|
19 |
#include <qaction.h>
|
|
20 |
#include <qactiongroup.h>
|
|
21 |
#include <hbmenu.h>
|
|
22 |
#include <hbaction.h>
|
|
23 |
#include <hbgroupbox.h>
|
|
24 |
#include <hbpushbutton.h>
|
|
25 |
|
30
|
26 |
#include "videocollectionuiloader.h"
|
|
27 |
#include "videolistview.h"
|
|
28 |
#include "videolistselectiondialog.h"
|
|
29 |
#include "videolistwidget.h"
|
|
30 |
#include "videohintwidget.h"
|
34
|
31 |
#include "videocollectionwrapper.h"
|
|
32 |
#include "videosortfilterproxymodel.h"
|
|
33 |
#include "videocollectionviewutils.h"
|
|
34 |
#include "videoservices.h"
|
|
35 |
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
// VideoCollectionUiLoader
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
VideoCollectionUiLoader::VideoCollectionUiLoader():
|
|
41 |
HbDocumentLoader(),
|
|
42 |
mTimerId(0),
|
|
43 |
mSortGroup(0),
|
|
44 |
mIsService(false)
|
|
45 |
{
|
|
46 |
}
|
30
|
47 |
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
// VideoCollectionUiLoader
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
//
|
34
|
52 |
VideoCollectionUiLoader::~VideoCollectionUiLoader()
|
|
53 |
{
|
35
|
54 |
if (mTimerId)
|
|
55 |
{
|
|
56 |
killTimer(mTimerId);
|
|
57 |
mTimerId = 0;
|
|
58 |
}
|
|
59 |
|
|
60 |
// selection dialog needs to be deleted manually
|
|
61 |
QGraphicsWidget *widget =
|
|
62 |
HbDocumentLoader::findWidget(DOCML_NAME_DIALOG);
|
|
63 |
|
34
|
64 |
VideoListSelectionDialog *dialog =
|
35
|
65 |
qobject_cast<VideoListSelectionDialog*>(widget);
|
34
|
66 |
delete dialog;
|
|
67 |
|
|
68 |
// clear queue and hash tables
|
|
69 |
mQueue.clear();
|
35
|
70 |
mDocmls.clear();
|
34
|
71 |
mWidgets.clear();
|
|
72 |
mObjects.clear();
|
|
73 |
}
|
|
74 |
|
|
75 |
// ---------------------------------------------------------------------------
|
35
|
76 |
// load
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
QObjectList VideoCollectionUiLoader::load( const QString &fileName, bool *ok )
|
|
80 |
{
|
|
81 |
QObjectList list;
|
|
82 |
if (!mDocmls.contains(fileName))
|
|
83 |
{
|
|
84 |
mDocmls.append(fileName);
|
|
85 |
list = HbDocumentLoader::load(fileName, ok);
|
|
86 |
//TODO: save returned and delete on destructor
|
|
87 |
}
|
|
88 |
return list;
|
|
89 |
}
|
|
90 |
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
// load
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
QObjectList VideoCollectionUiLoader::load( const QString &fileName, const QString §ion , bool *ok )
|
|
96 |
{
|
|
97 |
return HbDocumentLoader::load(fileName, section, ok);
|
|
98 |
//TODO: save returned and delete on destructor
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
34
|
102 |
// startLoading
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
void VideoCollectionUiLoader::startLoading(QSet<QString> uiSections,
|
|
106 |
QObject *receiver,
|
|
107 |
const char *widgetSlot,
|
|
108 |
const char *objectSlot)
|
30
|
109 |
{
|
34
|
110 |
if (uiSections.contains(DOCML_NAME_VC_HEADINGBANNER))
|
|
111 |
{
|
|
112 |
VideoCollectionUiLoader::Params params(
|
|
113 |
DOCML_NAME_VC_HEADINGBANNER,
|
|
114 |
true, // is widget
|
|
115 |
receiver,
|
|
116 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
117 |
0,
|
34
|
118 |
widgetSlot);
|
|
119 |
addToQueue(params);
|
|
120 |
}
|
|
121 |
if (uiSections.contains(DOCML_NAME_VC_VIDEOLISTWIDGET))
|
|
122 |
{
|
|
123 |
VideoCollectionUiLoader::Params params(
|
|
124 |
DOCML_NAME_VC_VIDEOLISTWIDGET,
|
|
125 |
true, // is widget
|
|
126 |
receiver,
|
|
127 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
128 |
0,
|
34
|
129 |
widgetSlot);
|
|
130 |
addToQueue(params);
|
|
131 |
}
|
|
132 |
if (uiSections.contains(DOCML_NAME_OPTIONS_MENU))
|
|
133 |
{
|
|
134 |
VideoCollectionUiLoader::Params params(
|
|
135 |
DOCML_NAME_OPTIONS_MENU,
|
|
136 |
true, // is widget
|
|
137 |
receiver,
|
|
138 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
139 |
0,
|
34
|
140 |
widgetSlot);
|
|
141 |
addToQueue(params);
|
|
142 |
}
|
|
143 |
if (uiSections.contains(DOCML_NAME_ADD_TO_COLLECTION))
|
|
144 |
{
|
|
145 |
VideoCollectionUiLoader::Params params(
|
|
146 |
DOCML_NAME_ADD_TO_COLLECTION,
|
|
147 |
false, // is object
|
|
148 |
receiver,
|
|
149 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
150 |
0,
|
34
|
151 |
objectSlot);
|
|
152 |
addToQueue(params);
|
|
153 |
}
|
|
154 |
if (uiSections.contains(DOCML_NAME_CREATE_COLLECTION))
|
|
155 |
{
|
|
156 |
VideoCollectionUiLoader::Params params(
|
|
157 |
DOCML_NAME_CREATE_COLLECTION,
|
|
158 |
false, // is object
|
|
159 |
receiver,
|
|
160 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
161 |
0,
|
34
|
162 |
objectSlot);
|
|
163 |
addToQueue(params);
|
|
164 |
}
|
|
165 |
if (uiSections.contains(DOCML_NAME_DELETE_MULTIPLE))
|
|
166 |
{
|
|
167 |
VideoCollectionUiLoader::Params params(
|
|
168 |
DOCML_NAME_DELETE_MULTIPLE,
|
|
169 |
false, // is object
|
|
170 |
receiver,
|
|
171 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
172 |
0,
|
34
|
173 |
objectSlot);
|
|
174 |
addToQueue(params);
|
|
175 |
}
|
|
176 |
if (uiSections.contains(DOCML_NAME_VC_VIDEOHINTWIDGET))
|
|
177 |
{
|
|
178 |
VideoCollectionUiLoader::Params params(
|
|
179 |
DOCML_NAME_VC_VIDEOHINTWIDGET,
|
|
180 |
true, // is widget
|
|
181 |
receiver,
|
|
182 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
183 |
DOCML_VIDEOCOLLECTIONVIEW_SECTION_HINT,
|
34
|
184 |
widgetSlot);
|
|
185 |
addToQueue(params);
|
|
186 |
}
|
|
187 |
if (uiSections.contains(DOCML_NAME_HINT_BUTTON))
|
|
188 |
{
|
|
189 |
VideoCollectionUiLoader::Params params(
|
|
190 |
DOCML_NAME_HINT_BUTTON,
|
|
191 |
true, // is widget
|
|
192 |
receiver,
|
|
193 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
194 |
DOCML_VIDEOCOLLECTIONVIEW_SECTION_HINT,
|
34
|
195 |
widgetSlot);
|
|
196 |
addToQueue(params);
|
|
197 |
}
|
|
198 |
if (uiSections.contains(DOCML_NAME_NO_VIDEOS_LABEL))
|
|
199 |
{
|
|
200 |
VideoCollectionUiLoader::Params params(
|
|
201 |
DOCML_NAME_NO_VIDEOS_LABEL,
|
|
202 |
true, // is widget
|
|
203 |
receiver,
|
|
204 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
205 |
DOCML_VIDEOCOLLECTIONVIEW_SECTION_HINT,
|
34
|
206 |
widgetSlot);
|
|
207 |
addToQueue(params);
|
|
208 |
}
|
|
209 |
if (uiSections.contains(DOCML_NAME_SORT_BY_DATE))
|
|
210 |
{
|
|
211 |
VideoCollectionUiLoader::Params params(
|
|
212 |
DOCML_NAME_SORT_BY_DATE,
|
|
213 |
false, // is object
|
|
214 |
receiver,
|
|
215 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
216 |
0,
|
34
|
217 |
objectSlot);
|
|
218 |
addToQueue(params);
|
|
219 |
}
|
|
220 |
if (uiSections.contains(DOCML_NAME_SORT_BY_NAME))
|
|
221 |
{
|
|
222 |
VideoCollectionUiLoader::Params params(
|
|
223 |
DOCML_NAME_SORT_BY_NAME,
|
|
224 |
false, // is object
|
|
225 |
receiver,
|
|
226 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
227 |
0,
|
34
|
228 |
objectSlot);
|
|
229 |
addToQueue(params);
|
|
230 |
}
|
|
231 |
if (uiSections.contains(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS))
|
|
232 |
{
|
|
233 |
VideoCollectionUiLoader::Params params(
|
|
234 |
DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS,
|
|
235 |
false, // is object
|
|
236 |
receiver,
|
|
237 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
238 |
0,
|
34
|
239 |
objectSlot);
|
|
240 |
addToQueue(params);
|
|
241 |
}
|
|
242 |
if (uiSections.contains(DOCML_NAME_SORT_BY_SIZE))
|
|
243 |
{
|
|
244 |
VideoCollectionUiLoader::Params params(
|
|
245 |
DOCML_NAME_SORT_BY_SIZE,
|
|
246 |
false, // is object
|
|
247 |
receiver,
|
|
248 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
249 |
0,
|
34
|
250 |
objectSlot);
|
|
251 |
addToQueue(params);
|
|
252 |
}
|
|
253 |
if (uiSections.contains(DOCML_NAME_SORT_MENU))
|
|
254 |
{
|
|
255 |
VideoCollectionUiLoader::Params params(
|
|
256 |
DOCML_NAME_SORT_MENU,
|
|
257 |
true, // is widget
|
|
258 |
receiver,
|
|
259 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
260 |
0,
|
34
|
261 |
widgetSlot);
|
|
262 |
addToQueue(params);
|
|
263 |
}
|
|
264 |
if (uiSections.contains(DOCML_NAME_VC_COLLECTIONWIDGET))
|
|
265 |
{
|
|
266 |
VideoCollectionUiLoader::Params params(
|
|
267 |
DOCML_NAME_VC_COLLECTIONWIDGET,
|
|
268 |
true, // is widget
|
|
269 |
receiver,
|
|
270 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
271 |
DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
|
34
|
272 |
widgetSlot);
|
|
273 |
addToQueue(params);
|
|
274 |
}
|
|
275 |
if (uiSections.contains(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET))
|
|
276 |
{
|
|
277 |
VideoCollectionUiLoader::Params params(
|
|
278 |
DOCML_NAME_VC_COLLECTIONCONTENTWIDGET,
|
|
279 |
true, // is widget
|
|
280 |
receiver,
|
|
281 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
35
|
282 |
DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
|
34
|
283 |
widgetSlot);
|
|
284 |
addToQueue(params);
|
|
285 |
}
|
|
286 |
if (uiSections.contains(DOCML_NAME_DIALOG))
|
|
287 |
{
|
|
288 |
VideoCollectionUiLoader::Params params(DOCML_NAME_DIALOG,
|
|
289 |
true, // is widget
|
|
290 |
receiver,
|
|
291 |
DOCML_VIDEOSELECTIONDIALOG_FILE,
|
35
|
292 |
0,
|
34
|
293 |
widgetSlot);
|
|
294 |
addToQueue(params);
|
|
295 |
}
|
|
296 |
}
|
|
297 |
|
|
298 |
// ---------------------------------------------------------------------------
|
|
299 |
// setIsService
|
|
300 |
// ---------------------------------------------------------------------------
|
|
301 |
//
|
|
302 |
void VideoCollectionUiLoader::setIsService(bool isService)
|
|
303 |
{
|
|
304 |
mIsService = isService;
|
|
305 |
}
|
|
306 |
|
|
307 |
// ---------------------------------------------------------------------------
|
|
308 |
// doFindWidget
|
|
309 |
// ---------------------------------------------------------------------------
|
|
310 |
//
|
|
311 |
QGraphicsWidget* VideoCollectionUiLoader::doFindWidget(const QString &name)
|
|
312 |
{
|
|
313 |
QGraphicsWidget *widget = 0;
|
|
314 |
|
|
315 |
// 1. check from hash
|
|
316 |
if (mWidgets.contains(name))
|
|
317 |
{
|
|
318 |
widget = mWidgets.value(name);
|
|
319 |
}
|
|
320 |
|
|
321 |
// 2. load from document
|
|
322 |
else
|
|
323 |
{
|
|
324 |
widget = HbDocumentLoader::findWidget(name);
|
35
|
325 |
if (!widget)
|
|
326 |
{
|
|
327 |
// check if the widget is being loaded and remove it from queue
|
|
328 |
int count = mQueue.count();
|
|
329 |
for (int i = 0; i < count; i++)
|
|
330 |
{
|
|
331 |
const Params& params = mQueue.at(i);
|
|
332 |
if (params.mName.compare(name) == 0)
|
|
333 |
{
|
|
334 |
bool ok(true);
|
|
335 |
|
|
336 |
if(!mDocmls.contains(params.mDocml))
|
|
337 |
{
|
|
338 |
load(params.mDocml, &ok);
|
|
339 |
|
|
340 |
if (ok)
|
|
341 |
{
|
|
342 |
mDocmls.append(params.mDocml);
|
|
343 |
}
|
|
344 |
}
|
|
345 |
if ((params.mSection != 0) && ok)
|
|
346 |
{
|
|
347 |
load(params.mDocml, params.mSection, &ok);
|
|
348 |
}
|
|
349 |
if(ok)
|
|
350 |
{
|
|
351 |
widget = HbDocumentLoader::findWidget(params.mName);
|
|
352 |
}
|
|
353 |
break;
|
|
354 |
}
|
|
355 |
}
|
|
356 |
}
|
34
|
357 |
if (widget)
|
|
358 |
{
|
|
359 |
// initialize widget
|
|
360 |
initWidget(widget, name);
|
|
361 |
|
|
362 |
// add it to the hash
|
|
363 |
mWidgets.insert(name, widget);
|
|
364 |
|
|
365 |
// check if the widget is being loaded and remove it from queue
|
|
366 |
int count = mQueue.count();
|
|
367 |
for (int i = 0; i < count; i++)
|
|
368 |
{
|
|
369 |
const Params& params = mQueue.at(i);
|
|
370 |
if (params.mName.compare(name) == 0)
|
|
371 |
{
|
|
372 |
if (connect(
|
|
373 |
this, SIGNAL(widgetReady(QGraphicsWidget*, const QString&)),
|
|
374 |
params.mReceiver, params.mMember))
|
|
375 |
{
|
|
376 |
emit widgetReady(widget, params.mName);
|
|
377 |
disconnect(
|
|
378 |
this, SIGNAL(widgetReady(QGraphicsWidget*, const QString&)),
|
|
379 |
params.mReceiver, params.mMember);
|
|
380 |
}
|
|
381 |
mQueue.removeAt(i);
|
35
|
382 |
runNext(); //removes timer if queue is empty
|
34
|
383 |
break;
|
|
384 |
}
|
|
385 |
}
|
|
386 |
}
|
|
387 |
}
|
|
388 |
|
|
389 |
return widget;
|
|
390 |
}
|
|
391 |
|
|
392 |
// ---------------------------------------------------------------------------
|
|
393 |
// doFindObject
|
|
394 |
// ---------------------------------------------------------------------------
|
|
395 |
//
|
|
396 |
QObject* VideoCollectionUiLoader::doFindObject(const QString &name)
|
|
397 |
{
|
|
398 |
QObject *object = 0;
|
|
399 |
|
|
400 |
// 1. check from hash
|
|
401 |
if (mObjects.contains(name))
|
|
402 |
{
|
|
403 |
object = mObjects.value(name);
|
|
404 |
}
|
|
405 |
|
|
406 |
// 2. load from document and cancel async loading
|
|
407 |
else
|
|
408 |
{
|
|
409 |
object = HbDocumentLoader::findObject(name);
|
35
|
410 |
if (!object)
|
|
411 |
{
|
|
412 |
// check if the object is being loaded and remove it from queue
|
|
413 |
int count = mQueue.count();
|
|
414 |
for (int i = 0; i < count; i++)
|
|
415 |
{
|
|
416 |
const Params& params = mQueue.at(i);
|
|
417 |
if (params.mName.compare(name) == 0)
|
|
418 |
{
|
|
419 |
bool ok(true);
|
|
420 |
|
|
421 |
if(!mDocmls.contains(params.mDocml))
|
|
422 |
{
|
|
423 |
load(params.mDocml, &ok);
|
|
424 |
|
|
425 |
if (ok)
|
|
426 |
{
|
|
427 |
mDocmls.append(params.mDocml);
|
|
428 |
}
|
|
429 |
}
|
|
430 |
if ((params.mSection != 0) && ok)
|
|
431 |
{
|
|
432 |
load(params.mDocml, params.mSection, &ok);
|
|
433 |
}
|
|
434 |
if(ok)
|
|
435 |
{
|
|
436 |
object = HbDocumentLoader::findObject(params.mName);
|
|
437 |
}
|
|
438 |
break;
|
|
439 |
}
|
|
440 |
}
|
|
441 |
}
|
34
|
442 |
if (object)
|
|
443 |
{
|
|
444 |
// initialize widget
|
|
445 |
initObject(object, name);
|
|
446 |
|
|
447 |
// add it to the hash
|
|
448 |
mObjects.insert(name, object);
|
|
449 |
|
|
450 |
// check if the object is being loaded and remove it from queue
|
|
451 |
int count = mQueue.count();
|
|
452 |
for (int i = 0; i < count; i++)
|
|
453 |
{
|
|
454 |
const Params& params = mQueue.at(i);
|
|
455 |
if (params.mName.compare(name) == 0)
|
|
456 |
{
|
|
457 |
if (connect(
|
|
458 |
this, SIGNAL(objectReady(QObject*, const QString&)),
|
|
459 |
params.mReceiver, params.mMember))
|
|
460 |
{
|
|
461 |
emit objectReady(object, params.mName);
|
|
462 |
disconnect(
|
|
463 |
this, SIGNAL(objectReady(QObject*, const QString&)),
|
|
464 |
params.mReceiver, params.mMember);
|
|
465 |
}
|
|
466 |
mQueue.removeAt(i);
|
35
|
467 |
runNext(); //removes timer if queue is empty
|
34
|
468 |
break;
|
|
469 |
}
|
|
470 |
}
|
|
471 |
}
|
|
472 |
}
|
|
473 |
|
|
474 |
return object;
|
30
|
475 |
}
|
|
476 |
|
|
477 |
// ---------------------------------------------------------------------------
|
34
|
478 |
// addToQueue
|
|
479 |
// ---------------------------------------------------------------------------
|
|
480 |
//
|
|
481 |
void VideoCollectionUiLoader::addToQueue(Params ¶ms)
|
|
482 |
{
|
|
483 |
if (isValid(params))
|
|
484 |
{
|
|
485 |
// add the params in async queue
|
|
486 |
mQueue.append(params);
|
|
487 |
runNext();
|
|
488 |
}
|
|
489 |
}
|
|
490 |
|
|
491 |
// ---------------------------------------------------------------------------
|
|
492 |
// initWidget
|
|
493 |
// ---------------------------------------------------------------------------
|
|
494 |
//
|
|
495 |
void VideoCollectionUiLoader::initWidget(QGraphicsWidget *widget,
|
|
496 |
const QString &name)
|
|
497 |
{
|
|
498 |
if (widget)
|
|
499 |
{
|
|
500 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
501 |
|
|
502 |
if (name.compare(DOCML_NAME_VC_VIDEOLISTWIDGET) == 0)
|
|
503 |
{
|
|
504 |
VideoListWidget *videoList = qobject_cast<VideoListWidget*>(widget);
|
|
505 |
if (videoList)
|
|
506 |
{
|
|
507 |
VideoSortFilterProxyModel *model =
|
|
508 |
wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
509 |
if(model)
|
|
510 |
{
|
|
511 |
// open and sort model
|
|
512 |
model->open(VideoCollectionCommon::ELevelVideos);
|
|
513 |
VideoCollectionViewUtils::sortModel(model, true);
|
|
514 |
|
|
515 |
// init widget
|
|
516 |
VideoServices *videoServices = 0;
|
|
517 |
if (mIsService)
|
|
518 |
{
|
|
519 |
videoServices = VideoServices::instance();
|
|
520 |
}
|
|
521 |
videoList->initialize(*model, videoServices);
|
|
522 |
}
|
|
523 |
}
|
|
524 |
}
|
|
525 |
else if (name.compare(DOCML_NAME_VC_COLLECTIONWIDGET) == 0)
|
|
526 |
{
|
|
527 |
VideoSortFilterProxyModel *model = wrapper.getModel(
|
|
528 |
VideoCollectionWrapper::ECollections);
|
|
529 |
if (model)
|
|
530 |
{
|
|
531 |
model->open(VideoCollectionCommon::ELevelCategory);
|
|
532 |
|
|
533 |
// initialize video collection widget
|
|
534 |
VideoListWidget *videoList =
|
|
535 |
qobject_cast<VideoListWidget*>(widget);
|
|
536 |
if (videoList)
|
|
537 |
{
|
|
538 |
// init widget
|
|
539 |
VideoServices *videoServices = 0;
|
|
540 |
if (mIsService)
|
|
541 |
{
|
|
542 |
videoServices = VideoServices::instance();
|
|
543 |
}
|
|
544 |
videoList->initialize(*model, videoServices);
|
|
545 |
}
|
|
546 |
}
|
|
547 |
}
|
|
548 |
else if (name.compare(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) == 0)
|
|
549 |
{
|
|
550 |
VideoSortFilterProxyModel *model = wrapper.getModel(
|
|
551 |
VideoCollectionWrapper::ECollectionContent);
|
|
552 |
if (model)
|
|
553 |
{
|
|
554 |
VideoListWidget *videoList = qobject_cast<VideoListWidget*>(widget);
|
|
555 |
if (videoList)
|
|
556 |
{
|
|
557 |
// init widget
|
|
558 |
VideoServices *videoServices = 0;
|
|
559 |
if (mIsService)
|
|
560 |
{
|
|
561 |
videoServices = VideoServices::instance();
|
|
562 |
}
|
|
563 |
videoList->initialize(*model, videoServices);
|
35
|
564 |
|
|
565 |
HbEffect::add(videoList,
|
|
566 |
EFFECT_SLIDE_IN_TO_LEFT_FILENAME,
|
|
567 |
EFFECT_SLIDE_IN_TO_LEFT);
|
|
568 |
|
|
569 |
HbEffect::add(videoList,
|
|
570 |
EFFECT_SLIDE_OUT_TO_LEFT_FILENAME,
|
|
571 |
EFFECT_SLIDE_OUT_TO_LEFT);
|
34
|
572 |
}
|
|
573 |
}
|
|
574 |
}
|
|
575 |
else if (name.compare(DOCML_NAME_DIALOG) == 0)
|
|
576 |
{
|
|
577 |
// by default, initialize the selection dialog to delete mode
|
|
578 |
VideoListSelectionDialog *dialog =
|
|
579 |
qobject_cast<VideoListSelectionDialog*>(widget);
|
|
580 |
if (dialog)
|
|
581 |
{
|
|
582 |
dialog->setupContent(VideoListSelectionDialog::EDeleteVideos,
|
|
583 |
TMPXItemId::InvalidId());
|
|
584 |
}
|
|
585 |
}
|
|
586 |
else if (name.compare(DOCML_NAME_SORT_MENU) == 0)
|
|
587 |
{
|
|
588 |
HbMenu *menu = qobject_cast<HbMenu*>(widget);
|
|
589 |
if (menu)
|
|
590 |
{
|
|
591 |
// create sort by menu action
|
|
592 |
mMenuActions[EActionSortBy] = menu->menuAction();
|
|
593 |
|
|
594 |
// ensure that all the actions related to sort menu are loaded
|
|
595 |
// when sort menu is loaded
|
|
596 |
findObject<HbAction>(DOCML_NAME_SORT_BY_DATE);
|
|
597 |
findObject<HbAction>(DOCML_NAME_SORT_BY_NAME);
|
|
598 |
findObject<HbAction>(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
|
|
599 |
findObject<HbAction>(DOCML_NAME_SORT_BY_SIZE);
|
|
600 |
|
|
601 |
// add sub menu actions
|
|
602 |
if (!mSortGroup)
|
|
603 |
{
|
|
604 |
mSortGroup = new QActionGroup(menu);
|
|
605 |
mSortGroup->addAction(mMenuActions[EActionSortByDate]);
|
|
606 |
mSortGroup->addAction(mMenuActions[EActionSortByName]);
|
|
607 |
mSortGroup->addAction(mMenuActions[EACtionSortByItemCount]);
|
|
608 |
mSortGroup->addAction(mMenuActions[EActionSortBySize]);
|
|
609 |
|
|
610 |
// set all sub menu items checkable
|
|
611 |
foreach (QAction *action, menu->actions())
|
|
612 |
{
|
|
613 |
action->setCheckable(true);
|
|
614 |
}
|
|
615 |
}
|
|
616 |
}
|
|
617 |
}
|
|
618 |
else if (name.compare(DOCML_NAME_VC_VIDEOHINTWIDGET) == 0)
|
|
619 |
{
|
|
620 |
VideoHintWidget *hintWidget = qobject_cast<VideoHintWidget*>(widget);
|
|
621 |
if (hintWidget)
|
|
622 |
{
|
|
623 |
hintWidget->initialize();
|
|
624 |
}
|
|
625 |
}
|
|
626 |
else if (name.compare(DOCML_NAME_OPTIONS_MENU) == 0)
|
|
627 |
{
|
|
628 |
// ensure that all the actions related to options menu are loaded
|
|
629 |
// when options menu is loaded
|
35
|
630 |
// when applicaton has been launched as a service,
|
|
631 |
// do not load components which are not required
|
|
632 |
if(!mIsService)
|
|
633 |
{
|
|
634 |
findObject<HbAction>(DOCML_NAME_ADD_TO_COLLECTION);
|
|
635 |
findObject<HbAction>(DOCML_NAME_CREATE_COLLECTION);
|
|
636 |
findObject<HbAction>(DOCML_NAME_DELETE_MULTIPLE);
|
|
637 |
}
|
34
|
638 |
}
|
|
639 |
}
|
|
640 |
}
|
|
641 |
|
|
642 |
// ---------------------------------------------------------------------------
|
|
643 |
// initObject
|
30
|
644 |
// ---------------------------------------------------------------------------
|
|
645 |
//
|
34
|
646 |
void VideoCollectionUiLoader::initObject(QObject *object,
|
|
647 |
const QString &name)
|
|
648 |
{
|
|
649 |
if (object)
|
|
650 |
{
|
|
651 |
if (name.compare(DOCML_NAME_ADD_TO_COLLECTION) == 0)
|
|
652 |
{
|
|
653 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
654 |
if (action)
|
|
655 |
{
|
|
656 |
mMenuActions[EActionAddToCollection] = action;
|
|
657 |
}
|
|
658 |
}
|
|
659 |
else if (name.compare(DOCML_NAME_CREATE_COLLECTION) == 0)
|
|
660 |
{
|
|
661 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
662 |
if (action)
|
|
663 |
{
|
|
664 |
mMenuActions[EActionNewCollection] = action;
|
|
665 |
}
|
|
666 |
}
|
|
667 |
else if (name.compare(DOCML_NAME_DELETE_MULTIPLE) == 0)
|
|
668 |
{
|
|
669 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
670 |
if (action)
|
|
671 |
{
|
|
672 |
mMenuActions[EActionDelete] = action;
|
|
673 |
}
|
|
674 |
}
|
|
675 |
else if (name.compare(DOCML_NAME_SORT_BY_DATE) == 0)
|
|
676 |
{
|
|
677 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
678 |
if (action)
|
|
679 |
{
|
|
680 |
mMenuActions[EActionSortByDate] = action;
|
|
681 |
}
|
|
682 |
}
|
|
683 |
else if (name.compare(DOCML_NAME_SORT_BY_NAME) == 0)
|
|
684 |
{
|
|
685 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
686 |
if (action)
|
|
687 |
{
|
|
688 |
mMenuActions[EActionSortByName] = action;
|
|
689 |
}
|
|
690 |
}
|
|
691 |
else if (name.compare(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS) == 0)
|
|
692 |
{
|
|
693 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
694 |
if (action)
|
|
695 |
{
|
|
696 |
mMenuActions[EACtionSortByItemCount] = action;
|
|
697 |
}
|
|
698 |
}
|
|
699 |
else if (name.compare(DOCML_NAME_SORT_BY_SIZE) == 0)
|
|
700 |
{
|
|
701 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
702 |
if (action)
|
|
703 |
{
|
|
704 |
mMenuActions[EActionSortBySize] = action;
|
|
705 |
}
|
|
706 |
}
|
|
707 |
}
|
|
708 |
}
|
|
709 |
|
|
710 |
// ---------------------------------------------------------------------------
|
|
711 |
// timerEvent
|
|
712 |
// ---------------------------------------------------------------------------
|
|
713 |
//
|
|
714 |
void VideoCollectionUiLoader::timerEvent(QTimerEvent *event)
|
30
|
715 |
{
|
34
|
716 |
if (event)
|
|
717 |
{
|
|
718 |
if (event->timerId() == mTimerId)
|
|
719 |
{
|
|
720 |
// get current request from queue
|
|
721 |
const Params ¶ms = mQueue.at(0);
|
|
722 |
|
|
723 |
// load the widget / object
|
|
724 |
if (params.mIsWidget)
|
|
725 |
{
|
|
726 |
// correct timer id, emit signal for receiver
|
|
727 |
bool ok = connect(
|
|
728 |
this, SIGNAL(widgetReady(QGraphicsWidget*, const QString&)),
|
|
729 |
params.mReceiver, params.mMember);
|
|
730 |
if (ok)
|
|
731 |
{
|
|
732 |
QGraphicsWidget *widget =
|
|
733 |
HbDocumentLoader::findWidget(params.mName);
|
|
734 |
if (!widget)
|
|
735 |
{
|
|
736 |
// widget not found, try to load the docml
|
35
|
737 |
if(!mDocmls.contains(params.mDocml))
|
|
738 |
{
|
|
739 |
load(params.mDocml, &ok);
|
|
740 |
|
|
741 |
if (ok)
|
|
742 |
{
|
|
743 |
mDocmls.append(params.mDocml);
|
|
744 |
}
|
|
745 |
}
|
|
746 |
if ((params.mSection != 0) && ok)
|
|
747 |
{
|
|
748 |
load(params.mDocml, params.mSection, &ok);
|
|
749 |
}
|
|
750 |
if(ok)
|
|
751 |
{
|
|
752 |
widget = HbDocumentLoader::findWidget(params.mName);
|
|
753 |
}
|
34
|
754 |
}
|
|
755 |
if (widget)
|
|
756 |
{
|
|
757 |
// widget found, add it to the hash
|
|
758 |
if (!mWidgets.contains(params.mName))
|
|
759 |
{
|
|
760 |
// initialize widget
|
|
761 |
initWidget(widget, params.mName);
|
|
762 |
|
|
763 |
// insert widget in hash table
|
|
764 |
mWidgets.insert(params.mName, widget);
|
|
765 |
}
|
|
766 |
emit widgetReady(widget, params.mName);
|
|
767 |
}
|
|
768 |
}
|
|
769 |
|
|
770 |
// disconnect
|
|
771 |
disconnect(
|
|
772 |
this, SIGNAL(widgetReady(QGraphicsWidget*, const QString&)),
|
|
773 |
params.mReceiver, params.mMember);
|
|
774 |
}
|
|
775 |
else
|
|
776 |
{
|
|
777 |
// correct timer id, emit signal for receiver
|
|
778 |
bool ok = connect(
|
|
779 |
this, SIGNAL(objectReady(QObject*, const QString&)),
|
|
780 |
params.mReceiver, params.mMember);
|
|
781 |
if (ok)
|
|
782 |
{
|
|
783 |
QObject *object =
|
|
784 |
HbDocumentLoader::findObject(params.mName);
|
|
785 |
if (!object)
|
|
786 |
{
|
|
787 |
// widget not found, try to load the docml
|
35
|
788 |
if(!mDocmls.contains(params.mDocml))
|
|
789 |
{
|
|
790 |
load(params.mDocml, &ok);
|
|
791 |
|
|
792 |
if (ok)
|
|
793 |
{
|
|
794 |
mDocmls.append(params.mDocml);
|
|
795 |
}
|
|
796 |
}
|
|
797 |
if ((params.mSection != 0) && ok)
|
|
798 |
{
|
|
799 |
load(params.mDocml, params.mSection, &ok);
|
|
800 |
}
|
|
801 |
if(ok)
|
|
802 |
{
|
|
803 |
object = HbDocumentLoader::findObject(params.mName);
|
|
804 |
}
|
34
|
805 |
}
|
|
806 |
if (object)
|
|
807 |
{
|
|
808 |
// object found, add it to the hash
|
|
809 |
if (!mObjects.contains(params.mName))
|
|
810 |
{
|
|
811 |
// initialize object
|
|
812 |
initObject(object, params.mName);
|
|
813 |
|
|
814 |
// add object in hash table
|
|
815 |
mObjects.insert(params.mName, object);
|
|
816 |
}
|
|
817 |
emit objectReady(object, params.mName);
|
|
818 |
}
|
|
819 |
}
|
|
820 |
|
|
821 |
// disconnect
|
|
822 |
disconnect(
|
|
823 |
this, SIGNAL(objectReady(QObject*, const QString&)),
|
|
824 |
params.mReceiver, params.mMember);
|
|
825 |
}
|
|
826 |
}
|
|
827 |
|
|
828 |
// remove the request from the queue and run next request if any
|
|
829 |
mQueue.removeAt(0);
|
|
830 |
runNext();
|
|
831 |
}
|
30
|
832 |
}
|
|
833 |
|
|
834 |
// ---------------------------------------------------------------------------
|
|
835 |
// createObject
|
|
836 |
// ---------------------------------------------------------------------------
|
|
837 |
//
|
|
838 |
QObject* VideoCollectionUiLoader::createObject( const QString& type, const QString &name )
|
|
839 |
{
|
|
840 |
QObject* object = 0;
|
|
841 |
|
|
842 |
if ( type == VideoListView::staticMetaObject.className() )
|
|
843 |
{
|
|
844 |
object = new VideoListView(this);
|
|
845 |
}
|
|
846 |
else if ( type == VideoListSelectionDialog::staticMetaObject.className() )
|
|
847 |
{
|
|
848 |
object = new VideoListSelectionDialog(this);
|
|
849 |
}
|
|
850 |
else if ( type == VideoListWidget::staticMetaObject.className() )
|
|
851 |
{
|
34
|
852 |
object = new VideoListWidget(this);
|
30
|
853 |
}
|
|
854 |
else if ( type == VideoHintWidget::staticMetaObject.className() )
|
|
855 |
{
|
|
856 |
object = new VideoHintWidget(this);
|
|
857 |
}
|
|
858 |
if ( object )
|
|
859 |
{
|
|
860 |
object->setObjectName( name );
|
|
861 |
return object;
|
|
862 |
}
|
|
863 |
|
|
864 |
return HbDocumentLoader::createObject( type, name );
|
|
865 |
}
|
34
|
866 |
|
|
867 |
// ---------------------------------------------------------------------------
|
|
868 |
// runNext
|
|
869 |
// ---------------------------------------------------------------------------
|
|
870 |
//
|
|
871 |
void VideoCollectionUiLoader::runNext()
|
|
872 |
{
|
|
873 |
if (mQueue.count())
|
|
874 |
{
|
|
875 |
if (!mTimerId)
|
|
876 |
{
|
|
877 |
// timer not running, start it
|
|
878 |
mTimerId = startTimer(ASYNC_FIND_TIMEOUT);
|
|
879 |
}
|
|
880 |
}
|
|
881 |
else
|
|
882 |
{
|
|
883 |
// no new requests, kill timer
|
|
884 |
if (mTimerId)
|
|
885 |
{
|
|
886 |
killTimer(mTimerId);
|
|
887 |
mTimerId = 0;
|
|
888 |
}
|
|
889 |
}
|
|
890 |
}
|
|
891 |
|
|
892 |
// ---------------------------------------------------------------------------
|
|
893 |
// isValid
|
|
894 |
// ---------------------------------------------------------------------------
|
|
895 |
//
|
|
896 |
bool VideoCollectionUiLoader::isValid(const Params ¶ms)
|
|
897 |
{
|
|
898 |
bool valid = true;
|
|
899 |
|
|
900 |
if (params.mName.length() &&
|
|
901 |
params.mDocml &&
|
|
902 |
params.mMember &&
|
|
903 |
params.mReceiver)
|
|
904 |
{
|
|
905 |
// check if the param is already in the queue
|
|
906 |
int count = mQueue.count();
|
|
907 |
for (int i = 0; i < count; i++)
|
|
908 |
{
|
|
909 |
if (mQueue.at(i).isDuplicate(params))
|
|
910 |
{
|
|
911 |
valid = false;
|
|
912 |
break;
|
|
913 |
}
|
|
914 |
}
|
|
915 |
|
|
916 |
// check that the item has not already been loaded
|
|
917 |
if (valid)
|
|
918 |
{
|
|
919 |
if (params.mIsWidget)
|
|
920 |
{
|
|
921 |
valid = !mWidgets.contains(params.mName);
|
|
922 |
}
|
|
923 |
else
|
|
924 |
{
|
|
925 |
valid = !mObjects.contains(params.mName);
|
|
926 |
}
|
|
927 |
}
|
|
928 |
}
|
|
929 |
else
|
|
930 |
{
|
|
931 |
valid = false;
|
|
932 |
}
|
|
933 |
|
|
934 |
return valid;
|
|
935 |
}
|