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: Videolist view class source code
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
66
|
18 |
// Version : %version: 113.1.15 %
|
36
|
19 |
|
|
20 |
// INCLUDE FILES
|
30
|
21 |
#include <hbinstance.h>
|
|
22 |
#include <hbmainwindow.h>
|
|
23 |
#include <hbtoolbar.h>
|
|
24 |
#include <hbaction.h>
|
|
25 |
#include <hbmenu.h>
|
|
26 |
#include <hbgroupbox.h>
|
44
|
27 |
#include <hbparameterlengthlimiter.h>
|
|
28 |
#include <hbtoolbarextension.h>
|
66
|
29 |
#include <hblabel.h>
|
63
|
30 |
#include <xqaiwdecl.h>
|
34
|
31 |
#include <vcxmyvideosdefs.h>
|
30
|
32 |
|
|
33 |
#include "videoservices.h"
|
|
34 |
#include "videocollectionviewutils.h"
|
|
35 |
#include "videolistwidget.h"
|
|
36 |
#include "videolistview.h"
|
63
|
37 |
#include "videolisttoolbar.h"
|
|
38 |
#include "videolistmenu.h"
|
30
|
39 |
#include "videocollectioncommon.h"
|
|
40 |
#include "videocollectionwrapper.h"
|
58
|
41 |
#include "videoproxymodelgeneric.h"
|
30
|
42 |
#include "videocollectionuiloader.h"
|
36
|
43 |
#include "videocollectiontrace.h"
|
30
|
44 |
|
38
|
45 |
// Object names.
|
|
46 |
const char* const LIST_VIEW_OBJECT_NAME_OPTIONS_MENU = "vc::ListViewOptionsMenu";
|
|
47 |
|
30
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
// Constructor
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
//
|
36
|
52 |
VideoListView::VideoListView( VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent )
|
63
|
53 |
: HbView(parent)
|
|
54 |
, mUiUtils(VideoCollectionViewUtils::instance())
|
|
55 |
, mWrapper(VideoCollectionWrapper::instance())
|
|
56 |
, mUiLoader(uiLoader)
|
|
57 |
, mToolbar(0)
|
|
58 |
, mMenu(0)
|
|
59 |
, mModelReady(false)
|
|
60 |
, mViewReady(false)
|
|
61 |
, mVideoServices(0)
|
|
62 |
, mCurrentList(0)
|
30
|
63 |
{
|
36
|
64 |
FUNC_LOG;
|
30
|
65 |
}
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// Destructor
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
VideoListView::~VideoListView()
|
|
72 |
{
|
36
|
73 |
FUNC_LOG;
|
34
|
74 |
|
35
|
75 |
toolBar()->clearActions();
|
|
76 |
|
30
|
77 |
if(mVideoServices)
|
|
78 |
{
|
|
79 |
mVideoServices->decreaseReferenceCount();
|
|
80 |
mVideoServices = 0;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
// initializeView()
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
int VideoListView::initializeView()
|
|
89 |
{
|
36
|
90 |
FUNC_LOG;
|
30
|
91 |
if(!mUiLoader)
|
|
92 |
{
|
34
|
93 |
cleanup();
|
30
|
94 |
return -1;
|
|
95 |
}
|
41
|
96 |
int videoListPhase = VideoCollectionUiLoaderParam::LoadPhasePrimary;
|
|
97 |
int collectionListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
|
|
98 |
int collectionContentListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
|
|
99 |
VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
|
58
|
100 |
if (mUiUtils.isService())
|
30
|
101 |
{
|
41
|
102 |
INFO("VideoListView::initializeView() initializing service.");
|
30
|
103 |
if (!mVideoServices)
|
|
104 |
{
|
41
|
105 |
mVideoServices = VideoServices::instance();
|
|
106 |
connect(mVideoServices, SIGNAL(titleReady(const QString&)),
|
|
107 |
this, SLOT(titleReadySlot(const QString&)));
|
30
|
108 |
}
|
41
|
109 |
|
30
|
110 |
}
|
41
|
111 |
else
|
39
|
112 |
{
|
41
|
113 |
if(mVideoServices)
|
|
114 |
{
|
|
115 |
disconnect(mVideoServices, SIGNAL(titleReady(const QString&)),
|
|
116 |
this, SLOT(titleReadySlot(const QString&)));
|
|
117 |
mVideoServices->decreaseReferenceCount();
|
|
118 |
mVideoServices = 0;
|
|
119 |
}
|
|
120 |
VideoCollectionViewUtils::getActivityWidgetLevel(level);
|
|
121 |
if(level == VideoCollectionCommon::ELevelCategory)
|
|
122 |
{
|
|
123 |
videoListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
|
|
124 |
collectionListPhase = VideoCollectionUiLoaderParam::LoadPhasePrimary;
|
|
125 |
collectionContentListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
|
|
126 |
}
|
|
127 |
else if(level == VideoCollectionCommon::ELevelDefaultColl ||
|
|
128 |
level == VideoCollectionCommon::ELevelAlbum)
|
|
129 |
{
|
|
130 |
videoListPhase = VideoCollectionUiLoaderParam::LoadPhaseSecondary;
|
|
131 |
collectionListPhase = VideoCollectionUiLoaderParam::LoadPhasePrimary;
|
|
132 |
collectionContentListPhase = VideoCollectionUiLoaderParam::LoadPhasePrimary;
|
|
133 |
}
|
39
|
134 |
}
|
36
|
135 |
// start loading objects and widgets
|
41
|
136 |
QList<VideoCollectionUiLoaderParam> params;
|
|
137 |
|
36
|
138 |
params.append(VideoCollectionUiLoaderParam(
|
41
|
139 |
DOCML_NAME_VC_VIDEOLISTWIDGET,
|
|
140 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
49
|
141 |
DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
|
41
|
142 |
true,
|
|
143 |
videoListPhase));
|
|
144 |
|
39
|
145 |
params.append(VideoCollectionUiLoaderParam(
|
41
|
146 |
DOCML_NAME_VC_COLLECTIONWIDGET,
|
|
147 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
|
148 |
DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
|
|
149 |
true,
|
|
150 |
collectionListPhase));
|
|
151 |
|
|
152 |
params.append(VideoCollectionUiLoaderParam(
|
|
153 |
DOCML_NAME_VC_COLLECTIONCONTENTWIDGET,
|
|
154 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
|
155 |
DOCML_VIDEOCOLLECTIONVIEW_SECTION_LIST,
|
|
156 |
true,
|
63
|
157 |
collectionContentListPhase));
|
41
|
158 |
|
36
|
159 |
params.append(VideoCollectionUiLoaderParam(
|
|
160 |
DOCML_NAME_VC_HEADINGBANNER,
|
|
161 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
|
162 |
true,
|
|
163 |
VideoCollectionUiLoaderParam::LoadPhaseSecondary));
|
|
164 |
params.append(VideoCollectionUiLoaderParam(
|
|
165 |
DOCML_NAME_DIALOG,
|
|
166 |
DOCML_VIDEOSELECTIONDIALOG_FILE,
|
|
167 |
true,
|
|
168 |
VideoCollectionUiLoaderParam::LoadPhaseSecondary));
|
|
169 |
params.append(VideoCollectionUiLoaderParam(
|
66
|
170 |
DOCML_NAME_NO_CONTENT_LABEL,
|
36
|
171 |
DOCML_VIDEOCOLLECTIONVIEW_FILE,
|
|
172 |
true,
|
|
173 |
VideoCollectionUiLoaderParam::LoadPhaseSecondary));
|
|
174 |
mUiLoader->addData(params,
|
|
175 |
this,
|
|
176 |
SLOT(objectReadySlot(QObject*, const QString&)));
|
63
|
177 |
params.clear();
|
|
178 |
|
|
179 |
if(!mMenu)
|
|
180 |
{
|
|
181 |
mMenu = new VideoListMenu(mUiLoader, this);
|
|
182 |
int err = mMenu->initializeMenu();
|
|
183 |
if(err)
|
|
184 |
{
|
|
185 |
cleanup();
|
|
186 |
return -1;
|
|
187 |
}
|
|
188 |
}
|
|
189 |
|
36
|
190 |
mUiLoader->loadPhase(VideoCollectionUiLoaderParam::LoadPhasePrimary);
|
34
|
191 |
|
41
|
192 |
// fetch current list right away for main views
|
|
193 |
// for default and user defined collections, currentList
|
|
194 |
// will be setted during activation
|
39
|
195 |
if(videoListPhase == VideoCollectionUiLoaderParam::LoadPhasePrimary)
|
|
196 |
{
|
|
197 |
mCurrentList = mUiLoader->findWidget<VideoListWidget>(
|
41
|
198 |
DOCML_NAME_VC_VIDEOLISTWIDGET );
|
39
|
199 |
}
|
41
|
200 |
else
|
39
|
201 |
{
|
|
202 |
mCurrentList = mUiLoader->findWidget<VideoListWidget>(
|
41
|
203 |
DOCML_NAME_VC_COLLECTIONWIDGET );
|
39
|
204 |
}
|
41
|
205 |
|
30
|
206 |
return 0;
|
|
207 |
}
|
|
208 |
|
|
209 |
// ---------------------------------------------------------------------------
|
|
210 |
// titleReadySlot()
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
void VideoListView::titleReadySlot(const QString& title)
|
|
214 |
{
|
36
|
215 |
FUNC_LOG;
|
30
|
216 |
setTitle(title);
|
|
217 |
}
|
|
218 |
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
// activateView()
|
|
221 |
// ---------------------------------------------------------------------------
|
|
222 |
//
|
41
|
223 |
int VideoListView::activateView( TMPXItemId &itemId)
|
30
|
224 |
{
|
36
|
225 |
FUNC_LOG;
|
|
226 |
|
41
|
227 |
int err = -1;
|
|
228 |
|
36
|
229 |
// activate collection to correct view
|
|
230 |
if (itemId == TMPXItemId::InvalidId())
|
41
|
231 |
{
|
|
232 |
|
|
233 |
VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
|
|
234 |
if(!mVideoServices)
|
|
235 |
{
|
|
236 |
VideoCollectionViewUtils::getActivityWidgetLevel(level);
|
|
237 |
}
|
|
238 |
if(level == VideoCollectionCommon::ELevelCategory ||
|
|
239 |
level == VideoCollectionCommon::ELevelVideos)
|
|
240 |
{
|
|
241 |
err = activateMainView();
|
|
242 |
}
|
|
243 |
else if(level == VideoCollectionCommon::ELevelDefaultColl ||
|
|
244 |
level == VideoCollectionCommon::ELevelAlbum)
|
|
245 |
{
|
|
246 |
// level is default or user defined collection
|
|
247 |
// see if we have item id
|
|
248 |
VideoCollectionViewUtils::getCollectionActivityData(itemId, mCollectionName);
|
|
249 |
}
|
34
|
250 |
}
|
41
|
251 |
if(itemId != TMPXItemId::InvalidId())
|
34
|
252 |
{
|
36
|
253 |
err = activateCollectionContentView(itemId);
|
30
|
254 |
}
|
34
|
255 |
|
41
|
256 |
if(!err)
|
|
257 |
{
|
|
258 |
|
|
259 |
err = createToolbar();
|
|
260 |
}
|
|
261 |
|
36
|
262 |
// connect signals if everything went ok
|
41
|
263 |
if (!err)
|
35
|
264 |
{
|
36
|
265 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
|
266 |
mainWnd->setOrientation(Qt::Vertical, false);
|
|
267 |
if (!connect(
|
|
268 |
mainWnd, SIGNAL(aboutToChangeOrientation()),
|
|
269 |
this, SLOT( aboutToChangeOrientationSlot())) ||
|
|
270 |
!connect(
|
|
271 |
mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
|
|
272 |
this, SLOT(orientationChangedSlot(Qt::Orientation))) ||
|
|
273 |
!connect(
|
|
274 |
&mWrapper, SIGNAL(asyncStatus(int, QVariant&)),
|
|
275 |
this, SLOT(handleAsyncStatusSlot(int, QVariant&))) ||
|
|
276 |
!connect(
|
40
|
277 |
mCurrentList->getModel()->sourceModel(), SIGNAL(modelChanged()),
|
36
|
278 |
this, SLOT(layoutChangedSlot())) ||
|
|
279 |
!connect(
|
40
|
280 |
mCurrentList->getModel()->sourceModel(), SIGNAL(modelReady()),
|
50
|
281 |
this, SLOT(modelReadySlot())) ||
|
|
282 |
!connect(
|
|
283 |
mCurrentList->getModel()->sourceModel(), SIGNAL(albumListReady()),
|
|
284 |
this, SLOT(albumListReadySlot())))
|
36
|
285 |
{
|
|
286 |
ERROR(-1, "VideoListView::activateView() failed to connect signals.");
|
|
287 |
// deactivate view so we get rid of dangling connections.
|
|
288 |
deactivateView();
|
|
289 |
err = -1;
|
|
290 |
}
|
35
|
291 |
}
|
41
|
292 |
else
|
|
293 |
{
|
|
294 |
deactivateView();
|
|
295 |
}
|
36
|
296 |
|
|
297 |
return err;
|
35
|
298 |
}
|
|
299 |
|
|
300 |
// ---------------------------------------------------------------------------
|
|
301 |
// doDelayedsSlot
|
|
302 |
// ---------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
void VideoListView::doDelayedsSlot()
|
|
305 |
{
|
36
|
306 |
FUNC_LOG;
|
|
307 |
mUiLoader->loadPhase(VideoCollectionUiLoaderParam::LoadPhaseSecondary);
|
39
|
308 |
if(mCurrentList)
|
|
309 |
{
|
|
310 |
mCurrentList->doDelayedsSlot();
|
|
311 |
}
|
35
|
312 |
}
|
|
313 |
|
30
|
314 |
// ---------------------------------------------------------------------------
|
|
315 |
// modelReadySlot
|
|
316 |
// ---------------------------------------------------------------------------
|
|
317 |
//
|
|
318 |
void VideoListView::modelReadySlot()
|
|
319 |
{
|
36
|
320 |
FUNC_LOG;
|
37
|
321 |
|
50
|
322 |
// check that current list is all videos or collection content.
|
|
323 |
VideoCollectionCommon::TCollectionLevels level = mCurrentList->getLevel();
|
|
324 |
if(level != VideoCollectionCommon::ELevelCategory)
|
37
|
325 |
{
|
50
|
326 |
modelReady();
|
37
|
327 |
}
|
50
|
328 |
}
|
|
329 |
|
|
330 |
// ---------------------------------------------------------------------------
|
|
331 |
// albumListReadySlot
|
|
332 |
// ---------------------------------------------------------------------------
|
|
333 |
//
|
|
334 |
void VideoListView::albumListReadySlot()
|
|
335 |
{
|
|
336 |
FUNC_LOG;
|
34
|
337 |
|
50
|
338 |
// check that current list is category list.
|
|
339 |
VideoCollectionCommon::TCollectionLevels level = mCurrentList->getLevel();
|
|
340 |
if(level == VideoCollectionCommon::ELevelCategory)
|
|
341 |
{
|
|
342 |
modelReady();
|
|
343 |
}
|
30
|
344 |
}
|
|
345 |
|
|
346 |
// ---------------------------------------------------------------------------
|
|
347 |
// layoutChangedSlot
|
|
348 |
// ---------------------------------------------------------------------------
|
|
349 |
//
|
|
350 |
void VideoListView::layoutChangedSlot()
|
|
351 |
{
|
36
|
352 |
FUNC_LOG;
|
38
|
353 |
// Note that showHint should be executed before updateSubLabel as it
|
|
354 |
// can modify the mModelReady flag.
|
|
355 |
showHint();
|
30
|
356 |
updateSubLabel();
|
|
357 |
}
|
|
358 |
|
|
359 |
// ---------------------------------------------------------------------------
|
|
360 |
// deactivateView()
|
|
361 |
// ---------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
void VideoListView::deactivateView()
|
|
364 |
{
|
36
|
365 |
FUNC_LOG;
|
30
|
366 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
34
|
367 |
|
|
368 |
mainWnd->unsetOrientation();
|
|
369 |
|
30
|
370 |
disconnect(mainWnd, SIGNAL(aboutToChangeOrientation()),
|
|
371 |
this, SLOT(aboutToChangeOrientationSlot()));
|
|
372 |
|
|
373 |
disconnect(mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
|
|
374 |
this, SLOT(orientationChangedSlot(Qt::Orientation)));
|
|
375 |
|
34
|
376 |
disconnect(&mWrapper, SIGNAL(asyncStatus(int, QVariant&)),
|
30
|
377 |
this, SLOT(handleAsyncStatusSlot(int, QVariant&)));
|
34
|
378 |
|
|
379 |
HbMenu *menu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_OPTIONS_MENU);
|
38
|
380 |
if(menu)
|
34
|
381 |
{
|
38
|
382 |
menu->setObjectName(LIST_VIEW_OBJECT_NAME_OPTIONS_MENU);
|
34
|
383 |
menu->hide();
|
|
384 |
}
|
40
|
385 |
|
|
386 |
if(mCurrentList && mCurrentList->getModel() && mCurrentList->getModel()->sourceModel())
|
34
|
387 |
{
|
40
|
388 |
disconnect(mCurrentList->getModel()->sourceModel(),
|
34
|
389 |
SIGNAL(modelChanged()),
|
|
390 |
this, SLOT(layoutChangedSlot()));
|
40
|
391 |
disconnect(mCurrentList->getModel()->sourceModel(),
|
34
|
392 |
SIGNAL(modelReady()),
|
|
393 |
this, SLOT(modelReadySlot()));
|
30
|
394 |
|
34
|
395 |
showHint(false);
|
41
|
396 |
if(!mVideoServices)
|
|
397 |
{
|
|
398 |
VideoCollectionCommon::TCollectionLevels level = mCurrentList->getLevel();
|
|
399 |
VideoCollectionViewUtils::setWidgetActivityLevel(level);
|
|
400 |
}
|
34
|
401 |
mCurrentList->deactivate();
|
30
|
402 |
}
|
|
403 |
}
|
|
404 |
|
|
405 |
// ---------------------------------------------------------------------------
|
|
406 |
// back()
|
|
407 |
// ---------------------------------------------------------------------------
|
|
408 |
//
|
|
409 |
void VideoListView::back()
|
|
410 |
{
|
36
|
411 |
FUNC_LOG;
|
30
|
412 |
}
|
|
413 |
|
|
414 |
// ---------------------------------------------------------------------------
|
63
|
415 |
// getCurrentList()
|
|
416 |
// ---------------------------------------------------------------------------
|
|
417 |
//
|
|
418 |
VideoListWidget* VideoListView::getCurrentList()
|
|
419 |
{
|
|
420 |
FUNC_LOG;
|
|
421 |
|
|
422 |
return mCurrentList;
|
|
423 |
}
|
|
424 |
|
|
425 |
// ---------------------------------------------------------------------------
|
50
|
426 |
// modelReady()
|
|
427 |
// ---------------------------------------------------------------------------
|
|
428 |
//
|
|
429 |
void VideoListView::modelReady()
|
|
430 |
{
|
|
431 |
FUNC_LOG;
|
|
432 |
|
|
433 |
// if mViewReady is false, then it means that this is the first time
|
|
434 |
// modelReady or albumListReady signal fires. Signaling that view is ready.
|
|
435 |
if(!mViewReady)
|
|
436 |
{
|
|
437 |
mViewReady = true;
|
|
438 |
emit viewReady();
|
|
439 |
}
|
|
440 |
|
|
441 |
mModelReady = true;
|
|
442 |
|
|
443 |
// since the reset signal arrives after
|
|
444 |
// layout changed, need to make sure that
|
|
445 |
// view is updated in case needed
|
|
446 |
layoutChangedSlot();
|
|
447 |
}
|
|
448 |
|
|
449 |
// ---------------------------------------------------------------------------
|
30
|
450 |
// cleanup()
|
|
451 |
// ---------------------------------------------------------------------------
|
|
452 |
//
|
|
453 |
void VideoListView::cleanup()
|
|
454 |
{
|
36
|
455 |
FUNC_LOG;
|
63
|
456 |
|
|
457 |
delete mToolbar;
|
|
458 |
mToolbar = 0;
|
|
459 |
|
34
|
460 |
mCurrentList = 0;
|
30
|
461 |
}
|
|
462 |
|
|
463 |
// ---------------------------------------------------------------------------
|
|
464 |
// createToolbar()
|
63
|
465 |
// Creates toolbar
|
30
|
466 |
// ---------------------------------------------------------------------------
|
|
467 |
//
|
|
468 |
int VideoListView::createToolbar()
|
|
469 |
{
|
36
|
470 |
FUNC_LOG;
|
38
|
471 |
|
63
|
472 |
// creates VideoListToolbar and HbToolbar
|
|
473 |
if(!mToolbar)
|
30
|
474 |
{
|
63
|
475 |
mToolbar = new VideoListToolbar(mUiLoader, this);
|
30
|
476 |
|
|
477 |
HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
|
63
|
478 |
|
|
479 |
if(!bar || !mToolbar ||
|
|
480 |
!connect(
|
|
481 |
mToolbar, SIGNAL(actionsChanged(QList<QAction*>)),
|
|
482 |
this, SLOT(toolbarActionsChanged(QList<QAction*>))) ||
|
|
483 |
!connect(
|
|
484 |
mToolbar, SIGNAL(toolbarExtensionChanged(HbToolBarExtension*)),
|
|
485 |
this, SLOT(toolbarExtensionChanged(HbToolBarExtension*))) ||
|
|
486 |
!connect(
|
|
487 |
mToolbar, SIGNAL(allVideosActionTriggered()),
|
|
488 |
this, SLOT(openAllVideosViewSlot())) ||
|
|
489 |
!connect(
|
|
490 |
mToolbar, SIGNAL(collectionViewActionTriggered()),
|
|
491 |
this, SLOT(openCollectionViewSlot())))
|
30
|
492 |
{
|
63
|
493 |
ERROR(-1, "VideoListView::createToolbar() failed to create all the toolbar.");
|
|
494 |
delete mToolbar;
|
|
495 |
mToolbar = 0;
|
|
496 |
return -1;
|
41
|
497 |
}
|
63
|
498 |
|
|
499 |
mToolbar->initialize();
|
|
500 |
mToolbar->viewStateChanged(mCurrentList->getLevel(), true, false);
|
30
|
501 |
}
|
|
502 |
|
|
503 |
return 0;
|
|
504 |
}
|
|
505 |
|
|
506 |
// ---------------------------------------------------------------------------
|
|
507 |
// showHint
|
|
508 |
// ---------------------------------------------------------------------------
|
|
509 |
//
|
|
510 |
void VideoListView::showHint(bool show)
|
|
511 |
{
|
36
|
512 |
FUNC_LOG;
|
34
|
513 |
if(!mCurrentList)
|
30
|
514 |
{
|
34
|
515 |
return;
|
30
|
516 |
}
|
34
|
517 |
|
58
|
518 |
VideoProxyModelGeneric *model = mCurrentList->getModel();
|
36
|
519 |
|
40
|
520 |
if(!model || (!mModelReady && model->rowCount() == 0))
|
38
|
521 |
{
|
|
522 |
return;
|
|
523 |
}
|
|
524 |
|
|
525 |
mModelReady = true;
|
|
526 |
|
66
|
527 |
// decide if no content label needs to be shown or not.
|
40
|
528 |
show = show && model->rowCount() == 0;
|
66
|
529 |
|
|
530 |
// set visibility for the label.
|
|
531 |
HbLabel *noContentLabel =
|
|
532 |
mUiLoader->findWidget<HbLabel>(
|
|
533 |
DOCML_NAME_NO_CONTENT_LABEL);
|
|
534 |
if (noContentLabel)
|
35
|
535 |
{
|
66
|
536 |
noContentLabel->setVisible(show);
|
36
|
537 |
}
|
|
538 |
|
63
|
539 |
mToolbar->viewStateChanged(mCurrentList->getLevel(), show, mModelReady);
|
|
540 |
|
36
|
541 |
// prepare sublabel
|
|
542 |
HbGroupBox *subLabel =
|
|
543 |
mUiLoader->findWidget<HbGroupBox>(
|
|
544 |
DOCML_NAME_VC_HEADINGBANNER);
|
34
|
545 |
if (subLabel)
|
|
546 |
{
|
|
547 |
if (show &&
|
|
548 |
mCurrentList->getLevel() == VideoCollectionCommon::ELevelVideos)
|
30
|
549 |
{
|
34
|
550 |
subLabel->hide();
|
|
551 |
}
|
36
|
552 |
else
|
34
|
553 |
{
|
|
554 |
subLabel->show();
|
30
|
555 |
}
|
|
556 |
}
|
|
557 |
}
|
|
558 |
|
|
559 |
// ---------------------------------------------------------------------------
|
|
560 |
// updateSubLabel
|
|
561 |
// ---------------------------------------------------------------------------
|
|
562 |
//
|
|
563 |
void VideoListView::updateSubLabel()
|
|
564 |
{
|
36
|
565 |
FUNC_LOG;
|
58
|
566 |
VideoProxyModelGeneric *model = 0;
|
34
|
567 |
if(mCurrentList)
|
|
568 |
{
|
40
|
569 |
model = mCurrentList->getModel();
|
34
|
570 |
}
|
|
571 |
|
38
|
572 |
if (model && mModelReady)
|
30
|
573 |
{
|
34
|
574 |
int itemCount = model->rowCount();
|
|
575 |
|
|
576 |
HbGroupBox *subLabel =
|
|
577 |
mUiLoader->findWidget<HbGroupBox>(
|
|
578 |
DOCML_NAME_VC_HEADINGBANNER);
|
35
|
579 |
|
36
|
580 |
if(subLabel && mCurrentList)
|
34
|
581 |
{
|
36
|
582 |
if (mCurrentList->getLevel() == VideoCollectionCommon::ELevelVideos)
|
35
|
583 |
{
|
66
|
584 |
// no need to update sublabel if there are no items in videolist.
|
|
585 |
// no content label is shown instead.
|
36
|
586 |
if (itemCount)
|
|
587 |
{
|
66
|
588 |
subLabel->setHeading(hbTrId("txt_videos_subtitle_all_videos_l1", itemCount));
|
36
|
589 |
}
|
35
|
590 |
}
|
36
|
591 |
else if (mCurrentList->getLevel() == VideoCollectionCommon::ELevelCategory)
|
35
|
592 |
{
|
66
|
593 |
subLabel->setHeading(hbTrId("txt_videos_subtitle_collections_l1", itemCount));
|
35
|
594 |
}
|
36
|
595 |
else
|
35
|
596 |
{
|
44
|
597 |
QString text = HbParameterLengthLimiter(hbTrId("txt_videos_subtitle_1_l2")).arg(mCollectionName).arg(itemCount);
|
|
598 |
subLabel->setHeading(text);
|
35
|
599 |
}
|
34
|
600 |
}
|
|
601 |
}
|
|
602 |
}
|
30
|
603 |
|
34
|
604 |
// ---------------------------------------------------------------------------
|
41
|
605 |
// activateMainView()
|
34
|
606 |
// ---------------------------------------------------------------------------
|
|
607 |
//
|
41
|
608 |
int VideoListView::activateMainView()
|
34
|
609 |
{
|
36
|
610 |
FUNC_LOG;
|
39
|
611 |
|
|
612 |
if(!mCurrentList)
|
|
613 |
{
|
|
614 |
return -1;
|
|
615 |
}
|
|
616 |
|
41
|
617 |
int result = mCurrentList->activate();
|
39
|
618 |
if(result < 0)
|
34
|
619 |
{
|
39
|
620 |
ERROR(result, "VideoListView::activateVideosView() failed to activate.");
|
|
621 |
return -1;
|
34
|
622 |
}
|
41
|
623 |
|
36
|
624 |
return 0;
|
34
|
625 |
}
|
|
626 |
|
|
627 |
// ---------------------------------------------------------------------------
|
36
|
628 |
// activateCollectionContentView()
|
34
|
629 |
// ---------------------------------------------------------------------------
|
|
630 |
//
|
36
|
631 |
int VideoListView::activateCollectionContentView(const TMPXItemId &itemId)
|
34
|
632 |
{
|
36
|
633 |
FUNC_LOG;
|
41
|
634 |
|
|
635 |
// resolve collection name if possible
|
|
636 |
if(itemId.iId2 == KVcxMvcMediaTypeCategory && mCollectionName.isEmpty())
|
34
|
637 |
{
|
41
|
638 |
if (itemId.iId1 == KVcxMvcCategoryIdDownloads)
|
|
639 |
{
|
|
640 |
mCollectionName = hbTrId("txt_videos_dblist_downloaded");
|
|
641 |
}
|
|
642 |
else if(itemId.iId1 == KVcxMvcCategoryIdCaptured)
|
|
643 |
{
|
|
644 |
mCollectionName = hbTrId("txt_videos_dblist_captured");
|
|
645 |
}
|
|
646 |
else
|
30
|
647 |
{
|
41
|
648 |
// only downloads and captured are supported in default collections
|
|
649 |
ERROR(-1, "VideoListView::activateVideosView() invalid defauld collection.");
|
|
650 |
return -1;
|
30
|
651 |
}
|
41
|
652 |
}
|
|
653 |
// at this point activation will fail if there's no collection name available
|
|
654 |
if(mCollectionName.isEmpty())
|
|
655 |
{
|
|
656 |
ERROR(-1, "VideoListView::activateVideosView() no collection name, cannot proceed.");
|
|
657 |
return -1;
|
36
|
658 |
}
|
41
|
659 |
|
|
660 |
// if current list at this point is already collection content,
|
|
661 |
// no need to init again, just activate
|
|
662 |
if(mCurrentList &&
|
|
663 |
(mCurrentList->getLevel() == VideoCollectionCommon::ELevelDefaultColl ||
|
|
664 |
mCurrentList->getLevel() == VideoCollectionCommon::ELevelAlbum))
|
36
|
665 |
{
|
41
|
666 |
|
|
667 |
return mCurrentList->activate();
|
|
668 |
}
|
|
669 |
// no currentlist, or currentlist differs, create and initialize all over
|
|
670 |
collectionOpenedSlot(true, mCollectionName, itemId);
|
|
671 |
|
|
672 |
if((!mCurrentList || !mCurrentList->getModel()) ||
|
|
673 |
(mCurrentList->getLevel() != VideoCollectionCommon::ELevelDefaultColl &&
|
|
674 |
mCurrentList->getLevel() != VideoCollectionCommon::ELevelAlbum ))
|
|
675 |
{
|
|
676 |
ERROR(-1, "VideoListView::activateVideosView() failed to init and activate collection.");
|
|
677 |
return -1;
|
30
|
678 |
}
|
34
|
679 |
|
41
|
680 |
// if we're servicing, need to fetch sorting role from client
|
|
681 |
// in normal use, sorting has set already at uiloader
|
|
682 |
|
|
683 |
if (mVideoServices)
|
|
684 |
{
|
|
685 |
// TODO: service sorting roles needs to be defined somewhere
|
|
686 |
int sortRole = mVideoServices->sortRole();
|
63
|
687 |
if(sortRole == XQService::SortTitle)
|
41
|
688 |
{
|
|
689 |
sortRole = VideoCollectionCommon::KeyTitle;
|
|
690 |
}
|
63
|
691 |
else if(sortRole == XQService::SortSize)
|
41
|
692 |
{
|
|
693 |
sortRole = VideoCollectionCommon::KeySizeValue;
|
|
694 |
}
|
|
695 |
else
|
|
696 |
{
|
|
697 |
// default
|
|
698 |
sortRole = VideoCollectionCommon::KeyDateTime;
|
|
699 |
}
|
|
700 |
mCurrentList->getModel()->doSorting(sortRole, Qt::AscendingOrder);
|
|
701 |
}
|
|
702 |
|
|
703 |
return 0;
|
30
|
704 |
}
|
|
705 |
|
|
706 |
// ---------------------------------------------------------------------------
|
|
707 |
// openAllVideosViewSlot()
|
|
708 |
// ---------------------------------------------------------------------------
|
|
709 |
//
|
|
710 |
void VideoListView::openAllVideosViewSlot()
|
|
711 |
{
|
36
|
712 |
FUNC_LOG;
|
34
|
713 |
VideoListWidget *videoListWidget =
|
|
714 |
mUiLoader->findWidget<VideoListWidget>(
|
|
715 |
DOCML_NAME_VC_VIDEOLISTWIDGET);
|
35
|
716 |
|
34
|
717 |
if (mCurrentList &&
|
|
718 |
videoListWidget &&
|
|
719 |
mCurrentList != videoListWidget)
|
|
720 |
{
|
|
721 |
// deactivate old list
|
|
722 |
mCurrentList->deactivate();
|
|
723 |
|
|
724 |
// activate all videos list
|
|
725 |
mCurrentList = videoListWidget;
|
|
726 |
mCurrentList->activate(VideoCollectionCommon::ELevelVideos);
|
38
|
727 |
|
|
728 |
// update the sublabel, as in most cases the data is already up to date.
|
|
729 |
updateSubLabel();
|
34
|
730 |
}
|
30
|
731 |
}
|
|
732 |
|
|
733 |
// ---------------------------------------------------------------------------
|
|
734 |
// openCollectionViewSlot()
|
|
735 |
// ---------------------------------------------------------------------------
|
|
736 |
//
|
|
737 |
void VideoListView::openCollectionViewSlot()
|
|
738 |
{
|
36
|
739 |
FUNC_LOG;
|
34
|
740 |
VideoListWidget *collectionWidget =
|
|
741 |
mUiLoader->findWidget<VideoListWidget>(
|
|
742 |
DOCML_NAME_VC_COLLECTIONWIDGET);
|
35
|
743 |
|
34
|
744 |
if (mCurrentList &&
|
|
745 |
mCurrentList != collectionWidget)
|
|
746 |
{
|
|
747 |
// deactivate all videos widget
|
|
748 |
mCurrentList->deactivate();
|
|
749 |
|
|
750 |
// activate video collection widget
|
|
751 |
mCurrentList = collectionWidget;
|
39
|
752 |
mCurrentList->activate(VideoCollectionCommon::ELevelCategory);
|
36
|
753 |
|
38
|
754 |
// the collection view is not empty, so we should hide the hint in advance.
|
34
|
755 |
showHint(false);
|
38
|
756 |
|
|
757 |
// also update the sublabel immediatelly, as the data is up to date almost always.
|
|
758 |
updateSubLabel();
|
34
|
759 |
}
|
|
760 |
}
|
|
761 |
|
30
|
762 |
// -------------------------------------------------------------------------------------------------
|
|
763 |
// aboutToChangeOrientationSlot()
|
|
764 |
// hide all items in the window during orientation change
|
|
765 |
// -------------------------------------------------------------------------------------------------
|
|
766 |
//
|
|
767 |
void VideoListView::aboutToChangeOrientationSlot()
|
|
768 |
{
|
36
|
769 |
FUNC_LOG;
|
30
|
770 |
// this method is required for changing from to mediawall
|
|
771 |
}
|
|
772 |
|
|
773 |
// -------------------------------------------------------------------------------------------------
|
|
774 |
// orientationChangedSlot()
|
|
775 |
// orientation changed, items can be put back to visible after view has handled the change
|
|
776 |
// -------------------------------------------------------------------------------------------------
|
|
777 |
//
|
|
778 |
void VideoListView::orientationChangedSlot( Qt::Orientation orientation )
|
|
779 |
{
|
36
|
780 |
FUNC_LOG;
|
30
|
781 |
// this method is required for changing from to mediawall
|
|
782 |
|
|
783 |
// in landscape we need to hide the title and the toolbar. (also required for the mediawall?)
|
|
784 |
// TODO: how about the feature where the toolbar comes visible if screen is tapped?
|
|
785 |
this->setItemVisible(Hb::AllItems, orientation == Qt::Vertical);
|
|
786 |
}
|
|
787 |
|
|
788 |
// -------------------------------------------------------------------------------------------------
|
|
789 |
// handleAsyncStatusSlot
|
|
790 |
// -------------------------------------------------------------------------------------------------
|
|
791 |
//
|
|
792 |
void VideoListView::handleAsyncStatusSlot(int statusCode, QVariant &additional)
|
|
793 |
{
|
36
|
794 |
FUNC_LOG;
|
30
|
795 |
// show msg from status
|
|
796 |
mUiUtils.showStatusMsgSlot(statusCode, additional);
|
|
797 |
}
|
|
798 |
|
|
799 |
// -------------------------------------------------------------------------------------------------
|
|
800 |
// collectionOpenedSlot
|
|
801 |
// -------------------------------------------------------------------------------------------------
|
|
802 |
//
|
41
|
803 |
void VideoListView::collectionOpenedSlot(bool openingCollection,
|
34
|
804 |
const QString& collection,
|
41
|
805 |
const TMPXItemId &collectionId)
|
30
|
806 |
{
|
36
|
807 |
FUNC_LOG;
|
49
|
808 |
|
|
809 |
// update / clear collection name
|
|
810 |
mCollectionName = collection;
|
30
|
811 |
|
41
|
812 |
if(openingCollection)
|
30
|
813 |
{
|
49
|
814 |
VideoListWidget *collectionContentWidget =
|
|
815 |
mUiLoader->findWidget<VideoListWidget>(
|
|
816 |
DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
|
|
817 |
// open album view, mCurrentList might be NULL at this point
|
|
818 |
if (!collectionContentWidget || mCurrentList == collectionContentWidget)
|
37
|
819 |
{
|
49
|
820 |
// collection widget cannot be loaded or
|
|
821 |
// currentlist is already collection content -list
|
34
|
822 |
return;
|
|
823 |
}
|
41
|
824 |
|
37
|
825 |
// get level from the item to be opened only default
|
|
826 |
// or user defined collections can be activated here
|
|
827 |
VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelInvalid;
|
41
|
828 |
if(collectionId.iId2 == KVcxMvcMediaTypeCategory)
|
36
|
829 |
{
|
37
|
830 |
level = VideoCollectionCommon::ELevelDefaultColl;
|
36
|
831 |
}
|
41
|
832 |
else if(collectionId.iId2 == KVcxMvcMediaTypeAlbum)
|
34
|
833 |
{
|
37
|
834 |
level = VideoCollectionCommon::ELevelAlbum;
|
|
835 |
}
|
|
836 |
else
|
|
837 |
{
|
36
|
838 |
return;
|
|
839 |
}
|
49
|
840 |
|
58
|
841 |
VideoProxyModelGeneric *model = collectionContentWidget->getModel();
|
40
|
842 |
if(!model)
|
|
843 |
{
|
|
844 |
// no model for content widget, cannot activate
|
|
845 |
return;
|
|
846 |
}
|
49
|
847 |
|
|
848 |
// disable collection content animations during widget change
|
|
849 |
HbAbstractItemView::ItemAnimations animationState = collectionContentWidget->enabledAnimations();
|
|
850 |
collectionContentWidget->setEnabledAnimations(HbAbstractItemView::None);
|
|
851 |
|
|
852 |
// Start fetching content before changing list widget
|
41
|
853 |
model->openItem(collectionId);
|
36
|
854 |
|
37
|
855 |
// deactivat current widget.
|
41
|
856 |
if(mCurrentList)
|
|
857 |
{
|
|
858 |
mCurrentList->deactivate();
|
|
859 |
}
|
36
|
860 |
|
37
|
861 |
// activate video collection content widget and set it as current list.
|
|
862 |
mCurrentList = collectionContentWidget;
|
|
863 |
mCurrentList->activate(level);
|
|
864 |
|
|
865 |
updateSubLabel();
|
|
866 |
|
40
|
867 |
mModelReady = model->rowCount() > 0;
|
66
|
868 |
|
63
|
869 |
if(mToolbar)
|
37
|
870 |
{
|
63
|
871 |
// if toolbar not yet created, it means that we're activating
|
|
872 |
// for the startup, toolbar will be updated during modelReady()
|
|
873 |
mToolbar->viewStateChanged(level, false, mModelReady);
|
49
|
874 |
}
|
63
|
875 |
|
49
|
876 |
// restore animations for collection content widget
|
|
877 |
collectionContentWidget->setEnabledAnimations(animationState);
|
30
|
878 |
}
|
|
879 |
else
|
|
880 |
{
|
37
|
881 |
// open collection view
|
63
|
882 |
openCollectionViewSlot();
|
|
883 |
|
|
884 |
mToolbar->viewStateChanged(VideoCollectionCommon::ELevelCategory, false, mModelReady);
|
49
|
885 |
}
|
41
|
886 |
if(!mVideoServices)
|
|
887 |
{
|
|
888 |
// save / clear collection related activity data
|
|
889 |
VideoCollectionViewUtils::setCollectionActivityData(collectionId, collection);
|
|
890 |
}
|
34
|
891 |
}
|
|
892 |
|
|
893 |
// -------------------------------------------------------------------------------------------------
|
36
|
894 |
// objectReadySlot
|
34
|
895 |
// -------------------------------------------------------------------------------------------------
|
|
896 |
//
|
36
|
897 |
void VideoListView::objectReadySlot(QObject *object, const QString &name)
|
34
|
898 |
{
|
36
|
899 |
FUNC_LOG;
|
34
|
900 |
if (name.compare(DOCML_NAME_VC_VIDEOLISTWIDGET) == 0)
|
|
901 |
{
|
36
|
902 |
connect(object, SIGNAL(command(int)), this, SIGNAL(command(int)));
|
39
|
903 |
if(mCurrentList != object)
|
|
904 |
{
|
|
905 |
// this widget not yet activated so it's has been created on the second phase
|
|
906 |
// safe to call doDelayed right away
|
|
907 |
qobject_cast<VideoListWidget*>(object)->doDelayedsSlot();
|
|
908 |
}
|
34
|
909 |
}
|
|
910 |
else if (name.compare(DOCML_NAME_VC_COLLECTIONWIDGET) == 0)
|
|
911 |
{
|
|
912 |
connect(
|
41
|
913 |
object, SIGNAL(collectionOpened(bool, const QString&, const TMPXItemId&)),
|
|
914 |
this, SLOT(collectionOpenedSlot(bool, const QString&, const TMPXItemId&)));
|
39
|
915 |
if(mCurrentList != object)
|
|
916 |
{
|
|
917 |
// this widget not yet activated so it's has been created on the second phase
|
|
918 |
// safe to call doDelayed right away
|
|
919 |
qobject_cast<VideoListWidget*>(object)->doDelayedsSlot();
|
|
920 |
}
|
34
|
921 |
}
|
|
922 |
else if (name.compare(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) == 0)
|
|
923 |
{
|
36
|
924 |
connect(object, SIGNAL(command(int)), this, SIGNAL(command(int)));
|
34
|
925 |
connect(
|
41
|
926 |
object, SIGNAL(collectionOpened(bool, const QString&, const TMPXItemId&)),
|
|
927 |
this, SLOT(collectionOpenedSlot(bool, const QString&, const TMPXItemId&)));
|
39
|
928 |
if(mCurrentList != object)
|
|
929 |
{
|
|
930 |
// this widget not yet activated so it's has been created on the second phase
|
|
931 |
// safe to call doDelayed right away
|
|
932 |
qobject_cast<VideoListWidget*>(object)->doDelayedsSlot();
|
|
933 |
}
|
34
|
934 |
}
|
30
|
935 |
}
|
|
936 |
|
63
|
937 |
// -------------------------------------------------------------------------------------------------
|
|
938 |
// toolbarActionsChanged
|
|
939 |
// -------------------------------------------------------------------------------------------------
|
|
940 |
//
|
|
941 |
void VideoListView::toolbarActionsChanged(QList<QAction*> newActions)
|
30
|
942 |
{
|
63
|
943 |
HbToolBar* bar = toolBar();
|
|
944 |
|
|
945 |
bar->clearActions();
|
|
946 |
|
|
947 |
if(newActions.count() > 0)
|
|
948 |
{
|
|
949 |
bar->addActions(newActions);
|
|
950 |
setItemVisible(Hb::ToolBarItem, true);
|
|
951 |
}
|
|
952 |
else
|
|
953 |
{
|
|
954 |
setItemVisible(Hb::ToolBarItem, false);
|
|
955 |
}
|
|
956 |
}
|
|
957 |
|
|
958 |
// -------------------------------------------------------------------------------------------------
|
|
959 |
// toolbarExtensionChanged
|
|
960 |
// -------------------------------------------------------------------------------------------------
|
|
961 |
//
|
|
962 |
void VideoListView::toolbarExtensionChanged(HbToolBarExtension* newExtension)
|
|
963 |
{
|
|
964 |
if(newExtension)
|
|
965 |
{
|
|
966 |
HbAction *action = toolBar()->addExtension(newExtension);
|
|
967 |
HbIcon icon("qtg_mono_video_services");
|
|
968 |
action->setIcon(icon);
|
|
969 |
}
|
30
|
970 |
}
|
|
971 |
|
38
|
972 |
// End of file
|