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 |
|
|
18 |
#include <xqserviceutil.h>
|
|
19 |
#include <QActionGroup>
|
|
20 |
#include <hbinstance.h>
|
|
21 |
#include <hbmainwindow.h>
|
|
22 |
#include <hbmessagebox.h>
|
|
23 |
#include <hbstackedwidget.h>
|
|
24 |
#include <hbstackedlayout.h>
|
|
25 |
#include <hblistwidget.h>
|
|
26 |
#include <hbtoolbar.h>
|
|
27 |
#include <hbaction.h>
|
|
28 |
#include <hbmenu.h>
|
|
29 |
#include <hbgroupbox.h>
|
|
30 |
#include <hbpushbutton.h>
|
34
|
31 |
#include <hbinputdialog.h>
|
|
32 |
#include <vcxmyvideosdefs.h>
|
30
|
33 |
|
|
34 |
#include "videoservices.h"
|
|
35 |
#include "videolistselectiondialog.h"
|
|
36 |
#include "videocollectionviewutils.h"
|
|
37 |
#include "videolistwidget.h"
|
|
38 |
#include "videohintwidget.h"
|
|
39 |
#include "videolistview.h"
|
|
40 |
#include "videocollectioncommon.h"
|
|
41 |
#include "videocollectionwrapper.h"
|
|
42 |
#include "videosortfilterproxymodel.h"
|
|
43 |
#include "videocollectionuiloader.h"
|
35
|
44 |
#include "mpxhbvideocommondefs.h"
|
30
|
45 |
|
|
46 |
// remove these
|
|
47 |
#include <QDebug>
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// Constructor
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
VideoListView::VideoListView(VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent) :
|
|
54 |
HbView(parent),
|
|
55 |
mUiUtils(VideoCollectionViewUtils::instance()),
|
|
56 |
mWrapper(VideoCollectionWrapper::instance()),
|
|
57 |
mUiLoader(uiLoader),
|
|
58 |
mIsService(false),
|
35
|
59 |
mHintLoaded(false),
|
|
60 |
mListsLoaded(false),
|
|
61 |
mMultiselectionLoaded(false),
|
30
|
62 |
mModelReady(false),
|
35
|
63 |
mTransitionOngoing(false),
|
|
64 |
mHintLevel(VideoHintWidget::AllVideos),
|
30
|
65 |
mVideoServices(0),
|
34
|
66 |
mCurrentList(0),
|
30
|
67 |
mToolbarViewsActionGroup(0),
|
34
|
68 |
mToolbarCollectionActionGroup(0)
|
30
|
69 |
{
|
|
70 |
// NOP
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
// Destructor
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
VideoListView::~VideoListView()
|
|
78 |
{
|
|
79 |
qDebug() << "VideoListView::~VideoListView()";
|
34
|
80 |
|
35
|
81 |
toolBar()->clearActions();
|
|
82 |
|
30
|
83 |
mToolbarActions.clear();
|
|
84 |
mSortingRoles.clear();
|
|
85 |
|
|
86 |
if(mVideoServices)
|
|
87 |
{
|
|
88 |
mVideoServices->decreaseReferenceCount();
|
|
89 |
mVideoServices = 0;
|
|
90 |
}
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
// initializeView()
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
int VideoListView::initializeView()
|
|
98 |
{
|
|
99 |
if(!mUiLoader)
|
|
100 |
{
|
34
|
101 |
cleanup();
|
30
|
102 |
return -1;
|
|
103 |
}
|
|
104 |
|
|
105 |
if (XQServiceUtil::isService() && !mVideoServices)
|
|
106 |
{
|
|
107 |
mIsService = true;
|
|
108 |
|
|
109 |
mVideoServices = VideoServices::instance();
|
|
110 |
|
|
111 |
if (!mVideoServices)
|
|
112 |
{
|
34
|
113 |
cleanup();
|
30
|
114 |
return -1;
|
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
connect(mVideoServices, SIGNAL(titleReady(const QString&)), this, SLOT(titleReadySlot(const QString&)));
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
34
|
122 |
// start open all videos model
|
|
123 |
VideoSortFilterProxyModel *model =
|
|
124 |
mWrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
125 |
if (model)
|
30
|
126 |
{
|
34
|
127 |
model->open(VideoCollectionCommon::ELevelVideos);
|
|
128 |
}
|
|
129 |
else
|
30
|
130 |
{
|
|
131 |
cleanup();
|
|
132 |
return -1;
|
|
133 |
}
|
34
|
134 |
|
|
135 |
// start loading widgets
|
|
136 |
QSet<QString> uiItems;
|
|
137 |
uiItems.insert(DOCML_NAME_VC_VIDEOLISTWIDGET);
|
35
|
138 |
uiItems.insert(DOCML_NAME_VC_HEADINGBANNER);
|
34
|
139 |
uiItems.insert(DOCML_NAME_OPTIONS_MENU);
|
35
|
140 |
if(!mIsService)
|
|
141 |
{
|
|
142 |
uiItems.insert(DOCML_NAME_ADD_TO_COLLECTION);
|
|
143 |
uiItems.insert(DOCML_NAME_CREATE_COLLECTION);
|
|
144 |
uiItems.insert(DOCML_NAME_DELETE_MULTIPLE);
|
|
145 |
}
|
34
|
146 |
uiItems.insert(DOCML_NAME_SORT_MENU);
|
|
147 |
uiItems.insert(DOCML_NAME_SORT_BY_DATE);
|
|
148 |
uiItems.insert(DOCML_NAME_SORT_BY_NAME);
|
|
149 |
uiItems.insert(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
|
|
150 |
uiItems.insert(DOCML_NAME_SORT_BY_RATING);
|
|
151 |
uiItems.insert(DOCML_NAME_SORT_BY_SIZE);
|
|
152 |
mUiLoader->startLoading(uiItems,
|
|
153 |
this,
|
|
154 |
SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
|
|
155 |
SLOT(objectReadySlot(QObject*, const QString&)));
|
|
156 |
uiItems.clear();
|
|
157 |
|
|
158 |
// TODO: create toolbar temporarily here until it has been moved to docml
|
|
159 |
if (createToolbar() != 0)
|
|
160 |
{
|
|
161 |
cleanup();
|
|
162 |
return -1;
|
|
163 |
}
|
30
|
164 |
|
|
165 |
return 0;
|
|
166 |
}
|
|
167 |
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
// titleReadySlot()
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
void VideoListView::titleReadySlot(const QString& title)
|
|
173 |
{
|
|
174 |
setTitle(title);
|
|
175 |
}
|
|
176 |
|
|
177 |
// ---------------------------------------------------------------------------
|
|
178 |
// activateView()
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
int VideoListView::activateView()
|
|
182 |
{
|
34
|
183 |
VideoListWidget *videoList =
|
|
184 |
mUiLoader->findWidget<VideoListWidget>(
|
|
185 |
DOCML_NAME_VC_VIDEOLISTWIDGET);
|
|
186 |
if (videoList)
|
30
|
187 |
{
|
34
|
188 |
VideoCollectionCommon::TCollectionLevels level = VideoCollectionCommon::ELevelVideos;
|
|
189 |
if (mCurrentList)
|
|
190 |
{
|
|
191 |
level = mCurrentList->getLevel();
|
|
192 |
}
|
|
193 |
else
|
|
194 |
{
|
|
195 |
mCurrentList = videoList;
|
|
196 |
}
|
|
197 |
|
|
198 |
int result = mCurrentList->activate(level);
|
35
|
199 |
if(result < 0)
|
34
|
200 |
{
|
|
201 |
// activate failed, deactivate view so we get rid of dangling connections.
|
|
202 |
deactivateView();
|
|
203 |
return -1;
|
|
204 |
}
|
|
205 |
|
|
206 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
|
207 |
if (mainWnd)
|
|
208 |
{
|
|
209 |
mainWnd->setOrientation(Qt::Vertical, false);
|
|
210 |
if(!connect(
|
|
211 |
mainWnd, SIGNAL(aboutToChangeOrientation()),
|
|
212 |
this, SLOT( aboutToChangeOrientationSlot())) ||
|
|
213 |
!connect(
|
|
214 |
mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
|
|
215 |
this, SLOT(orientationChangedSlot(Qt::Orientation))) ||
|
|
216 |
!connect(
|
|
217 |
&mWrapper, SIGNAL(asyncStatus(int, QVariant&)),
|
|
218 |
this, SLOT(handleAsyncStatusSlot(int, QVariant&))) ||
|
|
219 |
!connect(
|
|
220 |
mCurrentList->getModel().sourceModel(), SIGNAL(modelChanged()),
|
|
221 |
this, SLOT(layoutChangedSlot())) ||
|
|
222 |
!connect(
|
|
223 |
mCurrentList->getModel().sourceModel(), SIGNAL(modelReady()),
|
|
224 |
this, SLOT(modelReadySlot())))
|
|
225 |
{
|
|
226 |
// deactivate view so we get rid of dangling connections.
|
|
227 |
deactivateView();
|
|
228 |
return -1;
|
|
229 |
}
|
|
230 |
}
|
|
231 |
else
|
|
232 |
{
|
|
233 |
return -1;
|
|
234 |
}
|
|
235 |
}
|
|
236 |
else
|
|
237 |
{
|
30
|
238 |
return -1;
|
|
239 |
}
|
34
|
240 |
|
|
241 |
return 0;
|
30
|
242 |
}
|
|
243 |
|
35
|
244 |
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
// loadMultiSelection
|
|
247 |
// ---------------------------------------------------------------------------
|
|
248 |
//
|
|
249 |
void VideoListView::loadMultiSelection()
|
|
250 |
{
|
|
251 |
if(!mIsService)
|
|
252 |
{
|
|
253 |
if(!mMultiselectionLoaded)
|
|
254 |
{
|
|
255 |
QSet<QString> uiItems;
|
|
256 |
uiItems.insert(DOCML_NAME_DIALOG);
|
|
257 |
mUiLoader->startLoading(uiItems,
|
|
258 |
this,
|
|
259 |
SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
|
|
260 |
SLOT(objectReadySlot(QObject*, const QString&)));
|
|
261 |
uiItems.clear();
|
|
262 |
mMultiselectionLoaded = true;
|
|
263 |
}
|
|
264 |
}
|
|
265 |
}
|
|
266 |
|
|
267 |
// ---------------------------------------------------------------------------
|
|
268 |
// loadLists
|
|
269 |
// ---------------------------------------------------------------------------
|
|
270 |
//
|
|
271 |
void VideoListView::loadLists(bool doAsync)
|
|
272 |
{
|
|
273 |
if(!mListsLoaded)
|
|
274 |
{
|
|
275 |
QSet<QString> uiItems;
|
|
276 |
uiItems.insert(DOCML_NAME_VC_COLLECTIONWIDGET);
|
|
277 |
uiItems.insert(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
|
|
278 |
mUiLoader->startLoading(uiItems,
|
|
279 |
this,
|
|
280 |
SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
|
|
281 |
SLOT(objectReadySlot(QObject*, const QString&)));
|
|
282 |
uiItems.clear();
|
|
283 |
|
|
284 |
if(!doAsync)
|
|
285 |
{
|
|
286 |
VideoListWidget* widget(0);
|
|
287 |
widget = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONWIDGET);
|
|
288 |
widget->setVisible(false);
|
|
289 |
widget = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
|
|
290 |
widget->setVisible(false);
|
|
291 |
}
|
|
292 |
mListsLoaded = true;
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
// ---------------------------------------------------------------------------
|
|
297 |
// doDelayedsSlot
|
|
298 |
// ---------------------------------------------------------------------------
|
|
299 |
//
|
|
300 |
void VideoListView::doDelayedsSlot()
|
|
301 |
{
|
|
302 |
loadLists(true);
|
|
303 |
loadMultiSelection();
|
|
304 |
loadHint(true);
|
|
305 |
emit doDelayeds();
|
|
306 |
}
|
|
307 |
|
30
|
308 |
// ---------------------------------------------------------------------------
|
|
309 |
// modelReadySlot
|
|
310 |
// ---------------------------------------------------------------------------
|
|
311 |
//
|
|
312 |
void VideoListView::modelReadySlot()
|
|
313 |
{
|
|
314 |
mModelReady = true;
|
34
|
315 |
|
30
|
316 |
// since the reset signal arrives after
|
|
317 |
// layout changed, need to make sure that
|
|
318 |
// view is updated in case needed
|
|
319 |
layoutChangedSlot();
|
|
320 |
}
|
|
321 |
|
|
322 |
// ---------------------------------------------------------------------------
|
|
323 |
// layoutChangedSlot
|
|
324 |
// ---------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
void VideoListView::layoutChangedSlot()
|
|
327 |
{
|
|
328 |
updateSubLabel();
|
|
329 |
|
|
330 |
if(mModelReady)
|
|
331 |
{
|
|
332 |
showHint();
|
|
333 |
}
|
|
334 |
}
|
|
335 |
|
|
336 |
// ---------------------------------------------------------------------------
|
|
337 |
// deactivateView()
|
|
338 |
// ---------------------------------------------------------------------------
|
|
339 |
//
|
|
340 |
void VideoListView::deactivateView()
|
|
341 |
{
|
|
342 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
34
|
343 |
|
|
344 |
mainWnd->unsetOrientation();
|
|
345 |
|
30
|
346 |
disconnect(mainWnd, SIGNAL(aboutToChangeOrientation()),
|
|
347 |
this, SLOT(aboutToChangeOrientationSlot()));
|
|
348 |
|
|
349 |
disconnect(mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
|
|
350 |
this, SLOT(orientationChangedSlot(Qt::Orientation)));
|
|
351 |
|
34
|
352 |
disconnect(&mWrapper, SIGNAL(asyncStatus(int, QVariant&)),
|
30
|
353 |
this, SLOT(handleAsyncStatusSlot(int, QVariant&)));
|
34
|
354 |
|
|
355 |
HbMenu *menu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_OPTIONS_MENU);
|
|
356 |
if (menu)
|
|
357 |
{
|
|
358 |
menu->hide();
|
|
359 |
}
|
|
360 |
|
|
361 |
if(mCurrentList && &(mCurrentList->getModel()) && mCurrentList->getModel().sourceModel())
|
|
362 |
{
|
|
363 |
disconnect(mCurrentList->getModel().sourceModel(),
|
|
364 |
SIGNAL(modelChanged()),
|
|
365 |
this, SLOT(layoutChangedSlot()));
|
|
366 |
disconnect(mCurrentList->getModel().sourceModel(),
|
|
367 |
SIGNAL(modelReady()),
|
|
368 |
this, SLOT(modelReadySlot()));
|
30
|
369 |
|
34
|
370 |
showHint(false);
|
|
371 |
}
|
30
|
372 |
|
34
|
373 |
if(mCurrentList)
|
30
|
374 |
{
|
34
|
375 |
mCurrentList->deactivate();
|
30
|
376 |
}
|
|
377 |
}
|
|
378 |
|
|
379 |
// ---------------------------------------------------------------------------
|
|
380 |
// back()
|
|
381 |
// ---------------------------------------------------------------------------
|
|
382 |
//
|
|
383 |
void VideoListView::back()
|
|
384 |
{
|
|
385 |
// NOP
|
|
386 |
}
|
|
387 |
|
|
388 |
// ---------------------------------------------------------------------------
|
|
389 |
// cleanup()
|
|
390 |
// ---------------------------------------------------------------------------
|
|
391 |
//
|
|
392 |
void VideoListView::cleanup()
|
|
393 |
{
|
|
394 |
delete mToolbarViewsActionGroup;
|
|
395 |
mToolbarViewsActionGroup = 0;
|
|
396 |
|
|
397 |
delete mToolbarCollectionActionGroup;
|
|
398 |
mToolbarCollectionActionGroup = 0;
|
|
399 |
|
34
|
400 |
mCurrentList = 0;
|
30
|
401 |
}
|
|
402 |
|
|
403 |
// ---------------------------------------------------------------------------
|
|
404 |
// createToolbar()
|
|
405 |
// Creates toolbar, toolbar actions and toolbar icons
|
|
406 |
// ---------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
int VideoListView::createToolbar()
|
|
409 |
{
|
|
410 |
// Create actiongroup and add all actions to it. This ensures that only one is
|
|
411 |
// active at certain moment.
|
|
412 |
|
|
413 |
if(!mToolbarViewsActionGroup && !mToolbarCollectionActionGroup)
|
|
414 |
{
|
|
415 |
mToolbarViewsActionGroup = new QActionGroup(this);
|
|
416 |
mToolbarCollectionActionGroup = new QActionGroup(this);
|
|
417 |
|
|
418 |
if(!mToolbarViewsActionGroup || !mToolbarCollectionActionGroup)
|
|
419 |
{
|
|
420 |
delete mToolbarViewsActionGroup;
|
|
421 |
mToolbarViewsActionGroup = 0;
|
|
422 |
|
|
423 |
delete mToolbarCollectionActionGroup;
|
|
424 |
mToolbarCollectionActionGroup = 0;
|
|
425 |
|
|
426 |
return -1;
|
|
427 |
}
|
|
428 |
|
|
429 |
// create toolbar item actions
|
|
430 |
|
|
431 |
// All Videos tab
|
34
|
432 |
mToolbarActions[ETBActionAllVideos] = createAction(":/images/qtg_mono_video_all.svg",
|
30
|
433 |
mToolbarViewsActionGroup, SLOT(openAllVideosViewSlot()));
|
|
434 |
|
|
435 |
// Collections tab
|
35
|
436 |
mToolbarActions[ETBActionCollections] = createAction("qtg_mono_video_collection",
|
30
|
437 |
mToolbarViewsActionGroup, SLOT(openCollectionViewSlot()));
|
|
438 |
|
|
439 |
if (!mIsService)
|
|
440 |
{
|
|
441 |
// Services tab
|
35
|
442 |
mToolbarActions[ETBActionServices] = createAction("qtg_mono_ovistore",
|
30
|
443 |
mToolbarViewsActionGroup, SLOT(openServicesViewSlot()));
|
|
444 |
// Add Videos tab
|
35
|
445 |
mToolbarActions[ETBActionAddVideos] =
|
|
446 |
createAction("qtg_mono_add_to_video_collection",
|
30
|
447 |
mToolbarCollectionActionGroup, SLOT(addVideosToCollectionSlot()));
|
|
448 |
|
|
449 |
// Remove Videos tab
|
35
|
450 |
mToolbarActions[ETBActionRemoveVideos] =
|
|
451 |
createAction(":/images/qtg_mono_remove_from_video_collection.svg",
|
|
452 |
mToolbarCollectionActionGroup, SLOT(removeVideosFromCollectionSlot()));
|
30
|
453 |
}
|
|
454 |
|
|
455 |
HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
|
|
456 |
|
|
457 |
if( !bar
|
|
458 |
|| !mToolbarActions[ETBActionAllVideos]
|
|
459 |
|| !mToolbarActions[ETBActionCollections]
|
|
460 |
|| (!mToolbarActions[ETBActionServices] && !mIsService)
|
|
461 |
|| (!mToolbarActions[ETBActionAddVideos] && !mIsService)
|
|
462 |
|| (!mToolbarActions[ETBActionRemoveVideos] && !mIsService))
|
|
463 |
{
|
|
464 |
delete mToolbarActions[ETBActionAllVideos];
|
|
465 |
delete mToolbarActions[ETBActionCollections];
|
|
466 |
delete mToolbarActions[ETBActionServices];
|
|
467 |
delete mToolbarActions[ETBActionAddVideos];
|
|
468 |
delete mToolbarActions[ETBActionRemoveVideos];
|
|
469 |
return -1;
|
|
470 |
}
|
|
471 |
|
|
472 |
// Collection view actions are not checkable
|
|
473 |
mToolbarActions[ETBActionAllVideos]->setCheckable(true);
|
|
474 |
mToolbarActions[ETBActionCollections]->setCheckable(true);
|
|
475 |
|
|
476 |
if (!mIsService)
|
|
477 |
{
|
35
|
478 |
mToolbarActions[ETBActionServices]->setCheckable(false);
|
30
|
479 |
}
|
|
480 |
|
|
481 |
// Allvideos is checked at creation phase
|
|
482 |
mToolbarActions[ETBActionAllVideos]->setChecked(true);
|
|
483 |
|
|
484 |
bar->addActions(mToolbarViewsActionGroup->actions());
|
34
|
485 |
bar->setVisible(true);
|
30
|
486 |
}
|
|
487 |
|
|
488 |
return 0;
|
|
489 |
}
|
|
490 |
|
|
491 |
// ---------------------------------------------------------------------------
|
|
492 |
// createAction()
|
|
493 |
// ---------------------------------------------------------------------------
|
|
494 |
//
|
34
|
495 |
HbAction* VideoListView::createAction(QString icon,
|
30
|
496 |
QActionGroup* actionGroup, const char *slot)
|
|
497 |
{
|
|
498 |
HbAction* action = new HbAction(actionGroup);
|
|
499 |
if(!action) {
|
|
500 |
return 0;
|
|
501 |
}
|
|
502 |
|
|
503 |
HbIcon hbIcon(icon);
|
|
504 |
action->setIcon(hbIcon);
|
|
505 |
|
|
506 |
if(!connect(action, SIGNAL(triggered()), this, slot)) {
|
|
507 |
// actiongroup deletion deletes this also.
|
|
508 |
// return 0 tells that there was a problem in creation to caller.
|
|
509 |
delete action;
|
|
510 |
return 0;
|
|
511 |
}
|
|
512 |
|
|
513 |
return action;
|
|
514 |
}
|
|
515 |
|
|
516 |
// ---------------------------------------------------------------------------
|
35
|
517 |
// loadHint
|
|
518 |
// ---------------------------------------------------------------------------
|
|
519 |
//
|
|
520 |
void VideoListView::loadHint(bool doAsync)
|
|
521 |
{
|
|
522 |
if(!mHintLoaded)
|
|
523 |
{
|
|
524 |
QSet<QString> uiItems;
|
|
525 |
uiItems.insert(DOCML_NAME_VC_VIDEOHINTWIDGET);
|
|
526 |
uiItems.insert(DOCML_NAME_HINT_BUTTON);
|
|
527 |
uiItems.insert(DOCML_NAME_NO_VIDEOS_LABEL);
|
|
528 |
mUiLoader->startLoading(uiItems,
|
|
529 |
this,
|
|
530 |
SLOT(widgetReadySlot(QGraphicsWidget*, const QString&)),
|
|
531 |
SLOT(objectReadySlot(QObject*, const QString&)));
|
|
532 |
uiItems.clear();
|
|
533 |
|
|
534 |
if(!doAsync)
|
|
535 |
{
|
|
536 |
HbPushButton* button = mUiLoader->findWidget<HbPushButton>(DOCML_NAME_HINT_BUTTON);
|
|
537 |
}
|
|
538 |
mHintLoaded = true;
|
|
539 |
}
|
|
540 |
}
|
|
541 |
|
|
542 |
// ---------------------------------------------------------------------------
|
30
|
543 |
// showHint
|
|
544 |
// ---------------------------------------------------------------------------
|
|
545 |
//
|
|
546 |
void VideoListView::showHint(bool show)
|
|
547 |
{
|
34
|
548 |
if(!mCurrentList)
|
30
|
549 |
{
|
34
|
550 |
return;
|
30
|
551 |
}
|
34
|
552 |
|
|
553 |
VideoSortFilterProxyModel &model = mCurrentList->getModel();
|
35
|
554 |
|
|
555 |
HbGroupBox *subLabel =
|
|
556 |
mUiLoader->findWidget<HbGroupBox>(DOCML_NAME_VC_HEADINGBANNER);
|
|
557 |
|
|
558 |
if((!mHintLoaded && !show) || (!mHintLoaded && model.rowCount() != 0))
|
|
559 |
{
|
|
560 |
if(subLabel)
|
|
561 |
{
|
|
562 |
subLabel->show();
|
|
563 |
}
|
|
564 |
return;
|
|
565 |
}
|
|
566 |
else if(!mHintLoaded)
|
|
567 |
{
|
|
568 |
loadHint(false);
|
|
569 |
}
|
|
570 |
|
34
|
571 |
VideoHintWidget *hintWidget =
|
|
572 |
mUiLoader->findWidget<VideoHintWidget>(
|
|
573 |
DOCML_NAME_VC_VIDEOHINTWIDGET);
|
35
|
574 |
|
|
575 |
if (hintWidget)
|
|
576 |
{
|
|
577 |
hintWidget->setLevel(mHintLevel);
|
|
578 |
}
|
|
579 |
|
34
|
580 |
if (mModelReady &&
|
|
581 |
model.rowCount() == 0 &&
|
|
582 |
hintWidget)
|
|
583 |
{
|
|
584 |
show ? hintWidget->activate() : hintWidget->deactivate();
|
|
585 |
}
|
|
586 |
else if (hintWidget)
|
30
|
587 |
{
|
|
588 |
show = false;
|
34
|
589 |
hintWidget->deactivate();
|
30
|
590 |
}
|
|
591 |
|
|
592 |
if(show && mToolbarViewsActionGroup && mToolbarCollectionActionGroup)
|
|
593 |
{
|
|
594 |
if(!mIsService)
|
|
595 |
{
|
34
|
596 |
mToolbarActions[ETBActionRemoveVideos]->setVisible(false);
|
30
|
597 |
}
|
34
|
598 |
if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelDefaultColl)
|
|
599 |
{
|
|
600 |
if(!mIsService)
|
|
601 |
{
|
|
602 |
mToolbarActions[ETBActionAddVideos]->setVisible(false);
|
|
603 |
}
|
|
604 |
hintWidget->setButtonShown(false);
|
|
605 |
}
|
|
606 |
else
|
|
607 |
{
|
|
608 |
hintWidget->setButtonShown(true);
|
|
609 |
}
|
30
|
610 |
}
|
34
|
611 |
else if(mToolbarViewsActionGroup && mToolbarCollectionActionGroup)
|
30
|
612 |
{
|
|
613 |
if(!mIsService)
|
|
614 |
{
|
34
|
615 |
if(mToolbarActions[ETBActionRemoveVideos]->isVisible() == false)
|
30
|
616 |
{
|
34
|
617 |
mToolbarActions[ETBActionRemoveVideos]->setVisible(true);
|
30
|
618 |
}
|
34
|
619 |
if(mToolbarActions[ETBActionAddVideos]->isVisible() == false)
|
|
620 |
{
|
|
621 |
mToolbarActions[ETBActionAddVideos]->setVisible(true);
|
|
622 |
}
|
30
|
623 |
}
|
34
|
624 |
hintWidget->setButtonShown(true);
|
|
625 |
}
|
|
626 |
|
|
627 |
if (subLabel)
|
|
628 |
{
|
|
629 |
if (show &&
|
35
|
630 |
subLabel->isVisible() &&
|
34
|
631 |
mCurrentList->getLevel() == VideoCollectionCommon::ELevelVideos)
|
30
|
632 |
{
|
34
|
633 |
subLabel->hide();
|
|
634 |
}
|
35
|
635 |
else if (!subLabel->isVisible())
|
34
|
636 |
{
|
|
637 |
subLabel->show();
|
30
|
638 |
}
|
|
639 |
}
|
|
640 |
}
|
|
641 |
|
|
642 |
// ---------------------------------------------------------------------------
|
34
|
643 |
// setHintLevel
|
|
644 |
// ---------------------------------------------------------------------------
|
|
645 |
//
|
|
646 |
void VideoListView::setHintLevel(VideoHintWidget::HintLevel level)
|
|
647 |
{
|
35
|
648 |
mHintLevel = level;
|
34
|
649 |
}
|
|
650 |
|
|
651 |
// ---------------------------------------------------------------------------
|
30
|
652 |
// updateSubLabel
|
|
653 |
// ---------------------------------------------------------------------------
|
|
654 |
//
|
|
655 |
void VideoListView::updateSubLabel()
|
|
656 |
{
|
34
|
657 |
VideoSortFilterProxyModel *model = 0;
|
|
658 |
if(mCurrentList)
|
|
659 |
{
|
|
660 |
model = &mCurrentList->getModel();
|
|
661 |
}
|
|
662 |
|
|
663 |
if (model)
|
30
|
664 |
{
|
34
|
665 |
int itemCount = model->rowCount();
|
|
666 |
VideoListWidget *videoListWidget =
|
|
667 |
mUiLoader->findWidget<VideoListWidget>(
|
|
668 |
DOCML_NAME_VC_VIDEOLISTWIDGET);
|
|
669 |
|
|
670 |
VideoListWidget *collectionWidget =
|
|
671 |
mUiLoader->findWidget<VideoListWidget>(
|
|
672 |
DOCML_NAME_VC_COLLECTIONWIDGET);
|
|
673 |
|
|
674 |
VideoListWidget *collectionContentWidget =
|
|
675 |
mUiLoader->findWidget<VideoListWidget>(
|
|
676 |
DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
|
|
677 |
|
|
678 |
HbGroupBox *subLabel =
|
|
679 |
mUiLoader->findWidget<HbGroupBox>(
|
|
680 |
DOCML_NAME_VC_HEADINGBANNER);
|
35
|
681 |
|
|
682 |
if(subLabel)
|
34
|
683 |
{
|
35
|
684 |
if (mCurrentList == videoListWidget)
|
|
685 |
{
|
|
686 |
subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_videos", itemCount));
|
|
687 |
}
|
|
688 |
else if (mCurrentList == collectionWidget)
|
|
689 |
{
|
|
690 |
subLabel->setHeading(hbTrId("txt_videos_subtitle_ln_collections", itemCount));
|
|
691 |
}
|
|
692 |
else if(mCurrentList == collectionContentWidget)
|
|
693 |
{
|
|
694 |
subLabel->setHeading(hbTrId("txt_videos_subtitle_1_l2").arg(mCollectionName).arg(itemCount));
|
|
695 |
}
|
34
|
696 |
}
|
|
697 |
}
|
|
698 |
}
|
30
|
699 |
|
34
|
700 |
// ---------------------------------------------------------------------------
|
|
701 |
// showAction()
|
|
702 |
// ---------------------------------------------------------------------------
|
|
703 |
//
|
|
704 |
void VideoListView::showAction(bool show, const QString &name)
|
|
705 |
{
|
|
706 |
HbAction *action = mUiLoader->findObject<HbAction>(name);
|
|
707 |
if (!action)
|
|
708 |
{
|
|
709 |
// must be menu widget
|
|
710 |
HbMenu *menu = mUiLoader->findWidget<HbMenu>(name);
|
|
711 |
if (menu)
|
30
|
712 |
{
|
34
|
713 |
action = menu->menuAction();
|
30
|
714 |
}
|
34
|
715 |
}
|
|
716 |
|
|
717 |
// hide or show action
|
|
718 |
if (action)
|
|
719 |
{
|
|
720 |
action->setVisible(show);
|
|
721 |
}
|
|
722 |
}
|
|
723 |
|
|
724 |
// ---------------------------------------------------------------------------
|
|
725 |
// isActionChecked()
|
|
726 |
// ---------------------------------------------------------------------------
|
|
727 |
//
|
|
728 |
bool VideoListView::isActionChecked(const QString &name)
|
|
729 |
{
|
|
730 |
bool isChecked = false;
|
|
731 |
|
|
732 |
HbAction *action = mUiLoader->findObject<HbAction>(name);
|
|
733 |
if (!action)
|
|
734 |
{
|
|
735 |
// must be menu widget
|
|
736 |
HbMenu *menu = mUiLoader->findWidget<HbMenu>(name);
|
|
737 |
if (menu)
|
30
|
738 |
{
|
34
|
739 |
action = menu->menuAction();
|
|
740 |
}
|
|
741 |
}
|
|
742 |
|
|
743 |
// check if action is checked
|
|
744 |
if (action)
|
|
745 |
{
|
|
746 |
isChecked = action->isChecked();
|
|
747 |
}
|
|
748 |
|
|
749 |
return isChecked;
|
|
750 |
}
|
|
751 |
|
|
752 |
// ---------------------------------------------------------------------------
|
|
753 |
// isActionChecked()
|
|
754 |
// ---------------------------------------------------------------------------
|
|
755 |
//
|
|
756 |
void VideoListView::setActionChecked(bool setChecked, const QString &name)
|
|
757 |
{
|
|
758 |
HbAction *action = mUiLoader->findObject<HbAction>(name);
|
|
759 |
if (!action)
|
|
760 |
{
|
|
761 |
// must be menu widget
|
|
762 |
HbMenu *menu = mUiLoader->findWidget<HbMenu>(name);
|
|
763 |
if (menu)
|
30
|
764 |
{
|
34
|
765 |
action = menu->menuAction();
|
30
|
766 |
}
|
|
767 |
}
|
34
|
768 |
|
|
769 |
// update action check state
|
|
770 |
if (action)
|
|
771 |
{
|
|
772 |
action->setChecked(setChecked);
|
|
773 |
}
|
30
|
774 |
}
|
|
775 |
|
|
776 |
// ---------------------------------------------------------------------------
|
|
777 |
// openAllVideosViewSlot()
|
|
778 |
// ---------------------------------------------------------------------------
|
|
779 |
//
|
|
780 |
void VideoListView::openAllVideosViewSlot()
|
|
781 |
{
|
35
|
782 |
if(!mListsLoaded)
|
|
783 |
{
|
|
784 |
loadLists(false);
|
|
785 |
}
|
|
786 |
|
34
|
787 |
VideoListWidget *videoListWidget =
|
|
788 |
mUiLoader->findWidget<VideoListWidget>(
|
|
789 |
DOCML_NAME_VC_VIDEOLISTWIDGET);
|
35
|
790 |
|
34
|
791 |
if (mCurrentList &&
|
|
792 |
videoListWidget &&
|
|
793 |
mCurrentList != videoListWidget)
|
|
794 |
{
|
|
795 |
// deactivate old list
|
|
796 |
mCurrentList->deactivate();
|
|
797 |
|
|
798 |
// activate all videos list
|
|
799 |
mCurrentList = videoListWidget;
|
|
800 |
mCurrentList->activate(VideoCollectionCommon::ELevelVideos);
|
|
801 |
|
|
802 |
// since collection is not to be opened at this point,
|
|
803 |
// we do not receive lauoutChanged for updating the hind -widget
|
|
804 |
// if needed, need to show it here is needed
|
|
805 |
setHintLevel(VideoHintWidget::AllVideos);
|
|
806 |
showHint();
|
|
807 |
}
|
30
|
808 |
}
|
|
809 |
|
|
810 |
// ---------------------------------------------------------------------------
|
|
811 |
// openCollectionViewSlot()
|
|
812 |
// ---------------------------------------------------------------------------
|
|
813 |
//
|
|
814 |
void VideoListView::openCollectionViewSlot()
|
|
815 |
{
|
35
|
816 |
if(!mListsLoaded)
|
|
817 |
{
|
|
818 |
loadLists(false);
|
|
819 |
}
|
|
820 |
|
34
|
821 |
VideoListWidget *collectionWidget =
|
|
822 |
mUiLoader->findWidget<VideoListWidget>(
|
|
823 |
DOCML_NAME_VC_COLLECTIONWIDGET);
|
35
|
824 |
|
34
|
825 |
if (mCurrentList &&
|
|
826 |
mCurrentList != collectionWidget)
|
|
827 |
{
|
|
828 |
// deactivate all videos widget
|
|
829 |
mCurrentList->deactivate();
|
|
830 |
|
|
831 |
// activate video collection widget
|
|
832 |
mCurrentList = collectionWidget;
|
|
833 |
mCurrentList->activate(VideoCollectionCommon::ELevelCategory);
|
|
834 |
|
|
835 |
VideoSortFilterProxyModel &model = mCurrentList->getModel();
|
|
836 |
VideoCollectionViewUtils::sortModel(&model, false);
|
|
837 |
|
|
838 |
// the collection view is not empty, so we can hide the hint in advance.
|
|
839 |
showHint(false);
|
|
840 |
}
|
|
841 |
}
|
|
842 |
|
|
843 |
// ---------------------------------------------------------------------------
|
|
844 |
// openNewAlbumSlot()
|
|
845 |
// ---------------------------------------------------------------------------
|
|
846 |
//
|
|
847 |
void VideoListView::openNewAlbumSlot(const QModelIndex &parent,
|
|
848 |
int start,
|
|
849 |
int end)
|
|
850 |
{
|
|
851 |
Q_UNUSED(end);
|
|
852 |
if(!mCurrentList)
|
|
853 |
{
|
|
854 |
return;
|
|
855 |
}
|
|
856 |
// invalidate model
|
|
857 |
VideoSortFilterProxyModel &model = mCurrentList->getModel();
|
|
858 |
model.invalidate();
|
|
859 |
|
|
860 |
// activate new index
|
|
861 |
QModelIndex index = model.index(start, 0, parent);
|
|
862 |
if (index.isValid())
|
|
863 |
{
|
|
864 |
// disconnect rowsInserted signal to prevent obsolete slot calls
|
|
865 |
disconnect( &model, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
|
|
866 |
this, SLOT(openNewAlbumSlot(const QModelIndex&, int, int)));
|
|
867 |
|
|
868 |
mCurrentList->emitActivated(index);
|
|
869 |
}
|
30
|
870 |
}
|
|
871 |
|
|
872 |
// ---------------------------------------------------------------------------
|
|
873 |
// openservicesViewSlot()
|
|
874 |
// ---------------------------------------------------------------------------
|
|
875 |
//
|
|
876 |
void VideoListView::openServicesViewSlot()
|
|
877 |
{
|
|
878 |
debugNotImplementedYet();
|
|
879 |
}
|
|
880 |
|
|
881 |
// ---------------------------------------------------------------------------
|
|
882 |
// startSorting()
|
|
883 |
// ---------------------------------------------------------------------------
|
|
884 |
//
|
|
885 |
void VideoListView::startSorting()
|
|
886 |
{
|
34
|
887 |
HbMenu *optionsMenu =
|
|
888 |
mUiLoader->findWidget<HbMenu>(
|
|
889 |
DOCML_NAME_OPTIONS_MENU);
|
|
890 |
if (optionsMenu)
|
30
|
891 |
{
|
34
|
892 |
// get sorting role from active action
|
|
893 |
HbAction *action = optionsMenu->activeAction()->menu()->activeAction();
|
35
|
894 |
if(action)
|
|
895 |
{
|
|
896 |
doSorting(mSortingRoles[action]);
|
|
897 |
}
|
|
898 |
}
|
|
899 |
}
|
30
|
900 |
|
35
|
901 |
// ---------------------------------------------------------------------------
|
|
902 |
// doSorting()
|
|
903 |
// ---------------------------------------------------------------------------
|
|
904 |
//
|
|
905 |
void VideoListView::doSorting(int role)
|
|
906 |
{
|
|
907 |
// sort model
|
|
908 |
Qt::SortOrder order(Qt::AscendingOrder);
|
|
909 |
VideoSortFilterProxyModel &model = mCurrentList->getModel();
|
|
910 |
if(model.sortRole() == role && model.sortOrder() == Qt::AscendingOrder)
|
|
911 |
{
|
|
912 |
order = Qt::DescendingOrder;
|
|
913 |
}
|
|
914 |
model.doSorting(role, order);
|
30
|
915 |
|
35
|
916 |
// save sorting values
|
|
917 |
mUiUtils.saveSortingValues(role, order);
|
30
|
918 |
}
|
|
919 |
|
|
920 |
// -------------------------------------------------------------------------------------------------
|
|
921 |
// aboutToChangeOrientationSlot()
|
|
922 |
// hide all items in the window during orientation change
|
|
923 |
// -------------------------------------------------------------------------------------------------
|
|
924 |
//
|
|
925 |
void VideoListView::aboutToChangeOrientationSlot()
|
|
926 |
{
|
|
927 |
// this method is required for changing from to mediawall
|
|
928 |
}
|
|
929 |
|
|
930 |
// -------------------------------------------------------------------------------------------------
|
|
931 |
// orientationChangedSlot()
|
|
932 |
// orientation changed, items can be put back to visible after view has handled the change
|
|
933 |
// -------------------------------------------------------------------------------------------------
|
|
934 |
//
|
|
935 |
void VideoListView::orientationChangedSlot( Qt::Orientation orientation )
|
|
936 |
{
|
|
937 |
// this method is required for changing from to mediawall
|
|
938 |
|
|
939 |
// in landscape we need to hide the title and the toolbar. (also required for the mediawall?)
|
|
940 |
// TODO: how about the feature where the toolbar comes visible if screen is tapped?
|
|
941 |
this->setItemVisible(Hb::AllItems, orientation == Qt::Vertical);
|
|
942 |
}
|
|
943 |
|
|
944 |
// -------------------------------------------------------------------------------------------------
|
|
945 |
// deleteItemsSlot
|
|
946 |
// -------------------------------------------------------------------------------------------------
|
|
947 |
//
|
|
948 |
void VideoListView::deleteItemsSlot()
|
|
949 |
{
|
34
|
950 |
if(!mCurrentList)
|
30
|
951 |
{
|
|
952 |
return;
|
|
953 |
}
|
35
|
954 |
|
|
955 |
if(!mMultiselectionLoaded)
|
|
956 |
{
|
|
957 |
loadMultiSelection();
|
|
958 |
}
|
|
959 |
|
34
|
960 |
VideoListSelectionDialog *dialog =
|
|
961 |
mUiLoader->findWidget<VideoListSelectionDialog>(
|
|
962 |
DOCML_NAME_DIALOG);
|
|
963 |
if (dialog)
|
30
|
964 |
{
|
34
|
965 |
TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
|
|
966 |
dialog->setupContent(VideoListSelectionDialog::EDeleteVideos, collectionId);
|
|
967 |
dialog->exec();
|
30
|
968 |
}
|
|
969 |
}
|
|
970 |
|
|
971 |
// -------------------------------------------------------------------------------------------------
|
|
972 |
// createCollectionSlot
|
|
973 |
// -------------------------------------------------------------------------------------------------
|
|
974 |
//
|
|
975 |
void VideoListView::createCollectionSlot()
|
|
976 |
{
|
34
|
977 |
if(!mCurrentList)
|
|
978 |
{
|
|
979 |
return;
|
|
980 |
}
|
|
981 |
|
|
982 |
VideoSortFilterProxyModel &model = mCurrentList->getModel();
|
|
983 |
|
|
984 |
|
|
985 |
bool ok = false;
|
|
986 |
// query a name for the collection
|
35
|
987 |
QString label(hbTrId("txt_videos_title_enter_name"));
|
|
988 |
QString text(hbTrId("txt_videos_dialog_entry_new_collection"));
|
34
|
989 |
text = HbInputDialog::getText(label, text, &ok);
|
|
990 |
if (ok && text.length())
|
|
991 |
{
|
|
992 |
// resolve collection true name and add new album
|
|
993 |
text = model.resolveAlbumName(text);
|
|
994 |
|
|
995 |
// when collection reports about new collection, we open it right away,
|
|
996 |
// for that, connect to rowsInserted so that the new album can be opened
|
|
997 |
if(!connect(&model, SIGNAL(rowsInserted(const QModelIndex&, int, int)),
|
|
998 |
this, SLOT(openNewAlbumSlot(const QModelIndex&, int, int))))
|
|
999 |
{
|
|
1000 |
return;
|
|
1001 |
}
|
|
1002 |
|
|
1003 |
model.addNewAlbum(text);
|
|
1004 |
}
|
30
|
1005 |
}
|
|
1006 |
|
|
1007 |
// -------------------------------------------------------------------------------------------------
|
|
1008 |
// addVideosToCollectionSlot
|
|
1009 |
// -------------------------------------------------------------------------------------------------
|
|
1010 |
//
|
|
1011 |
void VideoListView::addVideosToCollectionSlot()
|
|
1012 |
{
|
34
|
1013 |
if(!mCurrentList)
|
|
1014 |
{
|
|
1015 |
return;
|
|
1016 |
}
|
35
|
1017 |
|
|
1018 |
if(!mMultiselectionLoaded)
|
|
1019 |
{
|
|
1020 |
loadMultiSelection();
|
|
1021 |
}
|
|
1022 |
|
34
|
1023 |
VideoListSelectionDialog *dialog =
|
|
1024 |
mUiLoader->findWidget<VideoListSelectionDialog>(
|
|
1025 |
DOCML_NAME_DIALOG);
|
35
|
1026 |
if (!dialog)
|
34
|
1027 |
{
|
35
|
1028 |
// fatal: no selection dialog
|
|
1029 |
return;
|
|
1030 |
}
|
|
1031 |
if(mCurrentList->getLevel() == VideoCollectionCommon::ELevelAlbum)
|
|
1032 |
{
|
|
1033 |
// album is opened, do not proceed in case it already have same amount
|
|
1034 |
// of videos than all videos view.
|
|
1035 |
VideoListWidget *allVideos = mUiLoader->findWidget<VideoListWidget>(
|
|
1036 |
DOCML_NAME_VC_VIDEOLISTWIDGET);
|
|
1037 |
if(allVideos)
|
34
|
1038 |
{
|
35
|
1039 |
int count = allVideos->getModel().rowCount();
|
|
1040 |
if(count == mCurrentList->getModel().rowCount())
|
34
|
1041 |
{
|
35
|
1042 |
if(count)
|
34
|
1043 |
{
|
|
1044 |
QVariant emptyAdditional;
|
|
1045 |
mUiUtils.showStatusMsgSlot(
|
|
1046 |
VideoCollectionCommon::statusAllVideosAlreadyInCollection,
|
|
1047 |
emptyAdditional);
|
35
|
1048 |
}
|
|
1049 |
return;
|
|
1050 |
}
|
34
|
1051 |
}
|
35
|
1052 |
}
|
|
1053 |
TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
|
|
1054 |
dialog->setupContent(VideoListSelectionDialog::EAddToCollection, collectionId);
|
|
1055 |
dialog->exec();
|
|
1056 |
}
|
|
1057 |
|
|
1058 |
// -------------------------------------------------------------------------------------------------
|
|
1059 |
// removeVideosFromCollectionSlot
|
|
1060 |
// -------------------------------------------------------------------------------------------------
|
|
1061 |
//
|
|
1062 |
void VideoListView::removeVideosFromCollectionSlot()
|
|
1063 |
{
|
|
1064 |
if(!mCurrentList)
|
|
1065 |
{
|
|
1066 |
return;
|
|
1067 |
}
|
|
1068 |
// not allowed if for some reason current widget
|
|
1069 |
// is all videos or collection or there are no items
|
|
1070 |
if(mCurrentList->getLevel() < VideoCollectionCommon::ELevelDefaultColl ||
|
|
1071 |
!mCurrentList->getModel().rowCount())
|
|
1072 |
{
|
|
1073 |
return;
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
if(!mMultiselectionLoaded)
|
|
1077 |
{
|
|
1078 |
loadMultiSelection();
|
|
1079 |
}
|
|
1080 |
|
|
1081 |
VideoListSelectionDialog *dialog =
|
|
1082 |
mUiLoader->findWidget<VideoListSelectionDialog>(
|
|
1083 |
DOCML_NAME_DIALOG);
|
|
1084 |
if (!dialog)
|
|
1085 |
{
|
|
1086 |
// fatal: no selection dialog
|
|
1087 |
return;
|
|
1088 |
}
|
|
1089 |
TMPXItemId collectionId = mCurrentList->getModel().getOpenItem();
|
|
1090 |
if(collectionId != TMPXItemId::InvalidId() && collectionId.iId2 != KVcxMvcMediaTypeVideo)
|
|
1091 |
{
|
|
1092 |
dialog->setupContent(VideoListSelectionDialog::ERemoveFromCollection, collectionId);
|
34
|
1093 |
dialog->exec();
|
|
1094 |
}
|
30
|
1095 |
}
|
|
1096 |
|
|
1097 |
// -------------------------------------------------------------------------------------------------
|
|
1098 |
// aboutToShowMainMenuSlot
|
|
1099 |
// -------------------------------------------------------------------------------------------------
|
|
1100 |
//
|
|
1101 |
void VideoListView::aboutToShowMainMenuSlot()
|
|
1102 |
{
|
34
|
1103 |
if (!mCurrentList ||
|
|
1104 |
!mToolbarViewsActionGroup ||
|
|
1105 |
!mToolbarCollectionActionGroup)
|
30
|
1106 |
{
|
|
1107 |
return;
|
|
1108 |
}
|
34
|
1109 |
|
|
1110 |
// hide all actions by default
|
|
1111 |
showAction(false, DOCML_NAME_ADD_TO_COLLECTION);
|
|
1112 |
showAction(false, DOCML_NAME_CREATE_COLLECTION);
|
|
1113 |
showAction(false, DOCML_NAME_DELETE_MULTIPLE);
|
|
1114 |
showAction(false, DOCML_NAME_SORT_BY_DATE);
|
|
1115 |
showAction(false, DOCML_NAME_SORT_BY_NAME);
|
|
1116 |
showAction(false, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
|
|
1117 |
showAction(false, DOCML_NAME_SORT_BY_RATING);
|
|
1118 |
showAction(false, DOCML_NAME_SORT_BY_SIZE);
|
|
1119 |
showAction(false, DOCML_NAME_SORT_MENU);
|
|
1120 |
|
|
1121 |
VideoSortFilterProxyModel &model = mCurrentList->getModel();
|
|
1122 |
if (!model.rowCount(QModelIndex()))
|
30
|
1123 |
{
|
|
1124 |
return;
|
|
1125 |
}
|
34
|
1126 |
|
|
1127 |
// get current sorting values
|
|
1128 |
int role;
|
|
1129 |
Qt::SortOrder order;
|
|
1130 |
model.getSorting(role, order);
|
30
|
1131 |
|
|
1132 |
HbAction *firstAction = (HbAction*)(toolBar()->actions().first());
|
|
1133 |
|
|
1134 |
if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionAllVideos] &&
|
|
1135 |
firstAction == mToolbarActions[ETBActionAllVideos])
|
|
1136 |
{
|
34
|
1137 |
showAction(true, DOCML_NAME_SORT_MENU);
|
|
1138 |
showAction(true, DOCML_NAME_SORT_BY_DATE);
|
35
|
1139 |
if (isActionChecked(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS))
|
34
|
1140 |
{
|
|
1141 |
//TODO: when changing between videos and categories, sorting order needs to be changed, if new
|
|
1142 |
// view does not have the previously active sorting order supported
|
|
1143 |
showAction(true, DOCML_NAME_SORT_BY_DATE);
|
|
1144 |
}
|
|
1145 |
else
|
|
1146 |
{
|
|
1147 |
HbAction* action = mSortingRoles.key(role);
|
|
1148 |
if (action)
|
|
1149 |
{
|
|
1150 |
action->setChecked(true);
|
|
1151 |
}
|
|
1152 |
}
|
|
1153 |
|
|
1154 |
showAction(true, DOCML_NAME_SORT_BY_NAME);
|
|
1155 |
showAction(true, DOCML_NAME_SORT_BY_SIZE);
|
30
|
1156 |
|
|
1157 |
if (!mIsService)
|
|
1158 |
{
|
34
|
1159 |
showAction(true, DOCML_NAME_ADD_TO_COLLECTION);
|
|
1160 |
showAction(true, DOCML_NAME_DELETE_MULTIPLE);
|
30
|
1161 |
}
|
|
1162 |
}
|
|
1163 |
else if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionCollections] &&
|
|
1164 |
firstAction == mToolbarActions[ETBActionAllVideos] )
|
|
1165 |
{
|
|
1166 |
if (!mIsService)
|
|
1167 |
{
|
34
|
1168 |
showAction(true, DOCML_NAME_CREATE_COLLECTION);
|
30
|
1169 |
}
|
34
|
1170 |
showAction(true, DOCML_NAME_SORT_MENU);
|
|
1171 |
showAction(true, DOCML_NAME_SORT_BY_NAME);
|
|
1172 |
|
|
1173 |
if (isActionChecked(DOCML_NAME_SORT_BY_DATE) ||
|
|
1174 |
isActionChecked(DOCML_NAME_SORT_BY_SIZE))
|
|
1175 |
{
|
|
1176 |
//TODO: when changing between videos and categories, sorting order needs to be changed, if new
|
|
1177 |
// view does not have the previously active sorting order supported
|
|
1178 |
setActionChecked(true, DOCML_NAME_SORT_BY_NAME);
|
|
1179 |
}
|
|
1180 |
else
|
|
1181 |
{
|
|
1182 |
HbAction* action = mSortingRoles.key(role);
|
|
1183 |
if (action)
|
|
1184 |
{
|
|
1185 |
action->setChecked(true);
|
|
1186 |
}
|
|
1187 |
}
|
|
1188 |
|
|
1189 |
showAction(true, DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
|
30
|
1190 |
}
|
|
1191 |
else if(firstAction != mToolbarActions[ETBActionAllVideos])
|
|
1192 |
{
|
35
|
1193 |
showAction(true, DOCML_NAME_SORT_MENU);
|
|
1194 |
showAction(true, DOCML_NAME_SORT_BY_DATE);
|
|
1195 |
if (isActionChecked(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS))
|
|
1196 |
{
|
|
1197 |
//TODO: when changing between videos and categories, sorting order needs to be changed, if new
|
|
1198 |
// view does not have the previously active sorting order supported
|
|
1199 |
showAction(true, DOCML_NAME_SORT_BY_DATE);
|
|
1200 |
}
|
|
1201 |
else
|
|
1202 |
{
|
|
1203 |
HbAction* action = mSortingRoles.key(role);
|
|
1204 |
if (action)
|
|
1205 |
{
|
|
1206 |
action->setChecked(true);
|
|
1207 |
}
|
|
1208 |
}
|
|
1209 |
|
|
1210 |
showAction(true, DOCML_NAME_SORT_BY_NAME);
|
|
1211 |
showAction(true, DOCML_NAME_SORT_BY_SIZE);
|
|
1212 |
|
30
|
1213 |
if (!mIsService)
|
|
1214 |
{
|
34
|
1215 |
showAction(true, DOCML_NAME_DELETE_MULTIPLE);
|
30
|
1216 |
}
|
|
1217 |
}
|
|
1218 |
}
|
|
1219 |
|
|
1220 |
// -------------------------------------------------------------------------------------------------
|
|
1221 |
// handleAsyncStatusSlot
|
|
1222 |
// -------------------------------------------------------------------------------------------------
|
|
1223 |
//
|
|
1224 |
void VideoListView::handleAsyncStatusSlot(int statusCode, QVariant &additional)
|
|
1225 |
{
|
|
1226 |
// show msg from status
|
|
1227 |
mUiUtils.showStatusMsgSlot(statusCode, additional);
|
|
1228 |
}
|
|
1229 |
|
|
1230 |
// -------------------------------------------------------------------------------------------------
|
|
1231 |
// collectionOpenedSlot
|
|
1232 |
// -------------------------------------------------------------------------------------------------
|
|
1233 |
//
|
34
|
1234 |
void VideoListView::collectionOpenedSlot(bool collectionOpened,
|
|
1235 |
const QString& collection,
|
|
1236 |
const QModelIndex &index)
|
30
|
1237 |
{
|
35
|
1238 |
if(mTransitionOngoing)
|
|
1239 |
{
|
|
1240 |
return;
|
|
1241 |
}
|
|
1242 |
else
|
|
1243 |
{
|
|
1244 |
// clear toolbar actions.
|
|
1245 |
toolBar()->clearActions();
|
|
1246 |
}
|
|
1247 |
|
34
|
1248 |
// update collection specific information
|
|
1249 |
mCollectionName = collection;
|
30
|
1250 |
|
35
|
1251 |
if(collectionOpened)
|
30
|
1252 |
{
|
34
|
1253 |
if(!index.isValid())
|
|
1254 |
{
|
|
1255 |
return;
|
|
1256 |
}
|
35
|
1257 |
|
34
|
1258 |
// open album view
|
|
1259 |
VideoListWidget *collectionContentWidget =
|
|
1260 |
mUiLoader->findWidget<VideoListWidget>(
|
|
1261 |
DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
|
35
|
1262 |
|
34
|
1263 |
if (mCurrentList &&
|
|
1264 |
mCurrentList != collectionContentWidget)
|
|
1265 |
{
|
|
1266 |
// get item id before deactivating
|
|
1267 |
TMPXItemId itemId = TMPXItemId::InvalidId();
|
|
1268 |
itemId = mCurrentList->getModel().getMediaIdAtIndex(index);
|
|
1269 |
|
|
1270 |
// only category or album can be activated here
|
|
1271 |
if(itemId == TMPXItemId::InvalidId() ||
|
|
1272 |
(itemId.iId2 != KVcxMvcMediaTypeCategory &&
|
|
1273 |
itemId.iId2 != KVcxMvcMediaTypeAlbum))
|
|
1274 |
{
|
|
1275 |
return;
|
|
1276 |
}
|
|
1277 |
|
35
|
1278 |
// Send level that is opened with the effect.
|
|
1279 |
QVariant nextLevel;
|
34
|
1280 |
if(itemId.iId2 == KVcxMvcMediaTypeCategory)
|
|
1281 |
{
|
35
|
1282 |
nextLevel = QVariant(VideoCollectionCommon::ELevelDefaultColl);
|
34
|
1283 |
}
|
|
1284 |
else if(itemId.iId2 == KVcxMvcMediaTypeAlbum)
|
|
1285 |
{
|
35
|
1286 |
nextLevel = QVariant(VideoCollectionCommon::ELevelAlbum);
|
|
1287 |
}
|
|
1288 |
|
|
1289 |
// Start fetching content.
|
|
1290 |
collectionContentWidget->getModel().openItem(itemId);
|
34
|
1291 |
|
35
|
1292 |
HbEffect::start(collectionContentWidget,
|
|
1293 |
EFFECT_SLIDE_IN_TO_LEFT,
|
|
1294 |
this,
|
|
1295 |
"finishCollectionOpenedSlot",
|
|
1296 |
nextLevel);
|
34
|
1297 |
|
35
|
1298 |
mTransitionOngoing = true;
|
34
|
1299 |
}
|
30
|
1300 |
}
|
|
1301 |
else
|
|
1302 |
{
|
35
|
1303 |
// open categories view.
|
|
1304 |
VideoListWidget *collectionContentWidget =
|
|
1305 |
mUiLoader->findWidget<VideoListWidget>(
|
|
1306 |
DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
|
34
|
1307 |
|
35
|
1308 |
HbEffect::start(collectionContentWidget,
|
|
1309 |
EFFECT_SLIDE_OUT_TO_LEFT,
|
|
1310 |
this,
|
|
1311 |
"finishCollectionClosedSlot");
|
|
1312 |
|
|
1313 |
mTransitionOngoing = true;
|
30
|
1314 |
}
|
|
1315 |
}
|
|
1316 |
|
|
1317 |
// -------------------------------------------------------------------------------------------------
|
35
|
1318 |
// finishCollectionOpenedSlot
|
30
|
1319 |
// -------------------------------------------------------------------------------------------------
|
|
1320 |
//
|
35
|
1321 |
void VideoListView::finishCollectionOpenedSlot(const HbEffect::EffectStatus &status)
|
30
|
1322 |
{
|
35
|
1323 |
Q_UNUSED(status);
|
|
1324 |
|
|
1325 |
mTransitionOngoing = false;
|
|
1326 |
|
|
1327 |
// deactivat current widget.
|
|
1328 |
mCurrentList->deactivate();
|
|
1329 |
|
|
1330 |
// activate video collection content widget.
|
|
1331 |
mCurrentList = mUiLoader->findWidget<VideoListWidget>(
|
|
1332 |
DOCML_NAME_VC_COLLECTIONCONTENTWIDGET);
|
|
1333 |
|
|
1334 |
if(!mCurrentList || !status.userData.isValid())
|
30
|
1335 |
{
|
|
1336 |
return;
|
|
1337 |
}
|
34
|
1338 |
|
35
|
1339 |
updateSubLabel();
|
|
1340 |
|
|
1341 |
VideoCollectionCommon::TCollectionLevels level =
|
|
1342 |
static_cast<VideoCollectionCommon::TCollectionLevels>(status.userData.toInt());
|
|
1343 |
mCurrentList->activate(level);
|
34
|
1344 |
|
35
|
1345 |
// update hint widget
|
|
1346 |
setHintLevel(VideoHintWidget::Collection);
|
|
1347 |
showHint();
|
|
1348 |
|
|
1349 |
// update toolbar for albums, default categories don't have one.
|
|
1350 |
if(level == VideoCollectionCommon::ELevelAlbum &&
|
|
1351 |
mToolbarCollectionActionGroup && mToolbarActions.contains(ETBActionCollections))
|
34
|
1352 |
{
|
35
|
1353 |
mToolbarActions[ETBActionCollections]->setChecked(false);
|
|
1354 |
toolBar()->addActions(mToolbarCollectionActionGroup->actions());
|
|
1355 |
}
|
|
1356 |
}
|
30
|
1357 |
|
35
|
1358 |
// -------------------------------------------------------------------------------------------------
|
|
1359 |
// finishCollectionClosedSlot
|
|
1360 |
// -------------------------------------------------------------------------------------------------
|
|
1361 |
//
|
|
1362 |
void VideoListView::finishCollectionClosedSlot(const HbEffect::EffectStatus &status)
|
|
1363 |
{
|
|
1364 |
Q_UNUSED(status);
|
|
1365 |
|
|
1366 |
mTransitionOngoing = false;
|
|
1367 |
|
|
1368 |
// open collection view
|
|
1369 |
openCollectionViewSlot();
|
|
1370 |
|
|
1371 |
// update toolbar
|
|
1372 |
if(mToolbarViewsActionGroup && mToolbarActions.contains(ETBActionCollections))
|
|
1373 |
{
|
|
1374 |
toolBar()->addActions(mToolbarViewsActionGroup->actions());
|
|
1375 |
mToolbarActions[ETBActionCollections]->setChecked(true);
|
34
|
1376 |
}
|
|
1377 |
}
|
|
1378 |
|
|
1379 |
// -------------------------------------------------------------------------------------------------
|
|
1380 |
// widgetReadySlot
|
|
1381 |
// -------------------------------------------------------------------------------------------------
|
|
1382 |
//
|
|
1383 |
void VideoListView::widgetReadySlot(QGraphicsWidget *widget, const QString &name)
|
|
1384 |
{
|
|
1385 |
if (name.compare(DOCML_NAME_VC_VIDEOLISTWIDGET) == 0)
|
|
1386 |
{
|
|
1387 |
connect(widget, SIGNAL(command(int)), this, SIGNAL(command(int)));
|
35
|
1388 |
connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
|
34
|
1389 |
}
|
|
1390 |
else if (name.compare(DOCML_NAME_VC_COLLECTIONWIDGET) == 0)
|
|
1391 |
{
|
|
1392 |
connect(
|
|
1393 |
widget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)),
|
|
1394 |
this, SLOT(collectionOpenedSlot(bool, const QString&, const QModelIndex&)));
|
35
|
1395 |
connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
|
|
1396 |
emit(doDelayeds());
|
34
|
1397 |
}
|
|
1398 |
else if (name.compare(DOCML_NAME_VC_COLLECTIONCONTENTWIDGET) == 0)
|
|
1399 |
{
|
|
1400 |
connect(widget, SIGNAL(command(int)), this, SIGNAL(command(int)));
|
|
1401 |
connect(
|
|
1402 |
widget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)),
|
|
1403 |
this, SLOT(collectionOpenedSlot(bool, const QString&, const QModelIndex&)));
|
35
|
1404 |
connect(this, SIGNAL(doDelayeds()), widget, SLOT(doDelayedsSlot()));
|
|
1405 |
emit(doDelayeds());
|
34
|
1406 |
}
|
|
1407 |
else if (name.compare(DOCML_NAME_OPTIONS_MENU) == 0)
|
|
1408 |
{
|
|
1409 |
connect(
|
|
1410 |
widget, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMainMenuSlot()));
|
|
1411 |
}
|
|
1412 |
else if (name.compare(DOCML_NAME_HINT_BUTTON) == 0)
|
|
1413 |
{
|
|
1414 |
connect(widget, SIGNAL(clicked(bool)), this, SLOT(openServicesViewSlot()));
|
|
1415 |
}
|
|
1416 |
}
|
30
|
1417 |
|
34
|
1418 |
// -------------------------------------------------------------------------------------------------
|
|
1419 |
// objectReadySlot
|
|
1420 |
// -------------------------------------------------------------------------------------------------
|
|
1421 |
//
|
|
1422 |
void VideoListView::objectReadySlot(QObject *object, const QString &name)
|
|
1423 |
{
|
|
1424 |
if (name.compare(DOCML_NAME_SORT_BY_DATE) == 0)
|
|
1425 |
{
|
|
1426 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
1427 |
if (action)
|
|
1428 |
{
|
|
1429 |
connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
|
|
1430 |
mSortingRoles[action] = VideoCollectionCommon::KeyDateTime;
|
|
1431 |
}
|
|
1432 |
}
|
|
1433 |
else if (name.compare(DOCML_NAME_SORT_BY_NAME) == 0)
|
|
1434 |
{
|
|
1435 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
1436 |
if (action)
|
|
1437 |
{
|
|
1438 |
connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
|
|
1439 |
mSortingRoles[action] = Qt::DisplayRole;
|
|
1440 |
}
|
|
1441 |
}
|
|
1442 |
else if (name.compare(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS) == 0)
|
|
1443 |
{
|
|
1444 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
1445 |
if (action)
|
|
1446 |
{
|
|
1447 |
// TODO: implement
|
|
1448 |
connect(action, SIGNAL(triggered()), this, SLOT(debugNotImplementedYet()));
|
|
1449 |
mSortingRoles[action] = 0;
|
|
1450 |
}
|
|
1451 |
}
|
|
1452 |
else if (name.compare(DOCML_NAME_SORT_BY_SIZE) == 0)
|
|
1453 |
{
|
|
1454 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
1455 |
if (action)
|
|
1456 |
{
|
|
1457 |
connect(action, SIGNAL(triggered()), this, SLOT(startSorting()));
|
|
1458 |
mSortingRoles[action] = VideoCollectionCommon::KeySizeValue;
|
|
1459 |
}
|
|
1460 |
}
|
|
1461 |
else if (name.compare(DOCML_NAME_ADD_TO_COLLECTION) == 0)
|
|
1462 |
{
|
|
1463 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
1464 |
if (action)
|
|
1465 |
{
|
|
1466 |
connect(action, SIGNAL(triggered()), this, SLOT(addVideosToCollectionSlot()));
|
|
1467 |
}
|
|
1468 |
}
|
|
1469 |
else if (name.compare(DOCML_NAME_CREATE_COLLECTION) == 0)
|
|
1470 |
{
|
|
1471 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
1472 |
if (action)
|
|
1473 |
{
|
|
1474 |
connect(action, SIGNAL(triggered()), this, SLOT(createCollectionSlot()));
|
|
1475 |
}
|
|
1476 |
}
|
|
1477 |
else if (name.compare(DOCML_NAME_DELETE_MULTIPLE) == 0)
|
|
1478 |
{
|
|
1479 |
HbAction *action = qobject_cast<HbAction*>(object);
|
|
1480 |
if (action)
|
|
1481 |
{
|
|
1482 |
connect(action, SIGNAL(triggered()), this, SLOT(deleteItemsSlot()));
|
|
1483 |
}
|
|
1484 |
}
|
30
|
1485 |
}
|
|
1486 |
|
|
1487 |
// Just for testing, remove this
|
|
1488 |
void VideoListView::debugNotImplementedYet()
|
|
1489 |
{
|
|
1490 |
HbMessageBox::information(tr("Not implemented yet"));
|
|
1491 |
}
|
|
1492 |
|
|
1493 |
// end of file
|
|
1494 |
|