meetingrequest/mrgui/src/cesmraddressselectionquery.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 8 e1b6206813b4
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include "emailtrace.h"
    20 #include "emailtrace.h"
    21 #include "cesmraddressselectionquery.h"
    21 #include "cesmraddressselectionquery.h"
    22 
    22 
    23 #include <aknlists.h>
    23 #include <aknlists.h>
    24 #include <aknPopup.h>
    24 #include <aknpopup.h>
    25 #include <bautils.h>
    25 #include <bautils.h>
    26 #include <esmrgui.rsg>
    26 #include <esmrgui.rsg>
    27 #include <data_caging_path_literals.hrh>
    27 #include <data_caging_path_literals.hrh>
    28 
    28 
    29 #include "esmrhelper.h"//locateresourcefile
    29 #include "esmrhelper.h"//locateresourcefile
   113 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
   114 // CESMRAddressSelectionQuery::ExecuteAddressSelectionListL
   114 // CESMRAddressSelectionQuery::ExecuteAddressSelectionListL
   115 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   116 //
   116 //
   117 TInt CESMRAddressSelectionQuery::ExecuteAddressSelectionListL( 
   117 TInt CESMRAddressSelectionQuery::ExecuteAddressSelectionListL( 
   118         const RPointerArray<HBufC>& aAddressArray )
   118 		const RPointerArray<HBufC>& aAddressArray )
   119     {
   119     {
   120     FUNC_LOG;
   120     FUNC_LOG;
   121     TInt ret = ExecuteL( aAddressArray );
   121     TInt ret = ExecuteL( aAddressArray );
   122     return ret;
   122     return ret;
   123     }
   123     }
   125 // -----------------------------------------------------------------------------
   125 // -----------------------------------------------------------------------------
   126 // CESMRAddressSelectionQuery::ExecuteL
   126 // CESMRAddressSelectionQuery::ExecuteL
   127 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   128 //
   128 //
   129 TInt CESMRAddressSelectionQuery::ExecuteL( 
   129 TInt CESMRAddressSelectionQuery::ExecuteL( 
   130         const RPointerArray<HBufC>& aAddressArray )
   130 		const RPointerArray<HBufC>& aAddressArray )
   131     {
   131     {
   132     FUNC_LOG;
   132     FUNC_LOG;
   133     TInt response( KErrCancel );
   133     TInt response( KErrCancel );
   134 
   134 
   135     CAknDoublePopupMenuStyleListBox* list = 
   135     CAknDoublePopupMenuStyleListBox* list = 
   136         new( ELeave )CAknDoublePopupMenuStyleListBox;
   136     	new( ELeave )CAknDoublePopupMenuStyleListBox;
   137     CleanupStack::PushL( list );
   137     CleanupStack::PushL( list );
   138     
   138     
   139     CAknPopupList* popupList = CAknPopupList::NewL( list,
   139     CAknPopupList* popupList = CAknPopupList::NewL( list,
   140             R_AVKON_SOFTKEYS_SELECT_CANCEL,
   140             R_AVKON_SOFTKEYS_SELECT_CANCEL,
   141             AknPopupLayouts::EMenuDoubleWindow );
   141             AknPopupLayouts::EMenuDoubleWindow );
   173 // CESMRAddressSelectionQuery::SetListQueryTextsL
   173 // CESMRAddressSelectionQuery::SetListQueryTextsL
   174 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   175 //
   175 //
   176 
   176 
   177 void CESMRAddressSelectionQuery::SetListQueryTextsL( 
   177 void CESMRAddressSelectionQuery::SetListQueryTextsL( 
   178         CDesCArrayFlat* aItemArray,
   178 		CDesCArrayFlat* aItemArray,
   179         CAknPopupList* aPopupList,
   179 		CAknPopupList* aPopupList,
   180         const RPointerArray<HBufC>& aAddressArray )
   180 		const RPointerArray<HBufC>& aAddressArray )
   181     {
   181     {
   182     FUNC_LOG;
   182     FUNC_LOG;
   183     // Set title for popup
   183     // Set title for popup
   184     aPopupList->SetTitleL( *iEnv->AllocReadResourceAsDes16LC( 
   184     aPopupList->SetTitleL( *iEnv->AllocReadResourceAsDes16LC( 
   185             R_QTN_MEET_REQ_LOC_ADDRESS_SELECTION_TITLE ) );
   185     		R_QTN_MEET_REQ_LOC_ADDRESS_SELECTION_TITLE ) );
   186     CleanupStack::PopAndDestroy(); // Resource string
   186     CleanupStack::PopAndDestroy(); // Resource string
   187 
   187 
   188     // Amount of addresses the contact has
   188     // Amount of addresses the contact has
   189     TInt itemCount = aAddressArray.Count();
   189     TInt itemCount = aAddressArray.Count();
   190   
   190   
   191     RBuf item;
   191     RBuf item;
   192     item.Create( KMaxLength );
   192     item.Create( KMaxLength );
   193     item.CleanupClosePushL();
   193     item.CleanupClosePushL();
   194     
   194     
   195     for ( TInt i(0); i < itemCount; ++i )
   195     for ( TInt i(0); i < itemCount; ++i )
   196         {
   196     	{
   197         // Descriptor has separator between label and the actual address
   197         // Descriptor has separator between label and the actual address
   198         TPtr16 temp = aAddressArray[i]->Des();
   198         TPtr16 temp = aAddressArray[i]->Des();
   199 
   199 
   200         // Let's truncate too long adresses
   200         // Let's truncate too long adresses
   201         if( temp.Length() > KMaxLength )
   201         if( temp.Length() > KMaxLength )
   202             {
   202             {
   203             temp.SetLength( KMaxLength );
   203             temp.SetLength( KMaxLength );
   204             }
   204             }
   205         
   205         
   206         // Finding the first instance of a separator
   206     	// Finding the first instance of a separator
   207         TInt offset = temp.Find( KSeparator );
   207     	TInt offset = temp.Find( KSeparator );
   208         
   208     	
   209         if( 0 <= offset && offset < KMaxLength )
   209     	if( 0 <= offset && offset < KMaxLength )
   210             {
   210     	    {
   211             // Forming label from the beginning to the first separator
   211     	    // Forming label from the beginning to the first separator
   212             TPtrC16 tempLabel = temp.Mid( 0, offset );
   212     	    TPtrC16 tempLabel = temp.Mid( 0, offset );
   213             
   213     	    
   214             // Forming address from the first separator to the end
   214     	    // Forming address from the first separator to the end
   215             TPtrC16 tempAddress = temp.Mid( 
   215     	    TPtrC16 tempAddress = temp.Mid( 
   216                     offset + KSeparatorLength, 
   216     	            offset + KSeparatorLength, 
   217                     temp.Length() - offset - KSeparatorLength );
   217     	            temp.Length() - offset - KSeparatorLength );
   218                 
   218     	        
   219             // appending address item to array
   219     	    // appending address item to array
   220             item.Format( KListItemFormat, &tempLabel, &tempAddress );
   220     	    item.Format( KListItemFormat, &tempLabel, &tempAddress );
   221             aItemArray->AppendL( item );
   221     	    aItemArray->AppendL( item );
   222             }
   222     	    }
   223         
   223     	
   224         }
   224     	}
   225     CleanupStack::PopAndDestroy( &item );
   225     CleanupStack::PopAndDestroy( &item );
   226     }
   226     }
   227 
   227 
   228 //  End of File
   228 //  End of File
   229 
   229