20 #include "CPbk2AdaptiveSearchGridFiller.h" |
20 #include "CPbk2AdaptiveSearchGridFiller.h" |
21 #include "MVPbkViewContact.h" |
21 #include "MVPbkViewContact.h" |
22 #include "MVPbkContactViewBase.h" |
22 #include "MVPbkContactViewBase.h" |
23 #include "MPbk2ContactNameFormatter.h" |
23 #include "MPbk2ContactNameFormatter.h" |
24 |
24 |
|
25 #include <MPbk2ContactNameFormatter2.h> |
25 #include <FindUtil.h> |
26 #include <FindUtil.h> |
26 #include <badesca.h> |
27 #include <badesca.h> |
|
28 #include <featmgr.h> |
27 |
29 |
28 const TInt KMaxAdaptiveGridCacheCount = 10; |
30 const TInt KMaxAdaptiveGridCacheCount = 10; |
29 const TInt KAdaptiveSearchKeyMapGranularity = 100; |
31 const TInt KAdaptiveSearchKeyMapGranularity = 100; |
30 const TInt KAdaptiveSearchRefineStep = 10; |
32 const TInt KAdaptiveSearchRefineStep = 10; |
31 const TInt KContactFormattingFlags = MPbk2ContactNameFormatter::EPreserveLeadingSpaces | MPbk2ContactNameFormatter::EReplaceNonGraphicChars; |
33 const TInt KContactFormattingFlags = MPbk2ContactNameFormatter::EPreserveLeadingSpaces | |
|
34 MPbk2ContactNameFormatter::EReplaceNonGraphicChars | |
|
35 MPbk2ContactNameFormatter::EDisableCompanyNameSeparator; |
32 |
36 |
33 |
37 |
34 NONSHARABLE_CLASS(CPbk2AdaptiveGrid) : public CBase |
38 NONSHARABLE_CLASS(CPbk2AdaptiveGrid) : public CBase |
35 { |
39 { |
36 HBufC* iFindText; |
40 HBufC* iFindText; |
179 |
183 |
180 for( ; iCounter < stopCount; iCounter++ ) |
184 for( ; iCounter < stopCount; iCounter++ ) |
181 { |
185 { |
182 const MVPbkViewContact& contact = iView->ContactAtL( iCounter ); |
186 const MVPbkViewContact& contact = iView->ContactAtL( iCounter ); |
183 const TInt titleLength = iNameFormatter.MaxTitleLength( contact.Fields(), KContactFormattingFlags ); |
187 const TInt titleLength = iNameFormatter.MaxTitleLength( contact.Fields(), KContactFormattingFlags ); |
184 HBufC* title = HBufC::NewLC( titleLength ); |
188 HBufC* title = NULL; |
185 TPtr ptrTitle = title->Des(); |
189 |
186 iNameFormatter.GetContactTitle( contact.Fields(), ptrTitle, KContactFormattingFlags ); |
190 if( FeatureManager::FeatureSupported( KFeatureIdFfContactsCompanyNames ) ) |
187 BuildGridL( ptrTitle, *iSearchString, iKeyMap ); |
191 { |
|
192 MPbk2ContactNameFormatter2* nameformatterExtension = |
|
193 reinterpret_cast<MPbk2ContactNameFormatter2*>( iNameFormatter. |
|
194 ContactNameFormatterExtension( MPbk2ContactNameFormatterExtension2Uid ) ); |
|
195 if ( nameformatterExtension && titleLength ) |
|
196 { |
|
197 title = nameformatterExtension->GetContactTitleWithCompanyNameL( contact.Fields(), |
|
198 KContactFormattingFlags ); |
|
199 |
|
200 } |
|
201 } |
|
202 else if ( titleLength ) |
|
203 { |
|
204 title = iNameFormatter.GetContactTitleL( contact.Fields(), KContactFormattingFlags ); |
|
205 } |
|
206 |
|
207 if ( !title ) |
|
208 { |
|
209 title = HBufC::NewL( titleLength ); |
|
210 } |
|
211 |
|
212 CleanupStack::PushL( title ); |
|
213 BuildGridL( *title, *iSearchString, iKeyMap ); |
188 |
214 |
189 // check number of spaces in the contact title |
215 // check number of spaces in the contact title |
190 TInt numberOfSpaces = NumberOfSpacesInString( ptrTitle ); |
216 TInt numberOfSpaces = NumberOfSpacesInString( *title ); |
191 if ( numberOfSpaces > maxSpacesNumber ) |
217 if ( numberOfSpaces > maxSpacesNumber ) |
192 { |
218 { |
193 maxSpacesNumber = numberOfSpaces; |
219 maxSpacesNumber = numberOfSpaces; |
194 } |
220 } |
195 // Check if the contact's title include drgraphs, |
221 // Check if the contact's title include drgraphs, |
196 // if it is, add it to array to save. |
222 // if it is, add it to array to save. |
197 if ( IsDigraphContactsTitleL( ptrTitle ) ) |
223 if ( IsDigraphContactsTitleL( *title ) ) |
198 { |
224 { |
199 iDigraphContactsTitleArray.AppendL( title ); |
225 iDigraphContactsTitleArray.AppendL( title ); |
200 CleanupStack::Pop(); //title |
226 CleanupStack::Pop(); //title |
201 } |
227 } |
202 else |
228 else |