|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Methods for Phonebook contact view listbox model. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkContactViewListFixedIconModel.h" // This class |
|
22 #include <CPbkIconArray.h> |
|
23 |
|
24 // PbkEng.dll include files |
|
25 #include <CPbkContactEngine.h> |
|
26 #include <TPbkContactEntry.h> |
|
27 #include <PbkEngUtils.h> |
|
28 #include <MPbkContactNameFormat.h> |
|
29 #include <CPbkViewContactNameFormatter.h> |
|
30 |
|
31 #include <PbkDebug.h> |
|
32 |
|
33 |
|
34 /// Unnamed namespace for local definitions |
|
35 namespace { |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 |
|
39 #ifdef _DEBUG |
|
40 enum TPanicCode |
|
41 { |
|
42 EPanicPreCond_NewL = 1 |
|
43 }; |
|
44 #endif |
|
45 |
|
46 |
|
47 // ==================== LOCAL FUNCTIONS ==================== |
|
48 |
|
49 #ifdef _DEBUG |
|
50 void Panic(TPanicCode aReason) |
|
51 { |
|
52 _LIT(KPanicText, "CPbkContactViewListFixedIconModel"); |
|
53 User::Panic(KPanicText, aReason); |
|
54 } |
|
55 #endif |
|
56 |
|
57 } // namespace |
|
58 |
|
59 |
|
60 // ================= MEMBER FUNCTIONS ======================= |
|
61 |
|
62 inline CPbkContactViewListFixedIconModel::CPbkContactViewListFixedIconModel |
|
63 (PbkContactViewListModelFactory::TParams& aParams) : |
|
64 CPbkContactViewListModelCommon(aParams), |
|
65 iNameFormatter(aParams.iEngine->ContactNameFormat()) |
|
66 { |
|
67 // CBase::operator new(TLeave) resets other member data |
|
68 } |
|
69 |
|
70 inline void CPbkContactViewListFixedIconModel::ConstructL() |
|
71 { |
|
72 PBK_DEBUG_PRINT |
|
73 (PBK_DEBUG_STRING("CPbkContactViewListFixedIconModel")); |
|
74 __PBK_PROFILE_START(1); |
|
75 CPbkContactViewListModelCommon::ConstructL(); |
|
76 iViewContactNameFormatter = |
|
77 CPbkViewContactNameFormatter::NewL(iNameFormatter); |
|
78 __PBK_PROFILE_END(1); |
|
79 __PBK_PROFILE_DISPLAY(1); |
|
80 } |
|
81 |
|
82 CPbkContactViewListFixedIconModel* CPbkContactViewListFixedIconModel::NewL |
|
83 (PbkContactViewListModelFactory::TParams& aParams) |
|
84 { |
|
85 __ASSERT_DEBUG(aParams.iEngine && aParams.iView && aParams.iIconArray, |
|
86 Panic(EPanicPreCond_NewL)); |
|
87 __ASSERT_DEBUG(aParams.iDefaultId != EPbkNullIconId || |
|
88 aParams.iEmptyId != EPbkNullIconId, |
|
89 Panic(EPanicPreCond_NewL)); |
|
90 |
|
91 CPbkContactViewListFixedIconModel* self = |
|
92 new(ELeave) CPbkContactViewListFixedIconModel(aParams); |
|
93 CleanupStack::PushL(self); |
|
94 self->ConstructL(); |
|
95 CleanupStack::Pop(self); |
|
96 return self; |
|
97 } |
|
98 |
|
99 CPbkContactViewListFixedIconModel::~CPbkContactViewListFixedIconModel() |
|
100 { |
|
101 delete iViewContactNameFormatter; |
|
102 } |
|
103 |
|
104 const TText KSeparator = '\t'; |
|
105 |
|
106 void CPbkContactViewListFixedIconModel::FormatBufferForContactL |
|
107 (const CViewContact& aViewContact) const |
|
108 { |
|
109 // Format only name using aViewContact |
|
110 iBuffer.Zero(); |
|
111 AppendIconIndex(EPbkNullIconId); |
|
112 iBuffer.Append(KSeparator); |
|
113 TPtrC name(iViewContactNameFormatter->ContactTitleL |
|
114 (aViewContact, ViewSortOrder())); |
|
115 if (name.Length() == 0) |
|
116 { |
|
117 name.Set(iNameFormatter.UnnamedText()); |
|
118 } |
|
119 AppendName(name); |
|
120 } |
|
121 |
|
122 // End of File |