344 mListWidget->clearSelection(); |
349 mListWidget->clearSelection(); |
345 |
350 |
346 // scroll list back to top |
351 // scroll list back to top |
347 mListWidget->scrollTo(mModel->index(0, 0)); |
352 mListWidget->scrollTo(mModel->index(0, 0)); |
348 |
353 |
|
354 connectSignals(); |
|
355 |
349 if(mModel->rowCount()) |
356 if(mModel->rowCount()) |
350 { |
357 { |
351 connectSignals(); |
|
352 |
|
353 if(mTypeOfSelection == ECreateCollection) |
358 if(mTypeOfSelection == ECreateCollection) |
354 { |
359 { |
355 // note this does not leak memory as the dialog will destroy itself upon close. |
360 // note this does not leak memory as the dialog will destroy itself upon close. |
356 HbInputDialog *dialog = gCreateNewAlbumNameDialog(LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION); |
361 HbInputDialog *dialog = gCreateNewAlbumNameDialog(LIST_VIEW_OBJECT_NAME_CREATE_COLLECTION); |
357 dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *))); |
362 dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *))); |
360 { |
365 { |
361 // show dialog |
366 // show dialog |
362 HbDialog::open(); |
367 HbDialog::open(); |
363 } |
368 } |
364 } |
369 } |
365 else |
370 else if((mModelReady && mTypeOfSelection != ESelectCollection) || |
|
371 (mAlbumListReady && mTypeOfSelection == ESelectCollection)) |
366 { |
372 { |
367 INFO("VideoListSelectionDialog::exec(): nothing to show, finishing.") |
373 INFO("VideoListSelectionDialog::exec(): nothing to show, finishing.") |
368 // no items, finish right away |
374 // no items, finish right away |
369 finishedSlot(mPrimaryAction); |
375 finishedSlot(mPrimaryAction); |
370 } |
376 } |
387 if(mTypeOfSelection == ESelectCollection) |
393 if(mTypeOfSelection == ESelectCollection) |
388 { |
394 { |
389 mTypeOfSelection = EAddToCollection; |
395 mTypeOfSelection = EAddToCollection; |
390 if(mSelectedAlbumId == TMPXItemId::InvalidId()) |
396 if(mSelectedAlbumId == TMPXItemId::InvalidId()) |
391 { |
397 { |
|
398 close(); // closes selection dialog if it's open. |
|
399 |
392 // note this does not leak memory as the dialog will destroy itself upon close. |
400 // note this does not leak memory as the dialog will destroy itself upon close. |
393 HbInputDialog *dialog = gCreateNewAlbumNameDialog(SELECTION_DIALOG_OBJECT_NAME_NEW_COLLECTION); |
401 HbInputDialog *dialog = gCreateNewAlbumNameDialog(SELECTION_DIALOG_OBJECT_NAME_NEW_COLLECTION); |
394 dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *))); |
402 dialog->open(this, SLOT(newAlbumNameDialogFinished(HbAction *))); |
395 } |
403 } |
396 else |
404 else |
418 QVariant variant = dialog->value(); |
426 QVariant variant = dialog->value(); |
419 |
427 |
420 if(dialog->actions().first() == action && variant.isValid()) |
428 if(dialog->actions().first() == action && variant.isValid()) |
421 { |
429 { |
422 QString text = mModel->resolveAlbumName(variant.toString()); |
430 QString text = mModel->resolveAlbumName(variant.toString()); |
423 if(text.length()) |
431 if(!text.isEmpty()) |
424 { |
432 { |
425 if(mSelectedVideos.count() == 0) |
433 if(mSelectedVideos.count() == 0) |
426 { |
434 { |
427 mNewAlbumText = text; |
435 mNewAlbumText = text; |
428 // show video selection dialog |
436 // show video selection dialog |
584 // --------------------------------------------------------------------------- |
602 // --------------------------------------------------------------------------- |
585 // |
603 // |
586 void VideoListSelectionDialog::modelReadySlot() |
604 void VideoListSelectionDialog::modelReadySlot() |
587 { |
605 { |
588 FUNC_LOG; |
606 FUNC_LOG; |
|
607 mModelReady = true; |
|
608 |
|
609 if(mTypeOfSelection != ESelectCollection) |
|
610 { |
|
611 if(!mModel->rowCount()) |
|
612 { |
|
613 // no items, finish right away |
|
614 INFO("VideoListSelectionDialog::modelReadySlot(): nothing to show, finishing."); |
|
615 |
|
616 if(mTypeOfSelection == EAddToCollection || |
|
617 mTypeOfSelection == ERemoveFromCollection) |
|
618 { |
|
619 primaryActionTriggeredSlot(); |
|
620 } |
|
621 else |
|
622 { |
|
623 finishedSlot(mPrimaryAction); |
|
624 } |
|
625 |
|
626 return; |
|
627 } |
|
628 |
|
629 // if dialog is not yet visible, bring it visible. |
|
630 if(!isVisible() && mTypeOfSelection != ECreateCollection) |
|
631 { |
|
632 // scroll list back to top |
|
633 mListWidget->scrollTo(mModel->index(0, 0)); |
|
634 |
|
635 HbDialog::open(); |
|
636 } |
|
637 |
|
638 updateCounterSlot(); |
|
639 } |
|
640 } |
|
641 |
|
642 // --------------------------------------------------------------------------- |
|
643 // albumListReadySlot |
|
644 // --------------------------------------------------------------------------- |
|
645 // |
|
646 void VideoListSelectionDialog::albumListReadySlot() |
|
647 { |
|
648 mAlbumListReady = true; |
|
649 |
589 if(mTypeOfSelection == ESelectCollection) |
650 if(mTypeOfSelection == ESelectCollection) |
590 { |
651 { |
591 if(!mModel->rowCount()) |
652 if(!mModel->rowCount()) |
592 { |
653 { |
593 // in case there are no user defined albums, |
654 finishedSlot(mPrimaryAction); |
594 // start input dialog right away by accepting dialog |
|
595 INFO("VideoListSelectionDialog::selectionChangedSlot(): no albums, starting album creation.") |
|
596 mPrimaryAction->trigger(); |
|
597 return; |
655 return; |
598 } |
656 } |
599 } |
657 |
600 updateCounterSlot(); |
658 // if dialog is not yet visible, bring it visible. |
|
659 if(!isVisible()) |
|
660 { |
|
661 // scroll list back to top |
|
662 mListWidget->scrollTo(mModel->index(0, 0)); |
|
663 |
|
664 HbDialog::open(); |
|
665 } |
|
666 |
|
667 updateCounterSlot(); |
|
668 } |
601 } |
669 } |
602 |
670 |
603 // --------------------------------------------------------------------------- |
671 // --------------------------------------------------------------------------- |
604 // updateCounterSlot |
672 // updateCounterSlot |
605 // --------------------------------------------------------------------------- |
673 // --------------------------------------------------------------------------- |
637 // reconnect primary action |
705 // reconnect primary action |
638 mPrimaryAction->disconnect(SIGNAL(triggered())); |
706 mPrimaryAction->disconnect(SIGNAL(triggered())); |
639 connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(close())); |
707 connect(mPrimaryAction, SIGNAL(triggered()), this, SLOT(close())); |
640 |
708 |
641 // update video items selection here before content changes. |
709 // update video items selection here before content changes. |
642 int count = mSelection.indexes().count(); |
710 QModelIndexList indexes = mSelection.indexes(); |
|
711 int count = indexes.count(); |
643 TMPXItemId id = TMPXItemId::InvalidId(); |
712 TMPXItemId id = TMPXItemId::InvalidId(); |
644 for(int i = 0; i < count; ++i) |
713 for(int i = 0; i < count; ++i) |
645 { |
714 { |
646 id = mModel->getMediaIdAtIndex(mSelection.indexes().at(i)); |
715 id = mModel->getMediaIdAtIndex(indexes.at(i)); |
647 if(id.iId2 == KVcxMvcMediaTypeVideo) |
716 if(id.iId2 == KVcxMvcMediaTypeVideo) |
648 { |
717 { |
649 mSelectedVideos.insert(id); |
718 mSelectedVideos.insert(id); |
650 } |
719 } |
651 } |
720 } |
683 |
752 |
684 connect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)), |
753 connect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)), |
685 this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &))); |
754 this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &))); |
686 |
755 |
687 // model changes signals |
756 // model changes signals |
688 connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot())); |
757 connect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot())); |
689 connect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot())); |
758 connect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot())); |
|
759 connect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot())); |
690 |
760 |
691 // mark all state changes |
761 // mark all state changes |
692 connect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int))); |
762 connect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int))); |
693 } |
763 } |
694 |
764 |
707 disconnect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)), |
777 disconnect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)), |
708 this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &))); |
778 this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &))); |
709 |
779 |
710 // model changes signals |
780 // model changes signals |
711 disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot())); |
781 disconnect(mModel->sourceModel(), SIGNAL(modelReady()), this, SLOT(modelReadySlot())); |
|
782 disconnect(mModel->sourceModel(), SIGNAL(albumListReady()), this, SLOT(albumListReadySlot())); |
712 disconnect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot())); |
783 disconnect(mModel->sourceModel(), SIGNAL(modelChanged()), this, SLOT(updateCounterSlot())); |
713 |
784 |
714 // mark all state changes |
785 // mark all state changes |
715 disconnect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int))); |
786 disconnect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int))); |
716 } |
787 } |