messagingappbase/mce/src/MceMessageListContainer.cpp
branchRCL_3
changeset 71 17302fa075e1
parent 60 7fdbb852d323
child 77 da6ac9d688df
equal deleted inserted replaced
66:fc3320e39880 71:17302fa075e1
    88         }
    88         }
    89     
    89     
    90     delete iListBox;
    90     delete iListBox;
    91     delete iListItems;
    91     delete iListItems;
    92     delete iSelectedEntries;
    92     delete iSelectedEntries;
       
    93     delete iAddedMsvIds;
    93     }
    94     }
    94 
    95 
    95 // ----------------------------------------------------
    96 // ----------------------------------------------------
    96 // CMceMessageListContainer::NewL
    97 // CMceMessageListContainer::NewL
    97 // ----------------------------------------------------
    98 // ----------------------------------------------------
   136 
   137 
   137     iListBox->Model()->SetItemTextArray( iListItems );
   138     iListBox->Model()->SetItemTextArray( iListItems );
   138     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
   139     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
   139     
   140     
   140     iListBox->SetListBoxObserver( &iOwningView );
   141     iListBox->SetListBoxObserver( &iOwningView );
   141 
   142     iListBox->SetMarkingModeObserver( this );
   142     iSelectedEntries = new (ELeave) CMsvEntrySelection;
   143     iSelectedEntries = new (ELeave) CMsvEntrySelection;
   143     
   144     
   144     iListBox->CreateScrollBarFrameL( ETrue );
   145     iListBox->CreateScrollBarFrameL( ETrue );
   145     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
   146     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
   146         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
   147         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
   147 
   148 
   148     iListBox->ItemDrawer()->FormattedCellData()
   149     iListBox->ItemDrawer()->FormattedCellData()
   149         ->SetIconArray( aBitmapResolver.IconArray() );
   150         ->SetIconArray( aBitmapResolver.IconArray() );
   150     
   151     
   151     iPreviousInputMethod = EFalse;
   152     iPreviousInputMethod = EFalse;
       
   153     
       
   154     iAddedMsvIds = new (ELeave) CMsvEntrySelection;
   152     
   155     
   153     User::LeaveIfError( iQwertyModeStatusProperty.Attach( 
   156     User::LeaveIfError( iQwertyModeStatusProperty.Attach( 
   154         KCRUidAvkon, KAknQwertyInputModeActive ));
   157         KCRUidAvkon, KAknQwertyInputModeActive ));
   155   
   158   
   156     HandleQwertyModeChangeNotification();
   159     HandleQwertyModeChangeNotification();
   267     }
   270     }
   268 
   271 
   269 // ----------------------------------------------------
   272 // ----------------------------------------------------
   270 // CMceMessageListContainer::ItemCountChangedL
   273 // CMceMessageListContainer::ItemCountChangedL
   271 // ----------------------------------------------------
   274 // ----------------------------------------------------
   272 void CMceMessageListContainer::ItemCountChangedL( TBool aItemsAdded )
   275 void CMceMessageListContainer::ItemCountChangedL( TBool aItemsAdded,
       
   276         CArrayFix<TInt>* aAddedIndexes )
   273     {
   277     {
   274     if ( aItemsAdded )
   278     if ( aItemsAdded )
   275         {
   279         {
   276         iListBox->HandleItemAdditionL();     
   280         if( aAddedIndexes )
       
   281             {
       
   282             iListBox->HandleItemAdditionL( *aAddedIndexes );
       
   283             }
       
   284         else
       
   285             {
       
   286             iListBox->HandleItemAdditionL();
       
   287             }        
   277         }
   288         }
   278     else
   289     else
   279         {
   290         {
   280         iListBox->HandleItemRemovalL();
   291         iListBox->HandleItemRemovalL();
       
   292         if( iOwningView.MarkingMode() && iListItems->MessageCount() <= 0 )
       
   293             {
       
   294             SetMarkingModeOff();
       
   295             }
   281         }
   296         }
   282     }
   297     }
   283     
   298     
   284     
   299     
   285 // ----------------------------------------------------
   300 // ----------------------------------------------------
   443     }
   458     }
   444 
   459 
   445 // ----------------------------------------------------
   460 // ----------------------------------------------------
   446 // CMceMessageListContainer::RefreshSelectionIndexesL
   461 // CMceMessageListContainer::RefreshSelectionIndexesL
   447 // ----------------------------------------------------
   462 // ----------------------------------------------------
   448 void CMceMessageListContainer::RefreshSelectionIndexesL( TBool aForceUpdate )
   463 void CMceMessageListContainer::RefreshSelectionIndexesL( TBool /*aForceUpdate*/ )
   449     {
   464     {
   450     const CListBoxView::CSelectionIndexArray* selection = 
   465 
   451         iListBox->View()->SelectionIndexes();
       
   452 
       
   453     if ( selection->Count() > 0 || aForceUpdate )
       
   454         {
       
   455         CArrayFixFlat<TInt>* newSelection = new ( ELeave )
       
   456             CArrayFixFlat<TInt>( KMceListContainerGranuality );
       
   457         CleanupStack::PushL( newSelection );
       
   458         const TInt count = iSelectedEntries->Count();
       
   459         for ( TInt loop = count; loop >0; loop--)
       
   460             {
       
   461             TInt index = iListItems->ItemIndex( (*iSelectedEntries)[loop-1] );
       
   462             if ( index > KErrNotFound )
       
   463                 {
       
   464                 newSelection->AppendL( index );
       
   465                 }
       
   466             else
       
   467                 {
       
   468                 iSelectedEntries->Delete( loop-1 );
       
   469                 }
       
   470             }
       
   471         iListBox->SetSelectionIndexesL( newSelection );
       
   472         CleanupStack::PopAndDestroy( newSelection );
       
   473         }
       
   474     
   466     
   475     }
   467     }
   476 
   468 
   477 // ----------------------------------------------------
   469 // ----------------------------------------------------
   478 // CMceMessageListContainer::AddAllToSelectionL
   470 // CMceMessageListContainer::AddAllToSelectionL
   662             
   654             
   663             iOwningView.CancelMailboxTimer();
   655             iOwningView.CancelMailboxTimer();
   664 
   656 
   665             if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow )
   657             if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow )
   666                 {
   658                 {
       
   659                 if( iOwningView.MarkingMode() )
       
   660                     {
       
   661                     return EKeyWasConsumed;
       
   662                     }
   667                 return EKeyWasNotConsumed;
   663                 return EKeyWasNotConsumed;
   668                 }
   664                 }
   669 
   665 
   670             if ( iOwningView.MenuBar()->ItemSpecificCommandsEnabled() && aKeyEvent.iCode == EKeyBackspace )
   666             
       
   667 			if ( ( iOwningView.MenuBar()->ItemSpecificCommandsEnabled() || SelectionCount() ) && aKeyEvent.iCode == EKeyBackspace )
   671                 {
   668                 {
   672                 MarkItemSelectionL();
   669                 MarkItemSelectionL();
   673                 SetAnchorItemIdL( 
   670                 SetAnchorItemIdL( 
   674                     CMceMessageListContainerBase::EMessageListOperationGeneral );
   671                     CMceMessageListContainerBase::EMessageListOperationGeneral );
   675                 const TInt itemCount = CurrentItemSelectionCount();
   672                 const TInt itemCount = CurrentItemSelectionCount();
  1320     TBool aDraw )
  1317     TBool aDraw )
  1321     {
  1318     {
  1322 #ifdef _DEBUG
  1319 #ifdef _DEBUG
  1323     RDebug::Print(_L("CMceMessageListContainer2: iAnchorItemId 0x%x, iAnchorItemIndex %d"), iAnchorItemId, iAnchorItemIndex);
  1320     RDebug::Print(_L("CMceMessageListContainer2: iAnchorItemId 0x%x, iAnchorItemIndex %d"), iAnchorItemId, iAnchorItemIndex);
  1324 #endif
  1321 #endif
       
  1322     // listitem addition handling when all the new item indexes can be resolved
       
  1323     if( iOwningView.MarkingMode() && iAddedMsvIds->Count() > 0 )
       
  1324         {
       
  1325         TBool allItemsInTheList( ETrue );
       
  1326         CArrayFix<TInt>* addedIndexes = new( ELeave ) CArrayFixFlat<TInt> (
       
  1327                 KMceListContainerGranuality );
       
  1328         CleanupStack::PushL( addedIndexes );
       
  1329         for( TInt i( 0 ); i < iAddedMsvIds->Count(); i++ )
       
  1330             {
       
  1331             TMsvId msvId = (*iAddedMsvIds)[i];                 
       
  1332             TInt index = iListItems->ItemIndex( msvId );
       
  1333             if ( index > KErrNotFound )
       
  1334                 {
       
  1335                 addedIndexes->AppendL( index );
       
  1336                 }
       
  1337             else
       
  1338                 {
       
  1339                 allItemsInTheList = EFalse;
       
  1340                 break;
       
  1341                 }
       
  1342             }
       
  1343         if( allItemsInTheList )
       
  1344             {
       
  1345             ItemCountChangedL( ETrue, addedIndexes );
       
  1346             iAddedMsvIds->Reset();
       
  1347             }
       
  1348         CleanupStack::PopAndDestroy( addedIndexes );
       
  1349         addedIndexes = NULL;
       
  1350         }
       
  1351     else if( iAddedMsvIds->Count() > 0 )
       
  1352         {
       
  1353         iAddedMsvIds->Reset();
       
  1354         }
  1325     switch ( aEvent )
  1355     switch ( aEvent )
  1326         {
  1356         {
  1327         case MMsvSessionObserver::EMsvEntriesDeleted:
  1357         case MMsvSessionObserver::EMsvEntriesDeleted:
  1328             {
  1358             {
  1329 /*            if ( iOwningView.IsMSKMailBox() ) // focus setting only for email
  1359 /*            if ( iOwningView.IsMSKMailBox() ) // focus setting only for email
  1354                 RefreshListbox();
  1384                 RefreshListbox();
  1355                 }
  1385                 }
  1356             }
  1386             }
  1357         break;
  1387         break;
  1358         case MMsvSessionObserver::EMsvEntriesCreated:    
  1388         case MMsvSessionObserver::EMsvEntriesCreated:    
       
  1389             {
       
  1390             if( iOwningView.MarkingMode() )
       
  1391                 {
       
  1392                 // list item count not updated fast enough in hw so let's 
       
  1393                 // collect added ids for future handling
       
  1394                 for( TInt i( 0 ); i < aSelection.Count(); i++ )
       
  1395                     {
       
  1396                     TMsvId msvId = (aSelection)[ i ];
       
  1397                     if( iAddedMsvIds->Find( msvId ) == KErrNotFound  )
       
  1398                         {
       
  1399                         iAddedMsvIds->AppendL( msvId );
       
  1400                         }
       
  1401                     }
       
  1402                 }
       
  1403             else
       
  1404                 {
       
  1405                 ItemCountChangedL( ETrue );
       
  1406                 }
       
  1407             }
  1359         case MMsvSessionObserver::EMsvEntriesChanged:
  1408         case MMsvSessionObserver::EMsvEntriesChanged:
  1360             {
  1409             {
  1361             
  1410             if( aEvent == MMsvSessionObserver::EMsvEntriesChanged  )
  1362             ItemCountChangedL( ETrue );
  1411                 {
  1363             
  1412                 ItemCountChangedL( ETrue );
       
  1413                 }
  1364             if ( iLastOperationType != EMessageListOperationConnect &&
  1414             if ( iLastOperationType != EMessageListOperationConnect &&
  1365                  iAnchorItemId != KErrNotFound )
  1415                  iAnchorItemId != KErrNotFound )
  1366                 {
  1416                 {
  1367                 if ( iOwningView.IsMSKMailBox() ) // focus setting only for email
  1417                 if ( iOwningView.IsMSKMailBox() ) // focus setting only for email
  1368                     {
  1418                     {
  1537 void CMceMessageListContainer::UpdateIconArrayL()
  1587 void CMceMessageListContainer::UpdateIconArrayL()
  1538     {
  1588     {
  1539     // do nothing for two row list.
  1589     // do nothing for two row list.
  1540     }
  1590     }
  1541 
  1591 
       
  1592 void CMceMessageListContainer::SetMarkingModeOff()
       
  1593     {
       
  1594     if( iListBox )
       
  1595         {
       
  1596         iListBox->SetMarkingMode( EFalse );
       
  1597         }
       
  1598     }
       
  1599 
  1542 //  End of File
  1600 //  End of File