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 <hblabel.h>
|
|
23 |
#include <hbmessagebox.h>
|
|
24 |
#include <hbstackedwidget.h>
|
|
25 |
#include <hbstackedlayout.h>
|
|
26 |
#include <hblistwidget.h>
|
|
27 |
#include <hbtoolbar.h>
|
|
28 |
#include <hbaction.h>
|
|
29 |
#include <hbmenu.h>
|
|
30 |
#include <hbgroupbox.h>
|
|
31 |
#include <hbpushbutton.h>
|
|
32 |
|
|
33 |
#include "videoservices.h"
|
|
34 |
#include "videolistselectiondialog.h"
|
|
35 |
#include "videocollectionviewutils.h"
|
|
36 |
#include "videolistwidget.h"
|
|
37 |
#include "videohintwidget.h"
|
|
38 |
#include "videolistview.h"
|
|
39 |
#include "videocollectioncommon.h"
|
|
40 |
#include "videocollectionwrapper.h"
|
|
41 |
#include "videosortfilterproxymodel.h"
|
|
42 |
#include "videocollectionuiloader.h"
|
|
43 |
|
|
44 |
// remove these
|
|
45 |
#include <QDebug>
|
|
46 |
|
|
47 |
const int VIDEO_LIST_VIEW_OPTION_MENU_COUNT = 4;
|
|
48 |
const int VIDEO_LIST_VIEW_SORT_MENU_COUNT = 5;
|
|
49 |
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
// Constructor
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
VideoListView::VideoListView(VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent) :
|
|
55 |
HbView(parent),
|
|
56 |
mSortMenu(0),
|
|
57 |
mUiUtils(VideoCollectionViewUtils::instance()),
|
|
58 |
mWrapper(VideoCollectionWrapper::instance()),
|
|
59 |
mUiLoader(uiLoader),
|
|
60 |
mModel(0),
|
|
61 |
mIsService(false),
|
|
62 |
mModelReady(false),
|
|
63 |
mSubLabel(0),
|
|
64 |
mOptionsMenu(0),
|
|
65 |
mVideoServices(0),
|
|
66 |
mVideoListWidget(0),
|
|
67 |
mVideoHintWidget(0),
|
|
68 |
mToolbarViewsActionGroup(0),
|
|
69 |
mToolbarCollectionActionGroup(0),
|
|
70 |
mSelectionDialog(0)
|
|
71 |
{
|
|
72 |
// NOP
|
|
73 |
}
|
|
74 |
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
// Destructor
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
VideoListView::~VideoListView()
|
|
80 |
{
|
|
81 |
qDebug() << "VideoListView::~VideoListView()";
|
|
82 |
delete mSelectionDialog;
|
|
83 |
// widgets' destructors are being called throught
|
|
84 |
// orbit framework. No need to remove them here.
|
|
85 |
mMenuActions.clear();
|
|
86 |
mToolbarActions.clear();
|
|
87 |
mSortingRoles.clear();
|
|
88 |
|
|
89 |
if(mVideoServices)
|
|
90 |
{
|
|
91 |
mVideoServices->decreaseReferenceCount();
|
|
92 |
mVideoServices = 0;
|
|
93 |
}
|
|
94 |
|
|
95 |
if(mWrapper)
|
|
96 |
{
|
|
97 |
mWrapper->decreaseReferenceCount();
|
|
98 |
mWrapper = 0;
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
// initializeView()
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
int VideoListView::initializeView()
|
|
107 |
{
|
|
108 |
if(!mUiLoader)
|
|
109 |
{
|
|
110 |
return -1;
|
|
111 |
}
|
|
112 |
|
|
113 |
if (XQServiceUtil::isService() && !mVideoServices)
|
|
114 |
{
|
|
115 |
mIsService = true;
|
|
116 |
|
|
117 |
mVideoServices = VideoServices::instance();
|
|
118 |
|
|
119 |
if (!mVideoServices)
|
|
120 |
{
|
|
121 |
return -1;
|
|
122 |
}
|
|
123 |
else
|
|
124 |
{
|
|
125 |
connect(mVideoServices, SIGNAL(titleReady(const QString&)), this, SLOT(titleReadySlot(const QString&)));
|
|
126 |
}
|
|
127 |
}
|
|
128 |
|
|
129 |
// create model
|
|
130 |
if(mWrapper)
|
|
131 |
{
|
|
132 |
mModel = mWrapper->getModel();
|
|
133 |
}
|
|
134 |
|
|
135 |
if(!mModel || mModel->open(VideoListWidget::ELevelVideos) < 0)
|
|
136 |
{
|
|
137 |
cleanup();
|
|
138 |
return -1;
|
|
139 |
}
|
|
140 |
|
|
141 |
int sortRole(VideoCollectionCommon::KeyDateTime);
|
|
142 |
Qt::SortOrder sortOrder(Qt::AscendingOrder);
|
|
143 |
|
|
144 |
// return value ignored, as in case of error the sortRole and sortOrder variables
|
|
145 |
// stay at their predefined values, and in error cases those are the sorting values
|
|
146 |
// that are used.
|
|
147 |
mUiUtils.loadSortingValues(sortRole, sortOrder);
|
|
148 |
|
|
149 |
mModel->doSorting(sortRole, sortOrder, false);
|
|
150 |
|
|
151 |
mOptionsMenu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_OPTIONS_MENU);
|
|
152 |
|
|
153 |
if(!mOptionsMenu)
|
|
154 |
{
|
|
155 |
cleanup();
|
|
156 |
return -1;
|
|
157 |
}
|
|
158 |
|
|
159 |
mSubLabel = mUiLoader->findWidget<HbGroupBox>(DOCML_NAME_VC_HEADINGBANNER);
|
|
160 |
|
|
161 |
if(!mSubLabel)
|
|
162 |
{
|
|
163 |
cleanup();
|
|
164 |
return -1;
|
|
165 |
}
|
|
166 |
|
|
167 |
mSubLabel->setCollapsable(false);
|
|
168 |
|
|
169 |
// allocate and initialize views, menus and toolbar
|
|
170 |
if(createVideoWidget() != 0
|
|
171 |
|| createHintWidget() != 0
|
|
172 |
|| createToolbar() != 0
|
|
173 |
|| createMainMenu() != 0)
|
|
174 |
{
|
|
175 |
cleanup();
|
|
176 |
return -1;
|
|
177 |
}
|
|
178 |
|
|
179 |
mSubLabel->setHeading(tr("Retrieving list.."));
|
|
180 |
|
|
181 |
mCollectionName = "";
|
|
182 |
|
|
183 |
return 0;
|
|
184 |
}
|
|
185 |
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
// titleReadySlot()
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
void VideoListView::titleReadySlot(const QString& title)
|
|
191 |
{
|
|
192 |
setTitle(title);
|
|
193 |
}
|
|
194 |
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
// activateView()
|
|
197 |
// ---------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
int VideoListView::activateView()
|
|
200 |
{
|
|
201 |
mOptionsMenu->setEnabled(true);
|
|
202 |
|
|
203 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
|
204 |
|
|
205 |
if(!connect(mainWnd, SIGNAL(aboutToChangeOrientation()),
|
|
206 |
this, SLOT( aboutToChangeOrientationSlot())) ||
|
|
207 |
!connect(mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
|
|
208 |
this, SLOT(orientationChangedSlot(Qt::Orientation))) ||
|
|
209 |
!connect(mWrapper, SIGNAL(asyncStatus(int, QVariant&)),
|
|
210 |
this, SLOT(handleAsyncStatusSlot(int, QVariant&))) ||
|
|
211 |
|
|
212 |
//TODO: seems like rowsremoved is not signaled when files are removed, but layoutchanged
|
|
213 |
//TODO: on the other hand, layoutchanged is not signaled when items are added but rowsinserted is
|
|
214 |
|
|
215 |
!connect(mModel,
|
|
216 |
SIGNAL(rowsInserted(const QModelIndex&, int, int)),
|
|
217 |
this, SLOT(layoutChangedSlot())) ||
|
|
218 |
!connect(mModel,
|
|
219 |
SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
|
|
220 |
this, SLOT(layoutChangedSlot())) ||
|
|
221 |
//TODO: connect to rowsremoved rowsinserted once delete results emitting removed
|
|
222 |
!connect(mModel,
|
|
223 |
SIGNAL(layoutChanged()),
|
|
224 |
this, SLOT(layoutChangedSlot())) ||
|
|
225 |
!connect(mModel,
|
|
226 |
SIGNAL(modelReady()),
|
|
227 |
this, SLOT(modelReadySlot())))
|
|
228 |
{
|
|
229 |
// deactivate view so we get rid of dangling connections.
|
|
230 |
deactivateView();
|
|
231 |
return -1;
|
|
232 |
}
|
|
233 |
|
|
234 |
// activate current vidget, first make sure it's one that can be activated
|
|
235 |
if(mVideoListWidget)
|
|
236 |
{
|
|
237 |
int result = mVideoListWidget->activate();
|
|
238 |
if(result < 0) {
|
|
239 |
// activate failed, deactivate view so we get rid of dangling connections.
|
|
240 |
deactivateView();
|
|
241 |
}
|
|
242 |
else if (mSubLabel->heading() != tr("Retrieving list.."))
|
|
243 |
{
|
|
244 |
updateSubLabel();
|
|
245 |
}
|
|
246 |
|
|
247 |
showHint();
|
|
248 |
mainWnd->unsetOrientation();
|
|
249 |
|
|
250 |
return result;
|
|
251 |
}
|
|
252 |
|
|
253 |
// deactivate view so we get rid of dangling connections.
|
|
254 |
deactivateView();
|
|
255 |
return -1;
|
|
256 |
}
|
|
257 |
|
|
258 |
// ---------------------------------------------------------------------------
|
|
259 |
// modelReadySlot
|
|
260 |
// ---------------------------------------------------------------------------
|
|
261 |
//
|
|
262 |
void VideoListView::modelReadySlot()
|
|
263 |
{
|
|
264 |
mModelReady = true;
|
|
265 |
// since the reset signal arrives after
|
|
266 |
// layout changed, need to make sure that
|
|
267 |
// view is updated in case needed
|
|
268 |
layoutChangedSlot();
|
|
269 |
}
|
|
270 |
|
|
271 |
// ---------------------------------------------------------------------------
|
|
272 |
// layoutChangedSlot
|
|
273 |
// ---------------------------------------------------------------------------
|
|
274 |
//
|
|
275 |
void VideoListView::layoutChangedSlot()
|
|
276 |
{
|
|
277 |
updateSubLabel();
|
|
278 |
|
|
279 |
if(mModelReady)
|
|
280 |
{
|
|
281 |
showHint();
|
|
282 |
}
|
|
283 |
}
|
|
284 |
|
|
285 |
// ---------------------------------------------------------------------------
|
|
286 |
// deactivateView()
|
|
287 |
// ---------------------------------------------------------------------------
|
|
288 |
//
|
|
289 |
void VideoListView::deactivateView()
|
|
290 |
{
|
|
291 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
|
292 |
|
|
293 |
disconnect(mainWnd, SIGNAL(aboutToChangeOrientation()),
|
|
294 |
this, SLOT(aboutToChangeOrientationSlot()));
|
|
295 |
|
|
296 |
disconnect(mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
|
|
297 |
this, SLOT(orientationChangedSlot(Qt::Orientation)));
|
|
298 |
|
|
299 |
disconnect(mWrapper, SIGNAL(asyncStatus(int, QVariant&)),
|
|
300 |
this, SLOT(handleAsyncStatusSlot(int, QVariant&)));
|
|
301 |
|
|
302 |
disconnect(mModel,
|
|
303 |
SIGNAL(rowsInserted(const QModelIndex&, int, int)),
|
|
304 |
this, SLOT(layoutChangedSlot()));
|
|
305 |
disconnect(mModel,
|
|
306 |
SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
|
|
307 |
this, SLOT(layoutChangedSlot()));
|
|
308 |
disconnect(mModel,
|
|
309 |
SIGNAL(layoutChanged()),
|
|
310 |
this, SLOT(layoutChangedSlot()));
|
|
311 |
disconnect(mModel,
|
|
312 |
SIGNAL(modelReady()),
|
|
313 |
this, SLOT(modelReadySlot()));
|
|
314 |
|
|
315 |
mOptionsMenu->setVisible(false);
|
|
316 |
mOptionsMenu->setEnabled(false);
|
|
317 |
|
|
318 |
showHint(false);
|
|
319 |
|
|
320 |
if(mVideoListWidget)
|
|
321 |
{
|
|
322 |
mVideoListWidget->deactivate();
|
|
323 |
}
|
|
324 |
}
|
|
325 |
|
|
326 |
// ---------------------------------------------------------------------------
|
|
327 |
// back()
|
|
328 |
// ---------------------------------------------------------------------------
|
|
329 |
//
|
|
330 |
void VideoListView::back()
|
|
331 |
{
|
|
332 |
// NOP
|
|
333 |
}
|
|
334 |
|
|
335 |
// ---------------------------------------------------------------------------
|
|
336 |
// cleanup()
|
|
337 |
// ---------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
void VideoListView::cleanup()
|
|
340 |
{
|
|
341 |
delete mToolbarViewsActionGroup;
|
|
342 |
mToolbarViewsActionGroup = 0;
|
|
343 |
|
|
344 |
delete mToolbarCollectionActionGroup;
|
|
345 |
mToolbarCollectionActionGroup = 0;
|
|
346 |
|
|
347 |
// not deleted as the uiloader owns these.
|
|
348 |
mVideoListWidget = 0;
|
|
349 |
mVideoHintWidget = 0;
|
|
350 |
}
|
|
351 |
|
|
352 |
// ---------------------------------------------------------------------------
|
|
353 |
// createMainMenu()
|
|
354 |
// ---------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
int VideoListView::createMainMenu()
|
|
357 |
{
|
|
358 |
if(mMenuActions.count() > 0)
|
|
359 |
{
|
|
360 |
// Menu is already created.
|
|
361 |
return 0;
|
|
362 |
}
|
|
363 |
|
|
364 |
if(!connect(mOptionsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMainMenuSlot())))
|
|
365 |
{
|
|
366 |
return -1;
|
|
367 |
}
|
|
368 |
|
|
369 |
mMenuActions[EActionAddToCollection] = (HbAction*)mUiLoader->findObject<QObject>(DOCML_NAME_ADD_TO_COLLECTION);
|
|
370 |
connect(mMenuActions[EActionAddToCollection], SIGNAL(triggered()), this, SLOT(debugNotImplementedYet()));
|
|
371 |
|
|
372 |
mMenuActions[EActionNewCollection] = (HbAction*)mUiLoader->findObject<QObject>(DOCML_NAME_CREATE_COLLECTION);
|
|
373 |
connect(mMenuActions[EActionNewCollection], SIGNAL(triggered()), this, SLOT(createCollectionSlot()));
|
|
374 |
|
|
375 |
mMenuActions[EActionDelete] = (HbAction*)mUiLoader->findObject<QObject>(DOCML_NAME_DELETE_MULTIPLE);
|
|
376 |
connect(mMenuActions[EActionDelete], SIGNAL(triggered()), this, SLOT(deleteItemsSlot()));
|
|
377 |
|
|
378 |
mSortMenu = mUiLoader->findWidget<HbMenu>(DOCML_NAME_SORT_MENU);
|
|
379 |
|
|
380 |
mMenuActions[EActionSortBy] = mSortMenu->menuAction();
|
|
381 |
|
|
382 |
// submenu items and roles for sorting
|
|
383 |
mMenuActions[EActionSortByDate] = (HbAction*)mUiLoader->findObject<QObject>(DOCML_NAME_SORT_BY_DATE);
|
|
384 |
connect(mMenuActions[EActionSortByDate], SIGNAL(triggered()), this, SLOT(startSorting()));
|
|
385 |
mSortingRoles[mMenuActions[EActionSortByDate]] = VideoCollectionCommon::KeyDateTime;
|
|
386 |
|
|
387 |
mMenuActions[EActionSortByName] = (HbAction*)mUiLoader->findObject<QObject>(DOCML_NAME_SORT_BY_NAME);
|
|
388 |
connect(mMenuActions[EActionSortByName], SIGNAL(triggered()), this, SLOT(startSorting()));
|
|
389 |
mSortingRoles[mMenuActions[EActionSortByName]] = Qt::DisplayRole;
|
|
390 |
|
|
391 |
mMenuActions[EACtionSortByItemCount] = (HbAction*)mUiLoader->findObject<QObject>(DOCML_NAME_SORT_BY_NUMBER_OF_ITEMS);
|
|
392 |
connect(mMenuActions[EACtionSortByItemCount], SIGNAL(triggered()), this, SLOT(startSorting()));
|
|
393 |
// TODO:
|
|
394 |
mSortingRoles[mMenuActions[EACtionSortByItemCount]] = 0;
|
|
395 |
|
|
396 |
mMenuActions[EActionSortByLength] = (HbAction*)mUiLoader->findObject<QObject>(DOCML_NAME_SORT_BY_TOTAL_LENGTH);
|
|
397 |
connect(mMenuActions[EActionSortByLength], SIGNAL(triggered()), this, SLOT(startSorting()));
|
|
398 |
// TODO:
|
|
399 |
mSortingRoles[mMenuActions[EActionSortByLength]] = 0;
|
|
400 |
|
|
401 |
mMenuActions[EActionSortBySize] = (HbAction*)mUiLoader->findObject<QObject>(DOCML_NAME_SORT_BY_SIZE);
|
|
402 |
connect(mMenuActions[EActionSortBySize], SIGNAL(triggered()), this, SLOT(startSorting()));
|
|
403 |
mSortingRoles[mMenuActions[EActionSortBySize]] = VideoCollectionCommon::KeySizeValue;
|
|
404 |
|
|
405 |
if(mSortMenu->actions().count() != VIDEO_LIST_VIEW_SORT_MENU_COUNT
|
|
406 |
|| mOptionsMenu->actions().count() != VIDEO_LIST_VIEW_OPTION_MENU_COUNT)
|
|
407 |
{
|
|
408 |
return -1;
|
|
409 |
}
|
|
410 |
|
|
411 |
return 0;
|
|
412 |
}
|
|
413 |
|
|
414 |
// ---------------------------------------------------------------------------
|
|
415 |
// createToolbar()
|
|
416 |
// Creates toolbar, toolbar actions and toolbar icons
|
|
417 |
// ---------------------------------------------------------------------------
|
|
418 |
//
|
|
419 |
int VideoListView::createToolbar()
|
|
420 |
{
|
|
421 |
// Create actiongroup and add all actions to it. This ensures that only one is
|
|
422 |
// active at certain moment.
|
|
423 |
|
|
424 |
if(!mToolbarViewsActionGroup && !mToolbarCollectionActionGroup)
|
|
425 |
{
|
|
426 |
mToolbarViewsActionGroup = new QActionGroup(this);
|
|
427 |
mToolbarCollectionActionGroup = new QActionGroup(this);
|
|
428 |
|
|
429 |
if(!mToolbarViewsActionGroup || !mToolbarCollectionActionGroup)
|
|
430 |
{
|
|
431 |
delete mToolbarViewsActionGroup;
|
|
432 |
mToolbarViewsActionGroup = 0;
|
|
433 |
|
|
434 |
delete mToolbarCollectionActionGroup;
|
|
435 |
mToolbarCollectionActionGroup = 0;
|
|
436 |
|
|
437 |
return -1;
|
|
438 |
}
|
|
439 |
|
|
440 |
// create toolbar item actions
|
|
441 |
|
|
442 |
// All Videos tab
|
|
443 |
mToolbarActions[ETBActionAllVideos] = createAction(tr("All videos"), ":/images/qtg_mono_video_all.svg",
|
|
444 |
mToolbarViewsActionGroup, SLOT(openAllVideosViewSlot()));
|
|
445 |
|
|
446 |
// Collections tab
|
|
447 |
mToolbarActions[ETBActionCollections] = createAction(tr("Collections"), ":/images/qtg_mono_video_collection.svg",
|
|
448 |
mToolbarViewsActionGroup, SLOT(openCollectionViewSlot()));
|
|
449 |
|
|
450 |
if (!mIsService)
|
|
451 |
{
|
|
452 |
// Services tab
|
|
453 |
mToolbarActions[ETBActionServices] = createAction(tr("Services"), ":/images/qtg_mono_video_services.svg",
|
|
454 |
mToolbarViewsActionGroup, SLOT(openServicesViewSlot()));
|
|
455 |
// Add Videos tab
|
|
456 |
mToolbarActions[ETBActionAddVideos] = createAction(tr("Add videos"), ":/images/mono_video_addvideos.svg",
|
|
457 |
mToolbarCollectionActionGroup, SLOT(addVideosToCollectionSlot()));
|
|
458 |
|
|
459 |
// Remove Videos tab
|
|
460 |
mToolbarActions[ETBActionRemoveVideos] = createAction(tr("Remove videos"), ":/images/mono_video_removevideos.svg",
|
|
461 |
mToolbarCollectionActionGroup, SLOT(debugNotImplementedYet()));
|
|
462 |
}
|
|
463 |
|
|
464 |
// Sort by tab
|
|
465 |
mToolbarActions[ETBActionSortVideos] = createAction(tr("Sort by"), ":/images/mono_video_sortvideos.svg",
|
|
466 |
mToolbarCollectionActionGroup, SLOT(openSortByMenuSlot()));
|
|
467 |
|
|
468 |
HbToolBar *bar = toolBar(); // First call to toolBar() creates the object, so on failure it could return 0.
|
|
469 |
|
|
470 |
if( !bar
|
|
471 |
|| !mToolbarActions[ETBActionAllVideos]
|
|
472 |
|| !mToolbarActions[ETBActionCollections]
|
|
473 |
|| !mToolbarActions[ETBActionSortVideos]
|
|
474 |
|| (!mToolbarActions[ETBActionServices] && !mIsService)
|
|
475 |
|| (!mToolbarActions[ETBActionAddVideos] && !mIsService)
|
|
476 |
|| (!mToolbarActions[ETBActionRemoveVideos] && !mIsService))
|
|
477 |
{
|
|
478 |
delete mToolbarActions[ETBActionAllVideos];
|
|
479 |
delete mToolbarActions[ETBActionCollections];
|
|
480 |
delete mToolbarActions[ETBActionServices];
|
|
481 |
delete mToolbarActions[ETBActionAddVideos];
|
|
482 |
delete mToolbarActions[ETBActionRemoveVideos];
|
|
483 |
delete mToolbarActions[ETBActionSortVideos];
|
|
484 |
return -1;
|
|
485 |
}
|
|
486 |
|
|
487 |
// Collection view actions are not checkable
|
|
488 |
mToolbarActions[ETBActionAllVideos]->setCheckable(true);
|
|
489 |
mToolbarActions[ETBActionCollections]->setCheckable(true);
|
|
490 |
|
|
491 |
if (!mIsService)
|
|
492 |
{
|
|
493 |
mToolbarActions[ETBActionServices]->setCheckable(true);
|
|
494 |
}
|
|
495 |
|
|
496 |
// Allvideos is checked at creation phase
|
|
497 |
mToolbarActions[ETBActionAllVideos]->setChecked(true);
|
|
498 |
|
|
499 |
bar->addActions(mToolbarViewsActionGroup->actions());
|
|
500 |
}
|
|
501 |
|
|
502 |
return 0;
|
|
503 |
}
|
|
504 |
|
|
505 |
// ---------------------------------------------------------------------------
|
|
506 |
// createAction()
|
|
507 |
// ---------------------------------------------------------------------------
|
|
508 |
//
|
|
509 |
HbAction* VideoListView::createAction(QString tooltip, QString icon,
|
|
510 |
QActionGroup* actionGroup, const char *slot)
|
|
511 |
{
|
|
512 |
HbAction* action = new HbAction(actionGroup);
|
|
513 |
if(!action) {
|
|
514 |
return 0;
|
|
515 |
}
|
|
516 |
|
|
517 |
action->setToolTip(tooltip);
|
|
518 |
HbIcon hbIcon(icon);
|
|
519 |
action->setIcon(hbIcon);
|
|
520 |
|
|
521 |
if(!connect(action, SIGNAL(triggered()), this, slot)) {
|
|
522 |
// actiongroup deletion deletes this also.
|
|
523 |
// return 0 tells that there was a problem in creation to caller.
|
|
524 |
delete action;
|
|
525 |
return 0;
|
|
526 |
}
|
|
527 |
|
|
528 |
return action;
|
|
529 |
}
|
|
530 |
|
|
531 |
|
|
532 |
// ---------------------------------------------------------------------------
|
|
533 |
// createVideoWidget()
|
|
534 |
// ---------------------------------------------------------------------------
|
|
535 |
//
|
|
536 |
int VideoListView::createVideoWidget()
|
|
537 |
{
|
|
538 |
if(!mModel)
|
|
539 |
{
|
|
540 |
return -1;
|
|
541 |
}
|
|
542 |
if(!mVideoListWidget)
|
|
543 |
{
|
|
544 |
mVideoListWidget = mUiLoader->findWidget<VideoListWidget>(DOCML_NAME_VC_VIDEOLISTWIDGET);
|
|
545 |
if(!mVideoListWidget )
|
|
546 |
{
|
|
547 |
return -1;
|
|
548 |
}
|
|
549 |
if(mVideoListWidget->initialize(*mModel, mVideoServices) < 0)
|
|
550 |
{
|
|
551 |
return -1;
|
|
552 |
}
|
|
553 |
|
|
554 |
if(!connect(mVideoListWidget, SIGNAL( command(int)), this, SIGNAL(command(int))) ||
|
|
555 |
!connect(mVideoListWidget, SIGNAL( collectionOpened(bool, const QString&)), this, SLOT(collectionOpenedSlot(bool, const QString&))))
|
|
556 |
{
|
|
557 |
return -1;
|
|
558 |
}
|
|
559 |
}
|
|
560 |
|
|
561 |
return 0;
|
|
562 |
}
|
|
563 |
|
|
564 |
// ---------------------------------------------------------------------------
|
|
565 |
// createHintWidget()
|
|
566 |
// ---------------------------------------------------------------------------
|
|
567 |
//
|
|
568 |
int VideoListView::createHintWidget()
|
|
569 |
{
|
|
570 |
if(!mVideoHintWidget)
|
|
571 |
{
|
|
572 |
mVideoHintWidget = mUiLoader->findWidget<VideoHintWidget>(DOCML_NAME_VC_VIDEOHINTWIDGET);
|
|
573 |
if(!mVideoHintWidget )
|
|
574 |
{
|
|
575 |
return -1;
|
|
576 |
}
|
|
577 |
if(mVideoHintWidget->initialize() < 0)
|
|
578 |
{
|
|
579 |
return -1;
|
|
580 |
}
|
|
581 |
|
|
582 |
HbPushButton* button = mUiLoader->findWidget<HbPushButton>(DOCML_NAME_HINT_BUTTON);
|
|
583 |
if(!connect(button, SIGNAL(clicked(bool)), this, SLOT(openServicesViewSlot())))
|
|
584 |
{
|
|
585 |
return -1;
|
|
586 |
}
|
|
587 |
}
|
|
588 |
|
|
589 |
return 0;
|
|
590 |
}
|
|
591 |
|
|
592 |
// ---------------------------------------------------------------------------
|
|
593 |
// showHint
|
|
594 |
// ---------------------------------------------------------------------------
|
|
595 |
//
|
|
596 |
void VideoListView::showHint(bool show)
|
|
597 |
{
|
|
598 |
if (mModel && mModelReady && (mModel->rowCount() == 0) && mVideoHintWidget)
|
|
599 |
{
|
|
600 |
mVideoHintWidget->setVisible(show);
|
|
601 |
}
|
|
602 |
else if (mVideoHintWidget)
|
|
603 |
{
|
|
604 |
show = false;
|
|
605 |
mVideoHintWidget->setVisible(false);
|
|
606 |
}
|
|
607 |
|
|
608 |
if(show && mToolbarViewsActionGroup && mToolbarCollectionActionGroup)
|
|
609 |
{
|
|
610 |
if(!mIsService)
|
|
611 |
{
|
|
612 |
mToolbarActions[ETBActionRemoveVideos]->setEnabled(false);
|
|
613 |
}
|
|
614 |
mToolbarActions[ETBActionSortVideos]->setEnabled(false);
|
|
615 |
}
|
|
616 |
else
|
|
617 |
{
|
|
618 |
if(!mIsService)
|
|
619 |
{
|
|
620 |
if(mToolbarActions[ETBActionRemoveVideos]->isEnabled() == false)
|
|
621 |
{
|
|
622 |
mToolbarActions[ETBActionRemoveVideos]->setEnabled(true);
|
|
623 |
}
|
|
624 |
}
|
|
625 |
if(mToolbarActions[ETBActionSortVideos]->isEnabled() == false)
|
|
626 |
{
|
|
627 |
mToolbarActions[ETBActionSortVideos]->setEnabled(true);
|
|
628 |
}
|
|
629 |
}
|
|
630 |
}
|
|
631 |
|
|
632 |
// ---------------------------------------------------------------------------
|
|
633 |
// updateSubLabel
|
|
634 |
// ---------------------------------------------------------------------------
|
|
635 |
//
|
|
636 |
void VideoListView::updateSubLabel()
|
|
637 |
{
|
|
638 |
//TODO: reduce unnecessary updates
|
|
639 |
if (mModel && mVideoListWidget)
|
|
640 |
{
|
|
641 |
int itemCount = mModel->rowCount();
|
|
642 |
|
|
643 |
VideoListWidget::TVideoListType type = mVideoListWidget->getType();
|
|
644 |
if (type == VideoListWidget::EAllVideos)
|
|
645 |
{
|
|
646 |
mSubLabel->setHeading(tr("%1 videos").arg(itemCount));
|
|
647 |
}
|
|
648 |
else if (type == VideoListWidget::ECollections)
|
|
649 |
{
|
|
650 |
mSubLabel->setHeading(tr("%1 collections").arg(itemCount));
|
|
651 |
}
|
|
652 |
else if (type == VideoListWidget::EDefaultColItems ||
|
|
653 |
type == VideoListWidget::EUserColItems)
|
|
654 |
{
|
|
655 |
mSubLabel->setHeading(tr("%1 (%2)").arg(mCollectionName).arg(itemCount));
|
|
656 |
}
|
|
657 |
}
|
|
658 |
}
|
|
659 |
|
|
660 |
// ---------------------------------------------------------------------------
|
|
661 |
// openAllVideosViewSlot()
|
|
662 |
// ---------------------------------------------------------------------------
|
|
663 |
//
|
|
664 |
void VideoListView::openAllVideosViewSlot()
|
|
665 |
{
|
|
666 |
mModel->open(VideoListWidget::ELevelVideos);
|
|
667 |
mVideoListWidget->activate(VideoListWidget::ELevelVideos);
|
|
668 |
mVideoHintWidget->setLevel(VideoHintWidget::AllVideos);
|
|
669 |
updateSubLabel();
|
|
670 |
}
|
|
671 |
|
|
672 |
// ---------------------------------------------------------------------------
|
|
673 |
// openCollectionViewSlot()
|
|
674 |
// ---------------------------------------------------------------------------
|
|
675 |
//
|
|
676 |
void VideoListView::openCollectionViewSlot()
|
|
677 |
{
|
|
678 |
mModel->open(VideoListWidget::ELevelCategory);
|
|
679 |
mVideoListWidget->activate(VideoListWidget::ELevelCategory);
|
|
680 |
mVideoHintWidget->setLevel(VideoHintWidget::Collection);
|
|
681 |
|
|
682 |
// the collection view is not empty, so we can hide the hint in advance.
|
|
683 |
showHint(false);
|
|
684 |
|
|
685 |
updateSubLabel();
|
|
686 |
}
|
|
687 |
|
|
688 |
// ---------------------------------------------------------------------------
|
|
689 |
// openservicesViewSlot()
|
|
690 |
// ---------------------------------------------------------------------------
|
|
691 |
//
|
|
692 |
void VideoListView::openServicesViewSlot()
|
|
693 |
{
|
|
694 |
debugNotImplementedYet();
|
|
695 |
}
|
|
696 |
|
|
697 |
// ---------------------------------------------------------------------------
|
|
698 |
// startSorting()
|
|
699 |
// ---------------------------------------------------------------------------
|
|
700 |
//
|
|
701 |
void VideoListView::startSorting()
|
|
702 |
{
|
|
703 |
if(!mModel || !mOptionsMenu)
|
|
704 |
{
|
|
705 |
return;
|
|
706 |
}
|
|
707 |
// Check that action is sort by and it has a sub menu.
|
|
708 |
if(mOptionsMenu->activeAction() != mMenuActions[EActionSortBy] || !mOptionsMenu->activeAction()->menu())
|
|
709 |
{
|
|
710 |
return;
|
|
711 |
}
|
|
712 |
|
|
713 |
int role = mSortingRoles[mOptionsMenu->activeAction()->menu()->activeAction()];
|
|
714 |
|
|
715 |
Qt::SortOrder order(Qt::AscendingOrder);
|
|
716 |
|
|
717 |
if(mModel->sortRole() == role && mModel->sortOrder() == Qt::AscendingOrder)
|
|
718 |
{
|
|
719 |
order = Qt::DescendingOrder;
|
|
720 |
}
|
|
721 |
|
|
722 |
mModel->doSorting(role, order);
|
|
723 |
|
|
724 |
mUiUtils.saveSortingValues(role, order);
|
|
725 |
}
|
|
726 |
|
|
727 |
// -------------------------------------------------------------------------------------------------
|
|
728 |
// aboutToChangeOrientationSlot()
|
|
729 |
// hide all items in the window during orientation change
|
|
730 |
// -------------------------------------------------------------------------------------------------
|
|
731 |
//
|
|
732 |
void VideoListView::aboutToChangeOrientationSlot()
|
|
733 |
{
|
|
734 |
// this method is required for changing from to mediawall
|
|
735 |
}
|
|
736 |
|
|
737 |
// -------------------------------------------------------------------------------------------------
|
|
738 |
// orientationChangedSlot()
|
|
739 |
// orientation changed, items can be put back to visible after view has handled the change
|
|
740 |
// -------------------------------------------------------------------------------------------------
|
|
741 |
//
|
|
742 |
void VideoListView::orientationChangedSlot( Qt::Orientation orientation )
|
|
743 |
{
|
|
744 |
// this method is required for changing from to mediawall
|
|
745 |
|
|
746 |
// in landscape we need to hide the title and the toolbar. (also required for the mediawall?)
|
|
747 |
// TODO: how about the feature where the toolbar comes visible if screen is tapped?
|
|
748 |
this->setItemVisible(Hb::AllItems, orientation == Qt::Vertical);
|
|
749 |
}
|
|
750 |
|
|
751 |
// -------------------------------------------------------------------------------------------------
|
|
752 |
// deleteItemsSlot
|
|
753 |
// -------------------------------------------------------------------------------------------------
|
|
754 |
//
|
|
755 |
void VideoListView::deleteItemsSlot()
|
|
756 |
{
|
|
757 |
if(!mModel)
|
|
758 |
{
|
|
759 |
return;
|
|
760 |
}
|
|
761 |
if(!mSelectionDialog)
|
|
762 |
{
|
|
763 |
bool ok(false);
|
|
764 |
mUiLoader->load(DOCML_VIDEOSELECTIONDIALOG_FILE, &ok);
|
|
765 |
if(!ok)
|
|
766 |
{
|
|
767 |
return;
|
|
768 |
}
|
|
769 |
mSelectionDialog = mUiLoader->findObject<VideoListSelectionDialog>( DOCML_NAME_DIALOG );
|
|
770 |
}
|
|
771 |
mSelectionDialog->setContent(tr("Delete items"), mVideoListWidget);
|
|
772 |
if(mSelectionDialog->exec() == mSelectionDialog->primaryAction())
|
|
773 |
{
|
|
774 |
// get selection and remove
|
|
775 |
QItemSelection selection = mSelectionDialog->getSelection();
|
|
776 |
mModel->deleteItems(selection.indexes());
|
|
777 |
// invalid model to get UI updated
|
|
778 |
mModel->invalidate();
|
|
779 |
}
|
|
780 |
}
|
|
781 |
|
|
782 |
// -------------------------------------------------------------------------------------------------
|
|
783 |
// createCollectionSlot
|
|
784 |
// -------------------------------------------------------------------------------------------------
|
|
785 |
//
|
|
786 |
void VideoListView::createCollectionSlot()
|
|
787 |
{
|
|
788 |
debugNotImplementedYet();
|
|
789 |
}
|
|
790 |
|
|
791 |
// -------------------------------------------------------------------------------------------------
|
|
792 |
// addVideosToCollectionSlot
|
|
793 |
// -------------------------------------------------------------------------------------------------
|
|
794 |
//
|
|
795 |
void VideoListView::addVideosToCollectionSlot()
|
|
796 |
{
|
|
797 |
debugNotImplementedYet();
|
|
798 |
}
|
|
799 |
|
|
800 |
// -------------------------------------------------------------------------------------------------
|
|
801 |
// aboutToShowMainMenuSlot
|
|
802 |
// -------------------------------------------------------------------------------------------------
|
|
803 |
//
|
|
804 |
void VideoListView::aboutToShowMainMenuSlot()
|
|
805 |
{
|
|
806 |
if(!mModel || !mToolbarViewsActionGroup || !mToolbarCollectionActionGroup)
|
|
807 |
{
|
|
808 |
return;
|
|
809 |
}
|
|
810 |
|
|
811 |
int menuActionCount = 0;
|
|
812 |
HbAction *action = 0;
|
|
813 |
foreach(action, mMenuActions.values())
|
|
814 |
{
|
|
815 |
if(action)
|
|
816 |
{
|
|
817 |
++menuActionCount;
|
|
818 |
action->setVisible(false);
|
|
819 |
}
|
|
820 |
}
|
|
821 |
if(menuActionCount != mMenuActions.values().count() || mMenuActions.values().count() == 0)
|
|
822 |
{
|
|
823 |
// fatal error, some action(s) was not created.
|
|
824 |
return;
|
|
825 |
}
|
|
826 |
|
|
827 |
if(!mModel->rowCount(QModelIndex()))
|
|
828 |
{
|
|
829 |
// no items, no menu
|
|
830 |
return;
|
|
831 |
}
|
|
832 |
|
|
833 |
HbAction *firstAction = (HbAction*)(toolBar()->actions().first());
|
|
834 |
|
|
835 |
if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionAllVideos] &&
|
|
836 |
firstAction == mToolbarActions[ETBActionAllVideos])
|
|
837 |
{
|
|
838 |
mMenuActions[EActionSortBy]->setVisible(true);
|
|
839 |
mMenuActions[EActionSortByDate]->setVisible(true);
|
|
840 |
mMenuActions[EActionSortByName]->setVisible(true);
|
|
841 |
mMenuActions[EActionSortBySize]->setVisible(true);
|
|
842 |
|
|
843 |
if (!mIsService)
|
|
844 |
{
|
|
845 |
mMenuActions[EActionAddToCollection]->setVisible(true);
|
|
846 |
mMenuActions[EActionDelete]->setVisible(true);
|
|
847 |
}
|
|
848 |
}
|
|
849 |
else if(mToolbarViewsActionGroup->checkedAction() == mToolbarActions[ETBActionCollections] &&
|
|
850 |
firstAction == mToolbarActions[ETBActionAllVideos] )
|
|
851 |
{
|
|
852 |
if (!mIsService)
|
|
853 |
{
|
|
854 |
mMenuActions[EActionNewCollection]->setVisible(true);
|
|
855 |
}
|
|
856 |
mMenuActions[EActionSortBy]->setVisible(true);
|
|
857 |
mMenuActions[EActionSortByName]->setVisible(true);
|
|
858 |
mMenuActions[EACtionSortByItemCount]->setVisible(true);
|
|
859 |
mMenuActions[EActionSortByLength]->setVisible(true);
|
|
860 |
}
|
|
861 |
else if(firstAction != mToolbarActions[ETBActionAllVideos])
|
|
862 |
{
|
|
863 |
//Add, Remove and Sort by will be launched from toolbar
|
|
864 |
if (!mIsService)
|
|
865 |
{
|
|
866 |
mMenuActions[EActionDelete]->setVisible(true);
|
|
867 |
}
|
|
868 |
}
|
|
869 |
}
|
|
870 |
|
|
871 |
// -------------------------------------------------------------------------------------------------
|
|
872 |
// handleAsyncStatusSlot
|
|
873 |
// -------------------------------------------------------------------------------------------------
|
|
874 |
//
|
|
875 |
void VideoListView::handleAsyncStatusSlot(int statusCode, QVariant &additional)
|
|
876 |
{
|
|
877 |
// in case of error concerns delete, need to reset filtering
|
|
878 |
if(statusCode == VideoCollectionCommon::statusSingleDeleteFail ||
|
|
879 |
statusCode == VideoCollectionCommon::statusMultipleDeleteFail)
|
|
880 |
{
|
|
881 |
if(mModel)
|
|
882 |
{
|
|
883 |
mModel->clear();
|
|
884 |
}
|
|
885 |
}
|
|
886 |
// show msg from status
|
|
887 |
mUiUtils.showStatusMsgSlot(statusCode, additional);
|
|
888 |
}
|
|
889 |
|
|
890 |
// -------------------------------------------------------------------------------------------------
|
|
891 |
// collectionOpenedSlot
|
|
892 |
// -------------------------------------------------------------------------------------------------
|
|
893 |
//
|
|
894 |
void VideoListView::collectionOpenedSlot(bool collectionOpened, const QString& collection)
|
|
895 |
{
|
|
896 |
if(!mToolbarCollectionActionGroup || !mToolbarViewsActionGroup || !mToolbarActions.contains(ETBActionCollections))
|
|
897 |
{
|
|
898 |
return;
|
|
899 |
}
|
|
900 |
|
|
901 |
mCollectionName = collection;
|
|
902 |
|
|
903 |
HbToolBar* bar = toolBar();
|
|
904 |
bar->clearActions();
|
|
905 |
|
|
906 |
if (collectionOpened)
|
|
907 |
{
|
|
908 |
mToolbarActions[ETBActionCollections]->setChecked(false);
|
|
909 |
bar->addActions(mToolbarCollectionActionGroup->actions());
|
|
910 |
}
|
|
911 |
else
|
|
912 |
{
|
|
913 |
bar->addActions(mToolbarViewsActionGroup->actions());
|
|
914 |
mToolbarActions[ETBActionCollections]->setChecked(true);
|
|
915 |
}
|
|
916 |
}
|
|
917 |
|
|
918 |
// -------------------------------------------------------------------------------------------------
|
|
919 |
// openSortByMenuSlot
|
|
920 |
// -------------------------------------------------------------------------------------------------
|
|
921 |
//
|
|
922 |
void VideoListView::openSortByMenuSlot()
|
|
923 |
{
|
|
924 |
if(!mModel)
|
|
925 |
{
|
|
926 |
return;
|
|
927 |
}
|
|
928 |
|
|
929 |
int menuActionCount = 0;
|
|
930 |
HbAction *action = 0;
|
|
931 |
foreach(action, mMenuActions.values())
|
|
932 |
{
|
|
933 |
if(action)
|
|
934 |
{
|
|
935 |
++menuActionCount;
|
|
936 |
action->setVisible(false);
|
|
937 |
}
|
|
938 |
}
|
|
939 |
if(menuActionCount != mMenuActions.values().count() || mMenuActions.values().count() == 0)
|
|
940 |
{
|
|
941 |
// fatal error, some action(s) was not created.
|
|
942 |
return;
|
|
943 |
}
|
|
944 |
|
|
945 |
if(!mModel->rowCount(QModelIndex()))
|
|
946 |
{
|
|
947 |
// no items, no menu
|
|
948 |
return;
|
|
949 |
}
|
|
950 |
|
|
951 |
mSortMenu->setVisible(true);
|
|
952 |
mMenuActions[EActionSortBy]->setVisible(true);
|
|
953 |
mMenuActions[EActionSortByDate]->setVisible(true);
|
|
954 |
mMenuActions[EActionSortByName]->setVisible(true);
|
|
955 |
mMenuActions[EActionSortBySize]->setVisible(true);
|
|
956 |
|
|
957 |
QPointF coords((size()/2).width(), (size()/3).height());
|
|
958 |
mSortMenu->exec(coords);
|
|
959 |
}
|
|
960 |
|
|
961 |
// Just for testing, remove this
|
|
962 |
void VideoListView::debugNotImplementedYet()
|
|
963 |
{
|
|
964 |
HbMessageBox::information(tr("Not implemented yet"));
|
|
965 |
}
|
|
966 |
|
|
967 |
// end of file
|
|
968 |
|