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