wvuing/wvuiave/AppSrc/CCABlockingDialog.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Blocking contacts dialog
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "CCABlockingDialog.h"
       
    22 #include "CCAAppUi.h"
       
    23 #include "CCAStatusPaneHandler.h"
       
    24 #include "chatngclient.hrh"
       
    25 #include "ChatDebugAssert.h"
       
    26 #include "IMUtils.h"
       
    27 #include <csxhelp/imng.hlp.hrh>
       
    28 
       
    29 #include <ChatNG.rsg>
       
    30 #include <aknutils.h>
       
    31 #include <aknsfld.h>
       
    32 #include <aknlists.h>
       
    33 #include <aknnavi.h>
       
    34 #include <avkon.hrh>
       
    35 #include <barsread.h>
       
    36 #include <coemain.h>
       
    37 #include <eikcapc.h>
       
    38 #include <aknconsts.h>
       
    39 #include <eikclbd.h>
       
    40 #include <eikfrlbd.h>
       
    41 #include <eikmenub.h>
       
    42 #include <akniconutils.h>
       
    43 #include <FeatMgr.h>
       
    44 #include <hlplch.h>
       
    45 #include <catouchutils.h>
       
    46 // local variation
       
    47 #include    "IMPrivateCRKeys.h"
       
    48 #include    "IMVariant.hrh"
       
    49 
       
    50 // LOCAL FUNCTION PROTOTYPES
       
    51 // The Settings have been moved to Cenrep (also retained in the Resource file),
       
    52 // so the enums for keys and central repository header is added here
       
    53 #include 	"VariantKeys.h"
       
    54 
       
    55 // ==================== LOCAL FUNCTIONS ====================
       
    56 
       
    57 class CFindControl : public CCoeControl
       
    58     {
       
    59     public:
       
    60         CAknSearchField *iFind;
       
    61         ~CFindControl() {
       
    62             delete iFind;
       
    63             }
       
    64         void Draw( const TRect & ) const
       
    65             {
       
    66             // this removes flicker from CEikDialog's Draw().
       
    67             }
       
    68         void SizeChanged()
       
    69             {
       
    70 
       
    71             TRect appRect( iAvkonAppUi->ApplicationRect() );
       
    72             TAknLayoutRect mainPane;
       
    73             TAknLayoutRect listRect;
       
    74 
       
    75             mainPane.LayoutRect( appRect,
       
    76                                  AKN_LAYOUT_WINDOW_main_pane( appRect, 0, 0, 1 ) );
       
    77 
       
    78             listRect.LayoutRect( mainPane.Rect(), AknLayout::list_gen_pane( 0 ) );
       
    79 
       
    80             TRect r( listRect.Rect() );
       
    81             iPosition = TPoint( r.iTl );
       
    82             iSize = TSize( r.Width(), r.Height() );
       
    83             }
       
    84     };
       
    85 
       
    86 
       
    87 // ================= MEMBER FUNCTIONS =======================
       
    88 
       
    89 // C++ default constructor can NOT contain any code, that
       
    90 // might leave.
       
    91 //
       
    92 
       
    93 CCABlockingDialog* CCABlockingDialog::NewL( TInt &aValue, MDesCArray *aArray, TInt aMenuBarResourceId,
       
    94                                             TInt aOkMenuBarResourceId, MEikCommandObserver *aCommand,
       
    95                                             TBool aDontShowTabGroup )
       
    96     {
       
    97     CCABlockingDialog *dialog = NewLC( aValue, aArray, aMenuBarResourceId, aOkMenuBarResourceId,
       
    98                                        aCommand, aDontShowTabGroup );
       
    99     CleanupStack::Pop();
       
   100     return dialog;
       
   101     }
       
   102 // ---------------------------------------------------------
       
   103 // CCABlockingDialog::NewLC
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 CCABlockingDialog *CCABlockingDialog::NewLC( TInt &aValue, MDesCArray *aArray, TInt aMenuBarResourceId,
       
   107                                              TInt aOkMenuBarResourceId, MEikCommandObserver *aCommand,
       
   108                                              TBool aDontShowTabGroup )
       
   109     {
       
   110     CCABlockingDialog *dialog = new( ELeave )CCABlockingDialog( aValue,
       
   111                                                                 aArray,
       
   112                                                                 aMenuBarResourceId,
       
   113                                                                 aOkMenuBarResourceId,
       
   114                                                                 aCommand,
       
   115                                                                 aDontShowTabGroup );
       
   116     CleanupStack::PushL( dialog );
       
   117     dialog->ConstructL( aMenuBarResourceId );
       
   118     return dialog;
       
   119     }
       
   120 // ---------------------------------------------------------
       
   121 // CCABlockingDialog::CCABlockingDialog
       
   122 // ---------------------------------------------------------
       
   123 //
       
   124 CCABlockingDialog::CCABlockingDialog( TInt &aIndex,
       
   125                                       MDesCArray *aArray,
       
   126                                       TInt aMenuBarResourceId,
       
   127                                       TInt aOkMenuBarResourceId,
       
   128                                       MEikCommandObserver *aCommand,
       
   129                                       TBool aDontShowTabGroup )
       
   130         : iEnterKeyPressed( EFalse ),
       
   131         iSelectedItem( &aIndex ),
       
   132         iArray( aArray ),
       
   133         iCmdObserver( aCommand ),
       
   134         iMenuBarResourceId( aMenuBarResourceId ),
       
   135         iOkMenuBarResourceId( aOkMenuBarResourceId ),
       
   136         iFindBoxEnabled( EFalse ),
       
   137         iDontShowTabGroup( aDontShowTabGroup ),
       
   138         iExitEnabled( ETrue ),
       
   139         iAllowPenEvent( ETrue )
       
   140     {
       
   141     CCAAppUi* appUi = static_cast<CCAAppUi*>( CCoeEnv::Static()->AppUi() );
       
   142     iTitlePane = appUi->CAStatusPane();
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------
       
   146 // CCABlockingDialog::ConstructL
       
   147 // ---------------------------------------------------------
       
   148 //
       
   149 void CCABlockingDialog::ConstructL( TInt aMenuBarResourceId )
       
   150     {
       
   151     CAknDialog::ConstructL( aMenuBarResourceId );
       
   152 
       
   153 #ifndef RD_30_DISABLE_TOUCH
       
   154     iMenuBar->SetContextMenuTitleResourceId( iOkMenuBarResourceId );
       
   155 #endif // RD_30_DISABLE_TOUCH
       
   156     }
       
   157 
       
   158 // ---------------------------------------------------------
       
   159 // CCABlockingDialog::~CCABlockingDialog
       
   160 // ---------------------------------------------------------
       
   161 //
       
   162 CCABlockingDialog::~CCABlockingDialog()
       
   163     {
       
   164 
       
   165     // delete the same
       
   166     delete iFindPaneText;
       
   167 
       
   168     // dialog will be gone, so tab groups can be drawn again
       
   169     if ( iTitlePane )
       
   170         {
       
   171         iTitlePane->RestoreNaviPane();
       
   172         }
       
   173     else
       
   174         {
       
   175         iTitlePane->ProhibitTabGroup( EFalse );
       
   176         }
       
   177 
       
   178     if ( iAvkonAppUi )
       
   179         {
       
   180         iAvkonAppUi->RemoveFromStack( this );
       
   181         }
       
   182     }
       
   183 
       
   184 
       
   185 // ---------------------------------------------------------
       
   186 // CCABlockingDialog::ComponentControl
       
   187 // ---------------------------------------------------------
       
   188 //
       
   189 CCoeControl* CCABlockingDialog::ComponentControl( TInt aIndex ) const
       
   190     {
       
   191     if ( aIndex == CAknDialog::CountComponentControls() )
       
   192         {
       
   193         return FindBox();
       
   194         }
       
   195     return CAknDialog::ComponentControl( aIndex );
       
   196     }
       
   197 
       
   198 // ---------------------------------------------------------
       
   199 // CCABlockingDialog::CountComponentControls
       
   200 // ---------------------------------------------------------
       
   201 //
       
   202 TInt CCABlockingDialog::CountComponentControls() const
       
   203     {
       
   204     TInt newitems = 0;
       
   205     if ( FindBox() )
       
   206         {
       
   207         newitems++;
       
   208         }
       
   209 
       
   210     return CAknDialog::CountComponentControls() + newitems;
       
   211     }
       
   212 
       
   213 // ---------------------------------------------------------
       
   214 // CCABlockingDialog::OkToExitL
       
   215 // ---------------------------------------------------------
       
   216 //
       
   217 TBool CCABlockingDialog::OkToExitL( TInt aButtonId )
       
   218     {
       
   219     // If exit not enable, return false
       
   220     if ( !iExitEnabled )
       
   221         {
       
   222         return EFalse;
       
   223         }
       
   224 
       
   225     TBool b = CAknDialog::OkToExitL( aButtonId );
       
   226     *iSelectedItem = ListBox()->CurrentItemIndex();
       
   227     if ( FindBox() )
       
   228         {
       
   229         if ( *iSelectedItem != -1 )
       
   230             {
       
   231             *iSelectedItem = STATIC_CAST( CAknFilteredTextListBoxModel*, ListBox()->
       
   232                                           Model() )->Filter()->FilteredItemIndex( *iSelectedItem );
       
   233             }
       
   234         }
       
   235 
       
   236     if ( aButtonId == EAknSoftkeyContextOptions )
       
   237         {
       
   238         // MSK command, show context menu
       
   239         ShowContextMenuL();
       
   240         return EFalse;
       
   241         }
       
   242 
       
   243     return b;
       
   244     }
       
   245 
       
   246 // ---------------------------------------------------------
       
   247 // CCABlockingDialog::Draw
       
   248 // ---------------------------------------------------------
       
   249 //
       
   250 void CCABlockingDialog::Draw( const TRect & ) const
       
   251     {
       
   252     // this removes flicker from CEikDialog's Draw().
       
   253     }
       
   254 
       
   255 void CCABlockingDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   256     {
       
   257     if ( aResourceId == R_CHATCLIENT_GENERAL_MENU &&
       
   258          !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   259         {
       
   260         // dim the help menu item
       
   261         aMenuPane->SetItemDimmed( EChatClientCmdHelp, ETrue );
       
   262         }
       
   263 
       
   264     switch ( aResourceId )
       
   265         {
       
   266         case R_CHATCLIENT_MENUPANE_BLOCKING :
       
   267             {
       
   268             if ( ! ListBox()->Model()->NumberOfItems() )
       
   269                 {
       
   270                 aMenuPane->SetItemDimmed( EChatClientBlockingUnblock,
       
   271                                           ETrue );
       
   272                 }
       
   273             break;
       
   274             }
       
   275         default :
       
   276             {
       
   277             break;
       
   278             }
       
   279         }
       
   280     }
       
   281 
       
   282 // ---------------------------------------------------------
       
   283 // CCABlockingDialog::ProcessCommandL
       
   284 // ---------------------------------------------------------
       
   285 //
       
   286 void CCABlockingDialog::ProcessCommandL( TInt aCommand )
       
   287     {
       
   288     iAllowPenEvent = EFalse;
       
   289     
       
   290     // launch help
       
   291     if ( aCommand == EChatClientCmdHelp )
       
   292         {
       
   293 
       
   294         HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   295                                              ( CCoeEnv::Static()->AppUi() )->AppHelpContextL () );
       
   296         return;
       
   297         }
       
   298 
       
   299     // Handle exit command
       
   300     if ( aCommand == EChatClientCmdExit )
       
   301         {
       
   302         TryExitL( aCommand );
       
   303         return;
       
   304         }
       
   305 
       
   306     CAknDialog::ProcessCommandL( aCommand );
       
   307 
       
   308     if ( FindBox() && iFindType == EPopupFind )
       
   309         {
       
   310         AknFind::HandleFindPopupProcessCommandL( aCommand, ListBox(), FindBox(), this );
       
   311 
       
   312         }
       
   313     //update selected index
       
   314     *iSelectedItem = ListBox()->CurrentItemIndex();
       
   315 
       
   316     if ( iCmdObserver )
       
   317         {
       
   318         iCmdObserver->ProcessCommandL( aCommand );
       
   319         }
       
   320     
       
   321     iAllowPenEvent = ETrue;
       
   322     }
       
   323 
       
   324 // ---------------------------------------------------------
       
   325 // CCABlockingDialog::SelectionListProcessCommandL
       
   326 // ---------------------------------------------------------
       
   327 //
       
   328 void CCABlockingDialog::SelectionListProcessCommandL( TInt aCommand )
       
   329     {
       
   330     //update selected index
       
   331     *iSelectedItem = ListBox()->CurrentItemIndex();
       
   332 
       
   333     AknSelectionService::HandleSelectionListProcessCommandL( aCommand, ListBox() );
       
   334     }
       
   335 
       
   336 void CCABlockingDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   337     {
       
   338     switch ( aEventType )
       
   339         {
       
   340         case EEventEnterKeyPressed:
       
   341         case EEventItemDoubleClicked:
       
   342             {
       
   343             ShowContextMenuL();
       
   344             // Should do nothing after this - the dialog might be deleted..
       
   345             break;
       
   346             }
       
   347         default:
       
   348             {
       
   349             break;
       
   350             }
       
   351         };
       
   352     }
       
   353 
       
   354 // ---------------------------------------------------------
       
   355 // CCABlockingDialog::OfferKeyEventL
       
   356 // ---------------------------------------------------------
       
   357 //
       
   358 TKeyResponse CCABlockingDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   359                                                 TEventCode aType )
       
   360     {
       
   361     // must pass escape event to dialog - findbox and listbox "eat" escape events
       
   362     TKeyResponse res = EKeyWasNotConsumed;
       
   363     if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape )
       
   364         {
       
   365         iCmdObserver->ProcessCommandL( EChatClientCmdExit );
       
   366 
       
   367         res = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   368         }
       
   369 
       
   370     if ( res == EKeyWasConsumed )
       
   371         {
       
   372         return res;
       
   373         }
       
   374 
       
   375     // Set the needRefresh to true
       
   376     TBool needRefresh = ETrue;
       
   377 
       
   378     // Offer key events to find box if it is visible
       
   379     if ( FindBox()->IsVisible() )
       
   380         {
       
   381         res = AknFind::HandleFindOfferKeyEventL(
       
   382                   aKeyEvent, aType, this, ListBox(), FindBox(),
       
   383                   iFindType == EPopupFind, needRefresh );
       
   384         }
       
   385 
       
   386     if( needRefresh && FindBox() && FindBox()->IsVisible() )
       
   387         {
       
   388         if ( iFindType == EPopupFind )
       
   389             {
       
   390             AknFind::HandlePopupFindSizeChanged( this, ListBox(), FindBox() );
       
   391             }
       
   392         else if ( iFindType == EFixedFind )
       
   393             {
       
   394             AknFind::HandleFixedFindSizeChanged(
       
   395                 this, ( CAknColumnListBox* )ListBox(), FindBox() );
       
   396             }
       
   397 
       
   398         DrawNow();
       
   399         }
       
   400 
       
   401     if ( res == EKeyWasConsumed )
       
   402         {
       
   403         return res;
       
   404         }
       
   405 
       
   406     // Give the events to listbox first. This is because otherwise all events do not go to the controls.
       
   407     // Dialogs filter out KeyUp/KeyDown events. If we do not do this, marking is broken; Sometimes it does
       
   408     // not mark list items correctly.
       
   409     if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow )
       
   410         {
       
   411         // Multipage dialogs need the left/right keys
       
   412         res = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   413         }
       
   414     else
       
   415         {
       
   416         res = ListBox()->OfferKeyEventL( aKeyEvent, aType );
       
   417         }
       
   418 
       
   419     if ( ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter ) && ( aType == EEventKey ) )
       
   420         {
       
   421         ShowContextMenuL();
       
   422         res = EKeyWasConsumed;
       
   423         }
       
   424 
       
   425     if ( aKeyEvent.iCode == EKeyPhoneSend )
       
   426         {
       
   427         res = EKeyWasConsumed;
       
   428         }
       
   429 
       
   430     if ( res == EKeyWasNotConsumed )
       
   431         {
       
   432         res = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   433         }
       
   434 
       
   435     if ( iEnterKeyPressed )
       
   436         {
       
   437         TryExitL( EAknSoftkeyOk );
       
   438         }
       
   439 
       
   440 
       
   441     // should do nothing after this.
       
   442     return res;
       
   443     }
       
   444 
       
   445 // ---------------------------------------------------------
       
   446 // CCABlockingDialog::ListBox
       
   447 // ---------------------------------------------------------
       
   448 //
       
   449 CEikListBox *CCABlockingDialog::ListBox() const
       
   450     {
       
   451     return ( CEikListBox* )Control( ESelectionListControl );
       
   452     }
       
   453 
       
   454 // ---------------------------------------------------------
       
   455 // CCABlockingDialog::FindBox
       
   456 // ---------------------------------------------------------
       
   457 //
       
   458 CAknSearchField *CCABlockingDialog::FindBox() const
       
   459     {
       
   460     CFindControl *control = ( CFindControl* )ControlOrNull( EFindControl ) ;
       
   461     if ( control )
       
   462         {
       
   463         return control->iFind;
       
   464         }
       
   465     return NULL;
       
   466     }
       
   467 
       
   468 
       
   469 // ---------------------------------------------------------
       
   470 // CCABlockingDialog::GetFindBoxTextL
       
   471 // ---------------------------------------------------------
       
   472 //
       
   473 const TDesC& CCABlockingDialog::GetFindBoxTextL()
       
   474     {
       
   475 
       
   476     //if already some data available, free the same
       
   477     if ( iFindPaneText )
       
   478         {
       
   479         delete iFindPaneText;
       
   480         iFindPaneText = NULL;
       
   481         }
       
   482 
       
   483     if ( iFindBoxEnabled )
       
   484         {
       
   485         CAknSearchField *findBox = FindBox();
       
   486 
       
   487         if ( findBox )
       
   488             {
       
   489             //gets the text from the findBox
       
   490             iFindPaneText = findBox->Editor().GetTextInHBufL();
       
   491 
       
   492             if ( !iFindPaneText )
       
   493                 {
       
   494                 //if no text in the findPane initialise with KNullDesC()
       
   495                 iFindPaneText = KNullDesC().AllocL();
       
   496                 }
       
   497 
       
   498             return *iFindPaneText;
       
   499             }
       
   500         }
       
   501     return KNullDesC;
       
   502 
       
   503     }
       
   504 
       
   505 // ---------------------------------------------------------
       
   506 // CCABlockingDialog::SetupFind
       
   507 // ---------------------------------------------------------
       
   508 //
       
   509 void CCABlockingDialog::SetupFind( TFindType aType )
       
   510     {
       
   511     iFindType = aType;
       
   512     }
       
   513 
       
   514 // ---------------------------------------------------------
       
   515 // CCABlockingDialog::IsAcceptableListBoxType
       
   516 // ---------------------------------------------------------
       
   517 //
       
   518 TBool CCABlockingDialog::IsAcceptableListBoxType(
       
   519     TInt /*aControlType*/,
       
   520     TBool &/*aIsFormattedCellListBox*/ ) const
       
   521     {
       
   522     return EFalse;
       
   523     }
       
   524 
       
   525 // ---------------------------------------------------------
       
   526 // CCABlockingDialog::IsFormattedCellListBox
       
   527 // ---------------------------------------------------------
       
   528 //
       
   529 TBool CCABlockingDialog::IsFormattedCellListBox() const
       
   530     {
       
   531     CEikCaptionedControl *line = Line( ESelectionListControl );
       
   532     TInt controlType = line->iControlType;
       
   533     TBool result = EFalse;
       
   534     if ( IsAcceptableListBoxType( controlType, result ) )
       
   535         {
       
   536         return result;
       
   537         }
       
   538 
       
   539     switch ( controlType )
       
   540         {
       
   541         case EAknCtSingleListBox:
       
   542         case EAknCtSingleNumberListBox:
       
   543         case EAknCtSingleHeadingListBox:
       
   544         case EAknCtSingleGraphicListBox:
       
   545         case EAknCtSingleGraphicHeadingListBox:
       
   546         case EAknCtSingleNumberHeadingListBox:
       
   547         case EAknCtSingleLargeListBox:
       
   548             {
       
   549             return EFalse;
       
   550             }
       
   551         case EAknCtDoubleListBox:
       
   552         case EAknCtDoubleNumberListBox:
       
   553         case EAknCtDoubleTimeListBox:
       
   554         case EAknCtDoubleLargeListBox:
       
   555         case EAknCtDoubleGraphicListBox:
       
   556         case EAknCtSettingListBox:
       
   557         case EAknCtSettingNumberListBox:
       
   558             {
       
   559             return ETrue;
       
   560             }
       
   561         default:
       
   562             // If you hit this assert, you should derive from this dialog and
       
   563             // implement IsAcceptableListBoxType() method.
       
   564             __CHAT_ASSERT_DEBUG( EFalse );
       
   565             return ETrue;
       
   566         }
       
   567     }
       
   568 
       
   569 // ---------------------------------------------------------
       
   570 // CCABlockingDialog::IconArray
       
   571 // ---------------------------------------------------------
       
   572 //
       
   573 CArrayPtr<CGulIcon>* CCABlockingDialog::IconArray() const
       
   574     {
       
   575     if ( IsFormattedCellListBox() )
       
   576         {
       
   577         return ( ( CEikFormattedCellListBox* )ListBox() )->ItemDrawer()->FormattedCellData()->IconArray();
       
   578         }
       
   579     else
       
   580         {
       
   581         return ( ( CEikColumnListBox* )ListBox() )->ItemDrawer()->ColumnData()->IconArray();
       
   582         }
       
   583     }
       
   584 
       
   585 // ---------------------------------------------------------
       
   586 // CCABlockingDialog::SetIconArrayL
       
   587 // ---------------------------------------------------------
       
   588 //
       
   589 void CCABlockingDialog::SetIconArrayL( CArrayPtr<CGulIcon>* aIcons )
       
   590     {
       
   591     CArrayPtr<CGulIcon>* oldicons = IconArray();
       
   592     if ( oldicons )
       
   593         {
       
   594         oldicons->ResetAndDestroy();
       
   595         delete oldicons;
       
   596         }
       
   597 
       
   598     if ( IsFormattedCellListBox() )
       
   599         {
       
   600         ( ( CEikFormattedCellListBox* )ListBox() )->ItemDrawer()->FormattedCellData()->
       
   601         SetIconArray( aIcons );
       
   602         }
       
   603     else
       
   604         {
       
   605         ( ( CEikColumnListBox* )ListBox() )->ItemDrawer()->ColumnData()->SetIconArray( aIcons );
       
   606         }
       
   607 
       
   608     }
       
   609 
       
   610 // ---------------------------------------------------------
       
   611 // CCABlockingDialog::HandleItemRemovalL
       
   612 // ---------------------------------------------------------
       
   613 //
       
   614 void CCABlockingDialog::HandleItemRemovalL()
       
   615     {
       
   616     CEikListBox* listBox = ListBox();
       
   617     listBox->HandleItemRemovalL();
       
   618     TInt index( listBox->CurrentItemIndex() );
       
   619     TInt myItems( listBox->Model()->NumberOfItems() );
       
   620 
       
   621     if ( index > myItems || index == KErrNotFound && myItems > 0 )
       
   622         {
       
   623         listBox->SetCurrentItemIndex( myItems - 1 );
       
   624         }
       
   625 
       
   626     if ( myItems == 0 && iFindBoxEnabled )
       
   627         {
       
   628         // Hide find box
       
   629         TSize ignore( 0, 0 );
       
   630         SetSizeAndPosition( ignore );
       
   631         listBox->DrawDeferred();
       
   632         }
       
   633     // item removed now reset find box and show all
       
   634     ResetFindBoxL();
       
   635     }
       
   636 
       
   637 // ---------------------------------------------------------
       
   638 // CCABlockingDialog::SetDialogTitleL
       
   639 // ---------------------------------------------------------
       
   640 //
       
   641 void CCABlockingDialog::RefreshDialogTitleL()
       
   642     {
       
   643     HBufC* title = iEikonEnv->AllocReadResourceLC( R_QTN_CHAT_BLOCKED_CONTACTS_TITLE );
       
   644     iTitlePane->SetTitleL( *title );
       
   645     CleanupStack::PopAndDestroy( title );
       
   646     }
       
   647 
       
   648 // ---------------------------------------------------------
       
   649 // CCABlockingDialog::HandleItemAdditionL
       
   650 // ---------------------------------------------------------
       
   651 //
       
   652 void CCABlockingDialog::HandleItemAdditionL()
       
   653     {
       
   654     ListBox()->HandleItemAdditionL();
       
   655     if ( !iFindBoxEnabled )
       
   656         {
       
   657         // Show find box
       
   658         TSize ignore( 0, 0 );
       
   659         SetSizeAndPosition( ignore );
       
   660         }
       
   661     // item added now reset find box and show all
       
   662     ResetFindBoxL();
       
   663     }
       
   664 
       
   665 // ---------------------------------------------------------
       
   666 // CCABlockingDialog::CreateCustomControlL
       
   667 // ---------------------------------------------------------
       
   668 //
       
   669 SEikControlInfo CCABlockingDialog::CreateCustomControlL( TInt aControlType )
       
   670     {
       
   671     CFindControl *control1 = NULL;
       
   672     TBool findControl = EFalse;
       
   673     if ( aControlType == EAknCtSelectionListFixedFind )
       
   674         {
       
   675         iFindType = EFixedFind;
       
   676         findControl = ETrue;
       
   677         }
       
   678 
       
   679     if ( aControlType == EAknCtSelectionListPopupFind )
       
   680         {
       
   681         iFindType = EPopupFind;
       
   682         findControl = ETrue;
       
   683         }
       
   684 
       
   685     if ( findControl )
       
   686         {
       
   687         control1 = new ( ELeave ) CFindControl;
       
   688         }
       
   689 
       
   690     SEikControlInfo info;
       
   691     info.iControl = control1;
       
   692     info.iFlags = 0;
       
   693     info.iTrailerTextId = 0;
       
   694     return info;
       
   695     }
       
   696 
       
   697 // ---------------------------------------------------------
       
   698 // CCABlockingDialog::FocusChanged
       
   699 // ---------------------------------------------------------
       
   700 //
       
   701 void CCABlockingDialog::FocusChanged(TDrawNow aDrawNow)
       
   702 	{
       
   703 	if ( FindBox() )
       
   704 		{
       
   705 	    FindBox()->SetFocus( IsFocused() );
       
   706 		}
       
   707 	}
       
   708 
       
   709 // ---------------------------------------------------------
       
   710 // CCABlockingDialog::PreLayoutDynInitL
       
   711 // ---------------------------------------------------------
       
   712 //
       
   713 void CCABlockingDialog::PreLayoutDynInitL()
       
   714     {
       
   715     CEikCaptionedControl *line = Line( ESelectionListControl );
       
   716 
       
   717     CFindControl *control1 = ( CFindControl* )ControlOrNull( EFindControl );
       
   718     CAknSearchField *control = NULL;
       
   719     CAknSearchField::TSearchFieldStyle flags = CAknSearchField::EFixed;
       
   720     if ( control1 )
       
   721         {
       
   722         if ( iFindType == EPopupFind )
       
   723             {
       
   724             flags = CAknSearchField::EPopup;
       
   725             }
       
   726         if ( iFindType == EFixedFind )
       
   727             {
       
   728             flags = CAknSearchField::EFixed;
       
   729             }
       
   730         control = CAknSearchField::NewL( *control1, flags, 0, 40 );
       
   731         control1->iFind = control;
       
   732         }
       
   733 
       
   734     CAknDialog::PreLayoutDynInitL();
       
   735     iAvkonAppUi->AddToStackL( this );
       
   736 
       
   737     CEikListBox *listbox = ListBox();
       
   738     CEikTextListBox *txtlistbox = ( CEikTextListBox* )listbox;
       
   739 
       
   740     // Listbox items
       
   741     if ( iArray )
       
   742         {
       
   743         txtlistbox -> Model() -> SetItemTextArray( iArray );
       
   744         txtlistbox -> Model() -> SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   745         }
       
   746 
       
   747     // Scrollbar
       
   748     listbox->CreateScrollBarFrameL( ETrue );
       
   749     listbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   750 
       
   751     // Listbox observer
       
   752     listbox->SetListBoxObserver( this );
       
   753 
       
   754     // SimplifiedUI localisation variation for empty list
       
   755     if ( IMUtils::CRKeyL( KCRUidIMVariation, KIMVariationKey ) &
       
   756          EIMFeatSimplifiedUI )
       
   757         {
       
   758         HBufC* emptyTxtBuf = IMUtils::CombineStringFromResourceLC
       
   759                              ( R_QTN_CHAT_BLOCKED_CONTACTS_EMPTY,
       
   760                                R_QTN_CHAT_BLOCKED_CONTACTS_EMPTY_SECONDARY );
       
   761 
       
   762         listbox->View()->SetListEmptyTextL( *emptyTxtBuf );
       
   763         CleanupStack::PopAndDestroy( emptyTxtBuf );
       
   764         }
       
   765 
       
   766 
       
   767     // set marquee on
       
   768     if ( IsFormattedCellListBox() )
       
   769         {
       
   770         ( ( CEikFormattedCellListBox* )ListBox() )->ItemDrawer()->FormattedCellData()
       
   771         ->EnableMarqueeL( ETrue );
       
   772         }
       
   773     else
       
   774         {
       
   775         ( ( CEikColumnListBox* )ListBox() )->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
       
   776         }
       
   777 
       
   778     if ( FindBox() )
       
   779         {
       
   780         if ( iFindType == EPopupFind )
       
   781             {
       
   782             STATIC_CAST( CAknFilteredTextListBoxModel*, ListBox()->Model() )->CreateFilterL( ListBox(), FindBox() );
       
   783             }
       
   784         else if ( iFindType == EFixedFind )
       
   785             {
       
   786             // Fixed find is only available with list_single_graphic_pane
       
   787             STATIC_CAST( CAknFilteredTextListBoxModel*, ListBox()->Model() )->CreateFilterL( ListBox(), FindBox() );
       
   788             }
       
   789         }
       
   790 
       
   791     iTitlePane->ClearNaviPaneL();
       
   792 
       
   793     HBufC* title = iEikonEnv->AllocReadResourceLC( R_QTN_CHAT_BLOCKED_CONTACTS_TITLE );
       
   794     iTitlePane->SetTitleL( *title );
       
   795     CleanupStack::PopAndDestroy( title );
       
   796 
       
   797     // when the dialog is active, do not show any tabs even if the underlying
       
   798     // view would like to show them
       
   799     iTitlePane->ProhibitTabGroup();
       
   800     }
       
   801 
       
   802 // ---------------------------------------------------------
       
   803 // CCABlockingDialog::SetSizeAndPosition
       
   804 // ---------------------------------------------------------
       
   805 //
       
   806 void CCABlockingDialog::SetSizeAndPosition( const TSize &/*aSize*/ )
       
   807     {
       
   808     TRect rect;
       
   809     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, rect );
       
   810     SetRect( rect );
       
   811 
       
   812     // Show find box if there are items in list box
       
   813     if( FindBox() && iArray->MdcaCount() != 0/*Check the data source*/ )
       
   814 		{				    				
       
   815         /*if( iFindType == EPopupFind )
       
   816         	{
       
   817         	FindBox()->MakeVisible( EFalse );
       
   818         	AknFind::HandlePopupFindSizeChanged( this, ListBox(), FindBox() );
       
   819         	}
       
   820         else if( iFindType == EFixedFind )
       
   821         	{
       
   822         	AknFind::HandleFixedFindSizeChanged(
       
   823         	                this,( CAknColumnListBox* )ListBox(), FindBox() );
       
   824         	FindBox()->MakeVisible( ETrue );
       
   825         	}*/
       
   826 
       
   827         FindBox()->MakeVisible( EFalse );
       
   828         iFindBoxEnabled = ETrue;
       
   829         SetLayout();//layouting controls.
       
   830         FindBox()->MakeVisible( ETrue );
       
   831 	    FindBox()->SetFocus( IsFocused() );	
       
   832         }
       
   833     else
       
   834         {
       
   835         // Reset filtering
       
   836         TRAPD( error, static_cast<CAknFilteredTextListBoxModel*>( ListBox()->Model() )
       
   837                ->Filter()->ResetFilteringL(); );
       
   838         if ( error )
       
   839             {
       
   840             CActiveScheduler::Current()->Error( error );
       
   841             }
       
   842 
       
   843         // Signal listbox that find box went away
       
   844         static_cast<CAknColumnListBoxView*>( ListBox()->View() )
       
   845         ->SetFindEmptyListState( EFalse );
       
   846 
       
   847         // Hide find box
       
   848         if ( FindBox() )
       
   849             {
       
   850             FindBox()->MakeVisible( EFalse );
       
   851             FindBox()->SetFocus( EFalse );
       
   852             }
       
   853 
       
   854         // Layout list box correctly
       
   855         iFindBoxEnabled = EFalse;
       
   856         SetLayout();//layouting controls.
       
   857         }
       
   858     }
       
   859 
       
   860 // ---------------------------------------------------------
       
   861 // CCABlockingDialog::HandlePointerEventL
       
   862 // ---------------------------------------------------------
       
   863 //
       
   864 void CCABlockingDialog::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   865     {
       
   866 	if( !iAllowPenEvent )
       
   867 		{
       
   868 		return;
       
   869 		}
       
   870 	
       
   871     if ( !iArray->MdcaCount() == 0 )
       
   872         {
       
   873         ListBox()->HandlePointerEventL( aPointerEvent );
       
   874         return;
       
   875         }
       
   876 
       
   877     if ( !CATouchUtils::PenEnabled() )
       
   878         {
       
   879         return;
       
   880         }
       
   881 
       
   882     // Single tap on main pane (not on scroll bar)
       
   883     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   884         {
       
   885         ShowContextMenuL();
       
   886         }
       
   887     else
       
   888         {
       
   889         CAknDialog::HandlePointerEventL( aPointerEvent );
       
   890         }
       
   891     }
       
   892 
       
   893 // ---------------------------------------------------------
       
   894 // CCABlockingDialog::ResetFindBoxL
       
   895 // ---------------------------------------------------------
       
   896 //
       
   897 
       
   898 void CCABlockingDialog::ResetFindBoxL()
       
   899     {
       
   900     if ( FindBox() && ListBox()->Model()->NumberOfItems() != 0 )
       
   901         {
       
   902         FindBox()->ResetL();
       
   903         FindBox()->SetSearchTextL( KNullDesC );
       
   904         FindBox()->DrawNow();
       
   905         FindBox()->SetFocus( ETrue );
       
   906         }
       
   907     }
       
   908 // ---------------------------------------------------------
       
   909 // CCABlockingDialog::ShowContextMenuL
       
   910 // ---------------------------------------------------------
       
   911 //
       
   912 void CCABlockingDialog::ShowContextMenuL()
       
   913     {
       
   914 #ifndef RD_30_DISABLE_TOUCH
       
   915     // S60 COMMON
       
   916     iMenuBar->TryDisplayContextMenuBarL();
       
   917 
       
   918 #else
       
   919     // S60 3.0
       
   920     iMenuBar->SetMenuTitleResourceId( iOkMenuBarResourceId );
       
   921     // This must be trapped so that menubar will be restored on leave
       
   922     TRAP_IGNORE( iMenuBar->TryDisplayMenuBarL() );
       
   923     iEikonEnv->EikAppUi()->HandleStackChanged();
       
   924     iMenuBar->SetMenuTitleResourceId( iMenuBarResourceId );
       
   925 #endif // RD_30_DISABLE_TOUCH   
       
   926     }
       
   927 
       
   928 // ---------------------------------------------------------
       
   929 // CCABlockingDialog::SetLayout()
       
   930 // Layouts current components according to AVKON LAF
       
   931 // (other items were commented in a header).
       
   932 // ---------------------------------------------------------
       
   933 //
       
   934 void CCABlockingDialog::SetLayout()
       
   935     {
       
   936     const TRect rect( Rect() );
       
   937 
       
   938     if ( ListBox() && FindBox() && iFindBoxEnabled )
       
   939         {
       
   940         AknLayoutUtils::LayoutControl( ListBox(), rect, AKN_LAYOUT_WINDOW_list_gen_pane( 1 ) );
       
   941         AknLayoutUtils::LayoutControl( FindBox(), rect, AKN_LAYOUT_WINDOW_find_pane );
       
   942         }
       
   943     else if ( ListBox() )
       
   944         {
       
   945         AknLayoutUtils::LayoutControl( ListBox(), rect, AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) );
       
   946         }
       
   947     }
       
   948 
       
   949 
       
   950 
       
   951 /**
       
   952  * Help Key Support
       
   953  * This function is called by the Framework to get the context to launch
       
   954  * Help
       
   955  *
       
   956  * @param aContext	The context that contains the appid and the help id.
       
   957  */
       
   958 void CCABlockingDialog::GetHelpContext( TCoeHelpContext& aContext ) const
       
   959     {
       
   960     aContext.iMajor = KUidChatClient;
       
   961     aContext.iContext = KIMNG_HLP_BLOCKED_VIEW ;
       
   962     }
       
   963 
       
   964 // ---------------------------------------------------------
       
   965 // CCABlockingDialog::SetExitEnabled( TBool value )
       
   966 // (other items were commented in a header).
       
   967 // ---------------------------------------------------------
       
   968 //
       
   969 void CCABlockingDialog::SetExitEnabled( TBool aValue )
       
   970     {
       
   971     iExitEnabled = aValue;
       
   972     }
       
   973 
       
   974 //  End of File