mpviewplugins/mpcollectionviewplugin/src/mpcollectionpopuphandler.cpp
changeset 51 560ce2306a17
parent 43 0f32e550d9d8
child 55 f3930dda3342
equal deleted inserted replaced
47:4cc1412daed0 51:560ce2306a17
   365     TX_ENTRY
   365     TX_ENTRY
   366     mPermanentData->mIsolatedCollectionData = collectionData;
   366     mPermanentData->mIsolatedCollectionData = collectionData;
   367     MpCollectionDataModel *collectionDataModel;
   367     MpCollectionDataModel *collectionDataModel;
   368     collectionDataModel = new MpCollectionDataModel( collectionData );
   368     collectionDataModel = new MpCollectionDataModel( collectionData );
   369     collectionDataModel->refreshModel();
   369     collectionDataModel->refreshModel();
       
   370     mPermanentData->mAbstractItemModel = collectionDataModel;
   370 
   371 
   371     getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), collectionDataModel, 
   372     getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), collectionDataModel, 
   372                      SLOT( handleAddToCurrentPlaylist( HbAction* ) ) );
   373                      SLOT( handleAddToCurrentPlaylist( HbAction* ) ) );
   373     TX_EXIT
   374     TX_EXIT
   374 }
   375 }
   640         else {
   641         else {
   641             mPermanentData->clear();
   642             mPermanentData->clear();
   642         }
   643         }
   643     }
   644     }
   644 
   645 
   645     //Dialog is using CollectionView main model, avoid dialog destructor to alter it.
   646     //Dialog won't use CollectionView main model any more, return it to its original layout.
   646     dialog->setModel( 0 );
   647     MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( dialog->model() );
   647 
   648     if ( mpModel ) {
       
   649         //setLayout() only applies for MpCollectionDataModel where we need to 
       
   650         //decide which layout to use for the secondary text.
       
   651         //MpCollectionTBoneListDataModel doesn't have secondary text.
       
   652         mpModel->setLayout( ECollectionListView );
       
   653     }
   648     TX_EXIT
   654     TX_EXIT
   649 }
   655 }
   650 
   656 
   651 /*!
   657 /*!
   652  Slot to be called when select songs dialog (getModelIndexes) has finished, coming from DeleteSongs.
   658  Slot to be called when select songs dialog (getModelIndexes) has finished, coming from DeleteSongs.
   670                 requestDelete( selection );
   676                 requestDelete( selection );
   671             }
   677             }
   672         }
   678         }
   673     }
   679     }
   674 
   680 
   675     //Dialog is using CollectionView main model, avoid dialog destructor to alter it.
   681     //Dialog won't use CollectionView main model any more, return it to its original layout.
   676     dialog->setModel( 0 );
   682     MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( dialog->model() );
   677 
   683     if ( mpModel ) {
       
   684         //setLayout() only applies for MpCollectionDataModel where we need to 
       
   685         //decide which layout to use for the secondary text.
       
   686         //MpCollectionTBoneListDataModel doesn't have secondary text.
       
   687         mpModel->setLayout( ECollectionListView );
       
   688     }
   678     TX_EXIT
   689     TX_EXIT
   679 }
   690 }
   680 
   691 
   681 /*!
   692 /*!
   682  Slot to be called when select songs dialog (getModelIndexes) has finished, coming from AddToCurrentPlaylist.
   693  Slot to be called when select songs dialog (getModelIndexes) has finished, coming from AddToCurrentPlaylist.
   701                         mPermanentData->mIsolatedCollectionData );
   712                         mPermanentData->mIsolatedCollectionData );
   702             }
   713             }
   703         }
   714         }
   704     }
   715     }
   705 
   716 
   706     //Pull the model to delete it. Dialog destructor only removes items from model, but doesn't delete them.
   717     //Dialog is using an isolated model which will be deleted, no need to change its layout.
   707     mPermanentData->mAbstractItemModel = dialog->model();
       
   708     dialog->setModel( 0 );
       
   709 
       
   710     mPermanentData->clear();
   718     mPermanentData->clear();
   711 
   719 
   712     TX_EXIT
   720     TX_EXIT
   713 }
   721 }
   714 
   722 
   772             mMpEngine->createPlaylist( mPermanentData->mOriginalName, selection,
   780             mMpEngine->createPlaylist( mPermanentData->mOriginalName, selection,
   773                     mPermanentData->mIsolatedCollectionData );
   781                     mPermanentData->mIsolatedCollectionData );
   774         }
   782         }
   775     }
   783     }
   776 
   784 
   777     dialog->setModel( 0 );
   785     //Dialog is using an isolated model which will be deleted, no need to change its layout.
   778 
       
   779     mPermanentData->clear();
   786     mPermanentData->clear();
   780 
   787 
   781     TX_EXIT
   788     TX_EXIT
   782 }
   789 }
   783 
   790 
   831         if (count >= KSongsToDisplayProgressDlg) {  //show progress dialog if removing more than 100 songs
   838         if (count >= KSongsToDisplayProgressDlg) {  //show progress dialog if removing more than 100 songs
   832             launchProgressDialog( "txt_mus_info_removing_songs" );
   839             launchProgressDialog( "txt_mus_info_removing_songs" );
   833         }
   840         }
   834     }
   841     }
   835     else if (context != ECollectionContextPlaylists ) {  //no progress dialog for delete playlist
   842     else if (context != ECollectionContextPlaylists ) {  //no progress dialog for delete playlist
   836         launchProgressDialog( "txt_mus_info_deleting" );
   843         launchProgressDialog( "txt_common_info_deleting" );
   837     }
   844     }
   838     TX_EXIT
   845     TX_EXIT
   839 }
   846 }
   840 
   847 
   841 /*!
   848 /*!
  1019 
  1026 
  1020     HbAction *action;
  1027     HbAction *action;
  1021     HbSelectionDialog *dialog = new HbSelectionDialog();
  1028     HbSelectionDialog *dialog = new HbSelectionDialog();
  1022     dialog->setHeadingWidget( new HbLabel( label ) );
  1029     dialog->setHeadingWidget( new HbLabel( label ) );
  1023     dialog->setSelectionMode( HbAbstractItemView::MultiSelection );
  1030     dialog->setSelectionMode( HbAbstractItemView::MultiSelection );
       
  1031     MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( model );
       
  1032     if ( mpModel ) {
       
  1033         //setLayout() only applies for MpCollectionDataModel where we need to 
       
  1034         //decide which layout to use for the secondary text.
       
  1035         //MpCollectionTBoneListDataModel doesn't have secondary text.
       
  1036         mpModel->setLayout( ECollectionSelectionDialog );
       
  1037     }
  1024     dialog->setModel( model );
  1038     dialog->setModel( model );
  1025     dialog->clearActions();
  1039     dialog->clearActions();
  1026     action = new HbAction( hbTrId( "txt_common_button_ok" ) );
  1040     action = new HbAction( hbTrId( "txt_common_button_ok" ) );
  1027     action->setObjectName( KOk );
  1041     action->setObjectName( KOk );
  1028     dialog->addAction( action );
  1042     dialog->addAction( action );
  1053     scrollbar->show();
  1067     scrollbar->show();
  1054     scrollbar->setInteractive( true);
  1068     scrollbar->setInteractive( true);
  1055     listView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
  1069     listView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
  1056     MpCollectionDataModel *model;
  1070     MpCollectionDataModel *model;
  1057     //Ownership of the model is passed to the listView as a child object.
  1071     //Ownership of the model is passed to the listView as a child object.
  1058     model = new MpCollectionDataModel( mMpEngine->collectionData() , listView );
  1072     model = new MpCollectionDataModel( mMpEngine->collectionData() , mMpEngine->playbackData(), listView );
  1059     model->refreshModel();
  1073     model->refreshModel();
  1060     connect( model,
  1074     connect( model,
  1061              SIGNAL( orderChanged( int, int, int, int ) ),
  1075              SIGNAL( orderChanged( int, int, int, int ) ),
  1062              mMpEngine,
  1076              mMpEngine,
  1063              SLOT( reorderPlaylist( int, int, int, int ) ) );
  1077              SLOT( reorderPlaylist( int, int, int, int ) ) );
       
  1078     MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( model );
       
  1079     if ( mpModel ) {
       
  1080         //setLayout() only applies for MpCollectionDataModel where we need to 
       
  1081         //decide which layout to use for the secondary text.
       
  1082         //MpCollectionTBoneListDataModel doesn't have secondary text.
       
  1083         mpModel->setLayout( ECollectionArrangeSongsDialog );
       
  1084     }
  1064     listView->setModel( model );
  1085     listView->setModel( model );
  1065     listView->setArrangeMode( true );
  1086     listView->setArrangeMode( true );
  1066     HbDialog *dialog = new HbDialog();
  1087     HbDialog *dialog = new HbDialog();
  1067     dialog->setDismissPolicy( HbPopup::NoDismiss );
  1088     dialog->setDismissPolicy( HbPopup::NoDismiss );
  1068     dialog->setTimeout( HbPopup::NoTimeout );
  1089     dialog->setTimeout( HbPopup::NoTimeout );