author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 11:56:55 +0300 | |
branch | RCL_3 |
changeset 74 | 6b5524b4f673 |
parent 63 | f4a778e096c2 |
child 85 | 38bb213f60ba |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2002-2007 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 editor text field. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "CPbk2ContactEditorTextField.h" |
|
20 |
||
21 |
// Phonebook 2 |
|
22 |
#include "MPbk2ContactEditorUiBuilder.h" |
|
23 |
#include "MPbk2ContactEditorFieldVisitor.h" |
|
24 |
#include <MPbk2FieldProperty.h> |
|
25 |
#include <CPbk2PresentationContactField.h> |
|
26 |
#include <Pbk2PresentationUtils.h> |
|
27 |
||
28 |
// Virtual Phonebook |
|
29 |
#include <MVPbkContactFieldTextData.h> |
|
30 |
||
31 |
// System includes |
|
32 |
#include <eikcapc.h> |
|
33 |
#include <eikedwin.h> |
|
34 |
#include <AknUtils.h> |
|
35 |
||
36 |
// -------------------------------------------------------------------------- |
|
37 |
// CPbk2ContactEditorTextField::CPbk2ContactEditorTextField |
|
38 |
// -------------------------------------------------------------------------- |
|
39 |
// |
|
40 |
CPbk2ContactEditorTextField::CPbk2ContactEditorTextField |
|
41 |
( CPbk2PresentationContactField& aContactField, |
|
42 |
MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
43 |
CPbk2IconInfoContainer& aIconInfoContainer ) : |
|
44 |
CPbk2ContactEditorFieldBase( aContactField, aUiBuilder, |
|
45 |
aIconInfoContainer ) |
|
46 |
{ |
|
47 |
} |
|
48 |
||
49 |
// -------------------------------------------------------------------------- |
|
50 |
// CPbk2ContactEditorTextField::~CPbk2ContactEditorTextField |
|
51 |
// -------------------------------------------------------------------------- |
|
52 |
// |
|
53 |
CPbk2ContactEditorTextField::~CPbk2ContactEditorTextField() |
|
54 |
{ |
|
55 |
} |
|
56 |
||
57 |
// -------------------------------------------------------------------------- |
|
58 |
// CPbk2ContactEditorTextField::NewLC |
|
59 |
// -------------------------------------------------------------------------- |
|
60 |
// |
|
61 |
CPbk2ContactEditorTextField* CPbk2ContactEditorTextField::NewLC |
|
62 |
( CPbk2PresentationContactField& aContactField, |
|
63 |
MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
64 |
CPbk2IconInfoContainer& aIconInfoContainer ) |
|
65 |
{ |
|
66 |
CPbk2ContactEditorTextField* self = |
|
67 |
new ( ELeave ) CPbk2ContactEditorTextField( aContactField, |
|
68 |
aUiBuilder, aIconInfoContainer ); |
|
69 |
CleanupStack::PushL( self ); |
|
70 |
self->ConstructL(); |
|
71 |
return self; |
|
72 |
} |
|
73 |
||
74 |
// -------------------------------------------------------------------------- |
|
75 |
// CPbk2ContactEditorTextField::ConstructL |
|
76 |
// -------------------------------------------------------------------------- |
|
77 |
// |
|
78 |
void CPbk2ContactEditorTextField::ConstructL() |
|
79 |
{ |
|
80 |
// Create and insert a line in the dialog |
|
81 |
iControl = static_cast<CEikEdwin*>(iUiBuilder.CreateLineL( |
|
82 |
FieldLabel(), ControlId(), EEikCtEdwin)); |
|
83 |
||
84 |
// Control is now owned by the dialog |
|
85 |
TInt maxFieldLength = iContactField.MaxDataLength(); |
|
86 |
AknEditUtils::ConstructEditingL(iControl, maxFieldLength, |
|
87 |
maxFieldLength, EAknEditorTextCase | EAknEditorCharactersUpperCase |
|
88 |
| EAknEditorCharactersLowerCase, EAknEditorAlignLeft, |
|
89 |
ETrue, ETrue, EFalse); |
|
90 |
||
91 |
// Get text |
|
92 |
TPtrC dataPtr(MVPbkContactFieldTextData::Cast( |
|
93 |
iContactField.FieldData()).Text()); |
|
94 |
HBufC* textBuf = HBufC::NewLC(dataPtr.Length()); |
|
95 |
TPtr text = textBuf->Des(); |
|
96 |
text.Zero(); |
|
97 |
Pbk2PresentationUtils::AppendWithNewlineTranslationL(text, dataPtr); |
|
98 |
||
99 |
// T9 should be deactivated in all contact editors always |
|
100 |
DeactivateT9(iContactField.FieldProperty().EditMode()); |
|
101 |
||
74
6b5524b4f673
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
102 |
// Enable partial screen input |
6b5524b4f673
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
103 |
TInt flags = iControl->AknEditorFlags(); |
6b5524b4f673
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
104 |
iControl->SetAknEditorFlags(flags | EAknEditorFlagEnablePartialScreen); |
6b5524b4f673
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
105 |
|
63 | 106 |
if (iContactField.FieldProperty().EditMode() == |
107 |
EPbk2FieldEditModeLatinOnly) |
|
108 |
{ |
|
109 |
iControl->SetAknEditorSpecialCharacterTable( |
|
110 |
R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG ); |
|
111 |
} |
|
112 |
else |
|
113 |
{ |
|
114 |
// If not in 'only latin mode', convert digits to |
|
115 |
// foreign characters if necessary |
|
116 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion(text); |
|
117 |
} |
|
118 |
||
119 |
switch (iContactField.FieldProperty().DefaultCase()) |
|
120 |
{ |
|
121 |
case EPbk2FieldDefaultCaseLower: |
|
122 |
{ |
|
123 |
iControl->SetAknEditorCase(EAknEditorLowerCase); |
|
124 |
break; |
|
125 |
} |
|
126 |
case EPbk2FieldDefaultCaseText: |
|
127 |
{ |
|
128 |
iControl->SetAknEditorCase(EAknEditorTextCase); |
|
129 |
break; |
|
130 |
} |
|
131 |
default: |
|
132 |
{ |
|
133 |
// Do nothing |
|
134 |
break; |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
// Set formatted text to editor control |
|
139 |
iControl->SetTextL(&text); |
|
140 |
// SetTextL method above copied the text to the control, |
|
141 |
// so it is safe to destroy the buffer |
|
142 |
CleanupStack::PopAndDestroy(textBuf); |
|
143 |
||
144 |
iUiBuilder.LoadBitmapToFieldL |
|
145 |
( iContactField.FieldProperty(), iIconInfoContainer, ControlId() ); |
|
146 |
||
147 |
||
148 |
// Place cursor to the end of the line |
|
149 |
iControl->AddFlagToUserFlags(CEikEdwin::EJustAutoCurEnd); |
|
150 |
||
151 |
// CreateTextViewL() is flagged as deprecated but if it is not |
|
152 |
// called here the ActivateL() below crashes sometimes. |
|
153 |
iControl->CreateTextViewL(); |
|
154 |
iCaptionedCtrl = iUiBuilder.LineControl(ControlId()); |
|
155 |
iCaptionedCtrl->SetTakesEnterKey(EFalse); |
|
156 |
} |
|
157 |
||
158 |
// -------------------------------------------------------------------------- |
|
159 |
// CPbk2ContactEditorTextField::DeactivateT9 |
|
160 |
// -------------------------------------------------------------------------- |
|
161 |
// |
|
162 |
void CPbk2ContactEditorTextField::DeactivateT9(TInt8 aEditMode) |
|
163 |
{ |
|
164 |
if (iControl) |
|
165 |
{ |
|
166 |
if (aEditMode == EPbk2FieldEditModeLatinOnly) |
|
167 |
{ |
|
168 |
iControl->SetAknEditorFlags( |
|
169 |
EAknEditorFlagLatinInputModesOnly | EAknEditorFlagNoT9); |
|
170 |
} |
|
171 |
else |
|
172 |
{ |
|
173 |
iControl->SetAknEditorFlags(EAknEditorFlagNoT9); |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
||
178 |
// -------------------------------------------------------------------------- |
|
179 |
// CPbk2ContactEditorTextField::Control |
|
180 |
// -------------------------------------------------------------------------- |
|
181 |
// |
|
182 |
CEikEdwin* CPbk2ContactEditorTextField::Control() const |
|
183 |
{ |
|
184 |
return iControl; |
|
185 |
} |
|
186 |
||
187 |
// -------------------------------------------------------------------------- |
|
188 |
// CPbk2ContactEditorTextField::SaveFieldL |
|
189 |
// -------------------------------------------------------------------------- |
|
190 |
// |
|
191 |
void CPbk2ContactEditorTextField::SaveFieldL() |
|
192 |
{ |
|
193 |
iContactDataHasChanged = EFalse; |
|
194 |
||
195 |
MVPbkContactFieldTextData& data = |
|
196 |
MVPbkContactFieldTextData::Cast(iContactField.FieldData()); |
|
197 |
TPtrC curText(data.Text()); |
|
198 |
||
199 |
HBufC* text = iControl->GetTextInHBufL(); |
|
200 |
if (text) |
|
201 |
{ |
|
202 |
//Trim spaces at the end of formatted name |
|
203 |
text->Des().TrimRight(); |
|
204 |
if (curText.Compare(*text)) |
|
205 |
{ |
|
206 |
CleanupStack::PushL(text); |
|
207 |
data.SetTextL(*text); |
|
208 |
CleanupStack::PopAndDestroy(text); |
|
209 |
iContactDataHasChanged = ETrue; |
|
210 |
} |
|
211 |
else |
|
212 |
{ |
|
213 |
delete text; |
|
214 |
} |
|
215 |
} |
|
216 |
else if (curText.Length() > 0) |
|
217 |
{ |
|
218 |
data.SetTextL(KNullDesC); |
|
219 |
iContactDataHasChanged = ETrue; |
|
220 |
} |
|
221 |
} |
|
222 |
||
223 |
// -------------------------------------------------------------------------- |
|
224 |
// CPbk2ContactEditorTextField::ActivateL |
|
225 |
// -------------------------------------------------------------------------- |
|
226 |
// |
|
227 |
void CPbk2ContactEditorTextField::ActivateL() |
|
228 |
{ |
|
229 |
iCaptionedCtrl->ActivateL(); |
|
230 |
} |
|
231 |
||
232 |
// -------------------------------------------------------------------------- |
|
233 |
// CPbk2ContactEditorTextField::AcceptL |
|
234 |
// -------------------------------------------------------------------------- |
|
235 |
// |
|
236 |
void CPbk2ContactEditorTextField::AcceptL |
|
237 |
( MPbk2ContactEditorFieldVisitor& aVisitor ) |
|
238 |
{ |
|
239 |
aVisitor.VisitL( *this ); |
|
240 |
} |
|
241 |
||
242 |
// End of File |