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 |
|
36
|
18 |
// Version : %version: 22 %
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <qgraphicsitem.h>
|
30
|
22 |
#include <hblabel.h>
|
|
23 |
#include <hbcheckbox.h>
|
|
24 |
#include <hbaction.h>
|
|
25 |
#include <hbstackedwidget.h>
|
34
|
26 |
#include <hbabstractitemview.h>
|
|
27 |
#include <hbinputdialog.h>
|
|
28 |
#include <vcxmyvideosdefs.h>
|
|
29 |
|
30
|
30 |
#include "videocollectionuiloader.h"
|
|
31 |
#include "videolistwidget.h"
|
|
32 |
#include "videosortfilterproxymodel.h"
|
|
33 |
#include "videolistselectiondialog.h"
|
34
|
34 |
#include "videocollectionwrapper.h"
|
|
35 |
#include "videocollectionviewutils.h"
|
|
36 |
#include "videocollectionclient.h"
|
36
|
37 |
#include "videocollectiontrace.h"
|
34
|
38 |
|
|
39 |
/**
|
|
40 |
* global qHash function required fo creating hash values for TMPXItemId -keys
|
|
41 |
*/
|
|
42 |
inline uint qHash(TMPXItemId key)
|
|
43 |
{
|
|
44 |
QPair<uint, uint> keyPair(key.iId1, key.iId2);
|
|
45 |
|
|
46 |
return qHash(keyPair);
|
|
47 |
}
|
30
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// VideoListSelectionDialog
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
36
|
53 |
VideoListSelectionDialog::VideoListSelectionDialog( VideoCollectionUiLoader *uiLoader,
|
|
54 |
QGraphicsItem *parent)
|
|
55 |
: HbDialog( parent )
|
|
56 |
, mUiLoader( uiLoader )
|
|
57 |
, mTypeOfSelection( -1 )
|
|
58 |
, mHeading( 0 )
|
|
59 |
, mCheckboxContainer( 0 )
|
|
60 |
, mItemCount( 0 )
|
|
61 |
, mCheckBox( 0 )
|
|
62 |
, mListContainer( 0 )
|
|
63 |
, mForcedCheck( false )
|
|
64 |
, mModel( 0 )
|
|
65 |
, mListWidget( 0 )
|
|
66 |
, mPrimaryAction( 0 )
|
|
67 |
, mSecondaryAction( 0 )
|
30
|
68 |
{
|
36
|
69 |
FUNC_LOG;
|
30
|
70 |
setDismissPolicy(HbDialog::NoDismiss);
|
34
|
71 |
setTimeout(HbDialog::NoTimeout);
|
|
72 |
|
|
73 |
// create model for list widget
|
|
74 |
mModel =
|
|
75 |
VideoCollectionWrapper::instance().getModel(
|
36
|
76 |
VideoCollectionCommon::EModelTypeGeneric);
|
34
|
77 |
if (mModel)
|
|
78 |
{
|
|
79 |
// create list widget
|
|
80 |
mListWidget = new VideoListWidget(mUiLoader);
|
36
|
81 |
if(mListWidget->initialize(*mModel) < 0)
|
34
|
82 |
{
|
36
|
83 |
ERROR(-1, "VideoListSelectionDialog::VideoListSelectionDialog() failed to init list widget");
|
|
84 |
delete mListWidget;
|
|
85 |
mListWidget = 0;
|
34
|
86 |
}
|
|
87 |
}
|
30
|
88 |
}
|
|
89 |
|
|
90 |
// ---------------------------------------------------------------------------
|
|
91 |
// ~VideoListSelectionDialog
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
VideoListSelectionDialog::~VideoListSelectionDialog()
|
|
95 |
{
|
36
|
96 |
FUNC_LOG;
|
34
|
97 |
delete mListWidget;
|
30
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
34
|
101 |
// setupContent
|
30
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
//
|
34
|
104 |
void VideoListSelectionDialog::setupContent(int type, TMPXItemId activeItem)
|
30
|
105 |
{
|
36
|
106 |
FUNC_LOG;
|
|
107 |
INFO_1("VideoListSelectionDialog::setupContent() type: %d", type);
|
34
|
108 |
if(type < EDeleteVideos || type > ESelectCollection)
|
30
|
109 |
{
|
34
|
110 |
return;
|
|
111 |
}
|
|
112 |
|
|
113 |
mTypeOfSelection = type;
|
|
114 |
if(!initDialog())
|
|
115 |
{
|
36
|
116 |
ERROR(-1, "VideoListSelectionDialog::setupContent() dialog init failed.");
|
30
|
117 |
return;
|
|
118 |
}
|
34
|
119 |
mSelection.clear();
|
|
120 |
mSelectedVideos.clear();
|
|
121 |
mSelectedAlbumId = TMPXItemId::InvalidId();
|
30
|
122 |
|
34
|
123 |
// if provided "owner" is album or category
|
|
124 |
if(activeItem != TMPXItemId::InvalidId())
|
|
125 |
{
|
|
126 |
// if album, set as "selected"
|
|
127 |
if(activeItem.iId2 == KVcxMvcMediaTypeAlbum)
|
|
128 |
{
|
|
129 |
mSelectedAlbumId = activeItem;
|
|
130 |
}
|
|
131 |
else if(activeItem.iId2 == KVcxMvcMediaTypeVideo)
|
|
132 |
{
|
|
133 |
mSelectedVideos.insert(activeItem);
|
|
134 |
}
|
|
135 |
}
|
|
136 |
// set (or reset) generic id filter
|
35
|
137 |
bool filterValue = true;
|
|
138 |
if(mTypeOfSelection == EAddToCollection || mTypeOfSelection == ESelectCollection)
|
|
139 |
{
|
|
140 |
filterValue = false;
|
|
141 |
}
|
|
142 |
mModel->setGenericIdFilter(activeItem, filterValue);
|
34
|
143 |
activateSelection();
|
|
144 |
}
|
|
145 |
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
// initDialog
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
//
|
|
150 |
bool VideoListSelectionDialog::initDialog()
|
|
151 |
{
|
36
|
152 |
FUNC_LOG;
|
34
|
153 |
if(!mModel)
|
|
154 |
{
|
36
|
155 |
mModel = VideoCollectionWrapper::instance().getModel(VideoCollectionCommon::EModelTypeGeneric);
|
34
|
156 |
if (!mModel)
|
|
157 |
{
|
|
158 |
return false;
|
|
159 |
}
|
35
|
160 |
}
|
34
|
161 |
if (!mListContainer)
|
|
162 |
{
|
|
163 |
mListContainer =
|
35
|
164 |
mUiLoader->findWidget<HbStackedWidget>(DOCML_NAME_LIST_CONTAINER);
|
|
165 |
|
|
166 |
if(!mListWidget)
|
|
167 |
{
|
|
168 |
mListWidget = new VideoListWidget(mUiLoader);
|
|
169 |
if(mListWidget->initialize(*mModel) < 0)
|
|
170 |
{
|
36
|
171 |
ERROR(-1, "VideoListSelectionDialog::initDialog() failed to setup VideoListWidget.");
|
35
|
172 |
delete mListWidget;
|
|
173 |
mListWidget = 0;
|
|
174 |
mListContainer = 0;
|
|
175 |
return false;
|
|
176 |
}
|
|
177 |
}
|
|
178 |
if(mListContainer)
|
34
|
179 |
{
|
|
180 |
mListContainer->addWidget(mListWidget);
|
|
181 |
}
|
|
182 |
}
|
35
|
183 |
|
30
|
184 |
if(!mHeading)
|
|
185 |
{
|
|
186 |
mHeading = mUiLoader->findWidget<HbLabel>(DOCML_NAME_DLG_HEADINGLBL);
|
|
187 |
}
|
34
|
188 |
if(!mCheckboxContainer)
|
|
189 |
{
|
|
190 |
mCheckboxContainer = mUiLoader->findWidget<HbWidget>(DOCML_NAME_CHECK_CONTAINER);
|
|
191 |
}
|
30
|
192 |
if(!mItemCount)
|
|
193 |
{
|
|
194 |
mItemCount = mUiLoader->findWidget<HbLabel>(DOCML_NAME_LBL_SELECTION);
|
|
195 |
mItemCount->setAlignment(Qt::AlignRight);
|
34
|
196 |
}
|
30
|
197 |
if(!mCheckBox)
|
|
198 |
{
|
|
199 |
mCheckBox = mUiLoader->findWidget<HbCheckBox >(DOCML_NAME_MARKALL);
|
|
200 |
}
|
36
|
201 |
// HbDialog connects actions to finished signal by default.
|
|
202 |
if(!mPrimaryAction)
|
30
|
203 |
{
|
36
|
204 |
mPrimaryAction = new HbAction(hbTrId("txt_common_button_ok"));
|
|
205 |
addAction(mPrimaryAction);
|
30
|
206 |
}
|
36
|
207 |
if(!mSecondaryAction)
|
30
|
208 |
{
|
36
|
209 |
mSecondaryAction = new HbAction(hbTrId("txt_common_button_cancel"));
|
|
210 |
addAction(mSecondaryAction);
|
34
|
211 |
}
|
36
|
212 |
if(!mListContainer || !mHeading || !mCheckBox)
|
34
|
213 |
{
|
36
|
214 |
ERROR(-1, "VideoListSelectionDialog::initDialog() !mListContainer || !mHeading || !mCheckBox");
|
34
|
215 |
return false;
|
|
216 |
}
|
|
217 |
return true;
|
|
218 |
}
|
|
219 |
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
// activateSelection
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
void VideoListSelectionDialog::activateSelection()
|
|
225 |
{
|
36
|
226 |
FUNC_LOG;
|
35
|
227 |
// "add to collection" and "remove from collection -selections needs
|
34
|
228 |
// additional functionality for primary key
|
|
229 |
if(mTypeOfSelection == EAddToCollection ||
|
35
|
230 |
mTypeOfSelection == ERemoveFromCollection)
|
34
|
231 |
{
|
36
|
232 |
mPrimaryAction->disconnect(SIGNAL(triggered()));
|
|
233 |
connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(primaryActionTriggeredSlot()));
|
30
|
234 |
}
|
35
|
235 |
QString headingTxt("");
|
|
236 |
QString primaryTxt("");
|
|
237 |
// create texts
|
|
238 |
switch(mTypeOfSelection)
|
34
|
239 |
{
|
36
|
240 |
case EDeleteVideos:
|
|
241 |
primaryTxt = hbTrId("txt_common_button_delete");
|
|
242 |
break;
|
|
243 |
case EAddToCollection:
|
|
244 |
primaryTxt = hbTrId("txt_common_button_add");
|
|
245 |
break;
|
|
246 |
case ERemoveFromCollection:
|
|
247 |
primaryTxt = hbTrId("txt_common_button_remove");
|
|
248 |
break;
|
|
249 |
case ESelectCollection:
|
|
250 |
primaryTxt = hbTrId("txt_videos_button_new");
|
|
251 |
break;
|
|
252 |
default:
|
|
253 |
break;
|
35
|
254 |
}
|
|
255 |
|
36
|
256 |
mPrimaryAction->setText(primaryTxt);
|
35
|
257 |
|
|
258 |
if(mTypeOfSelection == ESelectCollection)
|
|
259 |
{
|
|
260 |
headingTxt = hbTrId("txt_videos_title_select_collection");
|
|
261 |
mCheckboxContainer->setVisible(false);
|
|
262 |
mListWidget->setSelectionMode(-1);
|
|
263 |
mListWidget->activate(VideoCollectionCommon::ELevelCategory);
|
|
264 |
// need to set primaryaction disabled here in order for it
|
|
265 |
// get correctly updated at modelReady(), where it will be enabled
|
|
266 |
// if state would be same, no update will happen
|
36
|
267 |
mPrimaryAction->setDisabled(true);
|
35
|
268 |
}
|
|
269 |
else
|
|
270 |
{
|
|
271 |
headingTxt = hbTrId("txt_videos_title_select_videos");
|
|
272 |
mListWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
|
34
|
273 |
mListWidget->activate(VideoCollectionCommon::ELevelVideos);
|
|
274 |
mCheckboxContainer->setVisible(true);
|
|
275 |
mItemCount->setPlainText(tr("0/%1").arg(mModel->rowCount()));
|
35
|
276 |
mCheckBox->setChecked(false);
|
|
277 |
// need to set primaryaction enabled here in order for it
|
|
278 |
// get correctly updated at modelReady(), where it will be disabled
|
|
279 |
// if state would be same, no update will happen
|
36
|
280 |
mPrimaryAction->setDisabled(false);
|
34
|
281 |
}
|
35
|
282 |
mHeading->setPlainText(headingTxt);
|
34
|
283 |
// sort to make sure dialog has correctly filtered content
|
|
284 |
// at the same order as in view
|
36
|
285 |
VideoCollectionViewUtils::sortModel(mModel, false, mListWidget->getLevel());
|
30
|
286 |
}
|
|
287 |
|
|
288 |
// ---------------------------------------------------------------------------
|
|
289 |
// exec
|
|
290 |
// ---------------------------------------------------------------------------
|
|
291 |
//
|
35
|
292 |
void VideoListSelectionDialog::exec()
|
30
|
293 |
{
|
36
|
294 |
FUNC_LOG;
|
34
|
295 |
// clear checkbox
|
|
296 |
mCheckBox->setChecked(false);
|
30
|
297 |
|
34
|
298 |
mListWidget->clearSelection();
|
30
|
299 |
|
34
|
300 |
// scroll list back to top
|
|
301 |
mListWidget->scrollTo(mModel->index(0, 0));
|
30
|
302 |
|
35
|
303 |
if(mModel->rowCount())
|
|
304 |
{
|
|
305 |
connectSignals();
|
30
|
306 |
|
35
|
307 |
// show dialog
|
|
308 |
HbDialog::open();
|
|
309 |
}
|
|
310 |
else
|
|
311 |
{
|
36
|
312 |
INFO("VideoListSelectionDialog::exec(): nothing to show, finishing.")
|
35
|
313 |
// no items, finish right away
|
36
|
314 |
finishedSlot(mPrimaryAction);
|
35
|
315 |
}
|
|
316 |
}
|
|
317 |
|
|
318 |
// ---------------------------------------------------------------------------
|
|
319 |
// finishedSlot
|
|
320 |
// ---------------------------------------------------------------------------
|
|
321 |
//
|
|
322 |
void VideoListSelectionDialog::finishedSlot(HbAction *action)
|
|
323 |
{
|
36
|
324 |
FUNC_LOG;
|
30
|
325 |
disconnectSignals();
|
36
|
326 |
if(action == mSecondaryAction)
|
35
|
327 |
{
|
36
|
328 |
INFO("VideoListSelectionDialog::exec(): secondary action triggered.")
|
35
|
329 |
return;
|
|
330 |
}
|
|
331 |
QString albumName("");
|
|
332 |
if( mTypeOfSelection == ESelectCollection )
|
34
|
333 |
{
|
35
|
334 |
if( mSelectedAlbumId == TMPXItemId::InvalidId())
|
|
335 |
{
|
|
336 |
albumName = queryNewAlbumSelected();
|
|
337 |
if(mSelectedAlbumId == TMPXItemId::InvalidId())
|
34
|
338 |
{
|
36
|
339 |
// user canceled new album creation
|
35
|
340 |
return;
|
|
341 |
}
|
|
342 |
}
|
|
343 |
mTypeOfSelection = EAddToCollection;
|
|
344 |
}
|
36
|
345 |
|
|
346 |
// Must be checked again if type was ESelectCollection
|
35
|
347 |
if(mTypeOfSelection == EAddToCollection)
|
|
348 |
{
|
|
349 |
if(mSelectedAlbumId != TMPXItemId::InvalidId() && mSelectedVideos.count())
|
|
350 |
{
|
|
351 |
if(mModel->addItemsInAlbum(mSelectedAlbumId, mSelectedVideos.toList()) == 0)
|
|
352 |
{
|
|
353 |
if(!albumName.length())
|
34
|
354 |
{
|
35
|
355 |
albumName = getSelectedName();
|
34
|
356 |
}
|
35
|
357 |
QVariant data = albumName;
|
|
358 |
VideoCollectionViewUtils::instance().showStatusMsgSlot(
|
|
359 |
VideoCollectionCommon::statusVideosAddedToCollection,
|
|
360 |
data);
|
34
|
361 |
}
|
|
362 |
}
|
35
|
363 |
}
|
|
364 |
else if(mTypeOfSelection == ERemoveFromCollection)
|
|
365 |
{
|
|
366 |
if(mSelectedAlbumId != TMPXItemId::InvalidId() && mSelectedVideos.count())
|
34
|
367 |
{
|
35
|
368 |
if(mModel->removeItemsFromAlbum(mSelectedAlbumId, mSelectedVideos.toList()) == 0)
|
|
369 |
{
|
|
370 |
QVariant data = getSelectedName();
|
|
371 |
VideoCollectionViewUtils::instance().showStatusMsgSlot(
|
|
372 |
VideoCollectionCommon::statusVideosRemovedFromCollection,
|
|
373 |
data);
|
|
374 |
}
|
34
|
375 |
}
|
35
|
376 |
}
|
|
377 |
// user is deleting videos
|
|
378 |
else if(mTypeOfSelection == EDeleteVideos)
|
|
379 |
{
|
|
380 |
QVariant data = mSelection.indexes().count();
|
|
381 |
VideoCollectionViewUtils::instance().showStatusMsgSlot(
|
|
382 |
VideoCollectionCommon::statusDeleteInProgress,
|
|
383 |
data);
|
|
384 |
// delete items
|
|
385 |
mModel->deleteItems(mSelection.indexes());
|
34
|
386 |
}
|
30
|
387 |
}
|
|
388 |
|
|
389 |
// ---------------------------------------------------------------------------
|
|
390 |
// markAllStateChanged
|
|
391 |
// ---------------------------------------------------------------------------
|
|
392 |
//
|
|
393 |
void VideoListSelectionDialog::markAllStateChangedSlot(int state)
|
34
|
394 |
{
|
36
|
395 |
FUNC_LOG;
|
30
|
396 |
if(mForcedCheck)
|
|
397 |
{
|
|
398 |
return;
|
|
399 |
}
|
36
|
400 |
if(state == Qt::Checked)
|
30
|
401 |
{
|
34
|
402 |
mListWidget->selectAll();
|
30
|
403 |
}
|
|
404 |
else
|
|
405 |
{
|
34
|
406 |
mListWidget->clearSelection();
|
30
|
407 |
}
|
|
408 |
}
|
|
409 |
|
|
410 |
// ---------------------------------------------------------------------------
|
|
411 |
// selectionChangedSlot
|
|
412 |
// ---------------------------------------------------------------------------
|
|
413 |
//
|
|
414 |
void VideoListSelectionDialog::selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected)
|
|
415 |
{
|
36
|
416 |
FUNC_LOG;
|
|
417 |
if(!mPrimaryAction || mTypeOfSelection == ESelectCollection)
|
30
|
418 |
{
|
36
|
419 |
INFO("VideoListSelectionDialog::selectionChangedSlot(): no primary action or we are selecting collection.")
|
30
|
420 |
return;
|
|
421 |
}
|
34
|
422 |
|
30
|
423 |
if(selected.indexes().count() > 0)
|
|
424 |
{
|
|
425 |
mSelection.merge(selected, QItemSelectionModel::Select);
|
|
426 |
}
|
|
427 |
|
|
428 |
if(deselected.indexes().count() > 0)
|
|
429 |
{
|
|
430 |
mSelection.merge(deselected, QItemSelectionModel::Deselect);
|
|
431 |
}
|
|
432 |
|
|
433 |
if(mSelection.indexes().count() > 0)
|
|
434 |
{
|
36
|
435 |
mPrimaryAction->setDisabled(false);
|
30
|
436 |
}
|
|
437 |
else
|
|
438 |
{
|
36
|
439 |
mPrimaryAction->setDisabled(true);
|
30
|
440 |
}
|
|
441 |
|
|
442 |
updateCounterSlot();
|
|
443 |
}
|
|
444 |
|
|
445 |
// ---------------------------------------------------------------------------
|
34
|
446 |
// singleItemSelectedSlot
|
|
447 |
// ---------------------------------------------------------------------------
|
|
448 |
//
|
|
449 |
void VideoListSelectionDialog::singleItemSelectedSlot(const QModelIndex &index)
|
|
450 |
{
|
36
|
451 |
FUNC_LOG;
|
34
|
452 |
if(mTypeOfSelection == ESelectCollection)
|
|
453 |
{
|
|
454 |
if(index.isValid())
|
36
|
455 |
{
|
34
|
456 |
mSelectedAlbumId = mModel->getMediaIdAtIndex(index);
|
36
|
457 |
mPrimaryAction->trigger();
|
34
|
458 |
}
|
|
459 |
}
|
|
460 |
}
|
|
461 |
|
|
462 |
// ---------------------------------------------------------------------------
|
|
463 |
// modelReadySlot
|
|
464 |
// ---------------------------------------------------------------------------
|
|
465 |
//
|
|
466 |
void VideoListSelectionDialog::modelReadySlot()
|
|
467 |
{
|
36
|
468 |
FUNC_LOG;
|
35
|
469 |
if(mTypeOfSelection == ESelectCollection)
|
34
|
470 |
{
|
36
|
471 |
mPrimaryAction->setDisabled(false);
|
35
|
472 |
if(!mModel->rowCount())
|
34
|
473 |
{
|
35
|
474 |
// in case there are no user defined albums,
|
|
475 |
// start input dialog right away by accepting dialog
|
36
|
476 |
INFO("VideoListSelectionDialog::selectionChangedSlot(): no albums, starting album creation.")
|
|
477 |
mPrimaryAction->trigger();
|
35
|
478 |
return;
|
34
|
479 |
}
|
35
|
480 |
}
|
|
481 |
if(mTypeOfSelection != ESelectCollection)
|
|
482 |
{
|
36
|
483 |
mPrimaryAction->setDisabled(true);
|
34
|
484 |
}
|
|
485 |
updateCounterSlot();
|
|
486 |
}
|
|
487 |
|
|
488 |
// ---------------------------------------------------------------------------
|
30
|
489 |
// updateCounterSlot
|
|
490 |
// ---------------------------------------------------------------------------
|
|
491 |
//
|
|
492 |
void VideoListSelectionDialog::updateCounterSlot()
|
|
493 |
{
|
36
|
494 |
FUNC_LOG;
|
35
|
495 |
if(!mItemCount)
|
30
|
496 |
{
|
|
497 |
return;
|
|
498 |
}
|
35
|
499 |
|
|
500 |
int rowCount = mModel->rowCount();
|
30
|
501 |
int selectionCount = mSelection.indexes().count();
|
35
|
502 |
mItemCount->setPlainText(tr("%1/%2").arg(selectionCount).arg(rowCount));
|
30
|
503 |
mForcedCheck = true;
|
|
504 |
if(selectionCount == rowCount && rowCount > 0)
|
|
505 |
{
|
|
506 |
mCheckBox->setChecked(true);
|
|
507 |
}
|
|
508 |
else
|
|
509 |
{
|
|
510 |
mCheckBox->setChecked(false);
|
|
511 |
}
|
|
512 |
mForcedCheck = false;
|
|
513 |
}
|
|
514 |
|
|
515 |
// ---------------------------------------------------------------------------
|
34
|
516 |
// primaryActionTriggeredSlot
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
//
|
|
519 |
void VideoListSelectionDialog::primaryActionTriggeredSlot()
|
|
520 |
{
|
36
|
521 |
FUNC_LOG;
|
34
|
522 |
// reconnect primary action
|
36
|
523 |
mPrimaryAction->disconnect(SIGNAL(triggered()));
|
|
524 |
connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(close()));
|
|
525 |
|
34
|
526 |
// update video items selection here before content changes.
|
|
527 |
int count = mSelection.indexes().count();
|
|
528 |
TMPXItemId id = TMPXItemId::InvalidId();
|
|
529 |
for(int i = 0; i < count; ++i)
|
|
530 |
{
|
|
531 |
id = mModel->getMediaIdAtIndex(mSelection.indexes().at(i));
|
|
532 |
if(id.iId2 == KVcxMvcMediaTypeVideo)
|
|
533 |
{
|
|
534 |
mSelectedVideos.insert(id);
|
|
535 |
}
|
|
536 |
}
|
|
537 |
|
|
538 |
if(mSelectedAlbumId != TMPXItemId::InvalidId())
|
|
539 |
{
|
36
|
540 |
INFO("VideoListSelectionDialog::primaryActionTriggeredSlot(): closing dialog.")
|
|
541 |
mPrimaryAction->trigger();
|
34
|
542 |
return;
|
|
543 |
}
|
|
544 |
else if(mTypeOfSelection == EAddToCollection)
|
|
545 |
{
|
36
|
546 |
INFO("VideoListSelectionDialog::primaryActionTriggeredSlot(): activating collection selection.")
|
34
|
547 |
// videos for collection selected, but collection
|
|
548 |
// not yet selected, activate selection for it
|
|
549 |
mTypeOfSelection = ESelectCollection;
|
|
550 |
activateSelection();
|
|
551 |
}
|
|
552 |
}
|
|
553 |
|
|
554 |
// ---------------------------------------------------------------------------
|
30
|
555 |
// connectSignals
|
|
556 |
// ---------------------------------------------------------------------------
|
|
557 |
//
|
|
558 |
void VideoListSelectionDialog::connectSignals()
|
35
|
559 |
{
|
36
|
560 |
FUNC_LOG;
|
35
|
561 |
// dialog finished
|
|
562 |
connect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
|
|
563 |
|
30
|
564 |
// selection changes
|
34
|
565 |
connect(mListWidget, SIGNAL(activated(const QModelIndex&)),
|
|
566 |
this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
|
|
567 |
|
|
568 |
connect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
|
|
569 |
this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
|
36
|
570 |
|
30
|
571 |
// model changes signals
|
35
|
572 |
connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
|
|
573 |
connect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));
|
30
|
574 |
|
|
575 |
// mark all state changes
|
|
576 |
connect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int)));
|
|
577 |
}
|
|
578 |
|
|
579 |
// ---------------------------------------------------------------------------
|
|
580 |
// disconnectSignals
|
|
581 |
// ---------------------------------------------------------------------------
|
|
582 |
//
|
|
583 |
void VideoListSelectionDialog::disconnectSignals()
|
35
|
584 |
{
|
36
|
585 |
FUNC_LOG;
|
35
|
586 |
disconnect(this, SIGNAL(finished(HbAction*)), this, SLOT(finishedSlot(HbAction*)));
|
|
587 |
|
34
|
588 |
disconnect(mListWidget, SIGNAL(activated(const QModelIndex&)),
|
|
589 |
this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
|
30
|
590 |
|
34
|
591 |
disconnect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
|
30
|
592 |
this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
|
36
|
593 |
|
30
|
594 |
// model changes signals
|
35
|
595 |
disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
|
|
596 |
disconnect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));
|
30
|
597 |
|
|
598 |
// mark all state changes
|
36
|
599 |
disconnect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int)));
|
30
|
600 |
}
|
|
601 |
|
34
|
602 |
// ---------------------------------------------------------------------------
|
|
603 |
// getSelectedName
|
|
604 |
// ---------------------------------------------------------------------------
|
|
605 |
//
|
|
606 |
QString VideoListSelectionDialog::getSelectedName()
|
|
607 |
{
|
36
|
608 |
FUNC_LOG;
|
34
|
609 |
QString name;
|
|
610 |
if(mSelectedAlbumId.iId2 > KVcxMvcMediaTypeVideo)
|
|
611 |
{
|
|
612 |
VideoSortFilterProxyModel *model =
|
|
613 |
VideoCollectionWrapper::instance().getModel(
|
36
|
614 |
VideoCollectionCommon::EModelTypeCollections);
|
34
|
615 |
if(!model)
|
|
616 |
{
|
|
617 |
return name;
|
|
618 |
}
|
|
619 |
QModelIndex index = model->indexOfId(mSelectedAlbumId);
|
|
620 |
if(index.isValid())
|
|
621 |
{
|
36
|
622 |
name = model->data(index, VideoCollectionCommon::KeyTitle).toString();
|
34
|
623 |
}
|
|
624 |
}
|
|
625 |
|
|
626 |
return name;
|
|
627 |
}
|
30
|
628 |
|
34
|
629 |
// ---------------------------------------------------------------------------
|
35
|
630 |
// queryNewAlbumSelected
|
34
|
631 |
// ---------------------------------------------------------------------------
|
|
632 |
//
|
35
|
633 |
QString VideoListSelectionDialog::queryNewAlbumSelected()
|
34
|
634 |
{
|
36
|
635 |
FUNC_LOG;
|
35
|
636 |
mSelectedAlbumId = TMPXItemId::InvalidId();
|
34
|
637 |
bool ok = false;
|
35
|
638 |
QString label(hbTrId("txt_videos_title_enter_name"));
|
|
639 |
QString text("");
|
|
640 |
text = HbInputDialog::getText(label, hbTrId("txt_videos_dialog_entry_new_collection"), &ok);
|
34
|
641 |
if (ok && text.length())
|
|
642 |
{
|
|
643 |
// check for duplicate album name and add new album
|
35
|
644 |
text = mModel->resolveAlbumName(text);
|
|
645 |
mSelectedAlbumId = mModel->addNewAlbum(text);
|
34
|
646 |
}
|
35
|
647 |
return text;
|
34
|
648 |
}
|
|
649 |
|