notepad/notepad1/LibSrc/NpdListDialog.cpp
branchRCL_3
changeset 60 96907930389d
parent 59 aba12c885d83
child 67 1539a383d7b6
equal deleted inserted replaced
59:aba12c885d83 60:96907930389d
   353 // in the point that it must create a KeyArray by itself.
   353 // in the point that it must create a KeyArray by itself.
   354 // -----------------------------------------------------------------------------
   354 // -----------------------------------------------------------------------------
   355 //
   355 //
   356 void CNotepadListDialog::OnCmdDeleteL()
   356 void CNotepadListDialog::OnCmdDeleteL()
   357     {
   357     {
   358     if ( iModel->MdcaCount() == 0 ) // this is posible when clear key
   358     TInt markCount( iListBox->SelectionIndexes()->Count() );
       
   359     //For clear key,if nothing can be deleted ,do not handle the clear key
       
   360     if ( iModel->MdcaCount() == 0 || ( markCount == 0 && !iListBox->IsHighlightEnabled() ) ) 
   359         {
   361         {
   360         return;
   362         return;
   361         }
   363         }
       
   364     
       
   365     //Fixed Item 'New Note' in notes should not be deleted
       
   366     if ( IsNoteListDialog() && ( iListBox->CurrentItemIndex() == 0 ) && markCount == 0 )
       
   367         {
       
   368         return;
       
   369         }
       
   370     
   362     ClearSavedCurrentAndSelections();
   371     ClearSavedCurrentAndSelections();
   363     SaveCurrentAndSelectionsL();
   372     SaveCurrentAndSelectionsL();
   364     TInt markCount( iListBox->SelectionIndexes()->Count() );
   373     
   365     TInt deleteCount( markCount > 0 ? markCount : 1 ); 
   374     TInt deleteCount;
       
   375     if ( iListBox->IsHighlightEnabled() && markCount == 0 )
       
   376         {
       
   377         //for an Item highlighted and no Item marked
       
   378         deleteCount = 1;
       
   379         }
       
   380     else
       
   381         {
       
   382         deleteCount = markCount;
       
   383         }
       
   384     
   366     if ( ConfirmDeleteL( deleteCount ) )
   385     if ( ConfirmDeleteL( deleteCount ) )
   367         {
   386         {
   368         //be sure that the marks or the items might have gone while confirming
   387         //be sure that the marks or the items might have gone while confirming
   369         //
   388         //
   370         if ( markCount > 0 ? 
   389         if ( markCount > 0 ? 
   956                 }
   975                 }
   957             TInt currIndex = iListBox->CurrentItemIndex();
   976             TInt currIndex = iListBox->CurrentItemIndex();
   958             TKeyArrayFix itemKey(0,ECmpTUint);
   977             TKeyArrayFix itemKey(0,ECmpTUint);
   959             TInt ignore;
   978             TInt ignore;
   960             TInt itemMarked = iListBox->SelectionIndexes()->Find( currIndex, itemKey, ignore );
   979             TInt itemMarked = iListBox->SelectionIndexes()->Find( currIndex, itemKey, ignore );
       
   980 			
   961             if ( memoCount > 0 && 
   981             if ( memoCount > 0 && 
   962                 ( markCount == 0 || IsNotepad() || IsTemplates()) )
   982                 ( markCount == 0 || IsNotepad() || IsTemplates()) )
   963                 {
   983                 {
   964                 // this must preceed DeleteMenuItem(ENotepadCmdOpen)
   984                 // this must preceed DeleteMenuItem(ENotepadCmdOpen)
   965                 InsertSendMenuItemAfterL( *iSendUi, *aMenuPane, 
   985                 InsertSendMenuItemAfterL( *iSendUi, *aMenuPane, 
   966                     ENotepadCmdOpen );
   986                     ENotepadCmdOpen );
   967                 }
   987                 }
       
   988 				
   968             if ( memoCount == 0 )
   989             if ( memoCount == 0 )
   969                 {
   990                 {
   970                 aMenuPane->DeleteMenuItem(ENotepadCmdDelete);
   991                 aMenuPane->DeleteMenuItem( ENotepadCmdDelete );
   971                 }
   992                 }
   972             if ( (memoCount == 0) ||  ( markCount >= 1  ) )
   993 				
       
   994             //delete 'Open' item from Option list at the following situations:
       
   995             //no memo,have item marked,user select the 'New note'
       
   996             if ( ( memoCount == 0 ) || ( markCount >= 1 ) || 
       
   997                     ( ( currIndex == 0 ) && IsNotepad() ) )
   973                 {
   998                 {
   974                 // this must after InsertSendMenuItemAfterL
   999                 // this must after InsertSendMenuItemAfterL
   975                 aMenuPane->DeleteMenuItem(ENotepadCmdOpen);
  1000                 aMenuPane->DeleteMenuItem( ENotepadCmdOpen );
   976                 }
  1001                 }
       
  1002 				
   977             if ( markCount >= 1 && IsNoteListDialog() && ( memoCount > 0 ) )
  1003             if ( markCount >= 1 && IsNoteListDialog() && ( memoCount > 0 ) )
   978                 {
  1004                 {
   979                 aMenuPane->SetItemSpecific( ENotepadCmdSend, EFalse );
  1005                 aMenuPane->SetItemSpecific( ENotepadCmdSend, EFalse );
   980                 aMenuPane->SetItemSpecific( ENotepadCmdDelete, EFalse );
  1006                 aMenuPane->SetItemSpecific( ENotepadCmdDelete, EFalse );
   981                 }
  1007                 }
  1050     {
  1076     {
  1051     HideMenu();
  1077     HideMenu();
  1052     switch ( aCommandId )
  1078     switch ( aCommandId )
  1053         {
  1079         {
  1054         case ENotepadCmdOpen: // Open memo
  1080         case ENotepadCmdOpen: // Open memo
  1055             OnCmdOpenL(iListBox->CurrentItemIndex());
  1081             OnCmdOpenL( iListBox->CurrentItemIndex() );
  1056             break;
  1082             break;
  1057         case ENotepadCmdAdd:
  1083         case ENotepadCmdAdd:
  1058            OnCmdAddL();
  1084            OnCmdAddL();
  1059             break;
  1085             break;
  1060         case ENotepadCmdDelete:
  1086         case ENotepadCmdDelete:
  1354     TListBoxEvent aEventType )
  1380     TListBoxEvent aEventType )
  1355     {
  1381     {
  1356     switch(aEventType)
  1382     switch(aEventType)
  1357         {
  1383         {
  1358         case EEventEnterKeyPressed:
  1384         case EEventEnterKeyPressed:
  1359             OnCmdOpenL(aListBox->CurrentItemIndex());
  1385             
       
  1386             // create a new note with enter key when selected New Note in notes
       
  1387             if( aListBox->CurrentItemIndex() == 0 && IsNotepad() )
       
  1388                 {
       
  1389                 OnCmdAddL();
       
  1390                 }
       
  1391             else
       
  1392                 {
       
  1393                 OnCmdOpenL( aListBox->CurrentItemIndex() );
       
  1394                 }
       
  1395 
  1360             break;
  1396             break;
  1361         case EEventItemSingleClicked:
  1397         case EEventItemSingleClicked:
  1362         	if ( IsNotepad() )
  1398         	if ( IsNotepad() )
  1363 				{     
  1399 				{     
  1364 				if ( aListBox->Model()->NumberOfItems() != 0
  1400 				if ( aListBox->Model()->NumberOfItems() != 0
  1386                       iFlags |= ENotepadMenuByOkKey;
  1422                       iFlags |= ENotepadMenuByOkKey;
  1387                       iMskFlag=ETrue;
  1423                       iMskFlag=ETrue;
  1388                       DisplayMenuL();
  1424                       DisplayMenuL();
  1389                     }  
  1425                     }  
  1390                 }
  1426                 }
       
  1427             break;
  1391         default:
  1428         default:
  1392             break;
  1429             break;
  1393         }
  1430         }
  1394      MiddleSoftKeyL();   
  1431      MiddleSoftKeyL();   
  1395     }
  1432     }