mpviewplugins/mpcollectionviewplugin/src/mpcollectionpopuphandler.cpp
changeset 41 ea59c434026a
parent 29 8192e5b5c935
child 43 0f32e550d9d8
equal deleted inserted replaced
32:c163ef0b758d 41:ea59c434026a
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 #include <hbaction.h>
    19 #include <hbaction.h>
    20 #include <hbmenu.h>
    20 #include <hbmenu.h>
    21 #include <hbmessagebox.h>
    21 #include <hbmessagebox.h>
       
    22 #include <hbprogressdialog.h>
    22 #include <hbselectiondialog.h>
    23 #include <hbselectiondialog.h>
    23 #include <hbinputdialog.h>
    24 #include <hbinputdialog.h>
    24 #include <hblabel.h>
    25 #include <hblabel.h>
    25 #include <hblistview.h>
    26 #include <hblistview.h>
    26 #include <hbscrollbar.h>
    27 #include <hbscrollbar.h>
    28 #include "mpenginefactory.h"
    29 #include "mpenginefactory.h"
    29 #include "mpcollectionview.h"
    30 #include "mpcollectionview.h"
    30 #include "mpmpxcollectiondata.h"
    31 #include "mpmpxcollectiondata.h"
    31 #include "mpcollectiondatamodel.h"
    32 #include "mpcollectiondatamodel.h"
    32 #include "mpcollectiontbonelistdatamodel.h"
    33 #include "mpcollectiontbonelistdatamodel.h"
    33 #include "mpmpxcollectionviewdefs.h"
       
    34 #include "mpcollectionpopuphandler.h"
    34 #include "mpcollectionpopuphandler.h"
    35 #include "mptrace.h"
    35 #include "mptrace.h"
    36 
    36 
    37 const int KNullIndex = -1;
    37 const int KNullIndex = -1;
       
    38 const int KSongsToDisplayProgressDlg = 100;
       
    39 
       
    40 // Popups launched by this class
       
    41 const QString KContextMenu = QString( "ContextMenu" );
       
    42 const QString KProgressDialog = QString( "ProgressDialog" );
       
    43 const QString KAddToPlaylistSelectionDialog = QString( "AddToPlaylistSelectionDialog" );
       
    44 const QString KInputTextDialog = QString( "InputTextDialog" );
       
    45 const QString KGetModelIndexesListDialog = QString( "GetModelIndexesListDialog" );
       
    46 const QString KArrangeSongsDialog = QString( "ArrangeSongsDialog" );
       
    47 const QString KRequestDeleteMessageBox = QString( "RequestDeleteMessageBox" );
       
    48 
       
    49 // Popups Actions
       
    50 const QString KOk = QString( "Ok" );
       
    51 const QString KCancel = QString( "Cancel" );
       
    52 const QString KNew = QString( "New" );
       
    53 const QString KOpen = QString( "Open" );
       
    54 const QString KAdd = QString( "Add" );
       
    55 const QString KDelete = QString( "Delete" );
       
    56 const QString KRenamePlayList = QString( "RenamePlayList" );
       
    57 
       
    58 
       
    59 //------------------------------------------------------------------
       
    60 //    MpPopupHandlerPermanentData
       
    61 //------------------------------------------------------------------
       
    62 
       
    63 /*!
       
    64     \class MpPopupHandlerPermanentData. This class is used by MpCollectionPopupHandler to
       
    65     store permanent data needed during asynchronous popups operation.
       
    66 
       
    67 */
       
    68 
       
    69 class MpPopupHandlerPermanentData : public QObject
       
    70 {
       
    71     public:
       
    72         MpPopupHandlerPermanentData( QObject *parent=0 );
       
    73         virtual ~MpPopupHandlerPermanentData();
       
    74         void clear();
       
    75     public:
       
    76         MpMpxCollectionData         *mIsolatedCollectionData;        // Not own
       
    77         QAbstractItemModel          *mAbstractItemModel;             // Own
       
    78         QList<int>                  mSelectedItems;
       
    79         QString                     mOriginalName;
       
    80         int                         mContextMenuIndex;
       
    81 };
       
    82 
       
    83 /*!
       
    84  Constructs the popup handler permanent data.
       
    85  */
       
    86 MpPopupHandlerPermanentData::MpPopupHandlerPermanentData( QObject *parent )
       
    87     : QObject( parent ),
       
    88       mIsolatedCollectionData( 0 ),
       
    89       mAbstractItemModel( 0 ),
       
    90       mContextMenuIndex( KNullIndex )
       
    91 {
       
    92       TX_ENTRY
       
    93       mSelectedItems.clear();
       
    94       mOriginalName.clear();
       
    95       TX_EXIT
       
    96 }
       
    97 
       
    98 /*!
       
    99  Destructs the popup handler permanent data.
       
   100  */
       
   101 MpPopupHandlerPermanentData::~MpPopupHandlerPermanentData()
       
   102 {
       
   103     TX_ENTRY
       
   104     clear();
       
   105     TX_EXIT
       
   106 }
       
   107 
       
   108 /*!
       
   109  \internal
       
   110   Clears all permanent data. 
       
   111  */
       
   112 void MpPopupHandlerPermanentData::clear()
       
   113 {
       
   114     TX_ENTRY
       
   115     mSelectedItems.clear();
       
   116     mOriginalName.clear();
       
   117     mContextMenuIndex = KNullIndex;
       
   118     if ( mIsolatedCollectionData ) {
       
   119         MpEngineFactory::sharedEngine()->releaseIsolatedCollection();
       
   120         mIsolatedCollectionData = 0;
       
   121     }
       
   122     if ( mAbstractItemModel ) {
       
   123         delete mAbstractItemModel;
       
   124         mAbstractItemModel = 0;
       
   125     }
       
   126     //clearing any child Objects.
       
   127     foreach (QObject* child, children()) {
       
   128         child->deleteLater();
       
   129     }
       
   130     TX_EXIT
       
   131 }
       
   132 
       
   133 
       
   134 //------------------------------------------------------------------
       
   135 //    MpCollectionPopupHandler
       
   136 //------------------------------------------------------------------
    38 
   137 
    39 /*!
   138 /*!
    40     \class MpCollectionPopupHandler
   139     \class MpCollectionPopupHandler
    41     \brief Music Player collection popup handler.
   140     \brief Music Player collection popup handler.
    42 
   141 
    50 MpCollectionPopupHandler::MpCollectionPopupHandler( MpCollectionView *parent )
   149 MpCollectionPopupHandler::MpCollectionPopupHandler( MpCollectionView *parent )
    51     : QObject( parent ),
   150     : QObject( parent ),
    52       mView( parent ),
   151       mView( parent ),
    53       mOutstandingPopup( 0 ),
   152       mOutstandingPopup( 0 ),
    54       mMpEngine( 0 ),
   153       mMpEngine( 0 ),
    55       mPermanentData( 0 )
   154       mPermanentData( 0 ),
       
   155       mExternalEventsConnected( false )
    56 {
   156 {
    57     TX_ENTRY
   157     TX_ENTRY
    58     mMpEngine = MpEngineFactory::sharedEngine();
   158     mMpEngine = MpEngineFactory::sharedEngine();
    59     mPermanentData = new MpPopupHandlerPermanentData( this );
   159     mPermanentData = new MpPopupHandlerPermanentData( this );
    60     TX_EXIT
   160     TX_EXIT
    74  Default view context menu.
   174  Default view context menu.
    75  */
   175  */
    76 void MpCollectionPopupHandler::openDefaultViewContextMenu( int index, const QPointF &coords )
   176 void MpCollectionPopupHandler::openDefaultViewContextMenu( int index, const QPointF &coords )
    77 {
   177 {
    78     TX_ENTRY
   178     TX_ENTRY
    79     HbMenu *contextMenu = 0;
   179 
    80     HbAction *action;
   180     if ( mView->isActivated() ) {
    81     bool usbBlocked = mMpEngine->verifyUsbBlocking();
   181 
    82 
   182         HbMenu *contextMenu = 0;
    83     switch ( mMpEngine->collectionData()->context() ) {
   183         HbAction *action;
    84         case ECollectionContextAllSongs:
   184         bool usbBlocked = mMpEngine->verifyUsbBlocking();
    85         case ECollectionContextArtistAllSongs:
   185 
    86         case ECollectionContextArtistAlbumsTBone:
   186         switch ( mMpEngine->collectionData()->context() ) {
    87         case ECollectionContextAlbumsTBone:
   187             case ECollectionContextAllSongs:
    88             contextMenu = new HbMenu();
   188             case ECollectionContextArtistAllSongs:
    89             action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) );
   189             case ECollectionContextArtistAlbumsTBone:
    90             action->setObjectName( "open" );
   190             case ECollectionContextAlbumsTBone:
    91             action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) );
   191                 contextMenu = new HbMenu();
    92             action->setObjectName( "add" );
   192                 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) );
    93             action->setEnabled( !usbBlocked );
   193                 action->setObjectName( KOpen );
    94             action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
   194                 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) );
    95             action->setObjectName( "delete" );
   195                 action->setObjectName( KAdd );
    96             action->setEnabled( !usbBlocked );
   196                 action->setEnabled( !usbBlocked );
    97             break;
   197                 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
    98         case ECollectionContextAlbums:
   198                 action->setObjectName( KDelete );
    99         case ECollectionContextArtists:
   199                 action->setEnabled( !usbBlocked );
   100         case ECollectionContextArtistAlbums:
   200                 break;
   101             contextMenu = new HbMenu();
   201             case ECollectionContextAlbums:
   102             action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) );
   202             case ECollectionContextArtists:
   103             action->setObjectName( "open" );
   203             case ECollectionContextArtistAlbums:
   104             action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) );
       
   105             action->setObjectName( "add" );
       
   106             action->setEnabled( !usbBlocked );
       
   107             action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
       
   108             action->setObjectName( "delete" );
       
   109             action->setEnabled( !usbBlocked );
       
   110             break;
       
   111         case ECollectionContextPlaylists:
       
   112             if ( !mMpEngine->collectionData()->isAutoPlaylist( index ) ) {
       
   113                 contextMenu = new HbMenu();
   204                 contextMenu = new HbMenu();
   114                 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) );
   205                 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) );
   115                 action->setObjectName( "open" );
   206                 action->setObjectName( KOpen );
       
   207                 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) );
       
   208                 action->setObjectName( KAdd );
       
   209                 action->setEnabled( !usbBlocked );
   116                 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
   210                 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
   117                 action->setObjectName("delete");
   211                 action->setObjectName( KDelete );
   118                 action->setEnabled( !usbBlocked );
   212                 action->setEnabled( !usbBlocked );
   119                 action = contextMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) );
   213                 break;
   120                 action->setObjectName( "rename playlist" );
   214             case ECollectionContextPlaylists:
   121                 action->setEnabled( !usbBlocked );
   215                 if ( !mMpEngine->collectionData()->isAutoPlaylist( index ) ) {
   122             }
   216                     contextMenu = new HbMenu();
   123             break;
   217                     action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) );
   124         case ECollectionContextPlaylistSongs:
   218                     action->setObjectName( KOpen );
   125             if ( !mMpEngine->collectionData()->isAutoPlaylist() ) {
   219                     action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) );
       
   220                     action->setObjectName(KDelete);
       
   221                     action->setEnabled( !usbBlocked );
       
   222                     action = contextMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) );
       
   223                     action->setObjectName( KRenamePlayList );
       
   224                     action->setEnabled( !usbBlocked );
       
   225                 }
       
   226                 break;
       
   227             case ECollectionContextPlaylistSongs:
       
   228                 if ( !mMpEngine->collectionData()->isAutoPlaylist() ) {
       
   229                     contextMenu = new HbMenu();
       
   230                     action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) );
       
   231                     action->setObjectName( KOpen );
       
   232                     action = contextMenu->addAction( hbTrId( "txt_common_menu_remove" ) );
       
   233                     action->setObjectName( KDelete );
       
   234                     action->setEnabled( !usbBlocked );
       
   235                 }
       
   236                 break;
       
   237             default:
       
   238                 break;
       
   239         }
       
   240 
       
   241         if ( contextMenu ) {
       
   242             mPermanentData->mContextMenuIndex = index;
       
   243             contextMenu->setPreferredPos( coords );
       
   244             contextMenu->setObjectName( KContextMenu );
       
   245             contextMenu->setAttribute( Qt::WA_DeleteOnClose );
       
   246             setOutstandingPopup( contextMenu );
       
   247             contextMenu->open( this, SLOT( defaultContextMenuOptionSelected( HbAction* ) ) );
       
   248         }
       
   249     }
       
   250 
       
   251     TX_EXIT
       
   252 }
       
   253 
       
   254 /*!
       
   255  Fetch view context menu
       
   256  */
       
   257 void MpCollectionPopupHandler::openFetchViewContextMenu( int index, const QPointF &coords )
       
   258 {
       
   259     TX_ENTRY_ARGS( "index=" << index );
       
   260 
       
   261     if ( mView->isActivated() ) {
       
   262 
       
   263         HbAction *action;
       
   264         HbMenu *contextMenu = 0;
       
   265 
       
   266         switch ( mMpEngine->collectionData()->context() ) {
       
   267             case ECollectionContextAllSongs:
       
   268             case ECollectionContextArtistAlbumsTBone:
       
   269             case ECollectionContextArtistAllSongs:
       
   270             case ECollectionContextAlbumsTBone:
       
   271             case ECollectionContextPlaylistSongs:
   126                 contextMenu = new HbMenu();
   272                 contextMenu = new HbMenu();
   127                 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) );
   273                 action = contextMenu->addAction( hbTrId("txt_common_menu_play_music") );
   128                 action->setObjectName( "open" );
   274                 action->setEnabled( !mMpEngine->verifyUsbBlocking() );
   129                 action = contextMenu->addAction( hbTrId( "txt_common_menu_remove" ) );
   275                 break;
   130                 action->setObjectName( "delete" );
   276             default:
   131                 action->setEnabled( !usbBlocked );
   277                 break;
   132             }
   278         }
   133             break;
   279 
   134         default:
   280         if ( contextMenu ) {
   135             break;
       
   136     }
       
   137 
       
   138     if ( contextMenu ) {
       
   139         if ( mView->isActivated() ) {
       
   140             mPermanentData->mContextMenuIndex = index;
   281             mPermanentData->mContextMenuIndex = index;
   141             contextMenu->setPreferredPos( coords );
   282             contextMenu->setPreferredPos( coords );
   142             contextMenu->setAttribute( Qt::WA_DeleteOnClose );
   283             contextMenu->setAttribute( Qt::WA_DeleteOnClose );
       
   284             contextMenu->setObjectName( KContextMenu );
   143             setOutstandingPopup( contextMenu );
   285             setOutstandingPopup( contextMenu );
   144             contextMenu->open( this, SLOT( defaultContextMenuOptionSelected( HbAction* ) ) );
   286             contextMenu->open( this, SLOT( fetcherContextMenuOptionSelected( HbAction* ) ) );
   145         }
       
   146         else {
       
   147             delete contextMenu;
       
   148             contextMenu = 0;
       
   149         }
       
   150     }
       
   151 
       
   152     TX_EXIT
       
   153 }
       
   154 
       
   155 /*!
       
   156  Fetch view context menu
       
   157  */
       
   158 void MpCollectionPopupHandler::openFetchViewContextMenu( int index, const QPointF &coords )
       
   159 {
       
   160     TX_ENTRY_ARGS( "index=" << index );
       
   161 
       
   162     HbAction *action;
       
   163     HbMenu *contextMenu = 0;
       
   164 
       
   165     switch ( mMpEngine->collectionData()->context() ) {
       
   166         case ECollectionContextAllSongs:
       
   167         case ECollectionContextArtistAlbumsTBone:
       
   168         case ECollectionContextArtistAllSongs:
       
   169         case ECollectionContextAlbumsTBone:
       
   170         case ECollectionContextPlaylistSongs:
       
   171             contextMenu = new HbMenu();
       
   172             action = contextMenu->addAction( hbTrId("txt_common_menu_play_music") );
       
   173             action->setEnabled( !mMpEngine->verifyUsbBlocking() );
       
   174             break;
       
   175         default:
       
   176             break;
       
   177     }
       
   178 
       
   179     if ( contextMenu ) {
       
   180         if ( mView->isActivated() ) {
       
   181             mPermanentData->mContextMenuIndex = index;
       
   182             contextMenu->setPreferredPos( coords );
       
   183             contextMenu->setAttribute( Qt::WA_DeleteOnClose );
       
   184             setOutstandingPopup( contextMenu );
       
   185             contextMenu->open( this, SLOT( fetcherContextMenuOptionSelected( HbAction* ) ) );        
       
   186         }
       
   187         else {
       
   188             delete contextMenu;
       
   189             contextMenu = 0;
       
   190         }
   287         }
   191     }
   288     }
   192 
   289 
   193     TX_EXIT
   290     TX_EXIT
   194 }
   291 }
   234 void MpCollectionPopupHandler::openAddSongsToPlaylistFromTBone( )
   331 void MpCollectionPopupHandler::openAddSongsToPlaylistFromTBone( )
   235 {
   332 {
   236     TX_ENTRY
   333     TX_ENTRY
   237     MpCollectionTBoneListDataModel *model;
   334     MpCollectionTBoneListDataModel *model;
   238     model = new MpCollectionTBoneListDataModel( mMpEngine->collectionData() );
   335     model = new MpCollectionTBoneListDataModel( mMpEngine->collectionData() );
   239 	//this item will be deleted when clearing permanent data.
   336     //this item will be deleted when clearing permanent data.
   240     model->setParent(mPermanentData);
   337     model->setParent(mPermanentData);
   241     model->refreshModel();
   338     model->refreshModel();
   242     getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), model,
   339     getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), model,
   243                      SLOT( handleAddSongsToPlayList( HbAction* ) ) );
   340                      SLOT( handleAddSongsToPlayList( HbAction* ) ) );
   244     TX_EXIT
   341     TX_EXIT
   301 }
   398 }
   302 
   399 
   303 /*!
   400 /*!
   304  Closes any active popup
   401  Closes any active popup
   305  */
   402  */
   306 void MpCollectionPopupHandler::cancelOngoingPopup()
   403 void MpCollectionPopupHandler::cancelOngoingPopup( bool onlyContextMenu )
   307 {
   404 {
   308     TX_ENTRY    
   405     TX_ENTRY
   309     if ( mOutstandingPopup ) {
   406     if ( mOutstandingPopup ) {
   310          mOutstandingPopup->close();
   407         if ( onlyContextMenu ) {
   311          
   408             if ( mOutstandingPopup->objectName() == KContextMenu ) {
   312          //Delete/Clear permanent data until current popup gets deleted
   409                 mOutstandingPopup->close();
   313          mPermanentData->setParent( mOutstandingPopup );
   410                 mPermanentData->clear();
   314          //Generate new permanent data for future popups
   411             }
   315          mPermanentData = new MpPopupHandlerPermanentData( this );
   412         }
       
   413         else {
       
   414             mOutstandingPopup->close();
       
   415             //Delete/Clear permanent data until current popup gets deleted
       
   416             mPermanentData->setParent( mOutstandingPopup );
       
   417             //Generate new permanent data for future popups
       
   418             mPermanentData = new MpPopupHandlerPermanentData( this );
       
   419         }
   316     }
   420     }
   317     else {
   421     else {
   318         mPermanentData->clear();
   422         mPermanentData->clear();
   319     }
   423     }
   320 
   424     TX_EXIT
   321     TX_EXIT
       
   322 }
       
   323 
       
   324 /*!
       
   325  TODO: Workaround for HbListView multiple events: longPress and activated. Remove once HbListView get fixed (wk16)
       
   326  */
       
   327 bool MpCollectionPopupHandler::showingPopup()
       
   328 {
       
   329     return mOutstandingPopup;
       
   330 }
   425 }
   331 
   426 
   332 /*!
   427 /*!
   333  Slot to be called when an option has been selected from default context menu.
   428  Slot to be called when an option has been selected from default context menu.
   334  */
   429  */
   337     TX_ENTRY
   432     TX_ENTRY
   338     if ( selectedAction ) {
   433     if ( selectedAction ) {
   339         QString objectName = selectedAction->objectName();
   434         QString objectName = selectedAction->objectName();
   340         QList<int> selection;
   435         QList<int> selection;
   341         selection.append( mPermanentData->mContextMenuIndex );
   436         selection.append( mPermanentData->mContextMenuIndex );
   342         if ( objectName == "open" ) {
   437         if ( objectName == KOpen ) {
   343             mView->openItem( mPermanentData->mContextMenuIndex );
   438             mView->openItem( mPermanentData->mContextMenuIndex );
   344         }
   439         }
   345         if ( objectName == "add" ) {
   440         if ( objectName == KAdd ) {
   346             launchAddToPlaylistDialog( selection );
   441             launchAddToPlaylistDialog( selection );
   347         }
   442         }
   348         else if ( objectName == "delete" ) {
   443         else if ( objectName == KDelete ) {
   349             requestDelete( selection );
   444             requestDelete( selection );
   350         }
   445         }
   351         else if ( objectName == "rename playlist" ) {
   446         else if ( objectName == KRenamePlayList ) {
   352             QString currentName;
   447             QString currentName;
   353             currentName = mMpEngine->collectionData()->itemData( 
   448             currentName = mMpEngine->collectionData()->itemData( 
   354                     mPermanentData->mContextMenuIndex, MpMpxCollectionData::Title );
   449                     mPermanentData->mContextMenuIndex, MpMpxCollectionData::Title );
   355             openRenamePlaylistItemDialog( currentName );
   450             openRenamePlaylistItemDialog( currentName );
   356         }
   451         }
   381     clearOutstandingPopup( dialog );
   476     clearOutstandingPopup( dialog );
   382     bool operationCompleted( true );
   477     bool operationCompleted( true );
   383 
   478 
   384     if ( selectedAction ) {
   479     if ( selectedAction ) {
   385         QString objectName = selectedAction->objectName();
   480         QString objectName = selectedAction->objectName();
   386         if ( objectName == "new" ) {
   481         if ( objectName == KNew ) {
   387             QStringList playlists;
   482             QStringList playlists;
   388             mMpEngine->findPlaylists( playlists );
   483             mMpEngine->findPlaylists( playlists );
   389             queryNewPlaylistName( playlists, SLOT( handleAddToPlaylistGetTextFinished( HbAction* ) ) );
   484             queryNewPlaylistName( playlists, SLOT( handleAddToPlaylistGetTextFinished( HbAction* ) ) );
   390             operationCompleted = false;
   485             operationCompleted = false;
   391         }
   486         }
   411     clearOutstandingPopup( dialog );
   506     clearOutstandingPopup( dialog );
   412     bool operationCompleted( true );
   507     bool operationCompleted( true );
   413 
   508 
   414     if ( selectedAction ) {
   509     if ( selectedAction ) {
   415         QString objectName = selectedAction->objectName();
   510         QString objectName = selectedAction->objectName();
   416         if ( objectName == "ok" ) {
   511         if ( objectName == KOk ) {
   417             QString newPlaylistName = dialog->value().toString();
   512             QString newPlaylistName = dialog->value().toString();
   418             if ( newPlaylistName.length() ) {
   513             if ( newPlaylistName.length() ) {
   419                 //Create new playlist with given name
   514                 //Create new playlist with given name
   420                 mMpEngine->createPlaylist( newPlaylistName, mPermanentData->mSelectedItems );
   515                 mMpEngine->createPlaylist( newPlaylistName, mPermanentData->mSelectedItems );
   421             }
   516             }
   454     clearOutstandingPopup( dialog );
   549     clearOutstandingPopup( dialog );
   455     bool operationCompleted( true );
   550     bool operationCompleted( true );
   456 
   551 
   457     if ( selectedAction ) {
   552     if ( selectedAction ) {
   458         QString objectName = selectedAction->objectName();
   553         QString objectName = selectedAction->objectName();
   459         if ( objectName == "ok" ) {
   554         if ( objectName == KOk ) {
   460             QString newPlaylistName = dialog->value().toString();
   555             QString newPlaylistName = dialog->value().toString();
   461             if ( newPlaylistName.length() ) {
   556             if ( newPlaylistName.length() ) {
   462                 if ( newPlaylistName != mPermanentData->mOriginalName ) {
   557                 if ( newPlaylistName != mPermanentData->mOriginalName ) {
   463                     mMpEngine->renamePlaylist( newPlaylistName );
   558                     mMpEngine->renamePlaylist( newPlaylistName );
   464                 }
   559                 }
   488     clearOutstandingPopup( dialog );
   583     clearOutstandingPopup( dialog );
   489     bool operationCompleted( true );
   584     bool operationCompleted( true );
   490 
   585 
   491     if ( selectedAction ) {
   586     if ( selectedAction ) {
   492         QString objectName = selectedAction->objectName();
   587         QString objectName = selectedAction->objectName();
   493         if ( objectName == "ok" ) {
   588         if ( objectName == KOk ) {
   494             QString newPlaylistName = dialog->value().toString();
   589             QString newPlaylistName = dialog->value().toString();
   495             if ( newPlaylistName.length() ) {
   590             if ( newPlaylistName.length() ) {
   496                 if ( newPlaylistName != mPermanentData->mOriginalName ) {
   591                 if ( newPlaylistName != mPermanentData->mOriginalName ) {
   497                     mMpEngine->renamePlaylist( newPlaylistName, mPermanentData->mContextMenuIndex );
   592                     mMpEngine->renamePlaylist( newPlaylistName, mPermanentData->mContextMenuIndex );
   498                 }
   593                 }
   521     HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() );
   616     HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() );
   522     clearOutstandingPopup( dialog );
   617     clearOutstandingPopup( dialog );
   523 
   618 
   524     if ( selectedAction ) {
   619     if ( selectedAction ) {
   525         QString objectName = selectedAction->objectName();
   620         QString objectName = selectedAction->objectName();
   526         if ( objectName == "ok" ) {
   621         if ( objectName == KOk ) {
   527             QModelIndexList selectedModelIndexes;
   622             QModelIndexList selectedModelIndexes;
   528             selectedModelIndexes = dialog->selectedModelIndexes();
   623             selectedModelIndexes = dialog->selectedModelIndexes();
   529             if ( selectedModelIndexes.count() ) {
   624             if ( selectedModelIndexes.count() ) {
   530                 QList<int> selection;
   625                 QList<int> selection;
   531                 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) {
   626                 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) {
   554     HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() );
   649     HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() );
   555     clearOutstandingPopup( dialog );
   650     clearOutstandingPopup( dialog );
   556 
   651 
   557     if ( selectedAction ) {
   652     if ( selectedAction ) {
   558         QString objectName = selectedAction->objectName();
   653         QString objectName = selectedAction->objectName();
   559         if ( objectName == "ok" ) {
   654         if ( objectName == KOk ) {
   560             QModelIndexList selectedModelIndexes;
   655             QModelIndexList selectedModelIndexes;
   561             selectedModelIndexes = dialog->selectedModelIndexes();
   656             selectedModelIndexes = dialog->selectedModelIndexes();
   562             if ( selectedModelIndexes.count() ) {
   657             if ( selectedModelIndexes.count() ) {
   563                 QList<int> selection;
   658                 QList<int> selection;
   564                 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) {
   659                 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) {
   584     HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() );
   679     HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() );
   585     clearOutstandingPopup( dialog );
   680     clearOutstandingPopup( dialog );
   586 
   681 
   587     if ( selectedAction ) {
   682     if ( selectedAction ) {
   588         QString objectName = selectedAction->objectName();
   683         QString objectName = selectedAction->objectName();
   589         if ( objectName == "ok" ) {
   684         if ( objectName == KOk ) {
   590             QModelIndexList selectedModelIndexes;
   685             QModelIndexList selectedModelIndexes;
   591             selectedModelIndexes = dialog->selectedModelIndexes();
   686             selectedModelIndexes = dialog->selectedModelIndexes();
   592             if ( selectedModelIndexes.count() ) {
   687             if ( selectedModelIndexes.count() ) {
   593                 QList<int> selection;
   688                 QList<int> selection;
   594                 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) {
   689                 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) {
   619     clearOutstandingPopup( dialog );
   714     clearOutstandingPopup( dialog );
   620     bool operationCompleted( true );
   715     bool operationCompleted( true );
   621 
   716 
   622     if ( selectedAction ) {
   717     if ( selectedAction ) {
   623         QString objectName = selectedAction->objectName();
   718         QString objectName = selectedAction->objectName();
   624         if ( objectName == "ok" ) {
   719         if ( objectName == KOk ) {
   625             QString newPlaylistName = dialog->value().toString();
   720             QString newPlaylistName = dialog->value().toString();
   626             if ( newPlaylistName.length() ) {
   721             if ( newPlaylistName.length() ) {
   627                 //Store the new playlist name and query for the items to be added
   722                 //Store the new playlist name and query for the items to be added
   628                 mPermanentData->mOriginalName = newPlaylistName;
   723                 mPermanentData->mOriginalName = newPlaylistName;
   629                 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), 
   724                 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), 
   654     HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() );
   749     HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() );
   655     clearOutstandingPopup( dialog );
   750     clearOutstandingPopup( dialog );
   656 
   751 
   657     if ( selectedAction ) {
   752     if ( selectedAction ) {
   658         QString objectName = selectedAction->objectName();
   753         QString objectName = selectedAction->objectName();
   659         if ( objectName == "ok" ) {
   754         if ( objectName == KOk ) {
   660             QList<int> selection;
   755             QList<int> selection;
   661             QModelIndexList selectedModelIndexes;
   756             QModelIndexList selectedModelIndexes;
   662             selectedModelIndexes = dialog->selectedModelIndexes();
   757             selectedModelIndexes = dialog->selectedModelIndexes();
   663             if ( selectedModelIndexes.count() ) {
   758             if ( selectedModelIndexes.count() ) {
   664                 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) {
   759                 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) {
   704     HbMessageBox *dialog = qobject_cast<HbMessageBox *>( sender() );
   799     HbMessageBox *dialog = qobject_cast<HbMessageBox *>( sender() );
   705     clearOutstandingPopup( dialog );
   800     clearOutstandingPopup( dialog );
   706     
   801     
   707     if ( selectedAction ) {
   802     if ( selectedAction ) {
   708         QString objectName = selectedAction->objectName();
   803         QString objectName = selectedAction->objectName();
   709         if ( objectName == "ok" ) {
   804         if ( objectName == KOk ) {
   710             mMpEngine->deleteSongs( mPermanentData->mSelectedItems );
   805             mMpEngine->deleteSongs( mPermanentData->mSelectedItems );
   711         }
   806         }
   712         selectedAction->setEnabled( false );
   807         selectedAction->setEnabled( false );
   713     }
   808     }
   714 
   809 
   715     mPermanentData->clear();
   810     mPermanentData->clear();
   716 
   811 
       
   812     TX_EXIT
       
   813 }
       
   814 
       
   815 /*!
       
   816  Slot called upon notification from MpEngine indicating start of
       
   817  deleting process.
       
   818  */
       
   819 void MpCollectionPopupHandler::handleDeleteStarted( TCollectionContext context, int count )
       
   820 {
       
   821     TX_ENTRY
       
   822     if ( context == ECollectionContextPlaylistSongs ) {
       
   823         if (count >= KSongsToDisplayProgressDlg) {  //show progress dialog if removing more than 100 songs
       
   824             launchProgressDialog( "txt_mus_info_removing_songs" );
       
   825         }
       
   826     }
       
   827     else if (context != ECollectionContextPlaylists ) {  //no progress dialog for delete playlist
       
   828         launchProgressDialog( "txt_mus_info_deleting" );
       
   829     }
       
   830     TX_EXIT
       
   831 }
       
   832 
       
   833 /*!
       
   834  Slot called upon notification from MpEngine indicating 'count' songs are going to be added.
       
   835  */
       
   836 void MpCollectionPopupHandler::handleAddingSongs( int count )
       
   837 {
       
   838     TX_ENTRY
       
   839     if ( count >= KSongsToDisplayProgressDlg )
       
   840     {
       
   841         HbProgressDialog *addSongsWaitNote = new HbProgressDialog( HbProgressDialog::WaitDialog );
       
   842         connect( addSongsWaitNote, SIGNAL( cancelled() ), mMpEngine, SLOT( cancelCollectionRequest() ) );
       
   843         addSongsWaitNote->setModal( true );
       
   844         addSongsWaitNote->setText( hbTrId( "txt_mus_info_adding_songs" ) );
       
   845         addSongsWaitNote->setObjectName( KProgressDialog );
       
   846         addSongsWaitNote->setAttribute( Qt::WA_DeleteOnClose );
       
   847         setOutstandingPopup( addSongsWaitNote );
       
   848         addSongsWaitNote->show();
       
   849     }
       
   850     TX_EXIT
       
   851 }
       
   852 
       
   853 /*!
       
   854  Slot called upon notification from MpEngine indicating end of
       
   855  deleting or adding process.
       
   856  */
       
   857 void MpCollectionPopupHandler::handleOperationEnded( bool success )
       
   858 {
       
   859     TX_ENTRY
       
   860     Q_UNUSED( success );
       
   861     if ( mOutstandingPopup && ( mOutstandingPopup->objectName() == KProgressDialog ) ) {
       
   862         HbProgressDialog *dialog = qobject_cast<HbProgressDialog *>( mOutstandingPopup );
       
   863         dialog->cancel();
       
   864     }
   717     TX_EXIT
   865     TX_EXIT
   718 }
   866 }
   719 
   867 
   720 /*!
   868 /*!
   721  Slot to be called when a popup is getting closed. Usefull when a dialog is closed before it finishes
   869  Slot to be called when a popup is getting closed. Usefull when a dialog is closed before it finishes
   766  Launches the 'Add to playlist' dialog.
   914  Launches the 'Add to playlist' dialog.
   767  */
   915  */
   768 void MpCollectionPopupHandler::launchAddToPlaylistDialog( QList<int> &selection )
   916 void MpCollectionPopupHandler::launchAddToPlaylistDialog( QList<int> &selection )
   769 {
   917 {
   770     TX_ENTRY
   918     TX_ENTRY
   771     if (!mView->isActivated()) {
   919 
   772         mPermanentData->clear();
       
   773         return;
       
   774     }
       
   775  
       
   776     QStringList playlists;
   920     QStringList playlists;
   777     mPermanentData->mSelectedItems = selection;
   921     mPermanentData->mSelectedItems = selection;
   778     mMpEngine->findPlaylists( playlists );
   922     mMpEngine->findPlaylists( playlists );
   779     if ( playlists.count() ) {
   923     if ( playlists.count() ) {
   780         //There are saved playlists, query for a saved playlist or new.
   924         //There are saved playlists, query for a saved playlist or new.
   783         dialog->setStringItems( playlists );
   927         dialog->setStringItems( playlists );
   784         dialog->setSelectionMode( HbAbstractItemView::SingleSelection );
   928         dialog->setSelectionMode( HbAbstractItemView::SingleSelection );
   785         dialog->setHeadingWidget(new HbLabel( hbTrId( "txt_mus_title_select_playlist" ) ) );
   929         dialog->setHeadingWidget(new HbLabel( hbTrId( "txt_mus_title_select_playlist" ) ) );
   786         dialog->clearActions();
   930         dialog->clearActions();
   787         action = new HbAction( hbTrId( "txt_mus_button_new" ) );
   931         action = new HbAction( hbTrId( "txt_mus_button_new" ) );
   788         action->setObjectName( "new" );
   932         action->setObjectName( KNew );
   789         dialog->addAction( action );
   933         dialog->addAction( action );
   790         action = new HbAction( hbTrId( "txt_common_button_cancel" ) );
   934         action = new HbAction( hbTrId( "txt_common_button_cancel" ) );
   791         action->setObjectName( "cancel" );
   935         action->setObjectName( KCancel );
   792         dialog->addAction( action );
   936         dialog->addAction( action );
       
   937         dialog->setObjectName( KAddToPlaylistSelectionDialog );
   793         dialog->setAttribute( Qt::WA_DeleteOnClose );
   938         dialog->setAttribute( Qt::WA_DeleteOnClose );
   794         setOutstandingPopup( dialog );
   939         setOutstandingPopup( dialog );
   795         dialog->open( this, SLOT( handleAddToPlaylistDialogFinished( HbAction* ) ) );
   940         dialog->open( this, SLOT( handleAddToPlaylistDialogFinished( HbAction* ) ) );
   796     }
   941     }
   797     else {
   942     else {
   829  */
   974  */
   830 void MpCollectionPopupHandler::getText( const QString &label, const QString &text,
   975 void MpCollectionPopupHandler::getText( const QString &label, const QString &text,
   831                                         const char *handler )
   976                                         const char *handler )
   832 {
   977 {
   833     TX_ENTRY
   978     TX_ENTRY
   834     if ( !mView->isActivated() ) {
       
   835         mPermanentData->clear();
       
   836         return;
       
   837     }
       
   838 
       
   839     HbAction *action;
   979     HbAction *action;
   840     HbInputDialog *dialog = new HbInputDialog();
   980     HbInputDialog *dialog = new HbInputDialog();
   841     dialog->setPromptText( label );
   981     dialog->setPromptText( label );
   842     dialog->setInputMode( HbInputDialog::TextInput );
   982     dialog->setInputMode( HbInputDialog::TextInput );
   843     dialog->setValue( text );
   983     dialog->setValue( text );
   844     dialog->clearActions();
   984     dialog->clearActions();
   845     action = new HbAction( hbTrId( "txt_common_button_ok" ) );
   985     action = new HbAction( hbTrId( "txt_common_button_ok" ) );
   846     action->setObjectName( "ok" );
   986     action->setObjectName( KOk );
   847     dialog->addAction( action );
   987     dialog->addAction( action );
   848     action = new HbAction( hbTrId( "txt_common_button_cancel" ) );
   988     action = new HbAction( hbTrId( "txt_common_button_cancel" ) );
   849     action->setObjectName( "cancel" );
   989     action->setObjectName( KCancel );
   850     dialog->addAction( action );
   990     dialog->addAction( action );
       
   991     dialog->setObjectName( KInputTextDialog );
   851     dialog->setAttribute( Qt::WA_DeleteOnClose );
   992     dialog->setAttribute( Qt::WA_DeleteOnClose );
   852     setOutstandingPopup( dialog );
   993     setOutstandingPopup( dialog );
   853     dialog->open( this, handler );
   994     dialog->open( this, handler );
   854     TX_EXIT
   995     TX_EXIT
   855 }
   996 }
   864 void MpCollectionPopupHandler::getModelIndexes( const QString &label, QAbstractItemModel* model,
  1005 void MpCollectionPopupHandler::getModelIndexes( const QString &label, QAbstractItemModel* model,
   865                                                 const char *handler)
  1006                                                 const char *handler)
   866 {   
  1007 {   
   867     TX_ENTRY
  1008     TX_ENTRY
   868 
  1009 
   869     if ( !mView->isActivated() ) {
  1010     connectExternalEvents();
   870         mPermanentData->clear();
       
   871         return;
       
   872     }
       
   873 
  1011 
   874     HbAction *action;
  1012     HbAction *action;
   875     HbSelectionDialog *dialog = new HbSelectionDialog();
  1013     HbSelectionDialog *dialog = new HbSelectionDialog();
   876     dialog->setHeadingWidget( new HbLabel( label ) );
  1014     dialog->setHeadingWidget( new HbLabel( label ) );
   877     dialog->setSelectionMode( HbAbstractItemView::MultiSelection );
  1015     dialog->setSelectionMode( HbAbstractItemView::MultiSelection );
   878     dialog->setModel( model );
  1016     dialog->setModel( model );
   879     dialog->clearActions();
  1017     dialog->clearActions();
   880     action = new HbAction( hbTrId( "txt_common_button_ok" ) );
  1018     action = new HbAction( hbTrId( "txt_common_button_ok" ) );
   881     action->setObjectName( "ok" );
  1019     action->setObjectName( KOk );
   882     dialog->addAction( action );
  1020     dialog->addAction( action );
   883     action = new HbAction( hbTrId( "txt_common_button_cancel" ) );
  1021     action = new HbAction( hbTrId( "txt_common_button_cancel" ) );
   884     action->setObjectName( "cancel" );
  1022     action->setObjectName( KCancel );
   885     dialog->addAction( action );
  1023     dialog->addAction( action );
       
  1024     dialog->setObjectName( KGetModelIndexesListDialog );
   886     dialog->setAttribute( Qt::WA_DeleteOnClose );
  1025     dialog->setAttribute( Qt::WA_DeleteOnClose );
   887     setOutstandingPopup( dialog );
  1026     setOutstandingPopup( dialog );
   888     dialog->open( this, handler );
  1027     dialog->open( this, handler );
   889 
  1028 
   890     TX_EXIT
  1029     TX_EXIT
   895  Launches a list dialog to reorder them.
  1034  Launches a list dialog to reorder them.
   896  */
  1035  */
   897 void MpCollectionPopupHandler::launchArrangeSongsDialog()
  1036 void MpCollectionPopupHandler::launchArrangeSongsDialog()
   898 {   
  1037 {   
   899     TX_ENTRY
  1038     TX_ENTRY
   900 
       
   901     if ( !mView->isActivated() ) {
       
   902         return;
       
   903     }
       
   904 
  1039 
   905     HbListView *listView = new HbListView();
  1040     HbListView *listView = new HbListView();
   906     listView->setItemRecycling( true );
  1041     listView->setItemRecycling( true );
   907     listView->setScrollingStyle( HbListView::PanOrFlick );
  1042     listView->setScrollingStyle( HbListView::PanOrFlick );
   908     listView->setClampingStyle( HbListView::BounceBackClamping );
  1043     listView->setClampingStyle( HbListView::BounceBackClamping );
   929     dialog->setContentWidget( listView );
  1064     dialog->setContentWidget( listView );
   930     dialog->clearActions();
  1065     dialog->clearActions();
   931     HbAction *action;
  1066     HbAction *action;
   932     action = new HbAction( hbTrId( "txt_common_button_ok" ) );
  1067     action = new HbAction( hbTrId( "txt_common_button_ok" ) );
   933     dialog->addAction( action );
  1068     dialog->addAction( action );
       
  1069     dialog->setObjectName( KArrangeSongsDialog );
   934     dialog->setAttribute( Qt::WA_DeleteOnClose );
  1070     dialog->setAttribute( Qt::WA_DeleteOnClose );
   935     setOutstandingPopup(dialog);
  1071     setOutstandingPopup(dialog);
   936     dialog->open( this, SLOT( handleArrangeSongs( HbAction* ) ) );
  1072     dialog->open( this, SLOT( handleArrangeSongs( HbAction* ) ) );
   937 
  1073 
   938     TX_EXIT
  1074     TX_EXIT
   947 {
  1083 {
   948     TX_ENTRY
  1084     TX_ENTRY
   949     QString message;
  1085     QString message;
   950     mPermanentData->mSelectedItems = selection;
  1086     mPermanentData->mSelectedItems = selection;
   951     bool needsConfirmation = true;
  1087     bool needsConfirmation = true;
       
  1088     connectExternalEvents();
   952 
  1089 
   953     switch ( mMpEngine->collectionData()->context() ) {
  1090     switch ( mMpEngine->collectionData()->context() ) {
   954         case ECollectionContextAllSongs:
  1091         case ECollectionContextAllSongs:
   955         case ECollectionContextArtistAlbumsTBone:
  1092         case ECollectionContextArtistAlbumsTBone:
   956         case ECollectionContextArtistAllSongs:
  1093         case ECollectionContextArtistAllSongs:
   980             TX_LOG_ARGS( "Invalid Collection Context" );
  1117             TX_LOG_ARGS( "Invalid Collection Context" );
   981             break;
  1118             break;
   982     }
  1119     }
   983 
  1120 
   984     if ( needsConfirmation ) {
  1121     if ( needsConfirmation ) {
   985         if ( !mView->isActivated() ) {
       
   986             mPermanentData->clear();
       
   987             return;
       
   988         }
       
   989 
       
   990         HbAction *action;
  1122         HbAction *action;
   991         HbMessageBox *dialog = new HbMessageBox( HbMessageBox::MessageTypeQuestion );
  1123         HbMessageBox *dialog = new HbMessageBox( HbMessageBox::MessageTypeQuestion );
   992 
  1124 
   993         dialog->setText( message );
  1125         dialog->setText( message );
   994         dialog->setTimeout( HbPopup::NoTimeout );
  1126         dialog->setTimeout( HbPopup::NoTimeout );
   995         dialog->clearActions();
  1127         dialog->clearActions();
   996         action = new HbAction( hbTrId( "txt_common_button_yes" ) );
  1128         action = new HbAction( hbTrId( "txt_common_button_yes" ) );
   997         action->setObjectName( "ok" );
  1129         action->setObjectName( KOk );
   998         dialog->addAction( action );
  1130         dialog->addAction( action );
   999         action = new HbAction( hbTrId( "txt_common_button_no" ) );
  1131         action = new HbAction( hbTrId( "txt_common_button_no" ) );
  1000         action->setObjectName( "cancel" );
  1132         action->setObjectName( KCancel );
  1001         dialog->addAction( action );
  1133         dialog->addAction( action );
       
  1134         dialog->setObjectName( KRequestDeleteMessageBox );
  1002         dialog->setAttribute( Qt::WA_DeleteOnClose );
  1135         dialog->setAttribute( Qt::WA_DeleteOnClose );
  1003         setOutstandingPopup( dialog );
  1136         setOutstandingPopup( dialog );
  1004         dialog->open( this, SLOT( handleRequestDelete( HbAction* ) ) );
  1137         dialog->open( this, SLOT( handleRequestDelete( HbAction* ) ) );
  1005     }
  1138     }
  1006 
  1139 
  1007     TX_EXIT
  1140     TX_EXIT
  1008 }
  1141 }
  1009 
  1142 
  1010 
       
  1011 //------------------------------------------------------------------
       
  1012 //    MpPopupHandlerPermanentData
       
  1013 //------------------------------------------------------------------
       
  1014 /*!
       
  1015  Constructs the popup handler permanent data.
       
  1016  */
       
  1017 MpCollectionPopupHandler::MpPopupHandlerPermanentData::MpPopupHandlerPermanentData( QObject *parent )
       
  1018     : QObject( parent ),
       
  1019       mIsolatedCollectionData( 0 ),
       
  1020       mAbstractItemModel( 0 ),
       
  1021       mContextMenuIndex( KNullIndex )
       
  1022 {
       
  1023       TX_ENTRY
       
  1024       mSelectedItems.clear();
       
  1025       mOriginalName.clear();
       
  1026       TX_EXIT
       
  1027 }
       
  1028 
       
  1029 /*!
       
  1030  Destructs the popup handler permanent data.
       
  1031  */
       
  1032 MpCollectionPopupHandler::MpPopupHandlerPermanentData::~MpPopupHandlerPermanentData()
       
  1033 {
       
  1034     TX_ENTRY
       
  1035     clear();
       
  1036     TX_EXIT
       
  1037 }
       
  1038 
       
  1039 /*!
  1143 /*!
  1040  \internal
  1144  \internal
  1041   Clears all permanent data. 
  1145  Launches a waiting progress note.
  1042  */
  1146  \a content String id to display in the dialog.
  1043 void MpCollectionPopupHandler::MpPopupHandlerPermanentData::clear()
  1147  */
  1044 {
  1148 void MpCollectionPopupHandler::launchProgressDialog( const char *id )
  1045     TX_ENTRY
  1149 {
  1046     mSelectedItems.clear();
  1150     HbProgressDialog *deleteProgressNote = new HbProgressDialog( HbProgressDialog::WaitDialog );
  1047     mOriginalName.clear();
  1151     connect( deleteProgressNote, SIGNAL( cancelled() ), mMpEngine, SLOT( cancelCollectionRequest() ) );
  1048     mContextMenuIndex = KNullIndex;
  1152     deleteProgressNote->setModal( true );
  1049     if ( mIsolatedCollectionData ) {
  1153     deleteProgressNote->setDismissPolicy( HbPopup::NoDismiss );
  1050         MpEngineFactory::sharedEngine()->releaseIsolatedCollection();
  1154     deleteProgressNote->setText( hbTrId( id ) );
  1051         mIsolatedCollectionData = 0;
  1155     deleteProgressNote->setObjectName( KProgressDialog );
  1052     }
  1156     deleteProgressNote->setAttribute( Qt::WA_DeleteOnClose );
  1053     if ( mAbstractItemModel ) {
  1157     setOutstandingPopup( deleteProgressNote );
  1054         delete mAbstractItemModel;
  1158     deleteProgressNote->show();
  1055         mAbstractItemModel = 0;
  1159 }
  1056     }
  1160 
  1057     //clearing any child Objects.
  1161 /*!
  1058     foreach (QObject* child, children()) {
  1162  \internal
  1059         child->deleteLater();
  1163  Connects MpEngine signals on demand in order to save time at start up.
  1060     }
  1164   */
  1061     TX_EXIT
  1165 void MpCollectionPopupHandler::connectExternalEvents()
  1062 }
  1166 {
       
  1167     if ( !mExternalEventsConnected ) {
       
  1168         connect( mMpEngine, SIGNAL( deleteStarted( TCollectionContext, int ) ),
       
  1169                 this, SLOT( handleDeleteStarted( TCollectionContext, int ) ) );
       
  1170         connect( mMpEngine, SIGNAL( songsDeleted( bool ) ), this, SLOT( handleOperationEnded( bool ) ) );
       
  1171         connect( mMpEngine, SIGNAL( aboutToAddSongs( int ) ), this, SLOT( handleAddingSongs( int ) ) );
       
  1172         connect( mMpEngine, SIGNAL( playlistSaved( bool ) ), this, SLOT( handleOperationEnded( bool ) ) );
       
  1173         mExternalEventsConnected = true;
       
  1174     }
       
  1175 }
       
  1176