uifw/EikStd/coctlsrc/EIKLBX.CPP
branchRCL_3
changeset 72 a5e7a4f63858
parent 59 978afdc0236f
equal deleted inserted replaced
64:85902f042028 72:a5e7a4f63858
    73 #include <akncollection.h>
    73 #include <akncollection.h>
    74 #include <aknitemactionmenu.h>
    74 #include <aknitemactionmenu.h>
    75 #include <aknlongtapdetector.h>
    75 #include <aknlongtapdetector.h>
    76 #include <AknPriv.hrh>
    76 #include <AknPriv.hrh>
    77 #include <aknmarkingmodeobserver.h>
    77 #include <aknmarkingmodeobserver.h>
    78 #include <aknmarkingmode.h>
       
    79 #include "akntrace.h"
    78 #include "akntrace.h"
    80 
    79 
    81 // timeout for long keypress used in markable lists
    80 // timeout for long keypress used in markable lists
    82 const TInt KLongPressInterval = 600000; // 0,6 seconds
    81 const TInt KLongPressInterval = 600000; // 0,6 seconds
    83 const TInt KEikListBoxPointerRepeatInterval = 100000;  // in micro conds (= 0.1 secod)
    82 const TInt KEikListBoxPointerRepeatInterval = 100000;  // in micro conds (= 0.1 secod)
  1045         TUint aExtensionId, TAny*& a0, TAny* /*a1*/ )
  1044         TUint aExtensionId, TAny*& a0, TAny* /*a1*/ )
  1046     {
  1045     {
  1047     if ( aExtensionId == MAknMarkingCollection::TYPE )
  1046     if ( aExtensionId == MAknMarkingCollection::TYPE )
  1048         {
  1047         {
  1049         a0 = static_cast<MAknMarkingCollection*>( this );
  1048         a0 = static_cast<MAknMarkingCollection*>( this );
  1050         return KErrNone;
  1049         }
  1051         }
  1050 
  1052 
  1051     return KErrNone;
  1053     return KErrNotFound;
       
  1054     }
  1052     }
  1055 
  1053 
  1056 
  1054 
  1057 // -----------------------------------------------------------------------------
  1055 // -----------------------------------------------------------------------------
  1058 // CListBoxExt::SetMultipleMarkingState
  1056 // CListBoxExt::SetMultipleMarkingState
  1059 // -----------------------------------------------------------------------------
  1057 // -----------------------------------------------------------------------------
  1060 //
  1058 //
  1061 void CListBoxExt::SetMultipleMarkingState( TBool aActive )
  1059 void CListBoxExt::SetMultipleMarkingState( TBool aActive )
  1062     {
  1060     {
  1063     _AKNTRACE_FUNC_ENTER;
  1061     _AKNTRACE_FUNC_ENTER;
  1064     if ( iMarkingModeInUse != aActive ) 
  1062     iListBox.SetMarkingMode( aActive );
  1065         {
       
  1066         if ( aActive )
       
  1067             {
       
  1068             iListBox.iView->ItemDrawer()->SetFlags( 
       
  1069                     CListItemDrawer::EMarkingModeEnabled );
       
  1070             }
       
  1071         else
       
  1072             {
       
  1073             iListBox.iView->ItemDrawer()->ClearFlags( 
       
  1074                     CListItemDrawer::EMarkingModeEnabled );        
       
  1075 
       
  1076             if ( iListBox.iView->SelectionIndexes()->Count() > 0 )
       
  1077                 {
       
  1078                 iListBox.iView->ClearSelection( EFalse );
       
  1079                 }
       
  1080             } 
       
  1081 
       
  1082         iMarkingModeInUse = aActive;
       
  1083         iListBox.DrawDeferred();
       
  1084         } 
       
  1085 
       
  1086     if ( iListBox.MarkingModeObserver() )
       
  1087         {
       
  1088         iListBox.MarkingModeObserver()->MarkingModeStatusChanged( aActive );
       
  1089         }
       
  1090     
       
  1091     _AKNTRACE_FUNC_EXIT;
  1063     _AKNTRACE_FUNC_EXIT;
  1092     }
  1064     }
  1093 
  1065 
  1094 // -----------------------------------------------------------------------------
  1066 // -----------------------------------------------------------------------------
  1095 // CListBoxExt::ExitMarkingMode
  1067 // CListBoxExt::ExitMarkingMode
  1141         {
  1113         {
  1142         TInt index = iListBox.CurrentItemIndex();
  1114         TInt index = iListBox.CurrentItemIndex();
  1143         if ( index >= 0 && 
  1115         if ( index >= 0 && 
  1144                 !iListBox.iItemDrawer->Properties( index ).IsSelectionHidden() )
  1116                 !iListBox.iItemDrawer->Properties( index ).IsSelectionHidden() )
  1145             {
  1117             {
  1146             iListBox.View()->SelectItemL( index );
  1118             iListBox.View()->SelectItemL( iListBox.CurrentItemIndex() );
  1147             }
  1119             }
  1148         }
  1120         }
  1149     _AKNTRACE_FUNC_EXIT;
  1121     _AKNTRACE_FUNC_EXIT;
  1150     }
  1122     }
  1151 
  1123 
  1155 // -----------------------------------------------------------------------------
  1127 // -----------------------------------------------------------------------------
  1156 //
  1128 //
  1157 void CListBoxExt::MarkAllL()
  1129 void CListBoxExt::MarkAllL()
  1158     {
  1130     {
  1159     _AKNTRACE_FUNC_ENTER;
  1131     _AKNTRACE_FUNC_ENTER;
  1160     
  1132 
  1161     if ( iListBox.MarkingMode() && 
  1133     if ( iListBox.MarkingMode() )
  1162             iListBox.Model()->NumberOfItems() > 0 )
  1134         {       
  1163         {               
  1135         for ( TInt i = 0; i < iListBox.Model()->NumberOfItems(); ++i )
  1164         iListBox.View()->SelectAllL( ETrue );   
  1136             {
       
  1137             if ( !iListBox.iItemDrawer->Properties( i ).IsSelectionHidden() )
       
  1138                 {
       
  1139                 iListBox.View()->SelectItemL( i );
       
  1140                 }
       
  1141             }
  1165         }
  1142         }
  1166     _AKNTRACE_FUNC_EXIT;
  1143     _AKNTRACE_FUNC_EXIT;
  1167     }
  1144     }
  1168 
  1145 
  1169 
  1146 
  1210                                        const TPoint& aPenEventScreenLocation )
  1187                                        const TPoint& aPenEventScreenLocation )
  1211     {
  1188     {
  1212     _AKNTRACE_FUNC_ENTER;
  1189     _AKNTRACE_FUNC_ENTER;
  1213     iLongTappedItem = iLastDownTappedItem;
  1190     iLongTappedItem = iLastDownTappedItem;
  1214     iLastDownTappedItem = KErrNotFound;
  1191     iLastDownTappedItem = KErrNotFound;
  1215     iListBox.ReportListBoxEventL( MEikListBoxObserver::EEventItemLongTapped );
       
  1216     iItemActionMenu->ShowMenuL( aPenEventScreenLocation, 0 );
  1192     iItemActionMenu->ShowMenuL( aPenEventScreenLocation, 0 );
       
  1193     IgnorePointerEventsUntilUp();
  1217     iOldWinPos = iListBox.DrawableWindow()->OrdinalPosition();
  1194     iOldWinPos = iListBox.DrawableWindow()->OrdinalPosition();
  1218     _AKNTRACE_FUNC_EXIT;
  1195     _AKNTRACE_FUNC_EXIT;
  1219     }
  1196     }
  1220 
  1197 
  1221 
  1198 
  3442     UpdateScrollBarsL();
  3419     UpdateScrollBarsL();
  3443     UpdateScrollBarThumbs();
  3420     UpdateScrollBarThumbs();
  3444     iView->ClearFlags(CListBoxView::EItemCountModified);
  3421     iView->ClearFlags(CListBoxView::EItemCountModified);
  3445 
  3422 
  3446 
  3423 
  3447     if ( iListBoxExt->iItemActionMenu &&
  3424     if ( iListBoxExt && iListBoxExt->iLongTappedItem != KErrNotFound )
  3448          iListBoxExt->iLongTappedItem != KErrNotFound )
  3425         {
  3449         {
  3426         iListBoxExt->EnableHighlight( EFalse );
  3450         // Item action menu is being shown and it needs to be closed when
       
  3451         // items are added or removed to the list array, otherwise the
       
  3452         // item specific commands may be targeted to the wrong item. 
       
  3453         iListBoxExt->iItemActionMenu->HideMenu();
       
  3454         }
  3427         }
  3455 
  3428 
  3456     FireItemChange();
  3429     FireItemChange();
  3457     
  3430     
  3458     if ( iListBoxExt && iListBoxExt->iPhysics )
  3431     if ( iListBoxExt && iListBoxExt->iPhysics )
  3533 
  3506 
  3534 EXPORT_C void CEikListBox::HandleItemAdditionL()
  3507 EXPORT_C void CEikListBox::HandleItemAdditionL()
  3535     {
  3508     {
  3536     _AKNTRACE_FUNC_ENTER;
  3509     _AKNTRACE_FUNC_ENTER;
  3537     __ASSERT_DEBUG( iView, Panic( EEikPanicListBoxNoView ) );
  3510     __ASSERT_DEBUG( iView, Panic( EEikPanicListBoxNoView ) );
  3538 
  3511     //fix the bug EGGO-7SQA4S and EVSG-7TD9WZ     
  3539     TInt curItemIndex = iView->CurrentItemIndex();
  3512     TInt curItemIndex = iView->CurrentItemIndex();
  3540     if(curItemIndex >= 0 && curItemIndex < iModel->NumberOfItems() )
  3513     if(curItemIndex >= 0 && curItemIndex < iModel->NumberOfItems() )
  3541       {
  3514       {
  3542       TInt newTopItemIndex = iView->CalcNewTopItemIndexSoItemIsVisible( curItemIndex );
  3515       TInt newTopItemIndex = iView->CalcNewTopItemIndexSoItemIsVisible( curItemIndex );
  3543       iView->SetTopItemIndex( newTopItemIndex );
  3516       iView->SetTopItemIndex( newTopItemIndex );
  3544       }
  3517       }
  3545     iView->SetFlags(CListBoxView::EItemCountModified);
  3518     iView->SetFlags(CListBoxView::EItemCountModified);
  3546 
  3519     // following breaks lists in square layout, not needed in SERIES60?
       
  3520     //iView->CalcDataWidth();
  3547     iView->CalcBottomItemIndex();
  3521     iView->CalcBottomItemIndex();
  3548     UpdateScrollBarsL();
  3522     UpdateScrollBarsL();
  3549     UpdateScrollBarThumbs();
  3523     UpdateScrollBarThumbs();
  3550     if (IsReadyToDraw()) DrawDeferred();
  3524     if (IsReadyToDraw()) DrawDeferred();
  3551     iView->ClearFlags(CListBoxView::EItemCountModified);
  3525     iView->ClearFlags(CListBoxView::EItemCountModified);
  3552 
  3526 
  3553     FireItemChange();
  3527     FireItemChange();
  3554     
  3528     
  3555     if ( iListBoxExt )
  3529     if ( iListBoxExt )
  3556         {
  3530         {    
  3557         iListBoxExt->CheckScrollBarVisibility();
  3531         iListBoxExt->CheckScrollBarVisibility();
  3558         // Physics engine world size needs to be updated here, otherwise aknphysics 
  3532         // Physics engine world size needs to be updated here, otherwise aknphysics 
  3559         // cone observer may block pointer events on new items. this can happen 
  3533         // cone observer may block pointer events on new items. this can happen 
  3560         // when item addition inserts new row to taskswapper's grid and reuses list in Common Dialog
  3534         // when item addition inserts new row to taskswapper's grid and reuses list in Common Dialog
  3561         if ( iListBoxExt->iPhysics )
  3535         if ( iListBoxExt->iPhysics )
  3562             {
  3536             {
  3563             iListBoxExt->InitPhysicsL();
  3537             iListBoxExt->InitPhysicsL();
  3564             }
  3538             }
  3565         
  3539         }     
  3566         if ( iListBoxExt->iItemActionMenu &&
       
  3567              iListBoxExt->iLongTappedItem != KErrNotFound )
       
  3568             {
       
  3569             // Item action menu is being shown and it needs to be closed when
       
  3570             // items are added or removed to the list array, otherwise the
       
  3571             // item specific commands may be targeted to the wrong item. 
       
  3572             iListBoxExt->iItemActionMenu->HideMenu();
       
  3573             }
       
  3574         }
       
  3575 
       
  3576     _AKNTRACE_FUNC_EXIT;
  3540     _AKNTRACE_FUNC_EXIT;
  3577     }
  3541     }
  3578 
  3542 
  3579 EXPORT_C void CEikListBox::HandleItemRemovalL()
  3543 EXPORT_C void CEikListBox::HandleItemRemovalL()
  3580     {
  3544     {
  5191         {
  5155         {
  5192         case TPointerEvent::EButton1Down:
  5156         case TPointerEvent::EButton1Down:
  5193             _AKNTRACE("TPointerEvent::EButton1Down");
  5157             _AKNTRACE("TPointerEvent::EButton1Down");
  5194             // For drag outside listbox
  5158             // For drag outside listbox
  5195             iListBoxExt->iIsDownOnItem = pointerIsOverAnItem;
  5159             iListBoxExt->iIsDownOnItem = pointerIsOverAnItem;
  5196             iListBoxExt->iLastPoint = pointerPos;            
  5160             iListBoxExt->iLastPoint = pointerPos;
  5197 			iListBoxExt->iLongTappedItem = KErrNotFound;
       
  5198 
  5161 
  5199             // update index of the last down tapped item
  5162             // update index of the last down tapped item
  5200             iListBoxExt->iLastDownTappedItem = itemIndex;
  5163             iListBoxExt->iLastDownTappedItem = itemIndex;
  5201             iListBoxExt->iMarkableListShiftKeyPressed = EFalse; 
  5164             iListBoxExt->iMarkableListShiftKeyPressed = EFalse; 
  5202 
  5165 
  6748 // CEikListBox::SetMarkingMode
  6711 // CEikListBox::SetMarkingMode
  6749 // ---------------------------------------------------------------------------
  6712 // ---------------------------------------------------------------------------
  6750 //
  6713 //
  6751 EXPORT_C void CEikListBox::SetMarkingMode( TBool aEnable )
  6714 EXPORT_C void CEikListBox::SetMarkingMode( TBool aEnable )
  6752     {
  6715     {
  6753     _AKNTRACE_FUNC_ENTER;
  6716     if ( iListBoxExt && iListBoxExt->iSingleClickEnabled && 
  6754     if ( iListBoxExt 
  6717             ( iListBoxFlags & CEikListBox::ES60StyleMarkable ) )
  6755              && iListBoxExt->iSingleClickEnabled 
  6718         {
  6756              && ( iListBoxFlags & CEikListBox::ES60StyleMarkable ) 
  6719         if ( iListBoxExt->iMarkingModeInUse != aEnable ) 
  6757              && iListBoxExt->iItemActionMenu
  6720             {
  6758              && iListBoxExt->iMarkingModeInUse != aEnable )
  6721             if ( aEnable )
  6759         {
  6722                 {
  6760         CAknMarkingMode& markingMode = iListBoxExt->iItemActionMenu->MarkingMode();
  6723                 iView->ItemDrawer()->SetFlags( 
  6761         // Multiple marking state will be set, navi pane will be updated
  6724                         CListItemDrawer::EMarkingModeEnabled );
  6762         // and softkeys will be updated when entering and exiting marking mode.       
  6725                 }
  6763         markingMode.SetCollectionMultipleMarkingState( aEnable );
  6726             else
  6764         }
  6727                 {
  6765     _AKNTRACE_FUNC_EXIT;
  6728                 iView->ItemDrawer()->ClearFlags( 
       
  6729                         CListItemDrawer::EMarkingModeEnabled );
       
  6730             
       
  6731                 if ( iView->SelectionIndexes()->Count() > 0 )
       
  6732                     {
       
  6733                     iView->ClearSelection( EFalse );
       
  6734                     }
       
  6735                 }
       
  6736 
       
  6737             iListBoxExt->iMarkingModeInUse = aEnable;
       
  6738             DrawDeferred();
       
  6739             }
       
  6740 
       
  6741         if ( MarkingModeObserver() )
       
  6742             {
       
  6743             MarkingModeObserver()->MarkingModeStatusChanged( aEnable );
       
  6744             }
       
  6745         }
  6766     }
  6746     }
  6767 
  6747 
  6768 
  6748 
  6769 // ---------------------------------------------------------------------------
  6749 // ---------------------------------------------------------------------------
  6770 // CEikListBox::SetMarkingModeObserver
  6750 // CEikListBox::SetMarkingModeObserver
  6771 // ---------------------------------------------------------------------------
  6751 // ---------------------------------------------------------------------------
  6772 //
  6752 //
  6773 EXPORT_C void CEikListBox::SetMarkingModeObserver( 
  6753 EXPORT_C void CEikListBox::SetMarkingModeObserver( 
  6774         MAknMarkingModeObserver* aObserver )
  6754         MAknMarkingModeObserver* aObserver )
  6775     {
  6755     {
  6776     _AKNTRACE_FUNC_ENTER;
       
  6777     if ( iListBoxExt )
  6756     if ( iListBoxExt )
  6778         {
  6757         {
  6779         iListBoxExt->iMarkingModeObserver = aObserver;
  6758         iListBoxExt->iMarkingModeObserver = aObserver;
  6780         }
  6759         }
  6781     _AKNTRACE_FUNC_EXIT;
       
  6782     }
  6760     }
  6783 
  6761 
  6784 
  6762 
  6785 void CEikListBox::ScrollView( const TInt aOffset, TBool aDrawNow )
  6763 void CEikListBox::ScrollView( const TInt aOffset, TBool aDrawNow )
  6786 	{
  6764 	{
  6909             }
  6887             }
  6910         }
  6888         }
  6911 
  6889 
  6912     TBool blockEvent = EFalse;
  6890     TBool blockEvent = EFalse;
  6913     
  6891     
  6914     // If touch down in listbox area, kinetic scrolling is enabled, and single
  6892     TBool allowDragEvent( ( iListBoxFlags & ELeftDownInViewRect ) && !iListBoxExt->iScrollingDisabled );
  6915     // click is disabled or style popup menu is not shown when single click is
  6893 
  6916     // enabled, events of kinetic scrolling are sent to listbox.
       
  6917     TBool allowDragEvent( ( iListBoxFlags & ELeftDownInViewRect ) 
       
  6918         && !iListBoxExt->iScrollingDisabled 
       
  6919         && ( !iListBoxExt->iSingleClickEnabled
       
  6920             || iListBoxExt->iLongTappedItem == KErrNotFound ) );
       
  6921     
  6894     
  6922     switch ( aPointerEvent.iType )
  6895     switch ( aPointerEvent.iType )
  6923         {
  6896         {
  6924         case TPointerEvent::EButton1Down:
  6897         case TPointerEvent::EButton1Down:
  6925             {
  6898             {