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, |
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 ) |
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(); |
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 |
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 // |
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 |