|
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: Listbox model representing all requestors. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "lpdverifnotiflbmodel.h" |
|
21 #include "locrequestorutilsresolver.h" |
|
22 #include "lpdrequestorprocessor.h" |
|
23 #include "locphonenumberformat.h" |
|
24 #include "loctextutils.h" |
|
25 #include "locconsts.h" |
|
26 #include <locverifierdlg.rsg> |
|
27 #include <eikenv.h> |
|
28 |
|
29 // Unnamed namespace for local definitions |
|
30 |
|
31 const TInt KPostfixLBNameCellNbr = 0; // postfix icon |
|
32 // This fixed the space for icons in case icons are needed in verifier notifiers |
|
33 // Change this value to 2 if an icon is to be displayed. |
|
34 const TInt KLBIconMargin = 0; // space for zero icon |
|
35 |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CLpdVerifNotifLBModel::NewL |
|
41 // Two-phased constructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CLpdVerifNotifLBModel* CLpdVerifNotifLBModel::NewL( |
|
45 const CLpdRequestorProcessor& aRtorProcessor, |
|
46 CEikFormattedCellListBox& aListBox ) |
|
47 { |
|
48 CLpdVerifNotifLBModel* self = |
|
49 new( ELeave ) CLpdVerifNotifLBModel( aRtorProcessor, aListBox ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop(self); |
|
53 |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CLpdVerifNotifLBModel::CLpdVerifNotifLBModel |
|
59 // C++ default constructor can NOT contain any code, that |
|
60 // might leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CLpdVerifNotifLBModel::CLpdVerifNotifLBModel( |
|
64 const CLpdRequestorProcessor& aRtorProcessor, |
|
65 CEikFormattedCellListBox& aListBox ) |
|
66 : CLpdBaseModel( aRtorProcessor ), |
|
67 iListBox( aListBox ) |
|
68 { |
|
69 // Intentionally empty |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CLpdVerifNotifLBModel::ConstructL |
|
74 // Symbian 2nd phase constructor can leave. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CLpdVerifNotifLBModel::ConstructL() |
|
78 { |
|
79 BaseConstructL(); |
|
80 iFormatter = CLocPhoneNumberFormat::NewL(); |
|
81 } |
|
82 |
|
83 // Destructor |
|
84 CLpdVerifNotifLBModel::~CLpdVerifNotifLBModel() |
|
85 { |
|
86 delete iFormatter; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CLpdVerifNotifLBModel::MdcaCount |
|
91 // (other items were commented in a header). |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 TInt CLpdVerifNotifLBModel::MdcaCount() const |
|
95 { |
|
96 TInt count = 0; |
|
97 count = iRtorProcessor.Requestors().Count(); |
|
98 |
|
99 if ( count == 0 ) |
|
100 { // if there are no requestors we must add unknown requestor |
|
101 count = 1; |
|
102 } |
|
103 return count; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CLpdVerifNotifLBModel::MdcaPointL |
|
108 // (other items were commented in a header). |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CLpdVerifNotifLBModel::MdcaPointL( TInt aIndex ) const |
|
112 { |
|
113 |
|
114 |
|
115 if( aIndex >= MdcaCount() ) |
|
116 { |
|
117 User::Leave( KErrArgument ); |
|
118 } |
|
119 |
|
120 TPtr bufferDes = iBuffer->Des(); |
|
121 HBufC* name = NULL; |
|
122 |
|
123 if ( iRtorProcessor.Requestors().Count() == 0 ) // unknown requestor |
|
124 { |
|
125 name = CEikonEnv::Static()->AllocReadResourceLC( |
|
126 R_LPD_UNKNOWN_REQUESTER ); |
|
127 // No icons, no clipping, everything surely ok: |
|
128 bufferDes.Zero(); |
|
129 bufferDes.Append( *name ); |
|
130 } |
|
131 |
|
132 else |
|
133 { |
|
134 const CPosRequestor& requestor = |
|
135 *( iRtorProcessor.Requestors() )[aIndex]; |
|
136 name = iUtils->RequestorNameL( requestor ); |
|
137 CleanupStack::PushL( name ); |
|
138 TPtr nameDes = name->Des(); |
|
139 if ( iUtils->PhoneNumberAsName( requestor ) ) |
|
140 { |
|
141 iFormatter->PhoneNumberFormatL( nameDes, bufferDes, |
|
142 AknTextUtils::EClipFromBeginning, |
|
143 &iListBox, aIndex, |
|
144 KPostfixLBNameCellNbr, |
|
145 KLBIconMargin ); |
|
146 } |
|
147 else |
|
148 { |
|
149 LocTextUtils::ClipToFit( nameDes, AknTextUtils::EClipFromEnd, |
|
150 &iListBox, aIndex, KPostfixLBNameCellNbr, KLBIconMargin ); |
|
151 bufferDes.Zero(); |
|
152 bufferDes.Append( *name ); // this is safe after clipping |
|
153 } |
|
154 } |
|
155 |
|
156 CleanupStack::PopAndDestroy(name); |
|
157 } |
|
158 |
|
159 // End of File |