phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistbox.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2009-2009 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:  Phonebook 2 contact view double list box.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cpbk2contactviewdoublelistbox.h"
       
    21 
       
    22 #include <eikclbd.h>
       
    23 #include <AknLayout2ScalableDef.h>
       
    24 #include <aknlayoutscalable_avkon.cdl.h>
       
    25 #include <aknlayoutscalable_apps.cdl.h>
       
    26 #include "cpbk2doublelistboxmodelcmddecorator.h"
       
    27 
       
    28 //Virtual phonebook
       
    29 #include <MVPbkContactViewBase.h>
       
    30 #include <MVPbkViewContact.h>
       
    31 #include <MVPbkContactLink.h>
       
    32 
       
    33 //Internal
       
    34 #include "cpbk2contactviewdoublelistboxmodel.h"
       
    35 #include "CPbk2IconArray.h"
       
    36 
       
    37 
       
    38 
       
    39 // --------------------------------------------------------------------------
       
    40 // CPbk2ContactViewDoubleListBox::CPbk2ContactViewDoubleListBox
       
    41 // --------------------------------------------------------------------------
       
    42 //
       
    43 CPbk2ContactViewDoubleListBox::CPbk2ContactViewDoubleListBox(
       
    44     CCoeControl& aContainer,
       
    45     MPbk2ContactUiControlExtension* aUiExtension,
       
    46     CPbk2PredictiveSearchFilter& aSearchFilter,
       
    47     MPbk2FilteredViewStack& aView,
       
    48     CPbk2ThumbnailManager& aThumbManager ) :
       
    49     CPbk2ContactViewListBox( aContainer, aUiExtension, aSearchFilter ),
       
    50     iView( aView  ),
       
    51     iThumbManager( aThumbManager )
       
    52     {
       
    53     }
       
    54 
       
    55 // --------------------------------------------------------------------------
       
    56 // CPbk2ContactViewDoubleListBox::~CPbk2ContactViewDoubleListBox
       
    57 // --------------------------------------------------------------------------
       
    58 //
       
    59 CPbk2ContactViewDoubleListBox::~CPbk2ContactViewDoubleListBox()
       
    60     {
       
    61     // reset thumbnails
       
    62     iThumbManager.Reset();
       
    63     
       
    64     // icon array is destroyed, remove it from the manager
       
    65     iThumbManager.RemoveIconArray();
       
    66     }
       
    67 
       
    68 // --------------------------------------------------------------------------
       
    69 // CPbk2ContactViewDoubleListBox::NewL
       
    70 // --------------------------------------------------------------------------
       
    71 //
       
    72 CPbk2ContactViewDoubleListBox* CPbk2ContactViewDoubleListBox::NewL(
       
    73     CCoeControl& aContainer,
       
    74     TResourceReader& aResourceReader,
       
    75     const CVPbkContactManager& aManager, 
       
    76     MPbk2FilteredViewStack& aView,
       
    77     MPbk2ContactNameFormatter& aNameFormatter,
       
    78     CPbk2StorePropertyArray& aStoreProperties,
       
    79     MPbk2ContactUiControlExtension* aUiExtension,
       
    80     CPbk2PredictiveSearchFilter& aSearchFilter,
       
    81     CPbk2ThumbnailManager& aThumbManager )
       
    82     {
       
    83     CPbk2ContactViewDoubleListBox* self =
       
    84         new ( ELeave ) CPbk2ContactViewDoubleListBox( aContainer,aUiExtension, aSearchFilter, aView, aThumbManager );
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL( aContainer, aResourceReader, aManager,
       
    87         aView, aNameFormatter, aStoreProperties );
       
    88     
       
    89     
       
    90     
       
    91     CleanupStack::Pop( self );
       
    92     return self;
       
    93     }
       
    94 
       
    95 // --------------------------------------------------------------------------
       
    96 // CPbk2ContactViewDoubleListBox::ConstructL
       
    97 // --------------------------------------------------------------------------
       
    98 //
       
    99 void CPbk2ContactViewDoubleListBox::ConstructL(
       
   100         CCoeControl& aContainer, 
       
   101         TResourceReader& aResourceReader,
       
   102         const CVPbkContactManager& aManager, 
       
   103         MPbk2FilteredViewStack& aView,
       
   104         MPbk2ContactNameFormatter& aNameFormatter,
       
   105         CPbk2StorePropertyArray& aStoreProperties )
       
   106     {
       
   107     CPbk2ContactViewListBox::ConstructL( aContainer, 
       
   108 										aResourceReader, 
       
   109 										aManager,
       
   110 										aView, 
       
   111 										aNameFormatter, 
       
   112 										aStoreProperties );
       
   113     
       
   114     // set icon array for the manager
       
   115     iThumbManager.SetPbkIconArray( static_cast<CPbk2IconArray*>( ItemDrawer()->ColumnData()->IconArray() ) );
       
   116     iThumbManager.SetDefaultIconId( iResourceData.iDefaultIconId );
       
   117     }
       
   118 
       
   119 
       
   120 // --------------------------------------------------------------------------
       
   121 // CPbk2ContactViewDoubleListBox::DoCreateModelL
       
   122 // --------------------------------------------------------------------------
       
   123 //
       
   124 CPbk2ContactViewListBoxModel* CPbk2ContactViewDoubleListBox::DoCreateModelL( 
       
   125         		CPbk2ContactViewListBoxModel::TParams params )
       
   126 	{
       
   127 	return CPbk2ContactViewDoubleListBoxModel::NewL( 
       
   128 	        params, iThumbManager );
       
   129 	}
       
   130 
       
   131 
       
   132 // --------------------------------------------------------------------------
       
   133 // CPbk2ContactViewDoubleListBox::DoCreateDecorator
       
   134 // --------------------------------------------------------------------------
       
   135 //
       
   136 CPbk2ListboxModelCmdDecorator* CPbk2ContactViewDoubleListBox::DoCreateDecoratorL( 
       
   137 		const CPbk2IconArray& aIconArray,
       
   138 		TPbk2IconId aEmptyIconId,
       
   139 		TPbk2IconId aDefaultIconId )
       
   140 	{
       
   141 	return CPbk2DoubleListboxModelCmdDecorator::NewL(
       
   142 					aIconArray,
       
   143 					aEmptyIconId,
       
   144 					aDefaultIconId );
       
   145 	}
       
   146 
       
   147 
       
   148 // --------------------------------------------------------------------------
       
   149 // CPbk2ContactViewDoubleListBox::SizeChanged
       
   150 // --------------------------------------------------------------------------
       
   151 //
       
   152 void CPbk2ContactViewDoubleListBox::SizeChanged()
       
   153     {
       
   154     CPbk2ContactViewListBox::SizeChanged();
       
   155     TRAP_IGNORE( SizeChangedL() );
       
   156     }
       
   157 
       
   158 // --------------------------------------------------------------------------
       
   159 // CPbk2ContactViewDoubleListBox::SizeChangedL
       
   160 // --------------------------------------------------------------------------
       
   161 //
       
   162 void CPbk2ContactViewDoubleListBox::SizeChangedL()
       
   163     {
       
   164     
       
   165     // Modify list item format and layout. 
       
   166     // Text format: "0\tContactName\tStatusText\t1"
       
   167     // Icons: 
       
   168     //  0: Contact thumbnail
       
   169     //  1: Default listbox icon 1
       
   170     //
       
   171     // Layout: list_double_large_graphic_phob2_pane
       
   172     // ------------------------------------------------
       
   173     // |       |                                      |
       
   174     // |       | Contact Name                   [1]   |
       
   175     // |  [0]  |                                      |
       
   176     // |       | Status Text                          |
       
   177     // |       |                                      |
       
   178     // ------------------------------------------------
       
   179     //
       
   180     CColumnListBoxItemDrawer* itemDrawer = ItemDrawer();
       
   181     CColumnListBoxData* data = itemDrawer->ColumnData();
       
   182 
       
   183     // LIST PANE LAYOUT
       
   184     TAknWindowComponentLayout listPaneLayout( TAknWindowComponentLayout::Compose(
       
   185         AknLayoutScalable_Apps::phob2_listscroll_pane( 0 ),
       
   186         TAknWindowComponentLayout::Compose( 
       
   187             AknLayoutScalable_Apps::phob2_list_pane( 0 ), 
       
   188             AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane( 0 ) ) ) );    
       
   189 
       
   190     
       
   191     TAknLayoutRect listPaneLayoutRect;
       
   192     listPaneLayoutRect.LayoutRect( TRect( Size() ), listPaneLayout.LayoutLine() );
       
   193     TRect listPaneRowRect( listPaneLayoutRect.Rect() );
       
   194     
       
   195     SetHorizontalMargin( listPaneRowRect.iTl.iX );
       
   196     SetVerticalMargin( listPaneRowRect.iTl.iY );
       
   197     SetItemHeightL( listPaneRowRect.Height() );
       
   198     itemDrawer->SetItemCellSize( listPaneRowRect.Size() );
       
   199     
       
   200     // reset subcell definitions
       
   201     data->ResetSLSubCellArray();
       
   202     
       
   203     //THUMBNAIL SIZE
       
   204     TAknWindowComponentLayout thumbnailLayout( 
       
   205             AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_g1( 0 ) );
       
   206     
       
   207     TAknLayoutRect thumbnailLayoutRect;
       
   208     thumbnailLayoutRect.LayoutRect( listPaneLayoutRect.Rect(), thumbnailLayout.LayoutLine() );
       
   209     TRect thumbnailRect( thumbnailLayoutRect.Rect() );
       
   210     
       
   211     // ADD ICON SIZE TO MANAGER
       
   212     if( &iThumbManager )
       
   213 		{
       
   214 		iThumbManager.SetThumbnailIconSize( thumbnailRect.Size() );
       
   215 		}
       
   216     
       
   217     
       
   218     // 1. THUMBNAIL ICON
       
   219     data->SetGraphicSubCellL( 0, thumbnailLayout.LayoutLine() );	// cell index 0
       
   220     
       
   221     // 2. TEXT ROW 1 (Contact Name)
       
   222     TAknTextComponentLayout cntNameLayout( 
       
   223             AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_t1( 0 ) );
       
   224     data->SetTextSubCellL( 1, cntNameLayout );// cell index 1
       
   225 
       
   226     // 3. TEXT ROW 2 (Status Text)
       
   227     TAknTextComponentLayout statusTextLayout( 
       
   228             AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_t2( 0 ) );
       
   229     data->SetTextSubCellL( 2, statusTextLayout );	// cell index 2
       
   230     
       
   231     // 4. LISTBOX DEFAULT GFX 1
       
   232     TAknWindowLineLayout gfxLayout( 
       
   233             AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_g2( 0 ) );
       
   234     data->SetGraphicSubCellL( 3, gfxLayout );	// cell index 3
       
   235     
       
   236     
       
   237     // Conditional subcells must be added in priority order!
       
   238     // Text row #1 variation for 1 post icon
       
   239     cntNameLayout = AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_t1( 1 );
       
   240     data->SetConditionalSubCellL( 3, cntNameLayout, 1 );	// cell index 3
       
   241 
       
   242     // Marking
       
   243     _LIT( KMarkReplacement, "-1" );
       
   244     itemDrawer->SetItemMarkPosition( 3 );				// cell index 3 
       
   245     itemDrawer->SetItemMarkReplacement( KMarkReplacement );
       
   246     }
       
   247 
       
   248 // --------------------------------------------------------------------------
       
   249 // CPbk2ContactViewDoubleListBox::ThumbnailLoadingComplete
       
   250 // --------------------------------------------------------------------------
       
   251 //
       
   252 void CPbk2ContactViewDoubleListBox::ThumbnailLoadingComplete( TInt aError, TInt aIndex )
       
   253 	{
       
   254 	// there is a thumbnail
       
   255 	if( aError == KErrNone )
       
   256 		{
       
   257 		View()->DrawItem( aIndex );
       
   258 		}
       
   259 	}
       
   260 
       
   261 // --------------------------------------------------------------------------
       
   262 // CPbk2ContactViewDoubleListBox::ThumbnailRemoved
       
   263 // --------------------------------------------------------------------------
       
   264 //
       
   265 void CPbk2ContactViewDoubleListBox::ThumbnailRemoved( const MVPbkContactLink& /*aLink*/, TInt aIndex )
       
   266 	{
       
   267 	View()->DrawItem( aIndex );
       
   268 	}
       
   269 
       
   270 // --------------------------------------------------------------------------
       
   271 // CPbk2ContactViewDoubleListBox::LoadingFinished
       
   272 // --------------------------------------------------------------------------
       
   273 //
       
   274 void CPbk2ContactViewDoubleListBox::LoadingFinished()
       
   275 	{
       
   276 	DrawNow();
       
   277 	}
       
   278 
       
   279 
       
   280 // End of File