author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:15:33 +0300 | |
branch | RCL_3 |
changeset 85 | 38bb213f60ba |
parent 74 | 6b5524b4f673 |
permissions | -rw-r--r-- |
63 | 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: Temporary listbox model. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <VPbkContactStoreUris.h> |
|
19 |
#include <VPbkUtils.h> |
|
20 |
#include <MVPbkBaseContactFieldCollection.h> |
|
21 |
#include <MVPbkBaseContactField.h> |
|
22 |
#include <MVPbkContactFieldTextData.h> |
|
23 |
#include <MVPbkContactFieldUriData.h> |
|
24 |
#include <MVPbkContactFieldDateTimeData.h> |
|
25 |
#include <MVPbkContactFieldData.h> |
|
26 |
#include <MVPbkContactLinkArray.h> |
|
27 |
#include <CVPbkContactManager.h> |
|
28 |
#include <MVPbkContactOperationBase.h> |
|
29 |
#include <MVPbkContactStoreProperties.h> |
|
30 |
#include <MVPbkContactStore.h> |
|
31 |
#include <MVPbkFieldType.h> |
|
32 |
#include <MVPbkStoreContact.h> |
|
33 |
#include <CVPbkTopContactManager.h> |
|
34 |
#include <MVPbkContactAttributeManager.h> |
|
35 |
#include <CVPbkSpeedDialAttribute.h> |
|
36 |
#include <CVPbkDefaultAttribute.h> |
|
37 |
#include <MVPbkStoreContactField2.h> |
|
38 |
||
39 |
#include <CPbk2StorePropertyArray.h> |
|
40 |
#include <MPbk2ContactNameFormatter.h> |
|
41 |
#include <MPbk2FieldProperty.h> |
|
42 |
#include <MPbk2FieldPropertyArray.h> |
|
43 |
#include <Pbk2FieldPropertiesFactory.h> |
|
44 |
#include <TPbk2StoreContactAnalyzer.h> |
|
45 |
||
46 |
#include "TPbk2ContactEditorParams.h" |
|
47 |
#include "CPbk2ContactEditorDlg.h" |
|
48 |
||
49 |
#include "CPbk2ServiceManager.h" |
|
50 |
#include "CPbk2FieldPropertyArray.h" |
|
51 |
#include "CPbk2PresentationContact.h" |
|
52 |
#include "CPbk2PresentationContactField.h" |
|
53 |
#include "CPbk2PresentationContactFieldCollection.h" |
|
54 |
#include "CPbk2StoreSpecificFieldPropertyArray.h" |
|
55 |
#include "CPbk2IconArray.h" |
|
56 |
#include <CPbk2UIExtensionManager.h> |
|
57 |
#include <CPbk2ApplicationServices.h> |
|
58 |
#include <Pbk2PresentationUtils.h> |
|
59 |
#include <Pbk2AddressTools.h> |
|
60 |
#include <TVPbkFieldTypeParameters.h> |
|
61 |
#include <TVPbkFieldVersitProperty.h> |
|
62 |
#include <StringLoader.h> |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
63 |
|
63 | 64 |
#include <TPbk2AppIconId.h> |
65 |
||
66 |
#include <aknlists.h> |
|
67 |
||
68 |
#include <avkon.rsg> |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
69 |
#include <VPbkEng.rsg> |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
70 |
#include <Pbk2UIControls.rsg> |
74
6b5524b4f673
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
71 |
|
63 | 72 |
#include "ccappdetailsviewlistboxmodel.h" |
73 |
#include "ccappdetailsviewdefs.h" |
|
74 |
#include <ccappdetailsviewpluginrsc.rsg> |
|
75 |
#include "ccappdetailsviewplugin.h" |
|
76 |
#include "ccappdetailsviewpluginuids.hrh" |
|
77 |
#include "ccappdetailsview.hrh" |
|
78 |
||
79 |
const TInt KCacheGranularity = 4; |
|
80 |
const TInt KBufferSize = 256; |
|
81 |
||
82 |
_LIT( KCharsToReplace, "\t" ); |
|
83 |
_LIT( KReplacementChars, " " ); |
|
84 |
||
85 |
const TText KReplacedChars = ' '; |
|
86 |
||
87 |
||
88 |
// ======== LOCAL FUNCTIONS ======== |
|
89 |
||
90 |
// Utility to check file existence without BAFL |
|
91 |
inline TBool FileExists(RFs& aFs, const TDesC& aFileName) |
|
92 |
{ |
|
93 |
TEntry ignore; |
|
94 |
return (aFs.Entry(aFileName, ignore) == KErrNone); |
|
95 |
} |
|
96 |
||
97 |
// ======== MEMBER FUNCTIONS ======== |
|
98 |
||
99 |
// -------------------------------------------------------------------------- |
|
100 |
// CCCAppDetailsViewListBoxRow::CCCAppDetailsViewListBoxRow |
|
101 |
// -------------------------------------------------------------------------- |
|
102 |
// |
|
103 |
inline CCCAppDetailsViewListBoxRow::CCCAppDetailsViewListBoxRow() |
|
104 |
{ |
|
105 |
} |
|
106 |
||
107 |
// -------------------------------------------------------------------------- |
|
108 |
// CCCAppDetailsViewListBoxRow::~CCCAppDetailsViewListBoxRow |
|
109 |
// -------------------------------------------------------------------------- |
|
110 |
// |
|
111 |
CCCAppDetailsViewListBoxRow::~CCCAppDetailsViewListBoxRow() |
|
112 |
{ |
|
113 |
iColumns.ResetAndDestroy(); |
|
114 |
} |
|
115 |
||
116 |
// -------------------------------------------------------------------------- |
|
117 |
// CCCAppDetailsViewListBoxRow::NewL |
|
118 |
// -------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
CCCAppDetailsViewListBoxRow* CCCAppDetailsViewListBoxRow::NewL() |
|
121 |
{ |
|
122 |
return new(ELeave) CCCAppDetailsViewListBoxRow; |
|
123 |
} |
|
124 |
||
125 |
// -------------------------------------------------------------------------- |
|
126 |
// CCCAppDetailsViewListBoxRow::ColumnCount |
|
127 |
// -------------------------------------------------------------------------- |
|
128 |
// |
|
129 |
TInt CCCAppDetailsViewListBoxRow::ColumnCount() const |
|
130 |
{ |
|
131 |
return iColumns.Count(); |
|
132 |
} |
|
133 |
||
134 |
// -------------------------------------------------------------------------- |
|
135 |
// CCCAppDetailsViewListBoxRow::At |
|
136 |
// -------------------------------------------------------------------------- |
|
137 |
// |
|
138 |
TPtrC CCCAppDetailsViewListBoxRow::At(TInt aColumnIndex) const |
|
139 |
{ |
|
140 |
return *iColumns[aColumnIndex]; |
|
141 |
} |
|
142 |
||
143 |
// -------------------------------------------------------------------------- |
|
144 |
// CCCAppDetailsViewListBoxRow::AppendColumnL |
|
145 |
// -------------------------------------------------------------------------- |
|
146 |
// |
|
147 |
void CCCAppDetailsViewListBoxRow::AppendColumnL(const TDesC& aColumnText) |
|
148 |
{ |
|
149 |
HBufC* buf = aColumnText.AllocLC(); |
|
150 |
User::LeaveIfError(iColumns.Append(buf)); |
|
151 |
CleanupStack::Pop(buf); |
|
152 |
} |
|
153 |
||
154 |
// -------------------------------------------------------------------------- |
|
155 |
// CCCAppDetailsViewListBoxRow::IsClipRequired |
|
156 |
// -------------------------------------------------------------------------- |
|
157 |
// |
|
158 |
TBool CCCAppDetailsViewListBoxRow::IsClipRequired() const |
|
159 |
{ |
|
160 |
return iClipBeginning; |
|
161 |
} |
|
162 |
||
163 |
// -------------------------------------------------------------------------- |
|
164 |
// CCCAppDetailsViewListBoxRow::SetClipRequired |
|
165 |
// -------------------------------------------------------------------------- |
|
166 |
// |
|
167 |
void CCCAppDetailsViewListBoxRow::SetClipRequired(TBool aFlag) |
|
168 |
{ |
|
169 |
iClipBeginning = aFlag; |
|
170 |
} |
|
171 |
||
172 |
// -------------------------------------------------------------------------- |
|
173 |
// CCCAppDetailsViewListBoxRow::TotalLength |
|
174 |
// -------------------------------------------------------------------------- |
|
175 |
// |
|
176 |
TInt CCCAppDetailsViewListBoxRow::TotalLength() const |
|
177 |
{ |
|
178 |
TInt result = 0; |
|
179 |
const TInt count = iColumns.Count(); |
|
180 |
for (TInt i = 0; i < count; ++i) |
|
181 |
{ |
|
182 |
result += At(i).Length(); |
|
183 |
} |
|
184 |
return result; |
|
185 |
} |
|
186 |
||
187 |
// -------------------------------------------------------------------------- |
|
188 |
// CCCAppDetailsViewListBoxRow::MaxColumnLength |
|
189 |
// -------------------------------------------------------------------------- |
|
190 |
// |
|
191 |
TInt CCCAppDetailsViewListBoxRow::MaxColumnLength() const |
|
192 |
{ |
|
193 |
TInt result = 0; |
|
194 |
const TInt count = iColumns.Count(); |
|
195 |
for (TInt i = 0; i < count; ++i) |
|
196 |
{ |
|
197 |
result = Max(result, At(i).Length()); |
|
198 |
} |
|
199 |
return result; |
|
200 |
} |
|
201 |
||
202 |
// --------------------------------------------------------------------------- |
|
203 |
// CCCAppDetailsViewListBoxModel::NewL |
|
204 |
// --------------------------------------------------------------------------- |
|
205 |
// |
|
206 |
CCCAppDetailsViewListBoxModel* CCCAppDetailsViewListBoxModel::NewL( |
|
207 |
CCoeEnv& aCoeEnv, |
|
208 |
CEikListBox& aListBox, |
|
209 |
CPbk2ApplicationServices* aApplicationServices, |
|
210 |
CPbk2IconArray& aIconArray, |
|
211 |
CCCAppDetailsViewPlugin& aPlugin) |
|
212 |
{ |
|
213 |
CCCAppDetailsViewListBoxModel* self = |
|
214 |
new(ELeave) CCCAppDetailsViewListBoxModel( |
|
215 |
aCoeEnv, aListBox, aApplicationServices, aIconArray, |
|
216 |
aPlugin); |
|
217 |
CleanupStack::PushL(self); |
|
218 |
self->ConstructL(); |
|
219 |
CleanupStack::Pop(self); |
|
220 |
||
221 |
return self; |
|
222 |
} |
|
223 |
||
224 |
// --------------------------------------------------------------------------- |
|
225 |
// CCCAppDetailsViewListBoxModel::~CCCAppDetailsViewListBoxModel |
|
226 |
// --------------------------------------------------------------------------- |
|
227 |
// |
|
228 |
CCCAppDetailsViewListBoxModel::~CCCAppDetailsViewListBoxModel() |
|
229 |
{ |
|
230 |
Cancel(); |
|
231 |
||
232 |
iRows.ResetAndDestroy(); |
|
233 |
delete iLineBuf; |
|
234 |
delete iColumnBuf; |
|
235 |
delete iLinks; |
|
236 |
delete iStoreContact; |
|
237 |
delete iPresentationContact; |
|
238 |
delete iSpecificFieldProperties; |
|
239 |
delete iFieldProperties; |
|
240 |
delete iRetrieveOperation; |
|
241 |
iInxToPresentationIdx.Close(); |
|
242 |
} |
|
243 |
||
244 |
// --------------------------------------------------------------------------- |
|
245 |
// CCCAppDetailsViewListBoxModel::CCCAppDetailsViewListBoxModel |
|
246 |
// --------------------------------------------------------------------------- |
|
247 |
// |
|
248 |
CCCAppDetailsViewListBoxModel::CCCAppDetailsViewListBoxModel( |
|
249 |
CCoeEnv& aCoeEnv, |
|
250 |
CEikListBox& aListBox, |
|
251 |
CPbk2ApplicationServices* aApplicationServices, |
|
252 |
CPbk2IconArray& aIconArray, |
|
253 |
CCCAppDetailsViewPlugin& aPlugin) |
|
254 |
: |
|
255 |
CActive(EPriorityStandard), |
|
256 |
iCoeEnv(aCoeEnv), |
|
257 |
iListBox(aListBox), |
|
258 |
iRows(KCacheGranularity), |
|
259 |
iAppServices(aApplicationServices), |
|
260 |
iIconArray(aIconArray), |
|
261 |
iCommand(ECCAppDetailsViewCommandNone), |
|
262 |
iIsEditingAborted(EFalse), |
|
263 |
iPlugin(aPlugin) |
|
264 |
{ |
|
265 |
CActiveScheduler::Add(this); |
|
266 |
} |
|
267 |
||
268 |
// --------------------------------------------------------------------------- |
|
269 |
// CCCAppDetailsViewListBoxModel::ConstructL |
|
270 |
// --------------------------------------------------------------------------- |
|
271 |
// |
|
272 |
void CCCAppDetailsViewListBoxModel::ConstructL() |
|
273 |
{ |
|
274 |
CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::ConstructL()")); |
|
275 |
||
276 |
CCA_DP(KDetailsViewLogFile, CCA_L("iInitialFocusIndex = %d"), iInitialFocusIndex); |
|
277 |
||
278 |
iLineBuf = HBufC::NewL(KBufferSize); |
|
279 |
iColumnBuf = HBufC::NewL(KBufferSize); |
|
280 |
||
281 |
CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewListBoxModel::ConstructL()")); |
|
282 |
} |
|
283 |
||
284 |
// --------------------------------------------------------------------------- |
|
285 |
// CCCAppDetailsViewListBoxModel::SetLinks |
|
286 |
// --------------------------------------------------------------------------- |
|
287 |
// |
|
288 |
void CCCAppDetailsViewListBoxModel::SetLinks(MVPbkContactLinkArray* aLinks) |
|
289 |
{ |
|
290 |
delete iLinks; |
|
291 |
iLinks = aLinks; |
|
292 |
//iCurrentLink is now invalid since it points to old iLinks array |
|
293 |
iCurrentLink = NULL; |
|
294 |
||
295 |
delete iRetrieveOperation; |
|
296 |
iRetrieveOperation = NULL; |
|
297 |
||
298 |
IssueRequest(); |
|
299 |
} |
|
300 |
||
301 |
// --------------------------------------------------------------------------- |
|
302 |
// CCCAppDetailsViewListBoxModel::Links |
|
303 |
// --------------------------------------------------------------------------- |
|
304 |
// |
|
305 |
MVPbkContactLinkArray* CCCAppDetailsViewListBoxModel::Links() const |
|
306 |
{ |
|
307 |
return iLinks; |
|
308 |
} |
|
309 |
||
310 |
// --------------------------------------------------------------------------- |
|
311 |
// CCCAppDetailsViewListBoxModel::OpenEditorL |
|
312 |
// --------------------------------------------------------------------------- |
|
313 |
// |
|
314 |
void CCCAppDetailsViewListBoxModel::OpenEditorL() |
|
315 |
{ |
|
316 |
if (iStoreContact) |
|
317 |
{ |
|
318 |
iCommand = ECCAppDetailsViewCommandEdit; |
|
319 |
iStoreContact->LockL(*this); |
|
320 |
} |
|
321 |
} |
|
322 |
||
323 |
// --------------------------------------------------------------------------- |
|
324 |
// CCCAppDetailsViewListBoxModel::FocusedFieldIndex |
|
325 |
// --------------------------------------------------------------------------- |
|
326 |
// |
|
327 |
TInt CCCAppDetailsViewListBoxModel::FocusedFieldIndex() |
|
328 |
{ |
|
329 |
TInt *index = iInxToPresentationIdx.Find(iListBox.CurrentItemIndex()); |
|
330 |
||
331 |
if (index && *index >= KErrNone) |
|
332 |
{ |
|
333 |
return iPresentationContact->PresentationFields().StoreIndexOfField(*index); |
|
334 |
} |
|
335 |
else |
|
336 |
{ |
|
337 |
return KErrNotFound; |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
// --------------------------------------------------------------------------- |
|
342 |
// CCCAppDetailsViewListBoxModel::FocusedListIndex |
|
343 |
// --------------------------------------------------------------------------- |
|
344 |
// |
|
345 |
TInt CCCAppDetailsViewListBoxModel::FocusedListIndex() |
|
346 |
{ |
|
347 |
return iListBox.CurrentItemIndex(); |
|
348 |
} |
|
349 |
||
350 |
// --------------------------------------------------------------------------- |
|
351 |
// CCCAppDetailsViewListBoxModel::SetFocusedListIndex |
|
352 |
// --------------------------------------------------------------------------- |
|
353 |
// |
|
354 |
void CCCAppDetailsViewListBoxModel::SetFocusedListIndex(TInt aIndex) |
|
355 |
{ |
|
356 |
TInt items = iListBox.Model()->NumberOfItems(); |
|
357 |
||
358 |
if (aIndex >= items) |
|
359 |
{ |
|
360 |
aIndex = items - 1; |
|
361 |
} |
|
362 |
if (aIndex < 0) |
|
363 |
{ |
|
364 |
aIndex = 0; |
|
365 |
} |
|
366 |
||
367 |
CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::SetFocusedListIndex( %d )"), aIndex); |
|
368 |
||
369 |
iListBox.SetCurrentItemIndexAndDraw(aIndex); |
|
370 |
} |
|
371 |
||
372 |
// --------------------------------------------------------------------------- |
|
373 |
// CCCAppDetailsViewListBoxModel::SetInitialFocusIndex |
|
374 |
// --------------------------------------------------------------------------- |
|
375 |
// |
|
376 |
void CCCAppDetailsViewListBoxModel::SetInitialFocusIndex(TInt aIndex) |
|
377 |
{ |
|
378 |
CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::SetInitialFocusIndex( %d )"), aIndex); |
|
379 |
||
380 |
if (aIndex >= 0) |
|
381 |
{ |
|
382 |
iInitialFocusIndex = aIndex; |
|
383 |
} |
|
384 |
} |
|
385 |
||
386 |
TInt CCCAppDetailsViewListBoxModel::FindFocusListIndexByStoreIndex(TInt aIndex) |
|
387 |
{ |
|
388 |
TInt fieldIndex = iPresentationContact->PresentationFields().FieldIndexOfStoreField( aIndex ); |
|
389 |
||
390 |
TInt focusListIndex = KErrNotFound; |
|
391 |
||
392 |
TInt count = iInxToPresentationIdx.Count(); |
|
393 |
||
394 |
for ( TInt i = 0; i < count && focusListIndex == KErrNotFound; i++ ) |
|
395 |
{ |
|
396 |
TInt *index = iInxToPresentationIdx.Find( i ); |
|
397 |
if ( index && *index >= KErrNone && *index == fieldIndex ) |
|
398 |
{ |
|
399 |
focusListIndex = i; |
|
400 |
} |
|
401 |
} |
|
402 |
return focusListIndex; |
|
403 |
} |
|
404 |
||
405 |
||
406 |
// -------------------------------------------------------------------------- |
|
407 |
// CCCAppDetailsViewListBoxModel::FocusedFieldLC |
|
408 |
// -------------------------------------------------------------------------- |
|
409 |
// |
|
410 |
MVPbkBaseContactField* CCCAppDetailsViewListBoxModel::FocusedFieldLC() |
|
411 |
{ |
|
412 |
const TInt listIndex = iListBox.CurrentItemIndex(); |
|
413 |
||
414 |
if (listIndex != KErrNotFound) |
|
415 |
{ |
|
416 |
return FieldAtLC(listIndex); |
|
417 |
} |
|
418 |
||
419 |
return NULL; |
|
420 |
} |
|
421 |
||
422 |
// -------------------------------------------------------------------------- |
|
423 |
// CCCAppDetailsViewListBoxModel::StoreContact |
|
424 |
// -------------------------------------------------------------------------- |
|
425 |
// |
|
426 |
MVPbkStoreContact* CCCAppDetailsViewListBoxModel::StoreContact() |
|
427 |
{ |
|
428 |
return iStoreContact; |
|
429 |
} |
|
430 |
||
431 |
// -------------------------------------------------------------------------- |
|
432 |
// CCCAppDetailsViewListBoxModel::GetContactTitleL |
|
433 |
// -------------------------------------------------------------------------- |
|
434 |
// |
|
435 |
HBufC* CCCAppDetailsViewListBoxModel::GetContactTitleL() |
|
436 |
{ |
|
437 |
||
438 |
HBufC* title = iAppServices->NameFormatter().GetContactTitleL( |
|
439 |
iStoreContact->Fields(), |
|
440 |
MPbk2ContactNameFormatter::EPreserveLeadingSpaces | |
|
441 |
MPbk2ContactNameFormatter::EUseSeparator); |
|
442 |
||
443 |
return title; |
|
444 |
} |
|
445 |
||
446 |
// -------------------------------------------------------------------------- |
|
447 |
// CCCAppDetailsViewListBoxModel::IsFocusedFieldTypeL |
|
448 |
// -------------------------------------------------------------------------- |
|
449 |
// |
|
450 |
TBool CCCAppDetailsViewListBoxModel::IsFocusedFieldTypeL(TInt aSelectorResId) |
|
451 |
{ |
|
452 |
TBool ret = EFalse; |
|
453 |
||
454 |
MVPbkBaseContactField* field = FocusedFieldLC(); |
|
455 |
||
456 |
if (field) |
|
457 |
{ |
|
458 |
TPbk2StoreContactAnalyzer analyzer( |
|
459 |
iAppServices->ContactManager(), NULL); |
|
460 |
||
461 |
ret = analyzer.IsFieldTypeIncludedL(*field, aSelectorResId); |
|
462 |
||
463 |
CleanupStack::PopAndDestroy(field); |
|
464 |
} |
|
465 |
||
466 |
return ret; |
|
467 |
} |
|
468 |
||
469 |
// -------------------------------------------------------------------------- |
|
470 |
// CCCAppDetailsViewListBoxModel::HasContactFieldTypeL |
|
471 |
// -------------------------------------------------------------------------- |
|
472 |
// |
|
473 |
TBool CCCAppDetailsViewListBoxModel::HasContactFieldTypeL(TInt aSelectorResId) |
|
474 |
{ |
|
475 |
TBool ret = EFalse; |
|
476 |
||
477 |
TPbk2StoreContactAnalyzer analyzer( |
|
478 |
iAppServices->ContactManager(), iStoreContact); |
|
479 |
||
480 |
ret = analyzer.HasFieldL(aSelectorResId); |
|
481 |
||
482 |
return (ret != KErrNotFound); |
|
483 |
} |
|
484 |
||
485 |
// -------------------------------------------------------------------------- |
|
486 |
// CCCAppDetailsViewListBoxModel::IsTopContact |
|
487 |
// -------------------------------------------------------------------------- |
|
488 |
// |
|
489 |
TBool CCCAppDetailsViewListBoxModel::IsTopContact() const |
|
490 |
{ |
|
491 |
return CVPbkTopContactManager::IsTopContact(*iStoreContact); |
|
492 |
} |
|
493 |
||
494 |
// -------------------------------------------------------------------------- |
|
495 |
// CCCAppDetailsViewListBoxModel::IsReadOnlyContact |
|
496 |
// -------------------------------------------------------------------------- |
|
497 |
// |
|
498 |
TBool CCCAppDetailsViewListBoxModel::IsReadOnlyContact() const |
|
499 |
{ |
|
500 |
return iStoreContact->ParentStore().StoreProperties().ReadOnly(); |
|
501 |
} |
|
502 |
||
503 |
// --------------------------------------------------------------------------- |
|
504 |
// CCCAppDetailsViewListBoxModel::IsSimContact |
|
505 |
// --------------------------------------------------------------------------- |
|
506 |
// |
|
507 |
TBool CCCAppDetailsViewListBoxModel::IsSimContact() const |
|
508 |
{ |
|
509 |
TVPbkContactStoreUriPtr adnUri(VPbkContactStoreUris::SimGlobalAdnUri()); |
|
510 |
TVPbkContactStoreUriPtr fdnUri(VPbkContactStoreUris::SimGlobalFdnUri()); |
|
511 |
||
512 |
TVPbkContactStoreUriPtr uri = |
|
513 |
iStoreContact->ParentStore().StoreProperties().Uri(); |
|
514 |
||
515 |
return ( |
|
516 |
(uri.Compare(adnUri, |
|
517 |
TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) == 0) |
|
518 |
|| |
|
519 |
(uri.Compare(fdnUri, |
|
520 |
TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) == 0) |
|
521 |
); |
|
522 |
} |
|
523 |
||
524 |
// --------------------------------------------------------------------------- |
|
525 |
// CCCAppDetailsViewListBoxModel::IsSdnContact |
|
526 |
// --------------------------------------------------------------------------- |
|
527 |
// |
|
528 |
TBool CCCAppDetailsViewListBoxModel::IsSdnContact() const |
|
529 |
{ |
|
530 |
TVPbkContactStoreUriPtr sdnUri(VPbkContactStoreUris::SimGlobalSdnUri()); |
|
531 |
||
532 |
TVPbkContactStoreUriPtr uri = |
|
533 |
iStoreContact->ParentStore().StoreProperties().Uri(); |
|
534 |
||
535 |
return (uri.Compare(sdnUri, |
|
536 |
TVPbkContactStoreUriPtr::EContactStoreUriAllComponents) == 0); |
|
537 |
} |
|
538 |
||
539 |
// -------------------------------------------------------------------------- |
|
540 |
// CCCAppDetailsViewListBoxModel::HasSpeedDialL |
|
541 |
// -------------------------------------------------------------------------- |
|
542 |
// |
|
543 |
TBool CCCAppDetailsViewListBoxModel::HasSpeedDialL(TInt aIndex) |
|
544 |
{ |
|
545 |
TBool hasAttribute = EFalse; |
|
546 |
||
547 |
if (aIndex != KErrNotFound) |
|
548 |
{ |
|
549 |
const MVPbkStoreContactField& field = |
|
550 |
iStoreContact->Fields().FieldAt(aIndex); |
|
551 |
||
552 |
hasAttribute = iAppServices->ContactManager().ContactAttributeManagerL(). |
|
553 |
HasFieldAttributeL(CVPbkSpeedDialAttribute::Uid(), field); |
|
554 |
} |
|
555 |
||
556 |
return hasAttribute; |
|
557 |
} |
|
558 |
||
559 |
// -------------------------------------------------------------------------- |
|
560 |
// CCCAppDetailsViewListBoxModel::HasDefaultsL |
|
561 |
// -------------------------------------------------------------------------- |
|
562 |
// |
|
563 |
TBool CCCAppDetailsViewListBoxModel::HasDefaultsL(TInt aIndex) |
|
564 |
{ |
|
565 |
TBool hasAttribute = EFalse; |
|
566 |
||
567 |
if (aIndex != KErrNotFound) |
|
568 |
{ |
|
569 |
const MVPbkStoreContactField& field = |
|
570 |
iStoreContact->Fields().FieldAt(aIndex); |
|
571 |
||
572 |
hasAttribute = iAppServices->ContactManager().ContactAttributeManagerL(). |
|
573 |
HasFieldAttributeL(CVPbkDefaultAttribute::Uid(), field); |
|
574 |
} |
|
575 |
||
576 |
return hasAttribute; |
|
577 |
} |
|
578 |
||
579 |
// --------------------------------------------------------------------------- |
|
580 |
// CCCAppDetailsViewListBoxModel::RunL |
|
581 |
// --------------------------------------------------------------------------- |
|
582 |
// |
|
583 |
void CCCAppDetailsViewListBoxModel::RunL() |
|
584 |
{ |
|
585 |
TInt index = 0; |
|
586 |
||
587 |
if (iLinks && iCurrentLink) |
|
588 |
{ |
|
589 |
index = iLinks->Find(*iCurrentLink) + 1; |
|
590 |
} |
|
591 |
||
592 |
if (iAppServices && iLinks && index < iLinks->Count()) |
|
593 |
{ |
|
594 |
iCurrentLink = &iLinks->At(index); |
|
595 |
||
596 |
iRetrieveOperation = iAppServices->ContactManager().RetrieveContactL |
|
597 |
(*iCurrentLink, *this); |
|
598 |
} |
|
599 |
else |
|
600 |
{ |
|
601 |
iCurrentLink = NULL; |
|
602 |
} |
|
603 |
} |
|
604 |
||
605 |
// --------------------------------------------------------------------------- |
|
606 |
// CCCAppDetailsViewListBoxModel::RunError |
|
607 |
// --------------------------------------------------------------------------- |
|
608 |
// |
|
609 |
TInt CCCAppDetailsViewListBoxModel::RunError(TInt aError) |
|
610 |
{ |
|
611 |
return aError; |
|
612 |
} |
|
613 |
||
614 |
// --------------------------------------------------------------------------- |
|
615 |
// CCCAppDetailsViewListBoxModel::DoCancel |
|
616 |
// --------------------------------------------------------------------------- |
|
617 |
// |
|
618 |
void CCCAppDetailsViewListBoxModel::DoCancel() |
|
619 |
{ |
|
620 |
} |
|
621 |
||
622 |
// -------------------------------------------------------------------------- |
|
623 |
// CCCAppDetailsViewListBoxModel::ContactOperationCompleted |
|
624 |
// -------------------------------------------------------------------------- |
|
625 |
// |
|
626 |
void CCCAppDetailsViewListBoxModel::ContactOperationCompleted( |
|
627 |
TContactOpResult /*aResult*/) |
|
628 |
{ |
|
629 |
if (iCommand == ECCAppDetailsViewCommandEdit) |
|
630 |
{ |
|
631 |
// open editing dialog |
|
632 |
TRAP_IGNORE(ExecuteEditorL()); |
|
633 |
||
634 |
iCommand = ECCAppDetailsViewCommandNone; |
|
635 |
} |
|
636 |
} |
|
637 |
||
638 |
// -------------------------------------------------------------------------- |
|
639 |
// CCCAppDetailsViewListBoxModel::ContactOperationFailed |
|
640 |
// -------------------------------------------------------------------------- |
|
641 |
// |
|
642 |
void CCCAppDetailsViewListBoxModel::ContactOperationFailed( |
|
643 |
TContactOp /*aOpCode*/, |
|
644 |
TInt /*aErrorCode*/, |
|
645 |
TBool /*aErrorNotified*/) |
|
646 |
{ |
|
647 |
} |
|
648 |
||
649 |
// -------------------------------------------------------------------------- |
|
650 |
// CCCAppDetailsViewListBoxModel::ContactEditingComplete |
|
651 |
// -------------------------------------------------------------------------- |
|
652 |
// |
|
653 |
void CCCAppDetailsViewListBoxModel::ContactEditingComplete( |
|
654 |
MVPbkStoreContact* aEditedContact) |
|
655 |
{ |
|
656 |
iStoreContact = aEditedContact; |
|
657 |
} |
|
658 |
||
659 |
// -------------------------------------------------------------------------- |
|
660 |
// CCCAppDetailsViewListBoxModel::ContactEditingDeletedContact |
|
661 |
// -------------------------------------------------------------------------- |
|
662 |
// |
|
663 |
void CCCAppDetailsViewListBoxModel::ContactEditingDeletedContact( |
|
664 |
MVPbkStoreContact* aEditedContact) |
|
665 |
{ |
|
666 |
iStoreContact = aEditedContact; |
|
667 |
} |
|
668 |
||
669 |
// -------------------------------------------------------------------------- |
|
670 |
// CCCAppDetailsViewListBoxModel::ContactEditingAborted |
|
671 |
// -------------------------------------------------------------------------- |
|
672 |
// |
|
673 |
void CCCAppDetailsViewListBoxModel::ContactEditingAborted() |
|
674 |
{ |
|
675 |
iIsEditingAborted = ETrue; |
|
676 |
} |
|
677 |
||
678 |
// --------------------------------------------------------------------------- |
|
679 |
// CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationComplete |
|
680 |
// --------------------------------------------------------------------------- |
|
681 |
// |
|
682 |
void CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationComplete( |
|
683 |
MVPbkContactOperationBase& /*aOperation*/, |
|
684 |
MVPbkStoreContact* aContact) |
|
685 |
{ |
|
686 |
CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationComplete()")); |
|
687 |
||
688 |
delete iRetrieveOperation; |
|
689 |
iRetrieveOperation = NULL; |
|
690 |
||
691 |
delete iStoreContact; |
|
692 |
iStoreContact = aContact; |
|
693 |
||
694 |
TRAP_IGNORE( |
|
695 |
CreatePresentationContactL(); |
|
696 |
AddDataL(); |
|
697 |
SetTitleL(); |
|
698 |
UpdateMSKinCbaL(); |
|
699 |
); |
|
700 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
701 |
SetFocusedListIndex(iInitialFocusIndex); |
63 | 702 |
|
703 |
/*if (!iXspIdModifyState) |
|
704 |
{ |
|
705 |
iXspIdModifyState++; |
|
706 |
switch (iXspIdModifyState) |
|
707 |
{ |
|
708 |
case 1: |
|
709 |
aContact->LockL(*this); |
|
710 |
break; |
|
711 |
default: |
|
712 |
// Continue, the xspid is set now |
|
713 |
IssueRequest(); |
|
714 |
break; |
|
715 |
} |
|
716 |
} |
|
717 |
else*/ |
|
718 |
{ |
|
719 |
IssueRequest(); |
|
720 |
} |
|
721 |
||
722 |
CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationComplete()")); |
|
723 |
} |
|
724 |
||
725 |
// --------------------------------------------------------------------------- |
|
726 |
// CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationFailed |
|
727 |
// --------------------------------------------------------------------------- |
|
728 |
// |
|
729 |
void CCCAppDetailsViewListBoxModel::VPbkSingleContactOperationFailed( |
|
730 |
MVPbkContactOperationBase& /*aOperation*/, |
|
731 |
TInt /*aError*/) |
|
732 |
{ |
|
733 |
delete iRetrieveOperation; |
|
734 |
iRetrieveOperation = NULL; |
|
735 |
||
736 |
IssueRequest(); |
|
737 |
} |
|
738 |
||
739 |
// --------------------------------------------------------------------------- |
|
740 |
// CCCAppDetailsViewListBoxModel::MdcaCount |
|
741 |
// --------------------------------------------------------------------------- |
|
742 |
// |
|
743 |
TInt CCCAppDetailsViewListBoxModel::MdcaCount() const |
|
744 |
{ |
|
745 |
return iRows.Count(); |
|
746 |
} |
|
747 |
||
748 |
// --------------------------------------------------------------------------- |
|
749 |
// CCCAppDetailsViewListBoxModel::MdcaPoint |
|
750 |
// --------------------------------------------------------------------------- |
|
751 |
// |
|
752 |
TPtrC CCCAppDetailsViewListBoxModel::MdcaPoint(TInt aIndex) const |
|
753 |
{ |
|
754 |
const TText KSeparator = '\t'; |
|
755 |
TPtr rowText(iLineBuf->Des()); |
|
756 |
rowText.Zero(); |
|
757 |
||
758 |
const CCCAppDetailsViewListBoxRow& row = *iRows[aIndex]; |
|
759 |
const TInt columnCount = row.ColumnCount(); |
|
760 |
TInt fieldCount = iPresentationContact->PresentationFields().FieldCount(); |
|
761 |
||
762 |
for (TInt index = 0; index < columnCount; ++index) |
|
763 |
{ |
|
764 |
TPtr columnText(iColumnBuf->Des()); |
|
765 |
columnText.Copy(row.At(index)); |
|
766 |
||
767 |
// Clip the column if required |
|
768 |
if (index == EContentColumn && row.IsClipRequired() && aIndex < fieldCount) |
|
769 |
{ |
|
770 |
ClipFromBeginning(columnText, aIndex, index); |
|
771 |
} |
|
772 |
||
773 |
// Append the column and separator to the formatted row |
|
774 |
rowText.Append(columnText); |
|
775 |
rowText.Append(KSeparator); |
|
776 |
} |
|
777 |
||
778 |
return rowText; |
|
779 |
} |
|
780 |
||
781 |
// --------------------------------------------------------------------------- |
|
782 |
// CCCAppDetailsViewListBoxModel::IssueRequest |
|
783 |
// --------------------------------------------------------------------------- |
|
784 |
// |
|
785 |
void CCCAppDetailsViewListBoxModel::IssueRequest(TInt aError) |
|
786 |
{ |
|
787 |
if (IsActive()) |
|
788 |
{ |
|
789 |
return; |
|
790 |
} |
|
791 |
TRequestStatus* status = &iStatus; |
|
792 |
User::RequestComplete(status, aError); |
|
793 |
SetActive(); |
|
794 |
} |
|
795 |
||
796 |
// --------------------------------------------------------------------------- |
|
797 |
// CCCAppDetailsViewListBoxModel::CreatePresentationContactL |
|
798 |
// --------------------------------------------------------------------------- |
|
799 |
// |
|
800 |
void CCCAppDetailsViewListBoxModel::CreatePresentationContactL() |
|
801 |
{ |
|
802 |
delete iSpecificFieldProperties; |
|
803 |
iSpecificFieldProperties = NULL; |
|
804 |
delete iFieldProperties; |
|
805 |
iFieldProperties = NULL; |
|
806 |
||
807 |
RFs& fsSession(iCoeEnv.FsSession()); |
|
808 |
||
809 |
const MVPbkContactStoreProperties& storeProperties = |
|
810 |
iStoreContact->ParentStore().StoreProperties(); |
|
811 |
const MVPbkFieldTypeList& supportedFieldTypes = |
|
812 |
storeProperties.SupportedFields(); |
|
813 |
||
814 |
CPbk2ServiceManager& servMan = iAppServices->ServiceManager(); |
|
815 |
||
816 |
iFieldProperties = |
|
817 |
CPbk2FieldPropertyArray::NewL(supportedFieldTypes, fsSession, &servMan); |
|
818 |
||
819 |
// Create a field property list of the supported |
|
820 |
// field types of the used store |
|
821 |
CPbk2StorePropertyArray& pbk2StoreProperties = iAppServices->StoreProperties(); |
|
822 |
||
823 |
iSpecificFieldProperties = CPbk2StoreSpecificFieldPropertyArray::NewL( |
|
824 |
*iFieldProperties, |
|
825 |
pbk2StoreProperties, |
|
826 |
supportedFieldTypes, |
|
827 |
iStoreContact->ParentStore()); |
|
828 |
||
829 |
delete iPresentationContact; |
|
830 |
iPresentationContact = NULL; |
|
831 |
||
832 |
iPresentationContact = |
|
833 |
CPbk2PresentationContact::NewL(*iStoreContact, *iSpecificFieldProperties); |
|
834 |
} |
|
835 |
||
836 |
// -------------------------------------------------------------------------- |
|
837 |
// CCCAppDetailsViewListBoxModel::AddDataL |
|
838 |
// -------------------------------------------------------------------------- |
|
839 |
// |
|
840 |
void CCCAppDetailsViewListBoxModel::AddDataL() |
|
841 |
{ |
|
842 |
//CCA_DP(KDetailsViewLogFile, CCA_L(">>> CCCAppDetailsViewListBoxModel::AddDataL()")); |
|
843 |
||
844 |
iRows.ResetAndDestroy(); |
|
845 |
iInxToPresentationIdx.Close(); |
|
846 |
||
847 |
SetEmptyTextL(R_QTN_PHOB_NO_ITEMS); // in pbk2uicontrols.rsg |
|
848 |
||
849 |
TInt fieldCount = iPresentationContact->PresentationFields().FieldCount(); |
|
850 |
||
851 |
TBuf<KBufferSize> buffer; |
|
852 |
||
853 |
TVPbkFieldTypeParameters fieldParams; |
|
854 |
TInt listIdx = -1; |
|
855 |
||
856 |
for (TInt index = 0; index < fieldCount; index++) |
|
857 |
{ |
|
858 |
CPbk2PresentationContactField& field = |
|
859 |
iPresentationContact->PresentationFields().At(index); |
|
860 |
||
861 |
// Get master field type list and match field's type against it |
|
862 |
const MVPbkFieldType* fieldType = VPbkUtils::MatchFieldType( |
|
863 |
iAppServices->ContactManager().FieldTypes(), field); |
|
864 |
||
865 |
// TODO: what about field.IsVisibleInDetailsView() ? |
|
866 |
||
867 |
if (field.IsEditable() && fieldType && !IsHiddenField(fieldType)) |
|
868 |
{ |
|
869 |
TInt labelResId = 0; |
|
870 |
TVPbkFieldTypeName fieldTypeName = EVPbkVersitNameNone; |
|
871 |
TPbk2FieldGroupId groupId = EPbk2FieldGroupIdNone; |
|
872 |
TArray<TVPbkFieldVersitProperty> versitArr = fieldType->VersitProperties(); |
|
873 |
||
874 |
if (versitArr.Count()) |
|
875 |
{ |
|
876 |
const TVPbkFieldVersitProperty& prop = versitArr[0]; |
|
877 |
||
878 |
if (prop.Name() == EVPbkVersitNameADR) |
|
879 |
{ |
|
880 |
if (versitArr[0].Parameters().Contains(EVPbkVersitParamHOME)) |
|
881 |
{ |
|
882 |
if (fieldParams.Contains(EVPbkVersitParamHOME)) |
|
883 |
{ |
|
884 |
continue; |
|
885 |
} |
|
886 |
fieldParams.Add(EVPbkVersitParamHOME); |
|
887 |
labelResId = R_QTN_PHOB_LBL_ADDRESS_HOME; |
|
888 |
groupId = EPbk2FieldGroupIdHomeAddress; |
|
889 |
} |
|
890 |
else if (versitArr[0].Parameters().Contains(EVPbkVersitParamWORK)) |
|
891 |
{ |
|
892 |
if (fieldParams.Contains(EVPbkVersitParamWORK)) |
|
893 |
{ |
|
894 |
continue; |
|
895 |
} |
|
896 |
fieldParams.Add(EVPbkVersitParamWORK); |
|
897 |
labelResId = R_QTN_PHOB_LBL_ADDRESS_WORK; |
|
898 |
groupId = EPbk2FieldGroupIdCompanyAddress; |
|
899 |
} |
|
900 |
else |
|
901 |
{ |
|
902 |
if (fieldParams.Contains(EVPbkVersitParamPREF)) |
|
903 |
{ |
|
904 |
continue; |
|
905 |
} |
|
906 |
fieldParams.Add(EVPbkVersitParamPREF); |
|
907 |
labelResId = R_QTN_PHOB_LBL_ADDRESS; |
|
908 |
groupId = EPbk2FieldGroupIdPostalAddress; |
|
909 |
} |
|
910 |
fieldTypeName = EVPbkVersitNameADR; |
|
911 |
} |
|
912 |
} |
|
913 |
||
914 |
if (fieldTypeName == EVPbkVersitNameADR) |
|
915 |
{ |
|
916 |
HBufC* label = StringLoader::LoadLC(labelResId); |
|
917 |
CCCAppDetailsViewListBoxRow* row = CCCAppDetailsViewListBoxRow::NewL(); |
|
918 |
CleanupStack::PushL(row); |
|
919 |
||
920 |
// add icon. |
|
921 |
buffer.Zero(); |
|
922 |
TInt iconIndex = 0; |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
923 |
if (IsAddressValidated(groupId)) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
924 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
925 |
TPbk2IconId iconId(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_locev_map); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
926 |
iconIndex = iIconArray.FindIcon(iconId); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
927 |
buffer.AppendNum(iconIndex); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
928 |
} |
63 | 929 |
else |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
930 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
931 |
TPbk2IconId iconId(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_no_valid_lm); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
932 |
iconIndex = iIconArray.FindIcon(iconId); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
933 |
buffer.AppendNum(iconIndex); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
74
diff
changeset
|
934 |
} |
63 | 935 |
row->AppendColumnL(buffer); |
936 |
||
937 |
// add label. |
|
938 |
row->AppendColumnL(*label); |
|
939 |
||
940 |
RBuf text; |
|
941 |
Pbk2AddressTools::GetAddressPreviewLC(*iStoreContact, groupId, text); |
|
942 |
||
943 |
row->AppendColumnL(text); |
|
944 |
CleanupStack::PopAndDestroy(&text); |
|
945 |
||
946 |
// Expand row formatting buffer if required |
|
947 |
ExpandBuffersL(row); |
|
948 |
||
949 |
// Add the row. |
|
950 |
iRows.AppendL(row); |
|
951 |
iInxToPresentationIdx.InsertL(++listIdx, index); |
|
952 |
CleanupStack::Pop(row); |
|
953 |
CleanupStack::PopAndDestroy(label); |
|
954 |
} |
|
955 |
else |
|
956 |
{ |
|
957 |
HBufC* label = GetLabelLC(field); |
|
958 |
||
959 |
if (label->Length()) |
|
960 |
{ |
|
961 |
TBool skipThisData(EFalse); |
|
962 |
CCCAppDetailsViewListBoxRow* row = CCCAppDetailsViewListBoxRow::NewL(); |
|
963 |
CleanupStack::PushL(row); |
|
964 |
||
965 |
const MVPbkContactFieldData& fieldData = field.FieldData(); |
|
966 |
||
967 |
// add icon. |
|
968 |
buffer.Zero(); |
|
969 |
TInt iconIndex = iIconArray.FindIcon(field.FieldProperty().IconId()); |
|
970 |
buffer.AppendNum(iconIndex); |
|
971 |
row->AppendColumnL(buffer); |
|
972 |
||
973 |
// add label. |
|
974 |
row->AppendColumnL(*label); |
|
975 |
||
976 |
// Add current index to Presentation Contact index array |
|
977 |
// to estimate the text is needed to clip or not. |
|
978 |
if(!skipThisData) |
|
979 |
{ |
|
980 |
iInxToPresentationIdx.InsertL(++listIdx, index); |
|
981 |
} |
|
982 |
||
983 |
||
984 |
// add field content. |
|
985 |
switch (fieldData.DataType()) |
|
986 |
{ |
|
987 |
case EVPbkFieldStorageTypeText: |
|
988 |
{ |
|
989 |
TBool defaultTextSet = HandleTextTypeFieldL( |
|
990 |
index, |
|
991 |
fieldData, |
|
992 |
row, |
|
993 |
fieldType->FieldTypeResId()); |
|
994 |
//Don't show default ringtone |
|
995 |
if (defaultTextSet && |
|
996 |
fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_RINGTONE) |
|
997 |
{ |
|
998 |
skipThisData = ETrue; |
|
999 |
} |
|
1000 |
} |
|
1001 |
break; |
|
1002 |
||
1003 |
case EVPbkFieldStorageTypeDateTime: |
|
1004 |
HandleDateTimeTypeFieldL(fieldData, row); |
|
1005 |
break; |
|
1006 |
||
1007 |
case EVPbkFieldStorageTypeUri: |
|
1008 |
HandleUriTypeFieldL(index, fieldData, row); |
|
1009 |
break; |
|
1010 |
||
1011 |
default: |
|
1012 |
break; |
|
1013 |
} |
|
1014 |
||
1015 |
AddIconsToEndL(index, row); |
|
1016 |
||
1017 |
// Expand row formatting buffer if required |
|
1018 |
ExpandBuffersL(row); |
|
1019 |
||
1020 |
// Add the row if data ok to show to user. |
|
1021 |
if(!skipThisData) |
|
1022 |
{ |
|
1023 |
iRows.AppendL(row); |
|
1024 |
CleanupStack::Pop(row); |
|
1025 |
} |
|
1026 |
else |
|
1027 |
{ |
|
1028 |
CleanupStack::PopAndDestroy(row); |
|
1029 |
} |
|
1030 |
} |
|
1031 |
||
1032 |
CleanupStack::PopAndDestroy(label); |
|
1033 |
} |
|
1034 |
} |
|
1035 |
} // for |
|
1036 |
||
1037 |
iListBox.HandleItemAdditionL(); |
|
1038 |
||
1039 |
//CCA_DP(KDetailsViewLogFile, CCA_L("<<< CCCAppDetailsViewListBoxModel::AddDataL()")); |
|
1040 |
} |
|
1041 |
||
1042 |
// -------------------------------------------------------------------------- |
|
1043 |
// CCCAppDetailsViewListBoxModel::IsAddressValidated |
|
1044 |
// -------------------------------------------------------------------------- |
|
1045 |
// |
|
1046 |
TBool CCCAppDetailsViewListBoxModel::IsAddressValidated(TInt aGroupId) |
|
1047 |
{ |
|
1048 |
CPbk2PresentationContactFieldCollection& fields = |
|
1049 |
iPresentationContact->PresentationFields(); |
|
1050 |
||
1051 |
for (TInt idx = 0; idx < fields.FieldCount(); idx++) |
|
1052 |
{ |
|
1053 |
MVPbkStoreContactField& field = fields.FieldAt(idx); |
|
1054 |
TInt countProps = |
|
1055 |
field.BestMatchingFieldType()->VersitProperties().Count(); |
|
1056 |
TArray<TVPbkFieldVersitProperty> props = |
|
1057 |
field.BestMatchingFieldType()->VersitProperties(); |
|
1058 |
||
1059 |
for (TInt idx2 = 0; idx2 < countProps; idx2++) |
|
1060 |
{ |
|
1061 |
if (props[idx2].Name() == EVPbkVersitNameGEO && |
|
1062 |
((props[idx2].Parameters().Contains(EVPbkVersitParamHOME) && |
|
1063 |
aGroupId == EPbk2FieldGroupIdHomeAddress) || |
|
1064 |
(props[idx2].Parameters().Contains(EVPbkVersitParamWORK) && |
|
1065 |
aGroupId == EPbk2FieldGroupIdCompanyAddress) || |
|
1066 |
(!props[idx2].Parameters().Contains(EVPbkVersitParamHOME) && |
|
1067 |
!props[idx2].Parameters().Contains(EVPbkVersitParamWORK) && |
|
1068 |
aGroupId == EPbk2FieldGroupIdPostalAddress))) |
|
1069 |
{ |
|
1070 |
return ETrue; |
|
1071 |
} |
|
1072 |
} |
|
1073 |
} |
|
1074 |
return EFalse; |
|
1075 |
} |
|
1076 |
||
1077 |
// -------------------------------------------------------------------------- |
|
1078 |
// CCCAppDetailsViewListBoxModel::IsHiddenField |
|
1079 |
// -------------------------------------------------------------------------- |
|
1080 |
// |
|
1081 |
TBool CCCAppDetailsViewListBoxModel::IsHiddenField( |
|
1082 |
const MVPbkFieldType* aFieldType) |
|
1083 |
{ |
|
1084 |
TInt resId = aFieldType->FieldTypeResId(); |
|
1085 |
||
1086 |
return (resId == R_VPBK_FIELD_TYPE_SYNCCLASS); |
|
1087 |
} |
|
1088 |
||
1089 |
// --------------------------------------------------------------------------- |
|
1090 |
// CCCAppDetailsViewListBoxModel::FieldAtLC |
|
1091 |
// --------------------------------------------------------------------------- |
|
1092 |
// |
|
1093 |
MVPbkBaseContactField* CCCAppDetailsViewListBoxModel::FieldAtLC(TInt aIndex) |
|
1094 |
{ |
|
1095 |
TInt *presentationIdx = iInxToPresentationIdx.Find(aIndex); |
|
1096 |
||
1097 |
if (!presentationIdx) |
|
1098 |
{ |
|
1099 |
return NULL; |
|
1100 |
} |
|
1101 |
||
1102 |
TInt index = iPresentationContact->PresentationFields().StoreIndexOfField( |
|
1103 |
*presentationIdx); |
|
1104 |
||
1105 |
if (index != KErrNotFound) |
|
1106 |
{ |
|
1107 |
// Use FieldAtLC to avoid the unvalidity of the field after new |
|
1108 |
// FieldAt call. |
|
1109 |
return iStoreContact->Fields().FieldAtLC(index); |
|
1110 |
} |
|
1111 |
||
1112 |
return NULL; |
|
1113 |
} |
|
1114 |
||
1115 |
// --------------------------------------------------------------------------- |
|
1116 |
// CCCAppDetailsViewListBoxModel::IsFieldTypeL |
|
1117 |
// --------------------------------------------------------------------------- |
|
1118 |
// |
|
1119 |
TBool CCCAppDetailsViewListBoxModel::IsFieldTypeL( |
|
1120 |
TInt aIndex, |
|
1121 |
TInt aSelectorResId) |
|
1122 |
{ |
|
1123 |
TBool ret = EFalse; |
|
1124 |
||
1125 |
MVPbkBaseContactField* field = FieldAtLC(aIndex); |
|
1126 |
||
1127 |
if (field) |
|
1128 |
{ |
|
1129 |
TPbk2StoreContactAnalyzer analyzer(iAppServices->ContactManager(), NULL); |
|
1130 |
||
1131 |
ret = analyzer.IsFieldTypeIncludedL(*field, aSelectorResId); |
|
1132 |
||
1133 |
CleanupStack::PopAndDestroy(field); |
|
1134 |
} |
|
1135 |
||
1136 |
return ret; |
|
1137 |
} |
|
1138 |
||
1139 |
// --------------------------------------------------------------------------- |
|
1140 |
// CCCAppDetailsViewListBoxModel::HandleTextTypeFieldL |
|
1141 |
// --------------------------------------------------------------------------- |
|
1142 |
// |
|
1143 |
TBool CCCAppDetailsViewListBoxModel::HandleTextTypeFieldL( |
|
1144 |
TInt aIndex, |
|
1145 |
const MVPbkContactFieldData& aFieldData, |
|
1146 |
CCCAppDetailsViewListBoxRow* aRow, |
|
1147 |
TInt aResId) |
|
1148 |
{ |
|
1149 |
TBool defaultTextInserted(EFalse); |
|
1150 |
const TDesC& fieldText = |
|
1151 |
MVPbkContactFieldTextData::Cast(aFieldData).Text(); |
|
1152 |
||
1153 |
if (aResId == R_VPBK_FIELD_TYPE_CALLEROBJIMG || |
|
1154 |
aResId == R_VPBK_FIELD_TYPE_RINGTONE) |
|
1155 |
{ |
|
1156 |
RFs& fsSession(iCoeEnv.FsSession()); |
|
1157 |
||
1158 |
if (FileExists(fsSession, fieldText)) |
|
1159 |
{ |
|
1160 |
// parse path and show only filename. |
|
1161 |
HBufC* textBuf = HBufC::NewLC(fieldText.Length()); |
|
1162 |
TPtr text = textBuf->Des(); |
|
1163 |
text.Append(fieldText); |
|
1164 |
||
1165 |
TParsePtr parse(text); |
|
1166 |
TPtrC fileName(parse.Name()); |
|
1167 |
||
1168 |
aRow->AppendColumnL(fileName); |
|
1169 |
||
1170 |
CleanupStack::PopAndDestroy(textBuf); |
|
1171 |
} |
|
1172 |
else |
|
1173 |
{ |
|
1174 |
defaultTextInserted = ETrue; |
|
1175 |
TInt textResId = R_QTN_PHOB_FIELD_DEFAULT_TONE; // in pbk2uicontrols.rsg |
|
1176 |
||
1177 |
if (aResId == R_VPBK_FIELD_TYPE_CALLEROBJIMG) |
|
1178 |
{ |
|
1179 |
textResId = R_QTN_PHOB_FIELD_THUMBNAIL; // in pbk2uicontrols.rsg |
|
1180 |
} |
|
1181 |
||
1182 |
// cold filename (e.g mem card not present), show default text. |
|
1183 |
HBufC* defaultText = iCoeEnv.AllocReadResourceLC(textResId); |
|
1184 |
aRow->AppendColumnL(*defaultText); |
|
1185 |
CleanupStack::PopAndDestroy(defaultText); |
|
1186 |
} |
|
1187 |
} |
|
1188 |
else |
|
1189 |
{ |
|
1190 |
TBool isNumberField = IsFieldTypeL(aIndex, R_DETAILSVIEW_PHONENUMBER_SELECTOR); |
|
1191 |
TBool isAddressField = IsFieldTypeL(aIndex, R_DETAILSVIEW_EL_ADDRESS_SELECTOR); |
|
1192 |
||
1193 |
if (isNumberField || isAddressField) |
|
1194 |
{ |
|
1195 |
aRow->SetClipRequired(ETrue); |
|
1196 |
} |
|
1197 |
||
1198 |
TPtr columnBuf(iColumnBuf->Des()); |
|
1199 |
||
1200 |
columnBuf.Set(ExpandColumnBufferL(fieldText.Length())); |
|
1201 |
columnBuf.Zero(); |
|
1202 |
||
1203 |
// replace listbox separator characters. |
|
1204 |
Pbk2PresentationUtils::AppendAndReplaceChars( |
|
1205 |
columnBuf, fieldText, KCharsToReplace, KReplacementChars); |
|
1206 |
||
1207 |
// Replace characters that can not be displayed correctly. |
|
1208 |
Pbk2PresentationUtils::ReplaceNonGraphicCharacters(columnBuf, ' '); |
|
1209 |
||
1210 |
if ( isNumberField ) |
|
1211 |
{ |
|
1212 |
AknTextUtils::LanguageSpecificNumberConversion( columnBuf ); |
|
1213 |
} |
|
1214 |
aRow->AppendColumnL(columnBuf); |
|
1215 |
} |
|
1216 |
return defaultTextInserted; |
|
1217 |
} |
|
1218 |
||
1219 |
// --------------------------------------------------------------------------- |
|
1220 |
// CCCAppDetailsViewListBoxModel::HandleDateTimeTypeFieldL |
|
1221 |
// --------------------------------------------------------------------------- |
|
1222 |
// |
|
1223 |
void CCCAppDetailsViewListBoxModel::HandleDateTimeTypeFieldL( |
|
1224 |
const MVPbkContactFieldData& aFieldData, |
|
1225 |
CCCAppDetailsViewListBoxRow* aRow) |
|
1226 |
{ |
|
1227 |
TLocale locale; |
|
1228 |
TBuf<64> dateBuffer; |
|
1229 |
||
1230 |
const MVPbkContactFieldDateTimeData& date = |
|
1231 |
MVPbkContactFieldDateTimeData::Cast(aFieldData); |
|
1232 |
||
1233 |
TTime time(date.DateTime()); |
|
1234 |
||
1235 |
HBufC* dateFormat = iCoeEnv.AllocReadResourceLC( |
|
1236 |
R_QTN_DATE_USUAL_WITH_ZERO); // in avkon.rsg |
|
1237 |
time.FormatL(dateBuffer, *dateFormat, locale); |
|
1238 |
CleanupStack::PopAndDestroy(dateFormat); |
|
1239 |
||
1240 |
AknTextUtils::LanguageSpecificNumberConversion( dateBuffer ); |
|
1241 |
aRow->AppendColumnL(dateBuffer); |
|
1242 |
} |
|
1243 |
||
1244 |
// --------------------------------------------------------------------------- |
|
1245 |
// CCCAppDetailsViewListBoxModel::HandleUriTypeFieldL |
|
1246 |
// --------------------------------------------------------------------------- |
|
1247 |
// |
|
1248 |
void CCCAppDetailsViewListBoxModel::HandleUriTypeFieldL( |
|
1249 |
TInt aIndex, |
|
1250 |
const MVPbkContactFieldData& aFieldData, |
|
1251 |
CCCAppDetailsViewListBoxRow* aRow) |
|
1252 |
{ |
|
1253 |
TBool isXspField = IsFieldTypeL( aIndex, R_DETAILSVIEW_EL_ADDRESS_SELECTOR ); |
|
1254 |
if ( isXspField ) |
|
1255 |
{ |
|
1256 |
aRow->SetClipRequired( ETrue ); |
|
1257 |
} |
|
1258 |
||
1259 |
const MVPbkContactFieldUriData& uri = |
|
1260 |
MVPbkContactFieldUriData::Cast(aFieldData); |
|
1261 |
||
1262 |
HBufC* tempBuf = uri.Text().AllocLC(); |
|
1263 |
TPtr text = tempBuf->Des(); |
|
1264 |
// Replace characters that can not be displayed correctly. |
|
1265 |
Pbk2PresentationUtils::ReplaceNonGraphicCharacters( text, KReplacedChars ); |
|
1266 |
aRow->AppendColumnL(text); |
|
1267 |
CleanupStack::PopAndDestroy(tempBuf); |
|
1268 |
} |
|
1269 |
||
1270 |
// --------------------------------------------------------------------------- |
|
1271 |
// CCCAppDetailsViewListBoxModel::AddIconsToEndL |
|
1272 |
// --------------------------------------------------------------------------- |
|
1273 |
// |
|
1274 |
void CCCAppDetailsViewListBoxModel::AddIconsToEndL( |
|
1275 |
TInt aIndex, |
|
1276 |
CCCAppDetailsViewListBoxRow* aRow) |
|
1277 |
{ |
|
1278 |
TBuf<KBufferSize> buffer; |
|
1279 |
TInt iconIndex = 0; |
|
1280 |
TInt storeIndex = iPresentationContact->PresentationFields(). |
|
1281 |
StoreIndexOfField(aIndex); |
|
1282 |
||
1283 |
if (HasDefaultsL(storeIndex)) |
|
1284 |
{ |
|
1285 |
buffer.Zero(); |
|
1286 |
TPbk2IconId iconId( |
|
1287 |
TUid::Uid(KCCADetailsViewPluginImplmentationUid), |
|
1288 |
ECCAppDetailsViewQgn_indi_default_conn_add ); |
|
1289 |
iconIndex = iIconArray.FindIcon(iconId); |
|
1290 |
buffer.AppendNum(iconIndex); |
|
1291 |
aRow->AppendColumnL(buffer); |
|
1292 |
} |
|
1293 |
||
1294 |
// Check and add speed dial icon |
|
1295 |
MVPbkStoreContactField* storefield = |
|
1296 |
iStoreContact->Fields().FieldAtLC(storeIndex); |
|
1297 |
||
1298 |
if (storefield) |
|
1299 |
{ |
|
1300 |
MVPbkStoreContactField2* fieldext = |
|
1301 |
reinterpret_cast<MVPbkStoreContactField2*> |
|
1302 |
(storefield->StoreContactFieldExtension |
|
1303 |
(KMVPbkStoreContactFieldExtension2Uid)); |
|
1304 |
||
1305 |
if (fieldext) |
|
1306 |
{ |
|
1307 |
CArrayFix<TInt>* array = fieldext->SpeedDialIndexesL(); |
|
1308 |
||
1309 |
if (array) |
|
1310 |
{ |
|
1311 |
CleanupStack::PushL(array); |
|
1312 |
||
1313 |
buffer.Zero(); |
|
1314 |
||
1315 |
// find speed dial key (1 to 9) and set correct icon |
|
1316 |
TInt key = 0; |
|
1317 |
TInt count = array->Count(); |
|
1318 |
if ( count >0 ) |
|
1319 |
{ |
|
1320 |
key = (*array)[0]; |
|
1321 |
// Loop from end of array to find smallest key |
|
1322 |
// if more than one has been set to same field. |
|
1323 |
for ( TInt i = 1; i < count; i++ ) |
|
1324 |
{ |
|
1325 |
if ( (*array)[i] < key ) |
|
1326 |
{ |
|
1327 |
key = (*array)[i]; |
|
1328 |
} |
|
1329 |
} |
|
1330 |
} |
|
1331 |
||
1332 |
if (key > 0 && key <= 9) |
|
1333 |
{ |
|
1334 |
// icon id ECCAppDetailsViewQgn_indi_qdial_one_add = 1 |
|
1335 |
// so icons from one to nine maps to key value. |
|
1336 |
TPbk2IconId iconId( |
|
1337 |
TUid::Uid(KCCADetailsViewPluginImplmentationUid), key); |
|
1338 |
iconIndex = iIconArray.FindIcon(iconId); |
|
1339 |
||
1340 |
buffer.AppendNum(iconIndex); |
|
1341 |
aRow->AppendColumnL(buffer); |
|
1342 |
} |
|
1343 |
||
1344 |
CleanupStack::PopAndDestroy(array); |
|
1345 |
} |
|
1346 |
} |
|
1347 |
||
1348 |
CleanupStack::PopAndDestroy(storefield); |
|
1349 |
} |
|
1350 |
} |
|
1351 |
||
1352 |
// -------------------------------------------------------------------------- |
|
1353 |
// CCCAppDetailsViewListBoxModel::ClipFromBeginning |
|
1354 |
// -------------------------------------------------------------------------- |
|
1355 |
// |
|
1356 |
TBool CCCAppDetailsViewListBoxModel::ClipFromBeginning( |
|
1357 |
TDes& aBuffer, |
|
1358 |
TInt aItemIndex, |
|
1359 |
TInt aSubCellNumber) const |
|
1360 |
{ |
|
1361 |
CAknFormDoubleGraphicStyleListBox* listbox = |
|
1362 |
static_cast<CAknFormDoubleGraphicStyleListBox*>(&iListBox); |
|
1363 |
||
1364 |
return AknTextUtils::ClipToFit( |
|
1365 |
aBuffer, |
|
1366 |
AknTextUtils::EClipFromBeginning, |
|
1367 |
listbox, |
|
1368 |
aItemIndex, |
|
1369 |
aSubCellNumber); |
|
1370 |
} |
|
1371 |
||
1372 |
// -------------------------------------------------------------------------- |
|
1373 |
// CCCAppDetailsViewListBoxModel::ExpandBuffersL |
|
1374 |
// -------------------------------------------------------------------------- |
|
1375 |
// |
|
1376 |
void CCCAppDetailsViewListBoxModel::ExpandBuffersL( |
|
1377 |
CCCAppDetailsViewListBoxRow* aRow) |
|
1378 |
{ |
|
1379 |
// Row formatting buffer |
|
1380 |
const TInt rowLength = aRow->TotalLength() + aRow->ColumnCount(); // for separator characters |
|
1381 |
||
1382 |
if (rowLength > iLineBuf->Des().MaxLength()) |
|
1383 |
{ |
|
1384 |
iLineBuf = iLineBuf->ReAllocL(rowLength); |
|
1385 |
} |
|
1386 |
||
1387 |
ExpandColumnBufferL(aRow->MaxColumnLength()); |
|
1388 |
} |
|
1389 |
||
1390 |
// -------------------------------------------------------------------------- |
|
1391 |
// CCCAppDetailsViewListBoxModel::ExpandColumnBufferL |
|
1392 |
// -------------------------------------------------------------------------- |
|
1393 |
// |
|
1394 |
TPtr CCCAppDetailsViewListBoxModel::ExpandColumnBufferL(TInt aRequiredLength) |
|
1395 |
{ |
|
1396 |
if (aRequiredLength > iColumnBuf->Des().MaxLength()) |
|
1397 |
{ |
|
1398 |
iColumnBuf = iColumnBuf->ReAllocL(aRequiredLength); |
|
1399 |
} |
|
1400 |
||
1401 |
return (iColumnBuf->Des()); |
|
1402 |
} |
|
1403 |
||
1404 |
// -------------------------------------------------------------------------- |
|
1405 |
// CCCAppDetailsViewListBoxModel::ExecuteEditorL |
|
1406 |
// -------------------------------------------------------------------------- |
|
1407 |
// |
|
1408 |
void CCCAppDetailsViewListBoxModel::ExecuteEditorL() |
|
1409 |
{ |
|
1410 |
// verify syncronization field existance and content |
|
1411 |
/* |
|
1412 |
VPbkUtils::VerifySyncronizationFieldL( |
|
1413 |
CCoeEnv::Static()->FsSession(), |
|
1414 |
iStoreContact->ParentStore().StoreProperties().SupportedFields(), |
|
1415 |
*iStoreContact); |
|
1416 |
*/ |
|
1417 |
||
1418 |
// adjust focus |
|
1419 |
TPbk2ContactEditorParams params; |
|
1420 |
||
1421 |
params.iFocusedContactField = FocusedFieldLC(); |
|
1422 |
||
1423 |
// create and execute editing dialog |
|
1424 |
CPbk2ContactEditorDlg* dlg = |
|
1425 |
CPbk2ContactEditorDlg::NewL(params, iStoreContact, *this); |
|
1426 |
||
1427 |
iStoreContact = NULL; // ownership went to editor |
|
1428 |
dlg->ExecuteLD(); |
|
1429 |
||
1430 |
// clean after dialog execution |
|
1431 |
if (params.iFocusedContactField) |
|
1432 |
{ |
|
1433 |
CleanupStack::PopAndDestroy(params.iFocusedContactField); |
|
1434 |
} |
|
1435 |
||
1436 |
// If editing has been aborted we don't set focused contact. |
|
1437 |
if (iStoreContact && !iIsEditingAborted) |
|
1438 |
{ |
|
1439 |
// It is possible that the contact got changed while in edit |
|
1440 |
//iUiControl->SetFocusedFieldIndex(params.iFocusedIndex); |
|
1441 |
//iUiControl->SetFocusedContactL(*iStoreContact); |
|
1442 |
} |
|
1443 |
||
1444 |
// If contact got deleted in the editor, this call ensures |
|
1445 |
// that the contact info view is switched to the names list |
|
1446 |
//iUiControl->UpdateAfterCommandExecution(); |
|
1447 |
} |
|
1448 |
||
1449 |
// -------------------------------------------------------------------------- |
|
1450 |
// CCCAppDetailsViewListBoxModel::GetLabelLC |
|
1451 |
// -------------------------------------------------------------------------- |
|
1452 |
// |
|
1453 |
HBufC* CCCAppDetailsViewListBoxModel::GetLabelLC( |
|
1454 |
const CPbk2PresentationContactField& aField) |
|
1455 |
{ |
|
1456 |
TPtr columnBuf(iColumnBuf->Des()); |
|
1457 |
columnBuf.Set(ExpandColumnBufferL(aField.FieldLabel().Length())); |
|
1458 |
columnBuf.Zero(); |
|
1459 |
||
1460 |
// replace listbox separator characters. |
|
1461 |
Pbk2PresentationUtils::AppendAndReplaceChars( |
|
1462 |
columnBuf, aField.FieldLabel(), KCharsToReplace, KReplacementChars); |
|
1463 |
||
1464 |
// Replace characters that can not be displayed correctly |
|
1465 |
Pbk2PresentationUtils::ReplaceNonGraphicCharacters(columnBuf, ' '); |
|
1466 |
||
1467 |
HBufC* data = HBufC::NewLC(columnBuf.Length()); |
|
1468 |
data->Des().Append(columnBuf); |
|
1469 |
||
1470 |
return data; |
|
1471 |
} |
|
1472 |
||
1473 |
// -------------------------------------------------------------------------- |
|
1474 |
// CCCAppDetailsViewListBoxModel::SetEmptyTextL |
|
1475 |
// Sets empty text for list box from given resource id. |
|
1476 |
// -------------------------------------------------------------------------- |
|
1477 |
// |
|
1478 |
void CCCAppDetailsViewListBoxModel::SetEmptyTextL(TInt aResourceId) |
|
1479 |
{ |
|
1480 |
HBufC* text = iCoeEnv.AllocReadResourceLC(aResourceId); |
|
1481 |
iListBox.View()->SetListEmptyTextL(*text); |
|
1482 |
CleanupStack::PopAndDestroy(text); |
|
1483 |
} |
|
1484 |
||
1485 |
// -------------------------------------------------------------------------- |
|
1486 |
// CCCAppDetailsViewListBoxModel::SetTitleL |
|
1487 |
// Sets empty text for list box from given resource id. |
|
1488 |
// -------------------------------------------------------------------------- |
|
1489 |
// |
|
1490 |
void CCCAppDetailsViewListBoxModel::SetTitleL() |
|
1491 |
{ |
|
1492 |
HBufC* title = GetContactTitleL(); |
|
1493 |
CleanupStack::PushL(title); |
|
1494 |
iPlugin.SetTitleL(*title); |
|
1495 |
CleanupStack::PopAndDestroy(); |
|
1496 |
} |
|
1497 |
||
1498 |
// -------------------------------------------------------------------------- |
|
1499 |
// CCCAppDetailsViewListBoxModel::IsContactEditable |
|
1500 |
// -------------------------------------------------------------------------- |
|
1501 |
// |
|
1502 |
TBool CCCAppDetailsViewListBoxModel::IsContactEditable() |
|
1503 |
{ |
|
1504 |
return !(IsSdnContact() || IsReadOnlyContact()); |
|
1505 |
} |
|
1506 |
||
1507 |
// -------------------------------------------------------------------------- |
|
1508 |
// CCCAppDetailsViewListBoxModel::UpdateMSKinCbaL |
|
1509 |
// Sets empty MSK or MSK with text "Edit" when contact is editable. |
|
1510 |
// -------------------------------------------------------------------------- |
|
1511 |
// |
|
1512 |
void CCCAppDetailsViewListBoxModel::UpdateMSKinCbaL() |
|
1513 |
{ |
|
1514 |
iPlugin.UpdateMSKinCbaL(IsContactEditable()); |
|
1515 |
} |
|
1516 |
||
1517 |
// -------------------------------------------------------------------------- |
|
1518 |
// CCCAppDetailsViewListBoxModel::HandleEditRequestL |
|
1519 |
// -------------------------------------------------------------------------- |
|
1520 |
// |
|
1521 |
void CCCAppDetailsViewListBoxModel::HandleEditRequestL() |
|
1522 |
{ |
|
1523 |
if (iStoreContact != NULL && IsContactEditable()) |
|
1524 |
{ |
|
1525 |
iPlugin.HandleEditRequestL(); |
|
1526 |
} |
|
1527 |
} |
|
1528 |
||
1529 |
// -------------------------------------------------------------------------- |
|
1530 |
// CCCAppDetailsViewListBoxModel::HandleDeleteRequestL |
|
1531 |
// -------------------------------------------------------------------------- |
|
1532 |
// |
|
1533 |
void CCCAppDetailsViewListBoxModel::HandleDeleteRequestL() |
|
1534 |
{ |
|
1535 |
if ( iStoreContact != NULL && IsContactEditable() ) |
|
1536 |
{ |
|
1537 |
iPlugin.HandleDeleteRequestL(); |
|
1538 |
} |
|
1539 |
} |
|
1540 |
||
1541 |
// -------------------------------------------------------------------------- |
|
1542 |
// CCCAppDetailsViewListBoxModel::IsFieldMapped |
|
1543 |
// -------------------------------------------------------------------------- |
|
1544 |
// |
|
1545 |
TBool CCCAppDetailsViewListBoxModel::IsFieldMapped() const |
|
1546 |
{ |
|
1547 |
const TInt *index = iInxToPresentationIdx.Find(iListBox.CurrentItemIndex()); |
|
1548 |
if ( index && (*index >= KErrNone) && ( *index != iListBox.CurrentItemIndex())) |
|
1549 |
{ |
|
1550 |
return ETrue; |
|
1551 |
} |
|
1552 |
else |
|
1553 |
{ |
|
1554 |
return EFalse; |
|
1555 |
} |
|
1556 |
} |
|
1557 |
||
1558 |
// End of File |