|
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 MVPbkContactViewBase& 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 MVPbkContactViewBase& 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 MVPbkContactViewBase& 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( params, iThumbManager ); |
|
128 } |
|
129 |
|
130 |
|
131 // -------------------------------------------------------------------------- |
|
132 // CPbk2ContactViewDoubleListBox::DoCreateDecorator |
|
133 // -------------------------------------------------------------------------- |
|
134 // |
|
135 CPbk2ListboxModelCmdDecorator* CPbk2ContactViewDoubleListBox::DoCreateDecoratorL( |
|
136 const CPbk2IconArray& aIconArray, |
|
137 TPbk2IconId aEmptyIconId, |
|
138 TPbk2IconId aDefaultIconId ) |
|
139 { |
|
140 return CPbk2DoubleListboxModelCmdDecorator::NewL( |
|
141 aIconArray, |
|
142 aEmptyIconId, |
|
143 aDefaultIconId ); |
|
144 } |
|
145 |
|
146 |
|
147 // -------------------------------------------------------------------------- |
|
148 // CPbk2ContactViewDoubleListBox::SizeChanged |
|
149 // -------------------------------------------------------------------------- |
|
150 // |
|
151 void CPbk2ContactViewDoubleListBox::SizeChanged() |
|
152 { |
|
153 CPbk2ContactViewListBox::SizeChanged(); |
|
154 TRAP_IGNORE( SizeChangedL() ); |
|
155 } |
|
156 |
|
157 // -------------------------------------------------------------------------- |
|
158 // CPbk2ContactViewDoubleListBox::SizeChangedL |
|
159 // -------------------------------------------------------------------------- |
|
160 // |
|
161 void CPbk2ContactViewDoubleListBox::SizeChangedL() |
|
162 { |
|
163 |
|
164 // Modify list item format and layout. |
|
165 // Text format: "0\tContactName\tStatusText\t1" |
|
166 // Icons: |
|
167 // 0: Contact thumbnail |
|
168 // 1: Default listbox icon 1 |
|
169 // |
|
170 // Layout: list_double_large_graphic_phob2_pane |
|
171 // ------------------------------------------------ |
|
172 // | | | |
|
173 // | | Contact Name [1] | |
|
174 // | [0] | | |
|
175 // | | Status Text | |
|
176 // | | | |
|
177 // ------------------------------------------------ |
|
178 // |
|
179 CColumnListBoxItemDrawer* itemDrawer = ItemDrawer(); |
|
180 CColumnListBoxData* data = itemDrawer->ColumnData(); |
|
181 |
|
182 // LIST PANE LAYOUT |
|
183 TAknWindowComponentLayout listPaneLayout( TAknWindowComponentLayout::Compose( |
|
184 AknLayoutScalable_Apps::phob2_listscroll_pane( 0 ), |
|
185 TAknWindowComponentLayout::Compose( |
|
186 AknLayoutScalable_Apps::phob2_list_pane( 0 ), |
|
187 AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane( 0 ) ) ) ); |
|
188 |
|
189 |
|
190 TAknLayoutRect listPaneLayoutRect; |
|
191 listPaneLayoutRect.LayoutRect( TRect( Size() ), listPaneLayout.LayoutLine() ); |
|
192 TRect listPaneRowRect( listPaneLayoutRect.Rect() ); |
|
193 |
|
194 SetHorizontalMargin( listPaneRowRect.iTl.iX ); |
|
195 SetVerticalMargin( listPaneRowRect.iTl.iY ); |
|
196 SetItemHeightL( listPaneRowRect.Height() ); |
|
197 itemDrawer->SetItemCellSize( listPaneRowRect.Size() ); |
|
198 |
|
199 // reset subcell definitions |
|
200 data->ResetSLSubCellArray(); |
|
201 |
|
202 //THUMBNAIL SIZE |
|
203 TAknWindowComponentLayout thumbnailLayout( |
|
204 AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_g1( 0 ) ); |
|
205 |
|
206 TAknLayoutRect thumbnailLayoutRect; |
|
207 thumbnailLayoutRect.LayoutRect( listPaneLayoutRect.Rect(), thumbnailLayout.LayoutLine() ); |
|
208 TRect thumbnailRect( thumbnailLayoutRect.Rect() ); |
|
209 |
|
210 // ADD ICON SIZE TO MANAGER |
|
211 if( &iThumbManager ) |
|
212 { |
|
213 iThumbManager.SetThumbnailIconSize( thumbnailRect.Size() ); |
|
214 } |
|
215 |
|
216 |
|
217 // 1. THUMBNAIL ICON |
|
218 data->SetGraphicSubCellL( 0, thumbnailLayout.LayoutLine() ); // cell index 0 |
|
219 |
|
220 // 2. TEXT ROW 1 (Contact Name) |
|
221 TAknTextComponentLayout cntNameLayout( |
|
222 AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_t1( 0 ) ); |
|
223 data->SetTextSubCellL( 1, cntNameLayout );// cell index 1 |
|
224 |
|
225 // 3. TEXT ROW 2 (Status Text) |
|
226 TAknTextComponentLayout statusTextLayout( |
|
227 AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_t2( 0 ) ); |
|
228 data->SetTextSubCellL( 2, statusTextLayout ); // cell index 2 |
|
229 |
|
230 // 4. LISTBOX DEFAULT GFX 1 |
|
231 TAknWindowLineLayout gfxLayout( |
|
232 AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_g2( 0 ) ); |
|
233 data->SetGraphicSubCellL( 3, gfxLayout ); // cell index 3 |
|
234 |
|
235 |
|
236 // Conditional subcells must be added in priority order! |
|
237 // Text row #1 variation for 1 post icon |
|
238 cntNameLayout = AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_t1( 1 ); |
|
239 data->SetConditionalSubCellL( 3, cntNameLayout, 1 ); // cell index 3 |
|
240 |
|
241 // Marking |
|
242 _LIT( KMarkReplacement, "-1" ); |
|
243 itemDrawer->SetItemMarkPosition( 3 ); // cell index 3 |
|
244 itemDrawer->SetItemMarkReplacement( KMarkReplacement ); |
|
245 } |
|
246 |
|
247 // -------------------------------------------------------------------------- |
|
248 // CPbk2ContactViewDoubleListBox::ThumbnailLoadingComplete |
|
249 // -------------------------------------------------------------------------- |
|
250 // |
|
251 void CPbk2ContactViewDoubleListBox::ThumbnailLoadingComplete( TInt aError, TInt aIndex ) |
|
252 { |
|
253 // there is a thumbnail |
|
254 if( aError == KErrNone ) |
|
255 { |
|
256 View()->DrawItem( aIndex ); |
|
257 } |
|
258 } |
|
259 |
|
260 // -------------------------------------------------------------------------- |
|
261 // CPbk2ContactViewDoubleListBox::ThumbnailRemoved |
|
262 // -------------------------------------------------------------------------- |
|
263 // |
|
264 void CPbk2ContactViewDoubleListBox::ThumbnailRemoved( const MVPbkContactLink& /*aLink*/, TInt aIndex ) |
|
265 { |
|
266 View()->DrawItem( aIndex ); |
|
267 } |
|
268 |
|
269 // -------------------------------------------------------------------------- |
|
270 // CPbk2ContactViewDoubleListBox::LoadingFinished |
|
271 // -------------------------------------------------------------------------- |
|
272 // |
|
273 void CPbk2ContactViewDoubleListBox::LoadingFinished() |
|
274 { |
|
275 DrawNow(); |
|
276 } |
|
277 |
|
278 |
|
279 // End of File |