30
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 content widget implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
36
|
18 |
#include "videocollectiontrace.h"
|
30
|
19 |
#include "videolistwidget.h"
|
|
20 |
|
34
|
21 |
#include <qcoreapplication.h>
|
30
|
22 |
#include <qtimer.h>
|
|
23 |
#include <hbscrollbar.h>
|
|
24 |
#include <xqserviceutil.h>
|
|
25 |
#include <hbmenu.h>
|
|
26 |
#include <hbaction.h>
|
|
27 |
#include <hbinstance.h>
|
|
28 |
#include <hbmainwindow.h>
|
|
29 |
#include <hblistviewitem.h>
|
|
30 |
#include <hbmessagebox.h>
|
36
|
31 |
#include <hbinputdialog.h>
|
30
|
32 |
#include <vcxmyvideosdefs.h>
|
|
33 |
|
34
|
34 |
#include "videocollectionviewutils.h"
|
|
35 |
#include "videocollectionuiloader.h"
|
|
36 |
#include "videolistselectiondialog.h"
|
30
|
37 |
#include "videoservices.h"
|
|
38 |
#include "videothumbnaildata.h"
|
|
39 |
#include "videosortfilterproxymodel.h"
|
|
40 |
#include "videocollectioncommon.h"
|
|
41 |
#include "mpxhbvideocommondefs.h"
|
|
42 |
|
|
43 |
// Interval in ms to report the scroll position.
|
|
44 |
const int SCROLL_POSITION_TIMER_TIMEOUT = 100;
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// Constructor
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
34
|
50 |
VideoListWidget::VideoListWidget(VideoCollectionUiLoader *uiLoader, HbView *parent) :
|
30
|
51 |
HbListView(parent),
|
|
52 |
mModel(0),
|
|
53 |
mVideoServices(0),
|
34
|
54 |
mCurrentLevel(VideoCollectionCommon::ELevelInvalid),
|
30
|
55 |
mSignalsConnected(false),
|
|
56 |
mIsService(false),
|
36
|
57 |
mNavKeyAction(0),
|
30
|
58 |
mContextMenu(0),
|
34
|
59 |
mSelectionMode(HbAbstractItemView::NoSelection),
|
|
60 |
mScrollPositionTimer(0),
|
|
61 |
mUiLoader(uiLoader)
|
30
|
62 |
{
|
36
|
63 |
FUNC_LOG_ADDR(this);
|
30
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// Destructor
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
VideoListWidget::~VideoListWidget()
|
|
71 |
{
|
36
|
72 |
FUNC_LOG_ADDR(this);
|
30
|
73 |
delete mScrollPositionTimer;
|
|
74 |
mScrollPositionTimer = 0;
|
|
75 |
mContextMenuActions.clear();
|
|
76 |
disconnect();
|
|
77 |
delete mContextMenu;
|
|
78 |
mContextMenu = 0;
|
36
|
79 |
delete mNavKeyAction;
|
|
80 |
mNavKeyAction = 0;
|
30
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
// initialize
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
int VideoListWidget::initialize(VideoSortFilterProxyModel &model, VideoServices* videoServices)
|
|
88 |
{
|
36
|
89 |
FUNC_LOG_ADDR(this);
|
30
|
90 |
mModel = &model;
|
|
91 |
|
|
92 |
mVideoServices = videoServices;
|
|
93 |
|
|
94 |
if(mVideoServices)
|
|
95 |
{
|
|
96 |
mIsService = true;
|
|
97 |
}
|
|
98 |
|
34
|
99 |
// init list view
|
|
100 |
VideoCollectionViewUtils::initListView(this);
|
30
|
101 |
|
|
102 |
mScrollPositionTimer = new QTimer();
|
|
103 |
mScrollPositionTimer->setSingleShot(true);
|
|
104 |
|
|
105 |
if (mIsService)
|
|
106 |
{
|
|
107 |
connect(this, SIGNAL(fileUri(const QString&)), mVideoServices, SLOT(itemSelected(const QString&)));
|
|
108 |
}
|
|
109 |
|
35
|
110 |
setModel(mModel);
|
34
|
111 |
|
30
|
112 |
return 0;
|
|
113 |
}
|
|
114 |
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
// activate
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
int VideoListWidget::activate()
|
|
120 |
{
|
36
|
121 |
FUNC_LOG_ADDR(this);
|
30
|
122 |
return activate(mCurrentLevel);
|
|
123 |
}
|
|
124 |
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
// activate
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
34
|
129 |
int VideoListWidget::activate(VideoCollectionCommon::TCollectionLevels level)
|
30
|
130 |
{
|
36
|
131 |
FUNC_LOG_ADDR(this);
|
|
132 |
INFO_2("VideoListWidget::activate() [0x%x]: level: %d", this, level);
|
|
133 |
|
30
|
134 |
if(!mModel)
|
|
135 |
{
|
|
136 |
return -1;
|
|
137 |
}
|
35
|
138 |
|
30
|
139 |
mCurrentLevel = level;
|
35
|
140 |
setVisible(true);
|
30
|
141 |
|
36
|
142 |
setNavigationAction();
|
|
143 |
|
|
144 |
if (connectSignals() < 0)
|
30
|
145 |
{
|
36
|
146 |
ERROR_1(-1, "VideoListWidget::activate() [0x%x]: connecting signals failed.", this);
|
30
|
147 |
return -1;
|
|
148 |
}
|
|
149 |
|
34
|
150 |
// open model to the current level in case not in album or category
|
36
|
151 |
if (level != VideoCollectionCommon::ELevelAlbum &&
|
34
|
152 |
level != VideoCollectionCommon::ELevelDefaultColl)
|
|
153 |
{
|
|
154 |
mModel->open(level);
|
|
155 |
}
|
|
156 |
|
30
|
157 |
// Enable thumbnail background fetching.
|
|
158 |
VideoThumbnailData &thumbnailData = VideoThumbnailData::instance();
|
|
159 |
thumbnailData.enableBackgroundFetching(true);
|
34
|
160 |
thumbnailData.startBackgroundFetching(mModel, 0);
|
30
|
161 |
|
|
162 |
return 0;
|
|
163 |
}
|
|
164 |
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
// deactivate
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
void VideoListWidget::deactivate()
|
|
170 |
{
|
36
|
171 |
FUNC_LOG_ADDR(this);
|
30
|
172 |
if(mContextMenu)
|
|
173 |
{
|
|
174 |
mContextMenu->hide();
|
|
175 |
}
|
35
|
176 |
|
|
177 |
setVisible(false);
|
30
|
178 |
disConnectSignals();
|
36
|
179 |
|
30
|
180 |
// Free allocated memory for list thumbnails and disable background fetching.
|
|
181 |
VideoThumbnailData &thumbnailData = VideoThumbnailData::instance();
|
|
182 |
thumbnailData.enableBackgroundFetching(false);
|
|
183 |
thumbnailData.freeThumbnailData();
|
|
184 |
}
|
|
185 |
|
|
186 |
// ---------------------------------------------------------------------------
|
34
|
187 |
// getLevel
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
VideoCollectionCommon::TCollectionLevels VideoListWidget::getLevel()
|
|
191 |
{
|
36
|
192 |
FUNC_LOG_ADDR(this);
|
34
|
193 |
return mCurrentLevel;
|
|
194 |
}
|
|
195 |
|
|
196 |
// ---------------------------------------------------------------------------
|
30
|
197 |
// connectSignals
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
int VideoListWidget::connectSignals()
|
|
201 |
{
|
36
|
202 |
FUNC_LOG_ADDR(this);
|
|
203 |
|
|
204 |
int retval(0);
|
|
205 |
|
30
|
206 |
if (!mSignalsConnected)
|
|
207 |
{
|
34
|
208 |
if(!connect(this, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot())) ||
|
|
209 |
!connect(this, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot())) ||
|
30
|
210 |
!connect(this, SIGNAL(scrollPositionChanged(const QPointF &)),
|
|
211 |
this, SLOT(scrollPositionChangedSlot(const QPointF &))) ||
|
34
|
212 |
!connect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot())) ||
|
36
|
213 |
!connect(this, SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)),
|
|
214 |
this, SLOT(longPressedSlot(HbAbstractViewItem *, const QPointF &))))
|
30
|
215 |
{
|
|
216 |
return -1;
|
|
217 |
}
|
36
|
218 |
|
|
219 |
if (!isBrowsingService())
|
|
220 |
{
|
|
221 |
if(VideoCollectionCommon::EModelTypeCollectionContent == mModel->getType())
|
|
222 |
{
|
|
223 |
if (!connect(mNavKeyAction, SIGNAL(triggered()), this, SLOT(back())))
|
|
224 |
{
|
|
225 |
retval = -1;
|
|
226 |
}
|
|
227 |
}
|
|
228 |
else
|
|
229 |
{
|
|
230 |
if (!connect(mNavKeyAction, SIGNAL(triggered()), qApp, SLOT(quit())))
|
|
231 |
{
|
|
232 |
retval = -1;
|
|
233 |
}
|
|
234 |
}
|
|
235 |
}
|
|
236 |
|
30
|
237 |
mSignalsConnected = true;
|
|
238 |
}
|
36
|
239 |
return retval;
|
30
|
240 |
}
|
|
241 |
|
|
242 |
// ---------------------------------------------------------------------------
|
|
243 |
// disConnectSignals
|
|
244 |
// ---------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
void VideoListWidget::disConnectSignals()
|
|
247 |
{
|
36
|
248 |
FUNC_LOG_ADDR(this);
|
|
249 |
|
|
250 |
// safe to disconnect these always
|
|
251 |
disconnect(
|
|
252 |
this, SIGNAL(scrollingStarted()),
|
|
253 |
this, SLOT(scrollingStartedSlot()));
|
|
254 |
disconnect(
|
|
255 |
this, SIGNAL(scrollingEnded()),
|
|
256 |
this, SLOT(scrollingEndedSlot()));
|
|
257 |
disconnect(
|
|
258 |
this, SIGNAL(scrollPositionChanged(const QPointF&)),
|
|
259 |
this, SLOT(scrollPositionChangedSlot(const QPointF&)));
|
|
260 |
disconnect(this, SIGNAL(longPressed(HbAbstractViewItem *, const QPointF &)),
|
|
261 |
this, SLOT(longPressedSlot(HbAbstractViewItem *, const QPointF &)));
|
|
262 |
|
|
263 |
// check that scroll position timer is created
|
|
264 |
if (mScrollPositionTimer)
|
|
265 |
{
|
|
266 |
disconnect(
|
|
267 |
mScrollPositionTimer, SIGNAL(timeout()),
|
|
268 |
this, SLOT(scrollPositionTimerSlot()));
|
|
269 |
}
|
|
270 |
|
|
271 |
// check that model and navigation action exists
|
|
272 |
if (!isBrowsingService())
|
|
273 |
{
|
|
274 |
if (mModel &&
|
|
275 |
mModel->getType() == VideoCollectionCommon::EModelTypeCollectionContent)
|
|
276 |
{
|
|
277 |
if (mNavKeyAction)
|
|
278 |
{
|
|
279 |
disconnect(
|
|
280 |
mNavKeyAction, SIGNAL(triggered()),
|
|
281 |
this, SLOT(back()));
|
|
282 |
}
|
|
283 |
}
|
|
284 |
else
|
|
285 |
{
|
|
286 |
if (mNavKeyAction)
|
|
287 |
{
|
|
288 |
disconnect(
|
|
289 |
mNavKeyAction, SIGNAL(triggered()),
|
|
290 |
qApp, SLOT(quit()));
|
|
291 |
}
|
|
292 |
}
|
|
293 |
}
|
34
|
294 |
|
30
|
295 |
mSignalsConnected = false;
|
|
296 |
}
|
|
297 |
|
|
298 |
// ---------------------------------------------------------------------------
|
36
|
299 |
// isBrowsingService
|
|
300 |
// ---------------------------------------------------------------------------
|
|
301 |
//
|
|
302 |
bool VideoListWidget::isBrowsingService() const
|
|
303 |
{
|
|
304 |
FUNC_LOG_ADDR(this);
|
|
305 |
|
|
306 |
bool isBrowsingService = false;
|
|
307 |
|
|
308 |
if (mIsService &&
|
|
309 |
mVideoServices &&
|
|
310 |
mVideoServices->currentService() == VideoServices::EBrowse)
|
|
311 |
{
|
|
312 |
isBrowsingService = true;
|
|
313 |
}
|
|
314 |
|
|
315 |
return isBrowsingService;
|
|
316 |
|
|
317 |
}
|
|
318 |
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
// setNavigationAction
|
|
321 |
// ---------------------------------------------------------------------------
|
|
322 |
//
|
|
323 |
void VideoListWidget::setNavigationAction()
|
|
324 |
{
|
|
325 |
FUNC_LOG_ADDR(this);
|
|
326 |
|
|
327 |
// Create navigation action if not already created
|
|
328 |
if (!mNavKeyAction)
|
|
329 |
{
|
|
330 |
if (isBrowsingService())
|
|
331 |
{
|
|
332 |
mNavKeyAction = new HbAction(Hb::QuitNaviAction);
|
|
333 |
if (mNavKeyAction)
|
|
334 |
{
|
|
335 |
connect(
|
|
336 |
mNavKeyAction, SIGNAL(triggered()),
|
|
337 |
mVideoServices, SLOT(browsingEnded()));
|
|
338 |
}
|
|
339 |
}
|
|
340 |
else if (mModel)
|
|
341 |
{
|
|
342 |
if (VideoCollectionCommon::EModelTypeCollectionContent == mModel->getType())
|
|
343 |
{
|
|
344 |
mNavKeyAction = new HbAction(Hb::BackNaviAction);
|
|
345 |
}
|
|
346 |
else
|
|
347 |
{
|
|
348 |
mNavKeyAction = new HbAction(Hb::QuitNaviAction);
|
|
349 |
}
|
|
350 |
}
|
|
351 |
}
|
|
352 |
|
|
353 |
// Set navigation action only when widget is not in selection mode
|
|
354 |
if (mSelectionMode == HbAbstractItemView::NoSelection)
|
|
355 |
{
|
|
356 |
HbView *currentView = hbInstance->allMainWindows().value(0)->currentView();
|
|
357 |
if (currentView)
|
|
358 |
{
|
|
359 |
currentView->setNavigationAction(mNavKeyAction);
|
|
360 |
}
|
|
361 |
}
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------------------------
|
30
|
365 |
// deleteItemSlot
|
|
366 |
// ---------------------------------------------------------------------------
|
|
367 |
//
|
|
368 |
void VideoListWidget::deleteItemSlot()
|
|
369 |
{
|
36
|
370 |
FUNC_LOG_ADDR(this);
|
30
|
371 |
if(!mModel)
|
|
372 |
{
|
|
373 |
return;
|
|
374 |
}
|
|
375 |
|
|
376 |
QVariant variant;
|
|
377 |
QModelIndex index = currentIndex();
|
36
|
378 |
variant = mModel->data(index, VideoCollectionCommon::KeyTitle);
|
30
|
379 |
|
|
380 |
if (variant.isValid())
|
|
381 |
{
|
35
|
382 |
QString text = hbTrId("txt_videos_info_do_you_want_to_delete_1").arg(
|
36
|
383 |
variant.toString());
|
37
|
384 |
|
|
385 |
HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
|
|
386 |
messageBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
387 |
messageBox->open(this, SLOT(deleteItemDialogFinished(HbAction *)));
|
|
388 |
}
|
|
389 |
}
|
|
390 |
|
|
391 |
// ---------------------------------------------------------------------------
|
|
392 |
// deleteItemDialogFinished
|
|
393 |
// ---------------------------------------------------------------------------
|
|
394 |
//
|
|
395 |
void VideoListWidget::deleteItemDialogFinished(HbAction *action)
|
|
396 |
{
|
|
397 |
HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
|
|
398 |
if(action == dlg->actions().at(0))
|
|
399 |
{
|
|
400 |
QModelIndex index = currentIndex();
|
|
401 |
if(index.isValid())
|
30
|
402 |
{
|
|
403 |
QModelIndexList list;
|
|
404 |
list.append(index);
|
|
405 |
mModel->deleteItems(list);
|
|
406 |
}
|
|
407 |
}
|
|
408 |
}
|
|
409 |
|
|
410 |
// ---------------------------------------------------------------------------
|
|
411 |
// createContextMenu
|
|
412 |
// ---------------------------------------------------------------------------
|
|
413 |
//
|
|
414 |
void VideoListWidget::createContextMenu()
|
|
415 |
{
|
36
|
416 |
FUNC_LOG_ADDR(this);
|
30
|
417 |
if(mContextMenu)
|
|
418 |
{
|
|
419 |
return;
|
|
420 |
}
|
35
|
421 |
|
30
|
422 |
mContextMenu = new HbMenu();
|
35
|
423 |
if (mContextMenu)
|
30
|
424 |
{
|
35
|
425 |
mContextMenu->setDismissPolicy(HbPopup::TapAnywhere);
|
36
|
426 |
|
|
427 |
VideoServices::TVideoService service = VideoServices::ENoService;
|
|
428 |
if (mIsService &&
|
|
429 |
mVideoServices)
|
|
430 |
{
|
|
431 |
service = mVideoServices->currentService();
|
|
432 |
}
|
|
433 |
|
|
434 |
if (service == VideoServices::EUriFetcher)
|
35
|
435 |
{
|
37
|
436 |
mContextMenuActions[EActionAttach] =
|
|
437 |
mContextMenu->addAction(hbTrId("txt_videos_menu_attach"), this, SLOT(openItemSlot()));
|
35
|
438 |
mContextMenuActions[EActionPlay] =
|
37
|
439 |
mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot()));
|
36
|
440 |
mContextMenuActions[EActionDetails] =
|
|
441 |
mContextMenu->addAction(hbTrId("txt_common_menu_details"), this, SLOT(openDetailsSlot()));
|
|
442 |
}
|
|
443 |
else if (service == VideoServices::EBrowse)
|
|
444 |
{
|
|
445 |
mContextMenuActions[EActionPlay] =
|
37
|
446 |
mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot()));
|
36
|
447 |
mContextMenuActions[EActionDelete] =
|
|
448 |
mContextMenu->addAction(hbTrId("txt_common_menu_delete"), this, SLOT(deleteItemSlot()));
|
35
|
449 |
mContextMenuActions[EActionDetails] =
|
|
450 |
mContextMenu->addAction(hbTrId("txt_common_menu_details"), this, SLOT(openDetailsSlot()));
|
|
451 |
}
|
|
452 |
else
|
|
453 |
{
|
36
|
454 |
mContextMenuActions[EActionPlay] =
|
37
|
455 |
mContextMenu->addAction(hbTrId("txt_videos_menu_play"), this, SLOT(playItemSlot()));
|
36
|
456 |
mContextMenuActions[EActionOpen] =
|
|
457 |
mContextMenu->addAction(hbTrId("txt_common_menu_open"), this, SLOT(openItemSlot()));
|
35
|
458 |
mContextMenuActions[EActionAddToCollection] =
|
|
459 |
mContextMenu->addAction(hbTrId("txt_videos_menu_add_to_collection"), this, SLOT(addToCollectionSlot()));
|
|
460 |
mContextMenuActions[EActionRemove] =
|
|
461 |
mContextMenu->addAction(hbTrId("txt_videos_menu_remove_from_collection"), this, SLOT(removeFromCollectionSlot()));
|
|
462 |
mContextMenuActions[EActionRename] =
|
|
463 |
mContextMenu->addAction(hbTrId("txt_common_menu_rename_item"), this, SLOT(renameSlot()));
|
|
464 |
mContextMenuActions[EActionRemoveCollection] =
|
|
465 |
mContextMenu->addAction(hbTrId("txt_videos_menu_remove_collection"), this, SLOT(removeCollectionSlot()));
|
|
466 |
mContextMenuActions[EActionDelete] =
|
|
467 |
mContextMenu->addAction(hbTrId("txt_common_menu_delete"), this, SLOT(deleteItemSlot()));
|
|
468 |
mContextMenuActions[EActionDetails] =
|
|
469 |
mContextMenu->addAction(hbTrId("txt_common_menu_details"), this, SLOT(openDetailsSlot()));
|
|
470 |
}
|
30
|
471 |
}
|
|
472 |
}
|
|
473 |
|
|
474 |
// -------------------------------------------------------------------------------------------------
|
|
475 |
// setContextMenu
|
|
476 |
// -------------------------------------------------------------------------------------------------
|
|
477 |
//
|
34
|
478 |
void VideoListWidget::setContextMenu()
|
30
|
479 |
{
|
36
|
480 |
FUNC_LOG_ADDR(this);
|
30
|
481 |
if(!mContextMenu)
|
|
482 |
{
|
|
483 |
createContextMenu();
|
|
484 |
}
|
35
|
485 |
|
|
486 |
if (!mContextMenu)
|
|
487 |
{
|
36
|
488 |
ERROR_1(-1, "VideoListWidget::setContextMenu() [0x%x]: failed to create context menu.", this);
|
35
|
489 |
return;
|
|
490 |
}
|
|
491 |
|
30
|
492 |
int menuActionCount = 0;
|
|
493 |
HbAction *action = 0;
|
|
494 |
foreach(action, mContextMenuActions.values())
|
|
495 |
{
|
|
496 |
if(action)
|
|
497 |
{
|
|
498 |
++menuActionCount;
|
|
499 |
action->setVisible(false);
|
|
500 |
}
|
|
501 |
}
|
|
502 |
if(menuActionCount != mContextMenuActions.values().count() || mContextMenuActions.values().count() == 0)
|
|
503 |
{
|
36
|
504 |
ERROR_1(-1, "VideoListWidget::setContextMenu() [0x%x]: all actions have not been created.", this);
|
30
|
505 |
delete mContextMenu;
|
|
506 |
mContextMenu = 0;
|
|
507 |
mContextMenuActions.clear();
|
|
508 |
return;
|
|
509 |
}
|
|
510 |
|
36
|
511 |
if (isBrowsingService())
|
|
512 |
{
|
|
513 |
setBrowsingServiceContextMenu();
|
|
514 |
return;
|
|
515 |
}
|
|
516 |
|
30
|
517 |
|
34
|
518 |
if(mCurrentLevel == VideoCollectionCommon::ELevelVideos ||
|
|
519 |
mCurrentLevel == VideoCollectionCommon::ELevelDefaultColl)
|
36
|
520 |
{
|
30
|
521 |
if (!mIsService)
|
|
522 |
{
|
35
|
523 |
mContextMenuActions[EActionAddToCollection]->setVisible(true);
|
30
|
524 |
mContextMenuActions[EActionDelete]->setVisible(true);
|
37
|
525 |
} else {
|
|
526 |
mContextMenuActions[EActionAttach]->setVisible(true);
|
30
|
527 |
}
|
36
|
528 |
mContextMenuActions[EActionPlay]->setVisible(true);
|
30
|
529 |
mContextMenuActions[EActionDetails]->setVisible(true);
|
|
530 |
}
|
34
|
531 |
else if(mCurrentLevel == VideoCollectionCommon::ELevelCategory)
|
30
|
532 |
{
|
36
|
533 |
mContextMenuActions[EActionOpen]->setVisible(true);
|
|
534 |
TMPXItemId mpxId = mModel->getMediaIdAtIndex(currentIndex());
|
|
535 |
if(!mIsService && mpxId.iId2 == KVcxMvcMediaTypeAlbum)
|
30
|
536 |
{
|
|
537 |
mContextMenuActions[EActionRename]->setVisible(true);
|
35
|
538 |
mContextMenuActions[EActionRemoveCollection]->setVisible(true);
|
30
|
539 |
}
|
|
540 |
}
|
34
|
541 |
else if(mCurrentLevel == VideoCollectionCommon::ELevelAlbum)
|
30
|
542 |
{
|
|
543 |
if (!mIsService)
|
|
544 |
{
|
35
|
545 |
mContextMenuActions[EActionRemove]->setVisible(true);
|
30
|
546 |
mContextMenuActions[EActionDelete]->setVisible(true);
|
37
|
547 |
} else {
|
|
548 |
mContextMenuActions[EActionAttach]->setVisible(true);
|
|
549 |
}
|
36
|
550 |
mContextMenuActions[EActionPlay]->setVisible(true);
|
30
|
551 |
mContextMenuActions[EActionDetails]->setVisible(true);
|
|
552 |
}
|
|
553 |
}
|
|
554 |
|
36
|
555 |
// ---------------------------------------------------------------------------
|
|
556 |
// setBrowsingServiceContextMenu
|
|
557 |
// ---------------------------------------------------------------------------
|
|
558 |
//
|
|
559 |
void VideoListWidget::setBrowsingServiceContextMenu()
|
|
560 |
{
|
|
561 |
FUNC_LOG_ADDR(this);
|
|
562 |
mContextMenuActions[EActionPlay]->setVisible(true);
|
|
563 |
mContextMenuActions[EActionDelete]->setVisible(true);
|
|
564 |
mContextMenuActions[EActionDetails]->setVisible(true);
|
|
565 |
}
|
30
|
566 |
|
|
567 |
// ---------------------------------------------------------------------------
|
|
568 |
// getModel
|
|
569 |
// ---------------------------------------------------------------------------
|
|
570 |
//
|
|
571 |
VideoSortFilterProxyModel& VideoListWidget::getModel()
|
|
572 |
{
|
36
|
573 |
FUNC_LOG_ADDR(this);
|
30
|
574 |
return *mModel;
|
|
575 |
}
|
|
576 |
|
|
577 |
// ---------------------------------------------------------------------------
|
|
578 |
// emitActivated
|
|
579 |
// This slot is called by the fw when viewitem is activated
|
|
580 |
// ---------------------------------------------------------------------------
|
|
581 |
//
|
|
582 |
void VideoListWidget::emitActivated (const QModelIndex &modelIndex)
|
|
583 |
{
|
36
|
584 |
FUNC_LOG_ADDR(this);
|
|
585 |
// surprisingly interesting feature: after long press also single press
|
35
|
586 |
// is executed. as a workaround the following hack check is needed.
|
|
587 |
// otherwise after the context menu is shown also single press action
|
|
588 |
// is executed.
|
|
589 |
if (mContextMenu &&
|
|
590 |
mContextMenu->isVisible())
|
|
591 |
{
|
|
592 |
// do not activate context menu if it is already visible
|
|
593 |
return;
|
|
594 |
}
|
34
|
595 |
if(mSelectionMode != HbAbstractItemView::NoSelection)
|
30
|
596 |
{
|
34
|
597 |
// no custom functionality defined
|
|
598 |
emit activated(modelIndex);
|
|
599 |
return;
|
30
|
600 |
}
|
37
|
601 |
doEmitActivated(modelIndex);
|
|
602 |
}
|
|
603 |
|
|
604 |
// ---------------------------------------------------------------------------
|
|
605 |
// doEmitActivated
|
|
606 |
// ---------------------------------------------------------------------------
|
|
607 |
//
|
|
608 |
void VideoListWidget::doEmitActivated (const QModelIndex &index)
|
|
609 |
{
|
36
|
610 |
if(mIsService &&
|
|
611 |
mVideoServices &&
|
|
612 |
mVideoServices->currentService() == VideoServices::EUriFetcher &&
|
|
613 |
mCurrentLevel != VideoCollectionCommon::ELevelCategory)
|
|
614 |
{
|
37
|
615 |
QVariant variant = mModel->data(index, VideoCollectionCommon::KeyFilePath);
|
36
|
616 |
if ( variant.isValid() )
|
|
617 |
{
|
|
618 |
QString itemPath = variant.value<QString>();
|
|
619 |
emit(fileUri(itemPath));
|
|
620 |
}
|
|
621 |
}
|
|
622 |
else
|
|
623 |
{
|
37
|
624 |
doActivateItem(index);
|
36
|
625 |
}
|
|
626 |
}
|
30
|
627 |
|
36
|
628 |
// ---------------------------------------------------------------------------
|
|
629 |
// doActivateItem
|
|
630 |
// ---------------------------------------------------------------------------
|
|
631 |
//
|
|
632 |
void VideoListWidget::doActivateItem(const QModelIndex &index)
|
|
633 |
{
|
|
634 |
FUNC_LOG_ADDR(this);
|
|
635 |
if (!mModel || !index.isValid())
|
30
|
636 |
{
|
|
637 |
return;
|
|
638 |
}
|
34
|
639 |
|
|
640 |
if (mCurrentLevel == VideoCollectionCommon::ELevelCategory)
|
30
|
641 |
{
|
36
|
642 |
QVariant variant = mModel->data(index, VideoCollectionCommon::KeyTitle);
|
34
|
643 |
if (variant.isValid())
|
30
|
644 |
{
|
34
|
645 |
// signal view that item has been activated
|
|
646 |
emit(collectionOpened(true,
|
36
|
647 |
variant.toString(),
|
|
648 |
index));
|
30
|
649 |
}
|
35
|
650 |
return;
|
30
|
651 |
}
|
|
652 |
else
|
|
653 |
{
|
36
|
654 |
mModel->openItem(mModel->getMediaIdAtIndex(index));
|
30
|
655 |
}
|
|
656 |
}
|
|
657 |
|
|
658 |
// ---------------------------------------------------------------------------
|
34
|
659 |
// setSelectionMode
|
|
660 |
// called by the fw when user long presses some item
|
|
661 |
// ---------------------------------------------------------------------------
|
|
662 |
//
|
|
663 |
void VideoListWidget::setSelectionMode(int mode)
|
|
664 |
{
|
36
|
665 |
FUNC_LOG_ADDR(this);
|
34
|
666 |
HbAbstractItemView::SelectionMode selMode = HbAbstractItemView::NoSelection;
|
37
|
667 |
if(mode >= HbAbstractItemView::NoSelection && mode <= HbAbstractItemView::MultiSelection)
|
34
|
668 |
{
|
|
669 |
selMode = HbAbstractItemView::SelectionMode(mode);
|
|
670 |
}
|
|
671 |
|
|
672 |
HbListView::setSelectionMode(selMode);
|
|
673 |
mSelectionMode = mode;
|
|
674 |
}
|
|
675 |
|
|
676 |
// ---------------------------------------------------------------------------
|
36
|
677 |
// longPressedSlot
|
30
|
678 |
// called by the fw when user long presses some item
|
|
679 |
// ---------------------------------------------------------------------------
|
|
680 |
//
|
36
|
681 |
void VideoListWidget::longPressedSlot(HbAbstractViewItem *item, const QPointF &point)
|
30
|
682 |
{
|
36
|
683 |
FUNC_LOG_ADDR(this);
|
34
|
684 |
if(mSelectionMode != HbAbstractItemView::NoSelection)
|
30
|
685 |
{
|
|
686 |
// do not activate context menu during selection mode
|
|
687 |
return;
|
|
688 |
}
|
|
689 |
|
36
|
690 |
if(item)
|
35
|
691 |
{
|
36
|
692 |
QModelIndex index = item->modelIndex();
|
35
|
693 |
if(mModel && index.isValid())
|
36
|
694 |
{
|
|
695 |
setContextMenu();
|
|
696 |
// if menu not yet exists, it has been created
|
|
697 |
// setup might fail causing menu to be removed
|
|
698 |
if(mContextMenu)
|
34
|
699 |
{
|
36
|
700 |
mContextMenu->setPreferredPos(point);
|
|
701 |
mContextMenu->show();
|
34
|
702 |
}
|
35
|
703 |
}
|
30
|
704 |
}
|
36
|
705 |
}
|
|
706 |
|
|
707 |
// ---------------------------------------------------------------------------
|
|
708 |
// panGesture
|
|
709 |
// ---------------------------------------------------------------------------
|
|
710 |
//
|
|
711 |
void VideoListWidget::panGesture(const QPointF &point)
|
|
712 |
{
|
|
713 |
FUNC_LOG_ADDR(this);
|
|
714 |
if (mContextMenu)
|
|
715 |
{
|
|
716 |
if (!mContextMenu->isVisible())
|
|
717 |
{
|
|
718 |
HbListView::panGesture(point);
|
|
719 |
}
|
|
720 |
}
|
|
721 |
else
|
|
722 |
{
|
|
723 |
HbListView::panGesture(point);
|
|
724 |
}
|
30
|
725 |
}
|
|
726 |
|
|
727 |
// ---------------------------------------------------------------------------
|
35
|
728 |
// doDelayedsSlot
|
|
729 |
// ---------------------------------------------------------------------------
|
|
730 |
//
|
|
731 |
void VideoListWidget::doDelayedsSlot()
|
|
732 |
{
|
36
|
733 |
FUNC_LOG_ADDR(this);
|
35
|
734 |
if (!mContextMenu)
|
|
735 |
{
|
|
736 |
createContextMenu();
|
|
737 |
}
|
|
738 |
}
|
|
739 |
|
|
740 |
// ---------------------------------------------------------------------------
|
37
|
741 |
// openItemSlot
|
|
742 |
// ---------------------------------------------------------------------------
|
|
743 |
//
|
|
744 |
void VideoListWidget::openItemSlot()
|
|
745 |
{
|
|
746 |
FUNC_LOG_ADDR(this);
|
|
747 |
doEmitActivated(currentIndex());
|
|
748 |
}
|
|
749 |
|
|
750 |
// ---------------------------------------------------------------------------
|
30
|
751 |
// playItemSlot
|
|
752 |
// ---------------------------------------------------------------------------
|
|
753 |
//
|
37
|
754 |
void VideoListWidget::playItemSlot()
|
30
|
755 |
{
|
36
|
756 |
FUNC_LOG_ADDR(this);
|
|
757 |
doActivateItem(currentIndex());
|
30
|
758 |
}
|
|
759 |
|
|
760 |
// ---------------------------------------------------------------------------
|
|
761 |
// openDetailsSlot
|
|
762 |
// ---------------------------------------------------------------------------
|
|
763 |
//
|
|
764 |
void VideoListWidget::openDetailsSlot()
|
|
765 |
{
|
36
|
766 |
FUNC_LOG_ADDR(this);
|
30
|
767 |
if(mModel && mModel->fetchItemDetails(currentIndex()) == 0 )
|
|
768 |
{
|
|
769 |
emit command(MpxHbVideoCommon::ActivateVideoDetailsView);
|
|
770 |
}
|
|
771 |
}
|
34
|
772 |
|
30
|
773 |
// ---------------------------------------------------------------------------
|
|
774 |
// renameSlot
|
|
775 |
// ---------------------------------------------------------------------------
|
|
776 |
//
|
|
777 |
void VideoListWidget::renameSlot()
|
|
778 |
{
|
36
|
779 |
FUNC_LOG_ADDR(this);
|
|
780 |
if(!mModel)
|
|
781 |
{
|
|
782 |
return;
|
|
783 |
}
|
|
784 |
|
|
785 |
QModelIndex index = currentIndex();
|
|
786 |
QVariant variant = mModel->data(index, VideoCollectionCommon::KeyTitle);
|
|
787 |
TMPXItemId itemId = mModel->getMediaIdAtIndex(index);
|
|
788 |
|
|
789 |
if(variant.isValid() && itemId.iId2 == KVcxMvcMediaTypeAlbum)
|
|
790 |
{
|
|
791 |
QString label(hbTrId("txt_videos_title_enter_name"));
|
|
792 |
QString albumName = variant.toString();
|
37
|
793 |
|
|
794 |
HbInputDialog *dialog = new HbInputDialog();
|
|
795 |
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
796 |
dialog->getText(label, this, SLOT(renameDialogFinished(HbAction *)), albumName);
|
|
797 |
}
|
|
798 |
}
|
|
799 |
|
|
800 |
// -------------------------------------------------------------------------------------------------
|
|
801 |
// renameDialogFinished
|
|
802 |
// -------------------------------------------------------------------------------------------------
|
|
803 |
//
|
|
804 |
void VideoListWidget::renameDialogFinished(HbAction *action)
|
|
805 |
{
|
|
806 |
Q_UNUSED(action);
|
36
|
807 |
|
37
|
808 |
HbInputDialog *dialog = static_cast<HbInputDialog*>(sender());
|
|
809 |
|
|
810 |
QModelIndex index = currentIndex();
|
|
811 |
TMPXItemId itemId = mModel->getMediaIdAtIndex(index);
|
|
812 |
QVariant newNameVariant = dialog->value();
|
|
813 |
QVariant oldNameVariant = mModel->data(index, VideoCollectionCommon::KeyTitle);
|
|
814 |
|
|
815 |
if(dialog->actions().first() == action &&
|
|
816 |
oldNameVariant.isValid() && newNameVariant.isValid() && itemId.iId2 == KVcxMvcMediaTypeAlbum)
|
|
817 |
{
|
|
818 |
QString newAlbumName = newNameVariant.toString();
|
|
819 |
QString oldAlbumName = oldNameVariant.toString();
|
|
820 |
|
|
821 |
if(newAlbumName.length() && newAlbumName.trimmed() != oldAlbumName)
|
36
|
822 |
{
|
|
823 |
// Resolve collection true name and rename the album
|
|
824 |
newAlbumName = mModel->resolveAlbumName(newAlbumName);
|
|
825 |
mModel->renameAlbum(itemId, newAlbumName);
|
|
826 |
}
|
|
827 |
}
|
30
|
828 |
}
|
|
829 |
// ---------------------------------------------------------------------------
|
|
830 |
// addToCollectionSlot
|
|
831 |
// ---------------------------------------------------------------------------
|
|
832 |
//
|
|
833 |
void VideoListWidget::addToCollectionSlot()
|
|
834 |
{
|
36
|
835 |
FUNC_LOG_ADDR(this);
|
34
|
836 |
VideoListSelectionDialog *dialog =
|
|
837 |
mUiLoader->findWidget<VideoListSelectionDialog>(
|
|
838 |
DOCML_NAME_DIALOG);
|
|
839 |
if (!dialog || !mModel)
|
|
840 |
{
|
36
|
841 |
ERROR_1(-1, "VideoListWidget::addToCollectionSlot() [0x%x]: failed to get selection dialog or model is null.", this);
|
34
|
842 |
return;
|
|
843 |
}
|
|
844 |
TMPXItemId itemId = mModel->getMediaIdAtIndex(currentIndex());
|
|
845 |
if(itemId != TMPXItemId::InvalidId())
|
|
846 |
{
|
|
847 |
dialog->setupContent(VideoListSelectionDialog::ESelectCollection, itemId);
|
|
848 |
dialog->exec();
|
|
849 |
}
|
30
|
850 |
}
|
|
851 |
|
34
|
852 |
// ---------------------------------------------------------------------------
|
35
|
853 |
// removeFromCollectionSlot
|
|
854 |
// ---------------------------------------------------------------------------
|
|
855 |
//
|
|
856 |
void VideoListWidget::removeFromCollectionSlot()
|
|
857 |
{
|
36
|
858 |
FUNC_LOG_ADDR(this);
|
35
|
859 |
if(!mModel)
|
|
860 |
{
|
|
861 |
return;
|
|
862 |
}
|
|
863 |
TMPXItemId collectionId = mModel->getOpenItem();
|
|
864 |
TMPXItemId itemId = mModel->getMediaIdAtIndex(currentIndex());
|
|
865 |
if(collectionId != TMPXItemId::InvalidId() &&
|
|
866 |
itemId != TMPXItemId::InvalidId())
|
|
867 |
{
|
|
868 |
QList<TMPXItemId> ids;
|
|
869 |
ids.append(itemId);
|
|
870 |
mModel->removeItemsFromAlbum(collectionId, ids);
|
|
871 |
}
|
|
872 |
}
|
|
873 |
|
|
874 |
// ---------------------------------------------------------------------------
|
34
|
875 |
// removeCollectionSlot
|
|
876 |
// ---------------------------------------------------------------------------
|
|
877 |
//
|
|
878 |
void VideoListWidget::removeCollectionSlot()
|
|
879 |
{
|
36
|
880 |
FUNC_LOG_ADDR(this);
|
34
|
881 |
if(!mModel)
|
|
882 |
{
|
|
883 |
return;
|
|
884 |
}
|
|
885 |
|
|
886 |
QVariant variant;
|
|
887 |
QModelIndex index = currentIndex();
|
36
|
888 |
variant = mModel->data(index, VideoCollectionCommon::KeyTitle);
|
34
|
889 |
|
|
890 |
if (variant.isValid())
|
|
891 |
{
|
36
|
892 |
QString text = hbTrId("txt_videos_info_do_you_want_to_remove_collection").arg(
|
|
893 |
variant.toString());
|
37
|
894 |
HbMessageBox *messageBox = new HbMessageBox(text, HbMessageBox::MessageTypeQuestion);
|
|
895 |
messageBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
896 |
messageBox->open(this, SLOT(removeCollectionDialogFinished(HbAction *)));
|
|
897 |
}
|
|
898 |
}
|
|
899 |
|
|
900 |
// ---------------------------------------------------------------------------
|
|
901 |
// removeCollectionDialogFinished
|
|
902 |
// ---------------------------------------------------------------------------
|
|
903 |
//
|
|
904 |
void VideoListWidget::removeCollectionDialogFinished(HbAction *action)
|
|
905 |
{
|
|
906 |
HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
|
|
907 |
if(action == dlg->actions().at(0))
|
|
908 |
{
|
|
909 |
QModelIndex index = currentIndex();
|
|
910 |
if(index.isValid())
|
34
|
911 |
{
|
|
912 |
QModelIndexList list;
|
|
913 |
list.append(index);
|
37
|
914 |
mModel->removeAlbums(list);
|
34
|
915 |
}
|
|
916 |
}
|
|
917 |
}
|
30
|
918 |
|
|
919 |
// ---------------------------------------------------------------------------
|
|
920 |
// back
|
|
921 |
// ---------------------------------------------------------------------------
|
|
922 |
//
|
|
923 |
void VideoListWidget::back()
|
|
924 |
{
|
36
|
925 |
FUNC_LOG_ADDR(this);
|
|
926 |
|
30
|
927 |
if(mModel)
|
|
928 |
{
|
36
|
929 |
// Empty the proxy model causing the items to be removed from list widget.
|
|
930 |
mModel->setAlbumInUse(TMPXItemId::InvalidId());
|
|
931 |
emit collectionOpened(false, QString(), QModelIndex());
|
30
|
932 |
}
|
|
933 |
}
|
|
934 |
|
|
935 |
// ---------------------------------------------------------------------------
|
34
|
936 |
// scrollingStartedSlot
|
|
937 |
// ---------------------------------------------------------------------------
|
|
938 |
//
|
|
939 |
void VideoListWidget::scrollingStartedSlot()
|
|
940 |
{
|
36
|
941 |
FUNC_LOG_ADDR(this);
|
34
|
942 |
VideoThumbnailData::instance().enableThumbnailCreation(false);
|
|
943 |
}
|
|
944 |
|
|
945 |
// ---------------------------------------------------------------------------
|
30
|
946 |
// scrollingEndedSlot
|
|
947 |
// ---------------------------------------------------------------------------
|
|
948 |
//
|
|
949 |
void VideoListWidget::scrollingEndedSlot()
|
|
950 |
{
|
36
|
951 |
FUNC_LOG_ADDR(this);
|
30
|
952 |
if(mScrollPositionTimer)
|
36
|
953 |
{
|
|
954 |
mScrollPositionTimer->stop();
|
|
955 |
}
|
34
|
956 |
VideoThumbnailData::instance().enableThumbnailCreation(true);
|
|
957 |
fetchThumbnailsForVisibleItems();
|
30
|
958 |
}
|
|
959 |
|
|
960 |
// ---------------------------------------------------------------------------
|
|
961 |
// scrollPositionChangedSlot
|
|
962 |
// ---------------------------------------------------------------------------
|
|
963 |
//
|
|
964 |
void VideoListWidget::scrollPositionChangedSlot(const QPointF &newPosition)
|
|
965 |
{
|
|
966 |
Q_UNUSED(newPosition);
|
|
967 |
if(mScrollPositionTimer && !mScrollPositionTimer->isActive())
|
|
968 |
mScrollPositionTimer->start(SCROLL_POSITION_TIMER_TIMEOUT);
|
|
969 |
}
|
|
970 |
|
|
971 |
// ---------------------------------------------------------------------------
|
34
|
972 |
// scrollPositionTimerSlot
|
|
973 |
// ---------------------------------------------------------------------------
|
|
974 |
//
|
|
975 |
void VideoListWidget::scrollPositionTimerSlot()
|
|
976 |
{
|
36
|
977 |
FUNC_LOG_ADDR(this);
|
34
|
978 |
fetchThumbnailsForVisibleItems();
|
|
979 |
}
|
|
980 |
|
|
981 |
// ---------------------------------------------------------------------------
|
|
982 |
// fetchThumbnailsForVisibleItems
|
|
983 |
// ---------------------------------------------------------------------------
|
|
984 |
//
|
|
985 |
void VideoListWidget::fetchThumbnailsForVisibleItems()
|
|
986 |
{
|
36
|
987 |
FUNC_LOG_ADDR(this);
|
34
|
988 |
const QList<HbAbstractViewItem *> itemsVisible = visibleItems();
|
|
989 |
|
|
990 |
if(itemsVisible.count() > 0)
|
|
991 |
{
|
|
992 |
int row = itemsVisible.value(0)->modelIndex().row();
|
|
993 |
VideoThumbnailData::instance().startBackgroundFetching(mModel, row);
|
|
994 |
}
|
|
995 |
}
|
|
996 |
|
30
|
997 |
// end of file
|