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