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