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