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 selection dialog implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
67
|
18 |
// Version : %version: 30.1.7 %
|
36
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <qgraphicsitem.h>
|
67
|
22 |
#include <qtimer.h>
|
|
23 |
|
|
24 |
#include <vcxmyvideosdefs.h>
|
|
25 |
|
30
|
26 |
#include <hbaction.h>
|
34
|
27 |
#include <hbabstractitemview.h>
|
|
28 |
#include <hbinputdialog.h>
|
67
|
29 |
#include <hbwidget.h>
|
|
30 |
#include <hblistview.h>
|
|
31 |
#include <hblistviewitem.h>
|
34
|
32 |
|
58
|
33 |
#include "videoproxymodelgeneric.h"
|
30
|
34 |
#include "videolistselectiondialog.h"
|
34
|
35 |
#include "videocollectionwrapper.h"
|
|
36 |
#include "videocollectionviewutils.h"
|
|
37 |
#include "videocollectionclient.h"
|
36
|
38 |
#include "videocollectiontrace.h"
|
67
|
39 |
#include "videothumbnaildata.h"
|
34
|
40 |
|
38
|
41 |
// Object names.
|
|
42 |
const char* const SELECTION_DIALOG_OBJECT_NAME_NEW_COLLECTION = "vc:SelectionDialogNewCollection";
|
40
|
43 |
const char* const LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION = "vc::ListViewInputDialogCreateCollection";
|
38
|
44 |
const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK = "vc:SelectionDialogButtonOk";
|
|
45 |
const char* const SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL = "vc:SelectionDialogButtonCancel";
|
|
46 |
|
67
|
47 |
// Interval in ms to report the scroll position.
|
|
48 |
const int SCROLL_POSITION_TIMER_TIMEOUT = 100;
|
|
49 |
|
34
|
50 |
/**
|
|
51 |
* global qHash function required fo creating hash values for TMPXItemId -keys
|
|
52 |
*/
|
|
53 |
inline uint qHash(TMPXItemId key)
|
|
54 |
{
|
|
55 |
QPair<uint, uint> keyPair(key.iId1, key.iId2);
|
|
56 |
|
|
57 |
return qHash(keyPair);
|
|
58 |
}
|
30
|
59 |
|
40
|
60 |
/**
|
|
61 |
* Helper function for creating a new album name query dialog
|
|
62 |
*/
|
|
63 |
HbInputDialog* gCreateNewAlbumNameDialog(const char* objectName)
|
|
64 |
{
|
|
65 |
QString label(hbTrId("txt_videos_title_enter_name"));
|
|
66 |
QString text(hbTrId("txt_videos_dialog_entry_new_collection"));
|
|
67 |
HbInputDialog *dialog = new HbInputDialog();
|
|
68 |
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
69 |
dialog->setObjectName(objectName);
|
|
70 |
dialog->setPromptText(label);
|
|
71 |
dialog->setValue(text);
|
|
72 |
return dialog;
|
|
73 |
}
|
|
74 |
|
30
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
// VideoListSelectionDialog
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
//
|
67
|
79 |
VideoListSelectionDialog::VideoListSelectionDialog( QGraphicsItem *parent)
|
|
80 |
: HbSelectionDialog( parent )
|
|
81 |
, mTypeOfSelection( ENoFunction )
|
36
|
82 |
, mModel( 0 )
|
50
|
83 |
, mModelReady( false )
|
|
84 |
, mAlbumListReady( false )
|
67
|
85 |
, mListInitialised( false )
|
36
|
86 |
, mPrimaryAction( 0 )
|
|
87 |
, mSecondaryAction( 0 )
|
67
|
88 |
, mScrollPositionTimer( 0 )
|
30
|
89 |
{
|
36
|
90 |
FUNC_LOG;
|
37
|
91 |
|
67
|
92 |
// create model and init list, this will create listview in HbSelectionDialog
|
|
93 |
mModel = VideoCollectionWrapper::instance().getGenericModel();
|
|
94 |
initList(0);
|
30
|
95 |
}
|
|
96 |
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
// ~VideoListSelectionDialog
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
VideoListSelectionDialog::~VideoListSelectionDialog()
|
|
102 |
{
|
36
|
103 |
FUNC_LOG;
|
67
|
104 |
|
|
105 |
delete mScrollPositionTimer;
|
|
106 |
delete mPrimaryAction;
|
|
107 |
delete mSecondaryAction;
|
30
|
108 |
}
|
|
109 |
|
|
110 |
// ---------------------------------------------------------------------------
|
34
|
111 |
// setupContent
|
30
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
//
|
67
|
114 |
void VideoListSelectionDialog::setupContent(VideoListSelectionDialog::TSelectionFunction type, TMPXItemId activeItem)
|
30
|
115 |
{
|
36
|
116 |
FUNC_LOG;
|
|
117 |
INFO_1("VideoListSelectionDialog::setupContent() type: %d", type);
|
67
|
118 |
if(type == ENoFunction)
|
30
|
119 |
{
|
34
|
120 |
return;
|
|
121 |
}
|
|
122 |
|
|
123 |
mTypeOfSelection = type;
|
|
124 |
if(!initDialog())
|
|
125 |
{
|
36
|
126 |
ERROR(-1, "VideoListSelectionDialog::setupContent() dialog init failed.");
|
30
|
127 |
return;
|
|
128 |
}
|
34
|
129 |
mSelectedVideos.clear();
|
|
130 |
mSelectedAlbumId = TMPXItemId::InvalidId();
|
40
|
131 |
mNewAlbumText = QString();
|
30
|
132 |
|
34
|
133 |
// if provided "owner" is album or category
|
|
134 |
if(activeItem != TMPXItemId::InvalidId())
|
|
135 |
{
|
|
136 |
// if album, set as "selected"
|
|
137 |
if(activeItem.iId2 == KVcxMvcMediaTypeAlbum)
|
|
138 |
{
|
|
139 |
mSelectedAlbumId = activeItem;
|
|
140 |
}
|
|
141 |
else if(activeItem.iId2 == KVcxMvcMediaTypeVideo)
|
|
142 |
{
|
|
143 |
mSelectedVideos.insert(activeItem);
|
|
144 |
}
|
|
145 |
}
|
|
146 |
// set (or reset) generic id filter
|
35
|
147 |
bool filterValue = true;
|
40
|
148 |
if(mTypeOfSelection == EAddToCollection ||
|
|
149 |
mTypeOfSelection == ESelectCollection ||
|
|
150 |
mTypeOfSelection == ECreateCollection)
|
35
|
151 |
{
|
|
152 |
filterValue = false;
|
|
153 |
}
|
|
154 |
mModel->setGenericIdFilter(activeItem, filterValue);
|
34
|
155 |
activateSelection();
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
// initDialog
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
bool VideoListSelectionDialog::initDialog()
|
|
163 |
{
|
36
|
164 |
FUNC_LOG;
|
34
|
165 |
if(!mModel)
|
|
166 |
{
|
58
|
167 |
mModel = VideoCollectionWrapper::instance().getGenericModel();
|
34
|
168 |
if (!mModel)
|
|
169 |
{
|
|
170 |
return false;
|
|
171 |
}
|
35
|
172 |
}
|
67
|
173 |
|
|
174 |
if(!mScrollPositionTimer)
|
34
|
175 |
{
|
67
|
176 |
mScrollPositionTimer = new QTimer();
|
|
177 |
mScrollPositionTimer->setSingleShot(true);
|
|
178 |
}
|
|
179 |
return true;
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
// initList
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
//
|
|
186 |
bool VideoListSelectionDialog::initList(VideoProxyModelGeneric *model)
|
|
187 |
{
|
|
188 |
FUNC_LOG;
|
|
189 |
|
|
190 |
setModel(model);
|
|
191 |
|
|
192 |
if(!mListInitialised)
|
|
193 |
{
|
|
194 |
HbWidget* content = static_cast<HbWidget*>(this->primitive("content"));
|
|
195 |
if(content)
|
35
|
196 |
{
|
67
|
197 |
HbListView* view = static_cast<HbListView*>(content->primitive("list"));
|
|
198 |
if (view)
|
35
|
199 |
{
|
67
|
200 |
HbListViewItem *prototype = view->listItemPrototype();
|
|
201 |
if(prototype)
|
|
202 |
{
|
|
203 |
prototype->setGraphicsSize(HbListViewItem::WideThumbnail);
|
|
204 |
}
|
|
205 |
view->setItemRecycling(true);
|
|
206 |
view->setClampingStyle(HbScrollArea::BounceBackClamping);
|
|
207 |
view->setScrollingStyle(HbScrollArea::PanWithFollowOn);
|
|
208 |
view->setFrictionEnabled(true);
|
|
209 |
view->setUniformItemSizes(true);
|
|
210 |
view->setSelectionMode(HbAbstractItemView::NoSelection);
|
|
211 |
view->setItemPixmapCacheEnabled(true);
|
|
212 |
view->setEnabledAnimations(HbAbstractItemView::None);
|
|
213 |
|
|
214 |
mListInitialised = true;
|
35
|
215 |
}
|
|
216 |
}
|
34
|
217 |
}
|
67
|
218 |
return mListInitialised;
|
34
|
219 |
}
|
|
220 |
|
|
221 |
// ---------------------------------------------------------------------------
|
|
222 |
// activateSelection
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
//
|
67
|
225 |
void VideoListSelectionDialog::activateSelection(bool changeMode)
|
34
|
226 |
{
|
36
|
227 |
FUNC_LOG;
|
67
|
228 |
QString headingTxt("");
|
|
229 |
QString primaryTxt("");
|
|
230 |
// create texts
|
|
231 |
switch(mTypeOfSelection)
|
|
232 |
{
|
|
233 |
case EDeleteVideos:
|
|
234 |
primaryTxt = hbTrId("txt_common_button_delete");
|
|
235 |
headingTxt = hbTrId("txt_videos_title_delete_videos");
|
|
236 |
break;
|
|
237 |
case EAddToCollection:
|
|
238 |
primaryTxt = hbTrId("txt_common_button_add");
|
|
239 |
headingTxt = hbTrId("txt_videos_title_add_videos");
|
|
240 |
break;
|
|
241 |
case ECreateCollection:
|
|
242 |
primaryTxt = hbTrId("txt_common_button_ok");
|
|
243 |
headingTxt = hbTrId("txt_videos_title_add_videos");
|
|
244 |
break;
|
|
245 |
case ERemoveFromCollection:
|
|
246 |
primaryTxt = hbTrId("txt_common_button_remove");
|
|
247 |
headingTxt = hbTrId("txt_videos_title_remove_videos");
|
|
248 |
break;
|
|
249 |
case ESelectCollection:
|
|
250 |
primaryTxt = hbTrId("txt_videos_button_new");
|
|
251 |
headingTxt = hbTrId("txt_videos_title_select_collection");
|
|
252 |
break;
|
|
253 |
default:
|
|
254 |
break;
|
|
255 |
}
|
|
256 |
|
|
257 |
mModelReady = false;
|
|
258 |
mAlbumListReady = false;
|
|
259 |
setModel(0);
|
|
260 |
|
|
261 |
if(mTypeOfSelection == ESelectCollection)
|
|
262 |
{
|
|
263 |
mModel->open(VideoCollectionCommon::ELevelCategory);
|
|
264 |
VideoCollectionViewUtils::sortModel(mModel, false, VideoCollectionCommon::ELevelCategory);
|
|
265 |
|
|
266 |
setModel(mModel);
|
|
267 |
setSelectionMode(HbAbstractItemView::NoSelection);
|
|
268 |
|
|
269 |
if(changeMode)
|
|
270 |
{
|
|
271 |
removeAction(mSecondaryAction);
|
|
272 |
if(!mPrimaryAction)
|
|
273 |
{
|
|
274 |
mPrimaryAction = new HbAction();
|
|
275 |
mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK);
|
|
276 |
addAction(mPrimaryAction);
|
|
277 |
}
|
|
278 |
// New collection button is always enabled for collection selection.
|
|
279 |
mPrimaryAction->setDisabled(false);
|
|
280 |
}
|
|
281 |
else
|
|
282 |
{
|
|
283 |
clearActions();
|
|
284 |
|
|
285 |
if(!mPrimaryAction)
|
|
286 |
{
|
|
287 |
mPrimaryAction = new HbAction(primaryTxt);
|
|
288 |
mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK);
|
|
289 |
}
|
|
290 |
else
|
|
291 |
{
|
|
292 |
mPrimaryAction->setText(primaryTxt);
|
|
293 |
}
|
|
294 |
addAction(mPrimaryAction);
|
|
295 |
|
|
296 |
if(!mSecondaryAction)
|
|
297 |
{
|
|
298 |
mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
|
|
299 |
mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL);
|
|
300 |
}
|
|
301 |
addAction(mSecondaryAction);
|
|
302 |
|
|
303 |
// New collection button is always enabled for collection selection.
|
|
304 |
mPrimaryAction->setDisabled(false);
|
|
305 |
}
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
mModel->open(VideoCollectionCommon::ELevelVideos);
|
|
310 |
VideoCollectionViewUtils::sortModel(mModel, false, VideoCollectionCommon::ELevelVideos);
|
|
311 |
|
|
312 |
setModel(mModel);
|
|
313 |
setSelectionMode(HbAbstractItemView::MultiSelection);
|
|
314 |
clearActions();
|
|
315 |
|
|
316 |
if(!mPrimaryAction)
|
|
317 |
{
|
|
318 |
mPrimaryAction = new HbAction(primaryTxt);
|
|
319 |
mPrimaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_OK);
|
|
320 |
}
|
|
321 |
else
|
|
322 |
{
|
|
323 |
mPrimaryAction->setText(primaryTxt);
|
|
324 |
}
|
|
325 |
addAction(mPrimaryAction);
|
|
326 |
|
|
327 |
// Add button will be enabled when videos are selected from the list.
|
|
328 |
mPrimaryAction->setDisabled(mTypeOfSelection != ECreateCollection);
|
|
329 |
|
|
330 |
if(!mSecondaryAction)
|
|
331 |
{
|
|
332 |
mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
|
|
333 |
mSecondaryAction->setObjectName(SELECTION_DIALOG_OBJECT_NAME_BUTTON_CANCEL);
|
|
334 |
}
|
|
335 |
addAction(mSecondaryAction);
|
|
336 |
}
|
|
337 |
setHeadingText(headingTxt);
|
|
338 |
|
40
|
339 |
// "add to collection", "remove from collection" and "create collection" -selections
|
67
|
340 |
// needs additional functionality for primary key
|
34
|
341 |
if(mTypeOfSelection == EAddToCollection ||
|
40
|
342 |
mTypeOfSelection == ERemoveFromCollection ||
|
|
343 |
mTypeOfSelection == ECreateCollection)
|
34
|
344 |
{
|
36
|
345 |
mPrimaryAction->disconnect(SIGNAL(triggered()));
|
|
346 |
connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(primaryActionTriggeredSlot()));
|
30
|
347 |
}
|
|
348 |
}
|
|
349 |
|
|
350 |
// ---------------------------------------------------------------------------
|
|
351 |
// exec
|
|
352 |
// ---------------------------------------------------------------------------
|
|
353 |
//
|
35
|
354 |
void VideoListSelectionDialog::exec()
|
30
|
355 |
{
|
36
|
356 |
FUNC_LOG;
|
67
|
357 |
|
|
358 |
connectSignals();
|
50
|
359 |
|
55
|
360 |
if(mTypeOfSelection == ECreateCollection)
|
35
|
361 |
{
|
55
|
362 |
// note this does not leak memory as the dialog will destroy itself upon close.
|
|
363 |
HbInputDialog *dialog = gCreateNewAlbumNameDialog(LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION);
|
|
364 |
dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *)));
|
|
365 |
}
|
|
366 |
else if(mModel->rowCount())
|
|
367 |
{
|
|
368 |
// show dialog
|
67
|
369 |
VideoThumbnailData::instance().enableBackgroundFetching(true);
|
|
370 |
fetchThumbnailsForVisibleItems();
|
|
371 |
HbSelectionDialog::open();
|
35
|
372 |
}
|
50
|
373 |
else if((mModelReady && mTypeOfSelection != ESelectCollection) ||
|
|
374 |
(mAlbumListReady && mTypeOfSelection == ESelectCollection))
|
35
|
375 |
{
|
36
|
376 |
INFO("VideoListSelectionDialog::exec(): nothing to show, finishing.")
|
35
|
377 |
// no items, finish right away
|
36
|
378 |
finishedSlot(mPrimaryAction);
|
35
|
379 |
}
|
|
380 |
}
|
|
381 |
|
|
382 |
// ---------------------------------------------------------------------------
|
|
383 |
// finishedSlot
|
|
384 |
// ---------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
void VideoListSelectionDialog::finishedSlot(HbAction *action)
|
|
387 |
{
|
36
|
388 |
FUNC_LOG;
|
30
|
389 |
disconnectSignals();
|
67
|
390 |
if(mScrollPositionTimer)
|
|
391 |
{
|
|
392 |
if(mScrollPositionTimer->isActive())
|
|
393 |
{
|
|
394 |
mScrollPositionTimer->stop();
|
|
395 |
}
|
|
396 |
delete mScrollPositionTimer;
|
|
397 |
mScrollPositionTimer = 0;
|
|
398 |
}
|
|
399 |
if(action != mPrimaryAction)
|
35
|
400 |
{
|
67
|
401 |
if(mTypeOfSelection == ESelectCollection)
|
|
402 |
{
|
|
403 |
QModelIndexList selection = selectedModelIndexes();
|
|
404 |
int count(selection.count());
|
|
405 |
|
|
406 |
if((count == 1) && (selection.at(0).isValid()))
|
|
407 |
{
|
|
408 |
mSelectedAlbumId = mModel->getMediaIdAtIndex(selection.at(0));
|
|
409 |
}
|
|
410 |
else
|
|
411 |
{
|
|
412 |
INFO("VideoListSelectionDialog::exec(): secondary action triggered.")
|
|
413 |
return;
|
|
414 |
}
|
|
415 |
}
|
|
416 |
else
|
|
417 |
{
|
|
418 |
INFO("VideoListSelectionDialog::exec(): secondary action triggered.")
|
|
419 |
return;
|
|
420 |
}
|
35
|
421 |
}
|
40
|
422 |
|
38
|
423 |
if(mTypeOfSelection == ESelectCollection)
|
34
|
424 |
{
|
37
|
425 |
mTypeOfSelection = EAddToCollection;
|
38
|
426 |
if(mSelectedAlbumId == TMPXItemId::InvalidId())
|
35
|
427 |
{
|
50
|
428 |
close(); // closes selection dialog if it's open.
|
|
429 |
|
40
|
430 |
// note this does not leak memory as the dialog will destroy itself upon close.
|
|
431 |
HbInputDialog *dialog = gCreateNewAlbumNameDialog(SELECTION_DIALOG_OBJECT_NAME_NEW_COLLECTION);
|
38
|
432 |
dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *)));
|
37
|
433 |
}
|
|
434 |
else
|
|
435 |
{
|
|
436 |
finalize();
|
35
|
437 |
}
|
37
|
438 |
}
|
|
439 |
else
|
|
440 |
{
|
|
441 |
finalize();
|
35
|
442 |
}
|
37
|
443 |
}
|
|
444 |
|
|
445 |
// ---------------------------------------------------------------------------
|
|
446 |
// newAlbumNameDialogFinished
|
|
447 |
// ---------------------------------------------------------------------------
|
|
448 |
//
|
|
449 |
void VideoListSelectionDialog::newAlbumNameDialogFinished(HbAction *action)
|
|
450 |
{
|
|
451 |
FUNC_LOG;
|
|
452 |
Q_UNUSED(action);
|
36
|
453 |
|
37
|
454 |
HbInputDialog *dialog = static_cast<HbInputDialog*>(sender());
|
|
455 |
|
|
456 |
QVariant variant = dialog->value();
|
|
457 |
|
|
458 |
if(dialog->actions().first() == action && variant.isValid())
|
|
459 |
{
|
|
460 |
QString text = mModel->resolveAlbumName(variant.toString());
|
50
|
461 |
if(!text.isEmpty())
|
37
|
462 |
{
|
55
|
463 |
if(mSelectedVideos.count() == 0 && mModel->rowCount())
|
40
|
464 |
{
|
|
465 |
mNewAlbumText = text;
|
|
466 |
// show video selection dialog
|
67
|
467 |
VideoThumbnailData::instance().enableBackgroundFetching(true);
|
|
468 |
fetchThumbnailsForVisibleItems();
|
|
469 |
HbSelectionDialog::open();
|
40
|
470 |
}
|
|
471 |
else
|
|
472 |
{
|
|
473 |
mSelectedAlbumId = mModel->addNewAlbum(text);
|
|
474 |
finalize(text);
|
|
475 |
}
|
37
|
476 |
}
|
50
|
477 |
else
|
|
478 |
{
|
|
479 |
// new album name empty, effectively cancel, so disconnect signals.
|
|
480 |
disconnectSignals();
|
|
481 |
}
|
|
482 |
}
|
|
483 |
else
|
|
484 |
{
|
|
485 |
// new album dialog cancelled, disconnect signals.
|
|
486 |
disconnectSignals();
|
37
|
487 |
}
|
|
488 |
}
|
|
489 |
|
|
490 |
// ---------------------------------------------------------------------------
|
|
491 |
// finalize
|
|
492 |
// ---------------------------------------------------------------------------
|
|
493 |
//
|
|
494 |
void VideoListSelectionDialog::finalize(QString albumName)
|
|
495 |
{
|
67
|
496 |
close();
|
|
497 |
|
36
|
498 |
// Must be checked again if type was ESelectCollection
|
40
|
499 |
if(mTypeOfSelection == EAddToCollection ||
|
|
500 |
mTypeOfSelection == ECreateCollection)
|
|
501 |
{
|
|
502 |
if(mTypeOfSelection == ECreateCollection)
|
|
503 |
{
|
|
504 |
mSelectedAlbumId = mModel->addNewAlbum(mNewAlbumText);
|
|
505 |
albumName = mNewAlbumText;
|
|
506 |
}
|
|
507 |
|
35
|
508 |
if(mSelectedAlbumId != TMPXItemId::InvalidId() && mSelectedVideos.count())
|
|
509 |
{
|
|
510 |
if(mModel->addItemsInAlbum(mSelectedAlbumId, mSelectedVideos.toList()) == 0)
|
|
511 |
{
|
|
512 |
if(!albumName.length())
|
34
|
513 |
{
|
35
|
514 |
albumName = getSelectedName();
|
34
|
515 |
}
|
38
|
516 |
QList<QVariant> dataList;
|
|
517 |
dataList.append(QVariant(mSelectedVideos.count()));
|
|
518 |
dataList.append(QVariant(albumName));
|
|
519 |
QVariant data = dataList;
|
35
|
520 |
VideoCollectionViewUtils::instance().showStatusMsgSlot(
|
|
521 |
VideoCollectionCommon::statusVideosAddedToCollection,
|
|
522 |
data);
|
34
|
523 |
}
|
|
524 |
}
|
35
|
525 |
}
|
|
526 |
else if(mTypeOfSelection == ERemoveFromCollection)
|
|
527 |
{
|
|
528 |
if(mSelectedAlbumId != TMPXItemId::InvalidId() && mSelectedVideos.count())
|
34
|
529 |
{
|
35
|
530 |
if(mModel->removeItemsFromAlbum(mSelectedAlbumId, mSelectedVideos.toList()) == 0)
|
|
531 |
{
|
|
532 |
QVariant data = getSelectedName();
|
|
533 |
VideoCollectionViewUtils::instance().showStatusMsgSlot(
|
|
534 |
VideoCollectionCommon::statusVideosRemovedFromCollection,
|
|
535 |
data);
|
|
536 |
}
|
34
|
537 |
}
|
35
|
538 |
}
|
|
539 |
// user is deleting videos
|
|
540 |
else if(mTypeOfSelection == EDeleteVideos)
|
|
541 |
{
|
67
|
542 |
QModelIndexList selection = selectedModelIndexes();
|
|
543 |
QVariant data = selection.count();
|
|
544 |
|
35
|
545 |
VideoCollectionViewUtils::instance().showStatusMsgSlot(
|
|
546 |
VideoCollectionCommon::statusDeleteInProgress,
|
|
547 |
data);
|
67
|
548 |
// delete items
|
|
549 |
mModel->deleteItems(selection);
|
30
|
550 |
}
|
|
551 |
}
|
|
552 |
|
|
553 |
// ---------------------------------------------------------------------------
|
|
554 |
// selectionChangedSlot
|
|
555 |
// ---------------------------------------------------------------------------
|
|
556 |
//
|
67
|
557 |
void VideoListSelectionDialog::selectionChangedSlot()
|
|
558 |
{
|
|
559 |
FUNC_LOG;
|
36
|
560 |
if(!mPrimaryAction || mTypeOfSelection == ESelectCollection)
|
30
|
561 |
{
|
36
|
562 |
INFO("VideoListSelectionDialog::selectionChangedSlot(): no primary action or we are selecting collection.")
|
30
|
563 |
return;
|
|
564 |
}
|
67
|
565 |
|
|
566 |
QModelIndexList selected(selectedModelIndexes());
|
|
567 |
|
|
568 |
if(selected.count() > 0)
|
30
|
569 |
{
|
36
|
570 |
mPrimaryAction->setDisabled(false);
|
40
|
571 |
if(mTypeOfSelection == ECreateCollection)
|
67
|
572 |
|
40
|
573 |
{
|
|
574 |
mPrimaryAction->setText(hbTrId("txt_common_button_add"));
|
|
575 |
}
|
30
|
576 |
}
|
|
577 |
else
|
|
578 |
{
|
40
|
579 |
mPrimaryAction->setDisabled(mTypeOfSelection != ECreateCollection);
|
|
580 |
|
|
581 |
if(mTypeOfSelection == ECreateCollection)
|
|
582 |
{
|
|
583 |
mPrimaryAction->setText(hbTrId("txt_common_button_ok"));
|
|
584 |
}
|
34
|
585 |
}
|
|
586 |
}
|
|
587 |
|
|
588 |
// ---------------------------------------------------------------------------
|
|
589 |
// modelReadySlot
|
|
590 |
// ---------------------------------------------------------------------------
|
|
591 |
//
|
|
592 |
void VideoListSelectionDialog::modelReadySlot()
|
|
593 |
{
|
36
|
594 |
FUNC_LOG;
|
50
|
595 |
mModelReady = true;
|
|
596 |
|
|
597 |
if(mTypeOfSelection != ESelectCollection)
|
|
598 |
{
|
|
599 |
if(!mModel->rowCount())
|
|
600 |
{
|
|
601 |
// no items, finish right away
|
|
602 |
INFO("VideoListSelectionDialog::modelReadySlot(): nothing to show, finishing.");
|
|
603 |
|
|
604 |
if(mTypeOfSelection == EAddToCollection ||
|
|
605 |
mTypeOfSelection == ERemoveFromCollection)
|
|
606 |
{
|
|
607 |
primaryActionTriggeredSlot();
|
|
608 |
}
|
|
609 |
else
|
|
610 |
{
|
|
611 |
finishedSlot(mPrimaryAction);
|
|
612 |
}
|
|
613 |
return;
|
|
614 |
}
|
|
615 |
|
|
616 |
// if dialog is not yet visible, bring it visible.
|
|
617 |
if(!isVisible() && mTypeOfSelection != ECreateCollection)
|
|
618 |
{
|
67
|
619 |
HbSelectionDialog::open();
|
50
|
620 |
}
|
67
|
621 |
}
|
50
|
622 |
}
|
|
623 |
|
|
624 |
// ---------------------------------------------------------------------------
|
|
625 |
// albumListReadySlot
|
|
626 |
// ---------------------------------------------------------------------------
|
|
627 |
//
|
|
628 |
void VideoListSelectionDialog::albumListReadySlot()
|
|
629 |
{
|
|
630 |
mAlbumListReady = true;
|
|
631 |
|
35
|
632 |
if(mTypeOfSelection == ESelectCollection)
|
34
|
633 |
{
|
35
|
634 |
if(!mModel->rowCount())
|
34
|
635 |
{
|
50
|
636 |
finishedSlot(mPrimaryAction);
|
35
|
637 |
return;
|
34
|
638 |
}
|
67
|
639 |
else
|
|
640 |
{
|
|
641 |
mPrimaryAction->setText(hbTrId("txt_videos_button_new"));
|
|
642 |
}
|
50
|
643 |
// if dialog is not yet visible, bring it visible.
|
|
644 |
if(!isVisible())
|
|
645 |
{
|
67
|
646 |
HbSelectionDialog::open();
|
50
|
647 |
}
|
35
|
648 |
}
|
34
|
649 |
}
|
|
650 |
|
|
651 |
// ---------------------------------------------------------------------------
|
|
652 |
// primaryActionTriggeredSlot
|
|
653 |
// ---------------------------------------------------------------------------
|
|
654 |
//
|
|
655 |
void VideoListSelectionDialog::primaryActionTriggeredSlot()
|
|
656 |
{
|
36
|
657 |
FUNC_LOG;
|
34
|
658 |
// reconnect primary action
|
36
|
659 |
mPrimaryAction->disconnect(SIGNAL(triggered()));
|
|
660 |
connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(close()));
|
|
661 |
|
34
|
662 |
// update video items selection here before content changes.
|
67
|
663 |
QModelIndexList indexes = selectedModelIndexes();
|
50
|
664 |
int count = indexes.count();
|
34
|
665 |
TMPXItemId id = TMPXItemId::InvalidId();
|
|
666 |
for(int i = 0; i < count; ++i)
|
|
667 |
{
|
50
|
668 |
id = mModel->getMediaIdAtIndex(indexes.at(i));
|
34
|
669 |
if(id.iId2 == KVcxMvcMediaTypeVideo)
|
|
670 |
{
|
|
671 |
mSelectedVideos.insert(id);
|
|
672 |
}
|
|
673 |
}
|
|
674 |
|
40
|
675 |
if(mSelectedAlbumId != TMPXItemId::InvalidId() ||
|
|
676 |
mTypeOfSelection == ECreateCollection)
|
34
|
677 |
{
|
36
|
678 |
INFO("VideoListSelectionDialog::primaryActionTriggeredSlot(): closing dialog.")
|
|
679 |
mPrimaryAction->trigger();
|
34
|
680 |
return;
|
|
681 |
}
|
|
682 |
else if(mTypeOfSelection == EAddToCollection)
|
|
683 |
{
|
36
|
684 |
INFO("VideoListSelectionDialog::primaryActionTriggeredSlot(): activating collection selection.")
|
34
|
685 |
// videos for collection selected, but collection
|
|
686 |
// not yet selected, activate selection for it
|
|
687 |
mTypeOfSelection = ESelectCollection;
|
67
|
688 |
activateSelection(true);
|
|
689 |
}
|
34
|
690 |
}
|
|
691 |
|
|
692 |
// ---------------------------------------------------------------------------
|
30
|
693 |
// connectSignals
|
|
694 |
// ---------------------------------------------------------------------------
|
|
695 |
//
|
|
696 |
void VideoListSelectionDialog::connectSignals()
|
35
|
697 |
{
|
36
|
698 |
FUNC_LOG;
|
35
|
699 |
// dialog finished
|
|
700 |
connect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
|
67
|
701 |
|
|
702 |
//selection changes
|
|
703 |
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedSlot()));
|
36
|
704 |
|
30
|
705 |
// model changes signals
|
50
|
706 |
connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
|
|
707 |
connect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot()));
|
67
|
708 |
|
|
709 |
connect(mScrollPositionTimer, SIGNAL(timeout()), this, SLOT(scrollPositionTimerSlot()));
|
|
710 |
|
|
711 |
HbWidget* content = static_cast<HbWidget*>(this->primitive("content"));
|
|
712 |
HbListView* view(0);
|
|
713 |
if(content)
|
|
714 |
{
|
|
715 |
view = static_cast<HbListView*>(content->primitive("list"));
|
|
716 |
if (view)
|
|
717 |
{
|
|
718 |
connect(view, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot()));
|
|
719 |
connect(view, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot()));
|
|
720 |
connect(view, SIGNAL(scrollPositionChanged(const QPointF &)),
|
|
721 |
this, SLOT(scrollPositionChangedSlot(const QPointF &)));
|
|
722 |
}
|
|
723 |
}
|
30
|
724 |
}
|
67
|
725 |
|
30
|
726 |
// ---------------------------------------------------------------------------
|
|
727 |
// disconnectSignals
|
|
728 |
// ---------------------------------------------------------------------------
|
|
729 |
//
|
|
730 |
void VideoListSelectionDialog::disconnectSignals()
|
35
|
731 |
{
|
36
|
732 |
FUNC_LOG;
|
35
|
733 |
disconnect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
|
67
|
734 |
|
|
735 |
//selection changes
|
|
736 |
disconnect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedSlot()));
|
36
|
737 |
|
30
|
738 |
// model changes signals
|
67
|
739 |
disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
|
50
|
740 |
disconnect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot()));
|
67
|
741 |
|
|
742 |
// check that scroll position timer is created
|
|
743 |
if (mScrollPositionTimer)
|
|
744 |
{
|
|
745 |
disconnect(
|
|
746 |
mScrollPositionTimer, SIGNAL(timeout()),
|
|
747 |
this, SLOT(scrollPositionTimerSlot()));
|
|
748 |
}
|
|
749 |
|
|
750 |
HbWidget* content = static_cast<HbWidget*>(this->primitive("content"));
|
|
751 |
HbListView* view(0);
|
|
752 |
if(content)
|
|
753 |
{
|
|
754 |
view = static_cast<HbListView*>(content->primitive("list"));
|
|
755 |
if (view)
|
|
756 |
{
|
|
757 |
disconnect(view, SIGNAL(scrollingEnded()), this, SLOT(scrollingEndedSlot()));
|
|
758 |
disconnect(view, SIGNAL(scrollingStarted()), this, SLOT(scrollingStartedSlot()));
|
|
759 |
disconnect(view, SIGNAL(scrollPositionChanged(const QPointF &)),
|
|
760 |
this, SLOT(scrollPositionChangedSlot(const QPointF &)));
|
|
761 |
}
|
|
762 |
}
|
30
|
763 |
}
|
|
764 |
|
34
|
765 |
// ---------------------------------------------------------------------------
|
|
766 |
// getSelectedName
|
|
767 |
// ---------------------------------------------------------------------------
|
|
768 |
//
|
|
769 |
QString VideoListSelectionDialog::getSelectedName()
|
|
770 |
{
|
36
|
771 |
FUNC_LOG;
|
34
|
772 |
QString name;
|
|
773 |
if(mSelectedAlbumId.iId2 > KVcxMvcMediaTypeVideo)
|
|
774 |
{
|
67
|
775 |
VideoProxyModelGeneric *model = VideoCollectionWrapper::instance().getGenericModel();
|
|
776 |
|
34
|
777 |
if(!model)
|
|
778 |
{
|
|
779 |
return name;
|
|
780 |
}
|
|
781 |
QModelIndex index = model->indexOfId(mSelectedAlbumId);
|
|
782 |
if(index.isValid())
|
|
783 |
{
|
36
|
784 |
name = model->data(index, VideoCollectionCommon::KeyTitle).toString();
|
34
|
785 |
}
|
|
786 |
}
|
|
787 |
return name;
|
|
788 |
}
|
30
|
789 |
|
67
|
790 |
// ---------------------------------------------------------------------------
|
|
791 |
// scrollingStartedSlot
|
|
792 |
// ---------------------------------------------------------------------------
|
|
793 |
//
|
|
794 |
void VideoListSelectionDialog::scrollingStartedSlot()
|
|
795 |
{
|
|
796 |
FUNC_LOG_ADDR(this);
|
|
797 |
VideoThumbnailData::instance().enableThumbnailCreation(false);
|
|
798 |
}
|
|
799 |
|
|
800 |
// ---------------------------------------------------------------------------
|
|
801 |
// scrollingEndedSlot
|
|
802 |
// ---------------------------------------------------------------------------
|
|
803 |
//
|
|
804 |
void VideoListSelectionDialog::scrollingEndedSlot()
|
|
805 |
{
|
|
806 |
FUNC_LOG_ADDR(this);
|
|
807 |
|
|
808 |
if(mScrollPositionTimer)
|
|
809 |
{
|
|
810 |
mScrollPositionTimer->stop();
|
|
811 |
}
|
|
812 |
|
|
813 |
VideoThumbnailData::instance().enableBackgroundFetching(true);
|
|
814 |
VideoThumbnailData::instance().enableThumbnailCreation(true);
|
|
815 |
fetchThumbnailsForVisibleItems();
|
|
816 |
}
|
|
817 |
|
|
818 |
// ---------------------------------------------------------------------------
|
|
819 |
// scrollPositionChangedSlot
|
|
820 |
// ---------------------------------------------------------------------------
|
|
821 |
//
|
|
822 |
void VideoListSelectionDialog::scrollPositionChangedSlot(const QPointF &newPosition)
|
|
823 |
{
|
|
824 |
Q_UNUSED(newPosition);
|
|
825 |
|
|
826 |
if(mScrollPositionTimer && !mScrollPositionTimer->isActive())
|
|
827 |
mScrollPositionTimer->start(SCROLL_POSITION_TIMER_TIMEOUT);
|
|
828 |
}
|
|
829 |
|
|
830 |
// ---------------------------------------------------------------------------
|
|
831 |
// scrollPositionTimerSlot
|
|
832 |
// ---------------------------------------------------------------------------
|
|
833 |
//
|
|
834 |
void VideoListSelectionDialog::scrollPositionTimerSlot()
|
|
835 |
{
|
|
836 |
FUNC_LOG_ADDR(this);
|
|
837 |
|
|
838 |
fetchThumbnailsForVisibleItems();
|
|
839 |
}
|
|
840 |
|
|
841 |
// ---------------------------------------------------------------------------
|
|
842 |
// fetchThumbnailsForVisibleItems
|
|
843 |
// ---------------------------------------------------------------------------
|
|
844 |
//
|
|
845 |
void VideoListSelectionDialog::fetchThumbnailsForVisibleItems()
|
|
846 |
{
|
|
847 |
FUNC_LOG_ADDR(this);
|
|
848 |
|
|
849 |
// No need to do anything if thumbnail fetching is not enabled.
|
|
850 |
if(!VideoThumbnailData::instance().backgroundFetchingEnabled())
|
|
851 |
{
|
|
852 |
return;
|
|
853 |
}
|
|
854 |
HbWidget* content = static_cast<HbWidget*>(this->primitive("content"));
|
|
855 |
HbListView* view(0);
|
|
856 |
if(content)
|
|
857 |
{
|
|
858 |
view = static_cast<HbListView*>(content->primitive("list"));
|
|
859 |
if (!view)
|
|
860 |
{
|
|
861 |
return;
|
|
862 |
}
|
|
863 |
}
|
|
864 |
|
|
865 |
const QList<HbAbstractViewItem *> itemsVisible = view->visibleItems();
|
|
866 |
|
|
867 |
if(itemsVisible.count() > 0)
|
|
868 |
{
|
|
869 |
int row = itemsVisible.value(0)->modelIndex().row();
|
|
870 |
VideoThumbnailData::instance().startBackgroundFetching(mModel, row);
|
|
871 |
}
|
|
872 |
else
|
|
873 |
{
|
|
874 |
// Nothing visible yet, start from first index.
|
|
875 |
VideoThumbnailData::instance().startBackgroundFetching(mModel, 0);
|
|
876 |
}
|
|
877 |
}
|
|
878 |
|
38
|
879 |
// End of file
|