diff -r bbebb0235466 -r a8ba0c289b44 radioapp/radiowidgets/src/radiostationsview.cpp --- a/radioapp/radiowidgets/src/radiostationsview.cpp Mon Sep 20 18:04:48 2010 +0300 +++ b/radioapp/radiowidgets/src/radiostationsview.cpp Tue Oct 05 09:31:22 2010 +0300 @@ -23,6 +23,7 @@ #include #include #include +#include #include // User includes @@ -34,6 +35,7 @@ #include "radiouiloader.h" #include "radiostationmodel.h" #include "radiostation.h" +#include "radioutil.h" // Constants const char* REGEX_SHOW_FAVORITES = "true"; @@ -46,7 +48,7 @@ RadioViewBase( false ), mModel( 0 ), mScanStationsAction( 0 ), - mClearListAction( 0 ), + mMultiSelectionAction( 0 ), mStationsList( 0 ), mFavoritesButton( 0 ), mLocalStationsButton( 0 ), @@ -222,9 +224,8 @@ if ( !localStationsMode ) { listEmpty = mModel->favoriteCount() == 0; } - - mClearListAction->setEnabled( !listEmpty ); - + mMultiSelectionAction->setEnabled( !listEmpty ); + const bool scanAvailable = mUiEngine->isAntennaAttached() && localStationsMode; mScanStationsAction->setEnabled( scanAvailable ); HbPushButton* scanButton = mUiLoader->findWidget( DOCML::SV_NAME_SCAN_BUTTON ); @@ -237,12 +238,15 @@ * Private slot * */ -void RadioStationsView::clearList() +void RadioStationsView::openMultiSelection() { const bool favoriteMode = mFavoritesButton->isChecked(); - mCurrentQuestion = ClearList; - askQuestion( hbTrId( favoriteMode ? "txt_rad_info_clear_favourite_stations_list" - : "txt_rad_info_clear_all_stations_list" ) ); + mCurrentQuestion = MultiSelection; + showSelectionDialog( mFilterModel , + hbTrId( favoriteMode ? "txt_fmradio_title_remove_favorites" + : "txt_fmradio_title_delete_stations" ), + hbTrId( favoriteMode ? "txt_common_button_remove" + : "txt_common_button_delete_toolbar" ) ); } /*! @@ -298,6 +302,10 @@ { HbInputDialog* dlg = static_cast( sender() ); + if ( dlg->actions().first() != action ) { + return; + } + if( action ) { mModel->renameStation( mSelectedStation->presetIndex(), dlg->value().toString() ); } @@ -364,10 +372,10 @@ Radio::connect( mScanStationsAction, SIGNAL(triggered() ), this, SLOT(startScanning() ) ); - // "Remove all presets" menu item - mClearListAction = mUiLoader->findObject( DOCML::SV_NAME_CLEAR_LIST_ACTION ); - Radio::connect( mClearListAction, SIGNAL(triggered() ), - this, SLOT(clearList() ) ); + // menu item for opening selection dialog + mMultiSelectionAction = mUiLoader->findObject( DOCML::SV_NAME_MULTI_SELECTION_ACTION ); + Radio::connect( mMultiSelectionAction, SIGNAL(triggered() ), + this, SLOT(openMultiSelection() ) ); connectCommonMenuItem( MenuItem::UseLoudspeaker ); @@ -390,14 +398,31 @@ this, SLOT(finishScanning()) ); mFrequencyScanner->startScanning(); - } else if ( mCurrentQuestion == ClearList ){ - const bool favoriteMode = mFavoritesButton->isChecked(); - mModel->removeAll( favoriteMode ? RadioStationModel::RemoveFavorites : RadioStationModel::RemoveAll ); - updateVisibilities(); } else if ( mCurrentQuestion == DeleteStation ) { mModel->removeStation( *mSelectedStation ); + } else if ( mCurrentQuestion == MultiSelection ) { + HbSelectionDialog* dlg = static_cast( sender() ); + if( dlg ) { + QModelIndexList selected = dlg->selectedModelIndexes(); + const bool favoriteMode = mFavoritesButton->isChecked(); + int count = selected.count(); + if( count == mFilterModel->rowCount() ) { + // delete or remove all + mModel->removeAll( favoriteMode ? RadioStationModel::RemoveFavorites : RadioStationModel::RemoveAll ); + } else { + // delete or remove selected, one by one. + RadioStation station; + QModelIndexList sourceIndices; + RadioUtil::mapToSource(selected, sourceIndices, mFilterModel ); + mModel->removeByModelIndices( sourceIndices, favoriteMode ); + } + QString msg = hbTrId(favoriteMode ? "txt_rad_dpophead_l1_favorite_removed" : + "txt_rad_dpophead_l1_station_deleted", count ); + RadioUtil::showDiscreetNote( msg ); + + } } - + updateVisibilities(); mCurrentQuestion = NoQuestion; }