uiservicetab/vimpstutils/src/vimpstutilsdialog.cpp
changeset 0 5e5d6b214f4f
child 14 9fdee5e1da30
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Utils for IMUiServiceTab modules.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "vimpstutilsdialog.h"
       
    22 #include    "vimpstutilstextquerydialog.h"
       
    23 
       
    24 #include    <StringLoader.h>
       
    25 #include 	<AknQueryDialog.h> 
       
    26 #include    <vimpstuires.rsg>
       
    27 #include 	<AknQueryDialog.h>
       
    28 
       
    29 
       
    30 
       
    31 
       
    32 // ---------------------------------------------------------
       
    33 // VIMPSTUtilsDialog::DisplayNoteDialogL
       
    34 // (other items were commented in a header).
       
    35 // ---------------------------------------------------------
       
    36 //
       
    37 EXPORT_C TInt VIMPSTUtilsDialog::DisplayNoteDialogL( const TDesC& aText,
       
    38         const TInt aButtonsResourceId, /*= R_AVKON_SOFTKEYS_EMPTY*/
       
    39         const CAknNoteDialog::TTimeout& aTimeout /*= CAknNoteDialog::EShortTimeout*/ )
       
    40 	{
       
    41 	// CodeScanner warning ignored because CS does not
       
    42     // notice that PrepareLC puts the dialog to cleanupstack
       
    43     CAknNoteDialog* dlg = new ( ELeave ) CAknNoteDialog( // CSI: 35 # See comment above
       
    44 		CAknNoteDialog::EConfirmationTone , aTimeout );
       
    45 
       
    46 	//TODO : Modify the function body when required later
       
    47 	
       
    48 	dlg->PrepareLC( R_IM_INFO_NOTE_TEMPLATE );
       
    49 	dlg->SetTextL( aText );
       
    50 	
       
    51     CEikButtonGroupContainer& cba = dlg->ButtonGroupContainer();
       
    52 	cba.SetCommandSetL( aButtonsResourceId );
       
    53 
       
    54 	return dlg->RunLD();
       
    55 	}
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------
       
    59 // VIMPSTUtilsDialog::DisplayErrorNoteL
       
    60 // (other items were commented in a header).
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 EXPORT_C TInt VIMPSTUtilsDialog::DisplayErrorNoteL( const TDesC& aText, 
       
    64 													TBool aSoftkeyOk /*= EFalse*/ )
       
    65 	{
       
    66 	//TODO : Modify the function body when required later
       
    67 	if( aSoftkeyOk )
       
    68 	    {
       
    69 	    return VIMPSTUtilsDialog::DisplayQueryDialogL( R_IM_ERROR_NOTE_TEMPLATE_WITH_OK, aText );
       
    70 	    }
       
    71     else
       
    72         {
       
    73         // CodeScanner warning ignored because CS does not
       
    74         // notice that PrepareLC puts the dialog to cleanupstack
       
    75         CAknNoteDialog* dlg =   // CSI: 35 # See comment above
       
    76             new ( ELeave ) CAknNoteDialog( CAknNoteDialog::EErrorTone ,
       
    77                                            CAknNoteDialog::ELongTimeout );
       
    78 	    dlg->PrepareLC( R_IM_ERROR_NOTE_TEMPLATE );
       
    79 	    dlg->SetTextL( aText );
       
    80         return dlg->RunLD();
       
    81         }
       
    82 	}
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------
       
    86 // VIMPSTUtilsDialog::DisplayQueryDialogL
       
    87 // (other items were commented in a header).
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 EXPORT_C TInt VIMPSTUtilsDialog::DisplayQueryDialogL( TInt aDialogResourceId, 
       
    91             											const TDesC& aPrompt )
       
    92 	{
       
    93 	CAknQueryDialog* dlg = new (ELeave) CAknQueryDialog(
       
    94 											CAknQueryDialog::ENoTone );
       
    95 	if( aPrompt != KNullDesC )
       
    96 		{
       
    97 		CleanupStack::PushL( dlg );
       
    98 		dlg->SetPromptL( aPrompt );
       
    99 		CleanupStack::Pop( dlg );
       
   100 		}
       
   101 
       
   102 	return dlg->ExecuteLD( aDialogResourceId );
       
   103 	}
       
   104 
       
   105 // ---------------------------------------------------------
       
   106 // VIMPSTUtilsDialog::DisplayTextQueryDialogL()
       
   107 // Displays text query dialog
       
   108 // (other items were commented in a header).
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 EXPORT_C TInt VIMPSTUtilsDialog::DisplayTextQueryDialogL( 
       
   112         TDes& aDataText, 
       
   113         const TInt aTitleResourceId, 
       
   114         const TInt aDialogResourceId,
       
   115         TBool aPredictiveInput /* = EFalse */,
       
   116         TBool aLeftSoftkeyAlwaysVisible /* = EFalse */,
       
   117         TLeftSoftkey /*aLeftSoftkey  = EDefault */,
       
   118         TInitialSelectionMode aSelectionMode /* = ESelectAll */,
       
   119         TBool aDomainSelectionQuery /* = EFalse */ )
       
   120     {
       
   121     // CodeScanner warning ignored because CS does not
       
   122     // notice that PrepareLC puts the dialog to cleanupstack
       
   123     CAknTextQueryDialog* dlg = CVIMPSTUtilsTextQueryDialog::NewL( aDataText, // CSI: 35 # See comment above
       
   124             CAknQueryDialog::ENoTone,
       
   125             aLeftSoftkeyAlwaysVisible,
       
   126             aDomainSelectionQuery );
       
   127 
       
   128     dlg->PrepareLC( aDialogResourceId );
       
   129     HBufC* text = CEikonEnv::Static()->AllocReadResourceLC( aTitleResourceId );
       
   130     dlg->SetPromptL( *text );
       
   131     dlg->SetPredictiveTextInputPermitted( aPredictiveInput );
       
   132 
       
   133     CleanupStack::PopAndDestroy( text );
       
   134 
       
   135     // Set correct selection mode
       
   136     switch ( aSelectionMode )
       
   137         {
       
   138         case ESelectNone:
       
   139             {
       
   140             CCoeControl* ctrl = dlg->ControlOrNull( EGeneralQuery );
       
   141             if ( ctrl )
       
   142                 {
       
   143                 CAknQueryControl* query = static_cast<CAknQueryControl*>( ctrl );
       
   144                 ctrl = query->ControlByLayoutOrNull( EDataLayout );
       
   145                 if ( ctrl )
       
   146                     {
       
   147                     CEikEdwin* edwin = static_cast<CEikEdwin*>( ctrl );
       
   148                     edwin->AddFlagToUserFlags( CEikEdwin::ENoAutoSelection );
       
   149                     }                
       
   150                 }            
       
   151             break;
       
   152             }
       
   153         default:
       
   154             {
       
   155             // Use default flags in edwin
       
   156             break;
       
   157             }
       
   158         }
       
   159     return ( dlg->RunLD() );	
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------
       
   163 // VIMPSTUtilsDialog::DisplayListQueryDialogL
       
   164 // (other items were commented in a header).
       
   165 // ---------------------------------------------------------
       
   166 //
       
   167 EXPORT_C TInt VIMPSTUtilsDialog::DisplayListQueryDialogL( TInt* aSelectedIndex, 
       
   168         MDesCArray* aItemList, 
       
   169         const TInt aDialogResourceId,
       
   170         const TDesC& aAlternativeTitle /*KNullDesC*/,
       
   171         const TDesC& aListEmptyText /*= KNullDesC*/,
       
   172         const TBool aIsForwardQuery /* EFalse */,
       
   173         const TBool /*aIsOnlySelect  = EFalse */ )
       
   174 
       
   175     {
       
   176     CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( 
       
   177                                                     aSelectedIndex );
       
   178     dlg->PrepareLC( aDialogResourceId );
       
   179     dlg->SetItemTextArray( aItemList );
       
   180     dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   181 
       
   182 	if ( aAlternativeTitle != KNullDesC ) 
       
   183 		{
       
   184 		dlg->SetHeaderTextL( aAlternativeTitle );
       
   185 		}
       
   186 
       
   187 	if ( aItemList->MdcaCount() == 0 ) 
       
   188 		{
       
   189 		CEikButtonGroupContainer& cba = dlg->ButtonGroupContainer();
       
   190 		cba.SetCommandSetL( R_AVKON_SOFTKEYS_CANCEL );		
       
   191 		}
       
   192 	else
       
   193 		{
       
   194 		if ( aIsForwardQuery )
       
   195 			{
       
   196 			CEikButtonGroupContainer& cba = dlg->ButtonGroupContainer();
       
   197 			cba.SetCommandSetL( R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT );
       
   198 			}
       
   199 		}
       
   200     	
       
   201     dlg->ListBox()->SetCurrentItemIndex( *aSelectedIndex );
       
   202 
       
   203 	if( aListEmptyText != KNullDesC )
       
   204 		{
       
   205 		dlg->ListBox()->View()->SetListEmptyTextL( aListEmptyText );
       
   206 		}
       
   207 
       
   208 	return ( dlg->RunLD() );
       
   209 	}
       
   210 
       
   211 
       
   212 //  End of File