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