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