uifw/AvKon/aknhlist/src/akntreelistview.cpp
branchRCL_3
changeset 23 3d340a0166ff
parent 18 0aa5fbdfbc30
child 25 941195f2d488
equal deleted inserted replaced
18:0aa5fbdfbc30 23:3d340a0166ff
    24 #include <barsread.h>
    24 #include <barsread.h>
    25 #include <aknappui.h>
    25 #include <aknappui.h>
    26 #include <aknitemactionmenu.h>
    26 #include <aknitemactionmenu.h>
    27 #include <AknTasHook.h> // for testability hooks
    27 #include <AknTasHook.h> // for testability hooks
    28 #include <AknPriv.hrh>
    28 #include <AknPriv.hrh>
       
    29 #include <AknIconArray.h>
       
    30 #include <avkon.mbg>
       
    31 #include <gulicon.h>
    29 #include "akntreelistview.h"
    32 #include "akntreelistview.h"
    30 #include "akntree.h"
    33 #include "akntree.h"
    31 #include "akntreelist.h"
    34 #include "akntreelist.h"
    32 #include "akntreeiterator.h"
    35 #include "akntreeiterator.h"
    33 #include "akntreelistphysicshandler.h"
    36 #include "akntreelistphysicshandler.h"
    47 const TInt KLongPressInterval = 600000; // 0.6 seconds
    50 const TInt KLongPressInterval = 600000; // 0.6 seconds
    48 
    51 
    49 // Number of additional items to draw
    52 // Number of additional items to draw
    50 const TInt KAdditionalItems = 2;
    53 const TInt KAdditionalItems = 2;
    51 
    54 
       
    55 // Space for check box in marking mode
       
    56 const TInt KCheckBoxOffset = 30;
    52 
    57 
    53 // Tree list view flag definitions.
    58 // Tree list view flag definitions.
    54 enum TAknTreeListViewFlags
    59 enum TAknTreeListViewFlags
    55     {
    60     {
    56     EFlagStructureLines,
    61     EFlagStructureLines,
    57     EFlagIndention,
    62     EFlagIndention,
    58     EFlagLooping,
    63     EFlagLooping,
    59     EFlagUpdateBackground,
    64     EFlagUpdateBackground,
    60     EFlagMarkingEnabled, // Marking of list items is enabled.
    65     EFlagMarkingEnabled, // Marking of list items is enabled.
    61     EFlagMarkingMode, // List in marking mode (MSK controlled by list). 
    66     EFlagMarkingState, // List in marking state (MSK controlled by list).
    62     EFlagMark, // List items are being marked.
    67     EFlagMark, // List items are being marked.
    63     EFlagUnmark, // List items are being unmarked.
    68     EFlagUnmark, // List items are being unmarked.
    64     EFlagSimultaneousMarking, // Simultaneous marking ongoing.
    69     EFlagSimultaneousMarking, // Simultaneous marking ongoing.
    65     EFlagHashKeyPressed,
    70     EFlagHashKeyPressed,
    66     EFlagCtrlKeyPressed,
    71     EFlagCtrlKeyPressed,
   110         {
   115         {
   111         iItemActionMenu->RemoveCollection( *this );
   116         iItemActionMenu->RemoveCollection( *this );
   112         }
   117         }
   113     delete iLongTapDetector;
   118     delete iLongTapDetector;
   114 
   119 
       
   120     if ( iMarkingIconArray )
       
   121         {
       
   122         iMarkingIconArray->ResetAndDestroy();
       
   123         }
       
   124 
       
   125     delete iMarkingIconArray;
       
   126 
   115 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   127 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   116     if ( CAknListLoader::TfxApiInternal( iGc ) )
   128     if ( CAknListLoader::TfxApiInternal( iGc ) )
   117         {
   129         {
   118         delete iGc;
   130         delete iGc;
   119         }
   131         }
   468 // SelectItem
   480 // SelectItem
   469 // ---------------------------------------------------------------------------
   481 // ---------------------------------------------------------------------------
   470 //     
   482 //     
   471 void CAknTreeListView::SelectItem( CAknTreeItem* aSelectedItem )
   483 void CAknTreeListView::SelectItem( CAknTreeItem* aSelectedItem )
   472     {
   484     {
   473     SelectItem( aSelectedItem, EFalse );
   485     if ( iMarkingMode )
       
   486         {
       
   487         if ( aSelectedItem->IsMarkable() )
       
   488             {
       
   489             MarkItem( aSelectedItem, !aSelectedItem->IsMarked(), ETrue );
       
   490             }
       
   491         else if ( aSelectedItem->IsNode() )
       
   492             {
       
   493             SelectItem( aSelectedItem, EFalse );
       
   494             }
       
   495         }
       
   496     else 
       
   497         {
       
   498         SelectItem( aSelectedItem, EFalse );
       
   499         }
   474     }
   500     }
   475 
   501 
   476 
   502 
   477 // ---------------------------------------------------------------------------
   503 // ---------------------------------------------------------------------------
   478 // VisibleItemCount
   504 // VisibleItemCount
   785     {
   811     {
   786     CAknControl::HandleResourceChange( aType );
   812     CAknControl::HandleResourceChange( aType );
   787     
   813     
   788     switch ( aType )
   814     switch ( aType )
   789         {
   815         {
       
   816         case KEikMessageWindowsFadeChange:
       
   817              {
       
   818              ReportCollectionChangedEvent();
       
   819              }        
       
   820 
   790         case KAknsMessageSkinChange:
   821         case KAknsMessageSkinChange:
   791             {
   822             {
   792             TRAPD( error, CreateAnimationL() )
   823             TRAPD( error, CreateAnimationL() )
   793             if ( error )
   824             if ( error )
   794                 {
   825                 {
   795                 delete iAnimation;
   826                 delete iAnimation;
   796                 iAnimation = NULL;
   827                 iAnimation = NULL;
   797                 }
   828                 }
       
   829 
       
   830             TRAP_IGNORE( LoadMarkingIconsL() );
   798             break;
   831             break;
   799             }
   832             }
   800 
   833 
   801         case KEikDynamicLayoutVariantSwitch:
   834         case KEikDynamicLayoutVariantSwitch:
   802             {
   835             {
  1306         {
  1339         {
  1307         EnableHighlight( ETrue );
  1340         EnableHighlight( ETrue );
  1308         }
  1341         }
  1309     
  1342     
  1310     iMirroredLayoutInUse = AknLayoutUtils::LayoutMirrored();
  1343     iMirroredLayoutInUse = AknLayoutUtils::LayoutMirrored();
       
  1344     LoadMarkingIconsL();
  1311     }
  1345     }
  1312 
  1346 
  1313 
  1347 
  1314 // ---------------------------------------------------------------------------
  1348 // ---------------------------------------------------------------------------
  1315 // Handles an addition of new item into tree list. The focused item is kept
  1349 // Handles an addition of new item into tree list. The focused item is kept
  1637 void CAknTreeListView::HandleSelectionKeyEvent()
  1671 void CAknTreeListView::HandleSelectionKeyEvent()
  1638     {
  1672     {
  1639     CAknTreeItem* item = FocusedItem();
  1673     CAknTreeItem* item = FocusedItem();
  1640     if ( item )
  1674     if ( item )
  1641         {
  1675         {
  1642         if ( MarkingOngoing() )
  1676         if ( iMarkingMode )
  1643             {
  1677             {
  1644             MarkItem( item, !item->IsMarked(), ETrue );
  1678             if ( item->IsMarkable() )
       
  1679                 {
       
  1680                 MarkItem( item, !item->IsMarked(), ETrue );
       
  1681                 }
  1645             }
  1682             }
  1646         else
  1683         else
  1647             {
  1684             {
  1648             SelectItem( item, true );
  1685             SelectItem( item, EFalse );
  1649             }
  1686             }
  1650         }
  1687         }
  1651     }
  1688     }
  1652 
  1689 
  1653 
  1690 
  1985     CAknTreeItem* first = iItems.Count() ? iItems[0].Item() : NULL;
  2022     CAknTreeItem* first = iItems.Count() ? iItems[0].Item() : NULL;
  1986     if ( first )
  2023     if ( first )
  1987         {
  2024         {
  1988         iterator.SetCurrent( first );
  2025         iterator.SetCurrent( first );
  1989         iterator.Previous();
  2026         iterator.Previous();
       
  2027         }
       
  2028 
       
  2029     if ( iMarkingMode )
       
  2030         {
       
  2031         itemRect.iBr.iX -= KCheckBoxOffset;
  1990         }
  2032         }
  1991 
  2033 
  1992     // Update items and their rectangles.
  2034     // Update items and their rectangles.
  1993     for ( TInt ii = 0; ii < iItems.Count(); ++ii )
  2035     for ( TInt ii = 0; ii < iItems.Count(); ++ii )
  1994         {
  2036         {
  2579         {
  2621         {
  2580         iLongPressTimer->Cancel();
  2622         iLongPressTimer->Cancel();
  2581         }
  2623         }
  2582 
  2624 
  2583     // Exits marking mode.
  2625     // Exits marking mode.
  2584     if ( iFlags.IsSet( EFlagMarkingMode ) )
  2626     if ( iFlags.IsSet( EFlagMarkingState ) )
  2585         {
  2627         {
  2586         ExitMarkingMode();
  2628         ExitMarking();
  2587         }
  2629         }
  2588 
  2630 
  2589     // Remove MSK observer.
  2631     // Remove MSK observer.
  2590     CEikButtonGroupContainer* cba;
  2632     CEikButtonGroupContainer* cba;
  2591     MopGetObject( cba );
  2633     MopGetObject( cba );
  2642 // Handles long press.
  2684 // Handles long press.
  2643 // ---------------------------------------------------------------------------
  2685 // ---------------------------------------------------------------------------
  2644 //
  2686 //
  2645 void CAknTreeListView::DoHandleLongPressL()
  2687 void CAknTreeListView::DoHandleLongPressL()
  2646     {
  2688     {
  2647     if ( iFlags.IsClear( EFlagMarkingMode ) )
  2689     if ( iFlags.IsClear( EFlagMarkingState ) )
  2648         {
  2690         {
  2649         EnterMarkingMode();
  2691         EnterMarking();
  2650         }
  2692         }
  2651     }
  2693     }
  2652 
  2694 
  2653 
  2695 
  2654 // ---------------------------------------------------------------------------
  2696 // ---------------------------------------------------------------------------
  2655 // Enters marking mode.
  2697 // Enters marking state.
  2656 // ---------------------------------------------------------------------------
  2698 // ---------------------------------------------------------------------------
  2657 //
  2699 //
  2658 void CAknTreeListView::EnterMarkingMode()
  2700 void CAknTreeListView::EnterMarking()
  2659     {
  2701     {
  2660     CEikButtonGroupContainer* bgc;
  2702     CEikButtonGroupContainer* bgc;
  2661     CCoeControl* MSK = NULL;
  2703     CCoeControl* MSK = NULL;
  2662     MopGetObject( bgc );
  2704     MopGetObject( bgc );
  2663     if ( bgc )
  2705     if ( bgc )
  2687         TRAPD( err, bgc->AddCommandToStackL( 3, newResourceId ) );
  2729         TRAPD( err, bgc->AddCommandToStackL( 3, newResourceId ) );
  2688         if ( !err )
  2730         if ( !err )
  2689             {
  2731             {
  2690             ReportTreeListEvent( MAknTreeListObserver::EMarkingModeEnabled,
  2732             ReportTreeListEvent( MAknTreeListObserver::EMarkingModeEnabled,
  2691                 iTree.Id( FocusedItem() ) );
  2733                 iTree.Id( FocusedItem() ) );
  2692             iFlags.Set( EFlagMarkingMode );
  2734             iFlags.Set( EFlagMarkingState );
  2693             bgc->DrawNow();
  2735             bgc->DrawNow();
  2694             }
  2736             }
  2695         }
  2737         }
  2696     }
  2738     }
  2697 
  2739 
  2698 
  2740 
  2699 // ---------------------------------------------------------------------------
  2741 // ---------------------------------------------------------------------------
  2700 // Exits marking mode.
  2742 // Exits marking state.
  2701 // ---------------------------------------------------------------------------
  2743 // ---------------------------------------------------------------------------
  2702 //
  2744 //
  2703 void CAknTreeListView::ExitMarkingMode()
  2745 void CAknTreeListView::ExitMarking()
  2704     {
  2746     {
  2705     if ( iFlags.IsSet( EFlagMarkingMode ) )
  2747     if ( iFlags.IsSet( EFlagMarkingState ) )
  2706         {
  2748         {
  2707         CEikButtonGroupContainer* bgc = NULL;
  2749         CEikButtonGroupContainer* bgc = NULL;
  2708         CCoeControl* MSK = NULL;
  2750         CCoeControl* MSK = NULL;
  2709         MopGetObject( bgc );
  2751         MopGetObject( bgc );
  2710         if ( bgc )
  2752         if ( bgc )
  2720                     }
  2762                     }
  2721                 }
  2763                 }
  2722             }
  2764             }
  2723         ReportTreeListEvent( MAknTreeListObserver::EMarkingModeDisabled,
  2765         ReportTreeListEvent( MAknTreeListObserver::EMarkingModeDisabled,
  2724             iTree.Id( FocusedItem() ) );
  2766             iTree.Id( FocusedItem() ) );
  2725         iFlags.Clear( EFlagMarkingMode );
  2767         iFlags.Clear( EFlagMarkingState );
  2726         }
  2768         }
  2727     }
  2769     }
  2728 
  2770 
  2729 
  2771 
  2730 // ---------------------------------------------------------------------------
  2772 // ---------------------------------------------------------------------------
  2766 // ---------------------------------------------------------------------------
  2808 // ---------------------------------------------------------------------------
  2767 //
  2809 //
  2768 void CAknTreeListView::DrawItemsWithPhysics( const TRect& aRect ) const
  2810 void CAknTreeListView::DrawItemsWithPhysics( const TRect& aRect ) const
  2769     {
  2811     {
  2770     TBool empty = IsEmpty();
  2812     TBool empty = IsEmpty();
  2771     TInt offset = Offset();  
  2813     TInt offset = Offset();
  2772 
       
  2773 #ifdef RD_UI_TRANSITION_EFFECTS_LIST    
  2814 #ifdef RD_UI_TRANSITION_EFFECTS_LIST    
  2774     CWindowGc& gc = iGc && !empty ? *iGc : SystemGc();
  2815     CWindowGc& gc = iGc && !empty ? *iGc : SystemGc();
  2775 #else
  2816 #else
  2776     CWindowGc& gc = SystemGc();
  2817     CWindowGc& gc = SystemGc();
  2777 #endif
  2818 #endif
  2825         AknsUtils::GetCachedColor( skin,
  2866         AknsUtils::GetCachedColor( skin,
  2826                                    textColor, 
  2867                                    textColor, 
  2827                                    KAknsIIDQsnTextColors,
  2868                                    KAknsIIDQsnTextColors,
  2828                                    EAknsCIQsnTextColorsCG6 );
  2869                                    EAknsCIQsnTextColorsCG6 );
  2829 
  2870 
       
  2871         if ( iMarkingMode && iMarkingIconArray && iMarkingIconArray->Count()== 2 )
       
  2872             {
       
  2873             // Set sizes for marking icon bitmaps
       
  2874             TRect drawRect; 
       
  2875             if ( iItems.Count() > 0 ) 
       
  2876                 {
       
  2877                 drawRect = iItems[0].Rect();
       
  2878                 drawRect.iBr.iX += KCheckBoxOffset;
       
  2879                 }
       
  2880 
       
  2881             // Rect for the marking icon
       
  2882             TRect iconRect = RectFromLayout( drawRect,
       
  2883                     AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
       
  2884             iconRect.Move( 0, -offset );
       
  2885             
       
  2886             gc.SetPenColor( textColor );
       
  2887             gc.SetPenStyle( CGraphicsContext::ESolidPen );
       
  2888             
       
  2889             for ( TInt ii = 0; ii < iMarkingIconArray->Count(); ++ii )
       
  2890                 {
       
  2891                 CGulIcon* icon = (*iMarkingIconArray)[ii];
       
  2892                 CFbsBitmap* bitmap = icon->Bitmap();
       
  2893 
       
  2894                 if ( bitmap )
       
  2895                     {
       
  2896                     TSize size( bitmap->SizeInPixels() ); // set size if not already
       
  2897                     TSize targetSize( iconRect.Size() );
       
  2898 
       
  2899                     if ( size.iWidth != targetSize.iWidth && size.iHeight
       
  2900                             != targetSize.iHeight )
       
  2901                         {
       
  2902                         AknIconUtils::SetSize( bitmap, targetSize,
       
  2903                                 EAspectRatioPreservedAndUnusedSpaceRemoved );
       
  2904                         }
       
  2905                     }
       
  2906                 }
       
  2907             }
  2830         const TInt itemCount = iItems.Count();
  2908         const TInt itemCount = iItems.Count();
  2831         for ( TInt ii = 0; ii < itemCount; ++ii )
  2909         for ( TInt ii = 0; ii < itemCount; ++ii )
  2832             {
  2910             {
  2833             TRect drawRect( iItems[ii].Rect() );
  2911             TRect drawRect( iItems[ii].Rect() );
       
  2912 
       
  2913             if ( iMarkingMode )
       
  2914                 {
       
  2915                 drawRect.iBr.iX += KCheckBoxOffset;
       
  2916                 }
  2834 
  2917 
  2835             if ( iItems[ii].Item() )
  2918             if ( iItems[ii].Item() )
  2836                 {
  2919                 {
  2837 
  2920 
  2838 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2921 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2873                     {
  2956                     {
  2874                     transApi->StopDrawing();
  2957                     transApi->StopDrawing();
  2875                     }
  2958                     }
  2876 #endif
  2959 #endif
  2877 
  2960 
       
  2961                 if ( iMarkingMode && iMarkingIconArray && iMarkingIconArray->Count()== 2 )
       
  2962                     {
       
  2963                     // Rect for the marking icon
       
  2964                     TRect iconRect = RectFromLayout( drawRect,
       
  2965                         AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
       
  2966             
       
  2967                     iconRect.Move( 0, -offset );
       
  2968                     CGulIcon* icon = (*iMarkingIconArray)[1]; // unchecked
       
  2969 
       
  2970                     TBool marked = ( iItems[ii].Item()->IsMarked() );
       
  2971                     if ( marked )
       
  2972                         {
       
  2973                         icon = (*iMarkingIconArray)[0];
       
  2974                         }
       
  2975 
       
  2976                     CFbsBitmap* bitmap = icon->Bitmap();
       
  2977 
       
  2978                     if ( bitmap )
       
  2979                         {
       
  2980                         gc.BitBltMasked( iconRect.iTl, bitmap, 
       
  2981                             iconRect.Size(), icon->Mask(), EFalse );
       
  2982                        }
       
  2983                     }
       
  2984 
  2878                 if ( iItems[ii].Item() != iBottomItem )
  2985                 if ( iItems[ii].Item() != iBottomItem )
  2879                     {
  2986                     {
  2880                     TRect offsetRect( drawRect );
  2987                     TRect offsetRect( drawRect );
  2881                     offsetRect.Move( 0, -offset );
  2988                     offsetRect.Move( 0, -offset );
  2882                     AknListUtils::DrawSeparator( gc, offsetRect, textColor, skin );
  2989                     AknListUtils::DrawSeparator( gc, offsetRect, textColor, skin );
       
  2990                     }
       
  2991 
       
  2992                 if ( iMarkingMode )
       
  2993                     {
       
  2994                     gc.SetOrigin( TPoint( KCheckBoxOffset, 0 ) );
       
  2995                     drawRect.iBr.iX -= KCheckBoxOffset;
  2883                     }
  2996                     }
  2884 
  2997 
  2885                 TBool focused = ( FocusedItem() &&
  2998                 TBool focused = ( FocusedItem() &&
  2886                     iItems[ii].Item() == FocusedItem() );
  2999                     iItems[ii].Item() == FocusedItem() );
  2887 
  3000 
  2942                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  3055                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  2943                     transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
  3056                     transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
  2944                     }
  3057                     }
  2945 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3058 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2946 
  3059 
  2947                 // Draw item.
  3060                 if ( iMarkingMode )
  2948                 iItems[ii].Draw( gc, iTree, drawRect, focused, iViewLevel,
  3061                     {
  2949                     StructureLines(), Indention(), IndentionWidth() );
  3062                     TBool marked = iItems[ii].Item()->IsMarked();
       
  3063                     if ( marked )
       
  3064                         {
       
  3065                         iItems[ii].Item()->SetMarked( EFalse );
       
  3066                         }           
       
  3067                     iItems[ii].Draw( gc, iTree, drawRect, focused, iViewLevel,
       
  3068                         StructureLines(), Indention(), IndentionWidth() );
       
  3069 
       
  3070                     if ( marked )
       
  3071                         {
       
  3072                         iItems[ii].Item()->SetMarked( ETrue );
       
  3073                         }
       
  3074                     }
       
  3075                 else
       
  3076                     {
       
  3077                     iItems[ii].Draw( gc, iTree, drawRect, focused, iViewLevel,
       
  3078                             StructureLines(), Indention(), IndentionWidth() );                
       
  3079                     }
  2950 
  3080 
  2951 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3081 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2952                 if ( transApi )
  3082                 if ( transApi )
  2953                     {
  3083                     {
  2954                     transApi->StopDrawing();
  3084                     transApi->StopDrawing();
  2957                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  3087                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  2958                     }
  3088                     }
  2959                 }
  3089                 }
  2960 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3090 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2961 
  3091 
       
  3092                 if ( iMarkingMode )
       
  3093                     {
       
  3094                     gc.SetOrigin( TPoint( 0, 0 ) );
       
  3095                     }
  2962                 }
  3096                 }
  2963             }
  3097             }
  2964         }
  3098         }
  2965 
  3099 
  2966 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3100 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3068 
  3202 
  3069 // ---------------------------------------------------------------------------
  3203 // ---------------------------------------------------------------------------
  3070 // Enables or disables the highlight drawing
  3204 // Enables or disables the highlight drawing
  3071 // ---------------------------------------------------------------------------
  3205 // ---------------------------------------------------------------------------
  3072 //
  3206 //
  3073 void CAknTreeListView::EnableHighlight( TBool aEnabled )
  3207 void CAknTreeListView::EnableHighlight( TBool aEnabled, 
  3074     {
  3208                                         TBool aPointerEnabled )
       
  3209     {
       
  3210     TBool wasEnabled = iFlags.IsSet( EFlagHighlightEnabled );
       
  3211 
  3075     if ( aEnabled )
  3212     if ( aEnabled )
  3076         {
  3213         {
  3077         iFlags.Set( EFlagHighlightEnabled );
  3214         iFlags.Set( EFlagHighlightEnabled );
  3078         }
  3215         }
  3079     else
  3216     else
  3080         {
  3217         {
  3081         iFlags.Clear( EFlagHighlightEnabled );
  3218         iFlags.Clear( EFlagHighlightEnabled );
       
  3219         }
       
  3220 
       
  3221     if ( !aPointerEnabled
       
  3222             && ( ( wasEnabled && !aEnabled )
       
  3223                     || ( !wasEnabled && aEnabled ) ) )
       
  3224         {
       
  3225         ReportCollectionChangedEvent();
  3082         }
  3226         }
  3083     }
  3227     }
  3084 
  3228 
  3085 // ---------------------------------------------------------------------------
  3229 // ---------------------------------------------------------------------------
  3086 // Returns ETrue if highlight is enabled
  3230 // Returns ETrue if highlight is enabled
  3109 // -----------------------------------------------------------------------------
  3253 // -----------------------------------------------------------------------------
  3110 //
  3254 //
  3111 TUint CAknTreeListView::CollectionState() const
  3255 TUint CAknTreeListView::CollectionState() const
  3112     {
  3256     {
  3113     TUint state( 0 );
  3257     TUint state( 0 );
  3114     if ( IsVisible() )
  3258     if ( IsVisible() && ( !DrawableWindow() || !DrawableWindow()->IsFaded() ) )
  3115         {
  3259         {
  3116         state |= MAknCollection::EStateCollectionVisible;
  3260         state |= MAknCollection::EStateCollectionVisible;
  3117         }
  3261         }
  3118     if ( HighlightEnabled() )
  3262     if ( HighlightEnabled() )
  3119         {
  3263         {
  3120         state |= MAknCollection::EStateHighlightVisible;
  3264         state |= MAknCollection::EStateHighlightVisible;
  3121         }
  3265         }
       
  3266 
       
  3267     if ( iList.Flags() & KAknTreeListMarkable )
       
  3268         {
       
  3269         state |= MAknCollection::EStateMultipleSelection;        
       
  3270         }
       
  3271 
  3122     return state;
  3272     return state;
  3123     }
  3273     }
  3124 
  3274 
  3125 // -----------------------------------------------------------------------------
  3275 // -----------------------------------------------------------------------------
  3126 // CAknTreeListView::ItemActionMenuClosed
  3276 // CAknTreeListView::ItemActionMenuClosed
  3135 
  3285 
  3136 // -----------------------------------------------------------------------------
  3286 // -----------------------------------------------------------------------------
  3137 // CAknTreeListView::CollectionExtension
  3287 // CAknTreeListView::CollectionExtension
  3138 // -----------------------------------------------------------------------------
  3288 // -----------------------------------------------------------------------------
  3139 //
  3289 //
  3140 TInt CAknTreeListView::CollectionExtension( TUint /*aExtensionId*/,
  3290 TInt CAknTreeListView::CollectionExtension(
  3141         TAny*& /*a0*/, TAny* /*a1*/ )
  3291         TUint aExtensionId, TAny*& a0, TAny* /*a1*/ )
  3142     {
  3292     {
       
  3293     if ( aExtensionId == MAknMarkingCollection::TYPE )
       
  3294         {
       
  3295         a0 = static_cast<MAknMarkingCollection*>( this );
       
  3296         }
       
  3297 
  3143     return KErrNone;
  3298     return KErrNone;
  3144     }
  3299     }
       
  3300 
       
  3301 
       
  3302 // -----------------------------------------------------------------------------
       
  3303 // CAknTreeListView::SetMultipleMarkingState
       
  3304 // -----------------------------------------------------------------------------
       
  3305 //
       
  3306 void CAknTreeListView::SetMultipleMarkingState( TBool aActive )
       
  3307     {
       
  3308     if ( iMarkingMode != aActive )
       
  3309         {
       
  3310         if ( !aActive )
       
  3311             {
       
  3312             TBool markedItems( EFalse );
       
  3313             TRAP_IGNORE( markedItems = HasMarkedItemsL() );
       
  3314             if ( markedItems )
       
  3315                 {
       
  3316                 UnmarkAll();
       
  3317                 }
       
  3318             }
       
  3319         
       
  3320         EnableMarking( aActive );
       
  3321         iMarkingMode = aActive;
       
  3322         LayoutView();
       
  3323         DrawDeferred();
       
  3324 
       
  3325         if ( iList.MarkingModeObserver() )
       
  3326             {
       
  3327             iList.MarkingModeObserver()->MarkingModeStatusChanged( aActive );
       
  3328             }
       
  3329         }
       
  3330     }
       
  3331 
       
  3332 
       
  3333 // -----------------------------------------------------------------------------
       
  3334 // CAknTreeListView::MarkingState
       
  3335 // -----------------------------------------------------------------------------
       
  3336 //
       
  3337 TUint CAknTreeListView::MarkingState() const
       
  3338     {
       
  3339     TUint state( 0 );
       
  3340 
       
  3341     if ( iMarkingMode )
       
  3342         {
       
  3343         state |= MAknMarkingCollection::EStateMarkingMode;
       
  3344 
       
  3345         TBool markedItems ( EFalse );
       
  3346         TRAP_IGNORE( markedItems = HasMarkedItemsL() );
       
  3347         if ( markedItems )
       
  3348             {
       
  3349             state |= MAknMarkingCollection::EStateMarkedItems;
       
  3350             }
       
  3351         if ( iItems.Count() == 0 )
       
  3352             {
       
  3353             state |= MAknMarkingCollection::EStateCollectionEmpty;
       
  3354             }
       
  3355         }
       
  3356     return state;
       
  3357     }
       
  3358 
       
  3359 
       
  3360 // -----------------------------------------------------------------------------
       
  3361 // CAknTreeListView::MarkCurrentItemL
       
  3362 // -----------------------------------------------------------------------------
       
  3363 //
       
  3364 void CAknTreeListView::MarkCurrentItemL()
       
  3365     {
       
  3366     if ( iMarkingMode && FocusedItem() && FocusedItem()->IsMarkable() )
       
  3367         {
       
  3368         MarkItem( FocusedItem(), ETrue, ETrue );
       
  3369         }
       
  3370     }
       
  3371 
       
  3372 
       
  3373 // -----------------------------------------------------------------------------
       
  3374 // CAknTreeListView::MarkAllL
       
  3375 // -----------------------------------------------------------------------------
       
  3376 //
       
  3377 void CAknTreeListView::MarkAllL()
       
  3378     {
       
  3379     if ( iMarkingMode )
       
  3380         {
       
  3381         TAknTreeIterator iterator = iTree.Iterator();
       
  3382         CAknTreeItem* item = NULL;
       
  3383         item = iterator.First(); 
       
  3384         while ( item && iterator.HasNext() )
       
  3385             {
       
  3386             if ( item->IsMarkable() )
       
  3387                 {
       
  3388                 MarkItem( item, ETrue, EFalse );
       
  3389                 }
       
  3390             item = iterator.Next();
       
  3391             }
       
  3392         DrawDeferred(); 
       
  3393         }
       
  3394     }
       
  3395 
       
  3396 
       
  3397 // -----------------------------------------------------------------------------
       
  3398 // CAknTreeListView::UnmarkAll
       
  3399 // -----------------------------------------------------------------------------
       
  3400 //
       
  3401 void CAknTreeListView::UnmarkAll()
       
  3402     {
       
  3403     if ( iMarkingMode )
       
  3404         {
       
  3405         TAknTreeIterator iterator = iTree.Iterator();
       
  3406         CAknTreeItem* item = NULL;
       
  3407         item = iterator.First(); 
       
  3408         while ( item && iterator.HasNext() )
       
  3409             {
       
  3410             MarkItem( item, EFalse, EFalse );
       
  3411             item = iterator.Next();
       
  3412             }
       
  3413         DrawDeferred(); 
       
  3414         }
       
  3415     }
       
  3416 
       
  3417 
       
  3418  // -----------------------------------------------------------------------------
       
  3419 // CAknTreeListView::CurrentItemMarkable
       
  3420 // -----------------------------------------------------------------------------
       
  3421 //
       
  3422 TBool CAknTreeListView::CurrentItemMarkable()
       
  3423     {
       
  3424     if ( FocusedItem() && !FocusedItem()->IsMarkable() ) 
       
  3425         {
       
  3426         return EFalse;
       
  3427         }
       
  3428     return ETrue; 
       
  3429     }
       
  3430 
       
  3431 // -----------------------------------------------------------------------------
       
  3432 // CAknTreeListView::ExitMarkingMode
       
  3433 // -----------------------------------------------------------------------------
       
  3434 //
       
  3435 TBool CAknTreeListView::ExitMarkingMode()
       
  3436     {
       
  3437     if ( iList.MarkingModeObserver() )
       
  3438         {
       
  3439         return iList.MarkingModeObserver()->ExitMarkingMode();
       
  3440         }
       
  3441     return ETrue; 
       
  3442     }
       
  3443 
       
  3444 
       
  3445 // -----------------------------------------------------------------------------
       
  3446 // CAknTreeListView::ReportCollectionChangedEvent
       
  3447 // -----------------------------------------------------------------------------
       
  3448 //
       
  3449 void CAknTreeListView::ReportCollectionChangedEvent()
       
  3450     {
       
  3451     if ( iItemActionMenu )
       
  3452         {
       
  3453         iItemActionMenu->CollectionChanged( *this );
       
  3454         }
       
  3455     }
       
  3456 
  3145 
  3457 
  3146 // ---------------------------------------------------------------------------
  3458 // ---------------------------------------------------------------------------
  3147 // CAknTreeListView::HandleLongTapEventL
  3459 // CAknTreeListView::HandleLongTapEventL
  3148 // ---------------------------------------------------------------------------
  3460 // ---------------------------------------------------------------------------
  3149 //
  3461 //
  3184 
  3496 
  3185 // ---------------------------------------------------------------------------
  3497 // ---------------------------------------------------------------------------
  3186 // CAknTreeListView::HasMarkedItemsL
  3498 // CAknTreeListView::HasMarkedItemsL
  3187 // ---------------------------------------------------------------------------
  3499 // ---------------------------------------------------------------------------
  3188 //
  3500 //
  3189 TBool CAknTreeListView::HasMarkedItemsL()
  3501 TBool CAknTreeListView::HasMarkedItemsL() const
  3190     {
  3502     {
  3191     RArray<TInt> selection;
  3503     RArray<TInt> selection;
  3192     CleanupClosePushL( selection );
  3504     CleanupClosePushL( selection );
  3193     iList.GetMarkedItemsL( selection );
  3505     iList.GetMarkedItemsL( selection );
  3194     TInt count( selection.Count() );
  3506     TInt count( selection.Count() );
  3263         iHighlightIndex = iTree.VisibleItemIndex(FocusedItem());
  3575         iHighlightIndex = iTree.VisibleItemIndex(FocusedItem());
  3264 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3576 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3265         } 
  3577         } 
  3266     }
  3578     }
  3267 
  3579 
       
  3580 
       
  3581 // -----------------------------------------------------------------------------
       
  3582 // CAknTreeListView::LoadMarkingIconsL
       
  3583 // -----------------------------------------------------------------------------
       
  3584 //
       
  3585 void CAknTreeListView::LoadMarkingIconsL()
       
  3586     {
       
  3587     if ( !iMarkingIconArray )
       
  3588         {
       
  3589         iMarkingIconArray = new ( ELeave ) CAknIconArray( 2 );
       
  3590         }
       
  3591     else
       
  3592         {
       
  3593         iMarkingIconArray->ResetAndDestroy();
       
  3594         }
       
  3595 
       
  3596     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  3597     const TDesC& avkonIconFile = AknIconUtils::AvkonIconFileName();
       
  3598 
       
  3599     CGulIcon* icon = AknsUtils::CreateGulIconL( skin, 
       
  3600             KAknsIIDQgnPropCheckboxOn, 
       
  3601             avkonIconFile, 
       
  3602             EMbmAvkonQgn_prop_checkbox_on, 
       
  3603             EMbmAvkonQgn_prop_checkbox_on_mask );
       
  3604     
       
  3605     CleanupStack::PushL( icon );
       
  3606     iMarkingIconArray->AppendL( icon );
       
  3607     CleanupStack::Pop( icon );
       
  3608 
       
  3609     icon = AknsUtils::CreateGulIconL( skin, 
       
  3610             KAknsIIDQgnPropCheckboxOff, 
       
  3611             avkonIconFile, 
       
  3612             EMbmAvkonQgn_prop_checkbox_off, 
       
  3613             EMbmAvkonQgn_prop_checkbox_off_mask );
       
  3614 
       
  3615     CleanupStack::PushL( icon );
       
  3616     iMarkingIconArray->AppendL( icon );
       
  3617     CleanupStack::Pop( icon );
       
  3618     }
       
  3619