|
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 DTMF field. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2ContactEditorDTMFField.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "MPbk2ContactEditorUiBuilder.h" |
|
23 #include "MPbk2ContactEditorFieldVisitor.h" |
|
24 #include <MPbk2FieldProperty.h> |
|
25 #include <CPbk2PresentationContactField.h> |
|
26 #include <MPbk2ContactEditorExtension.h> |
|
27 #include <Phonebook2InternalCRKeys.h> |
|
28 |
|
29 // Virtual Phonebook |
|
30 #include <MVPbkContactFieldTextData.h> |
|
31 |
|
32 // System includes |
|
33 #include <eikcapc.h> |
|
34 #include <eikedwin.h> |
|
35 #include <AknUtils.h> |
|
36 |
|
37 // Debugging headers |
|
38 #include <Pbk2Debug.h> |
|
39 |
|
40 // -------------------------------------------------------------------------- |
|
41 // CPbk2ContactEditorDTMFField::CPbk2ContactEditorDTMFField |
|
42 // -------------------------------------------------------------------------- |
|
43 // |
|
44 inline CPbk2ContactEditorDTMFField::CPbk2ContactEditorDTMFField |
|
45 ( CPbk2PresentationContactField& aContactField, |
|
46 MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
47 CPbk2IconInfoContainer& aIconInfoContainer ) : |
|
48 CPbk2ContactEditorFieldBase( aContactField, aUiBuilder, |
|
49 aIconInfoContainer ) |
|
50 { |
|
51 } |
|
52 |
|
53 // -------------------------------------------------------------------------- |
|
54 // CPbk2ContactEditorDTMFField::~CPbk2ContactEditorDTMFField |
|
55 // -------------------------------------------------------------------------- |
|
56 // |
|
57 CPbk2ContactEditorDTMFField::~CPbk2ContactEditorDTMFField() |
|
58 { |
|
59 } |
|
60 |
|
61 // -------------------------------------------------------------------------- |
|
62 // CPbk2ContactEditorDTMFField::NewLC |
|
63 // -------------------------------------------------------------------------- |
|
64 // |
|
65 CPbk2ContactEditorDTMFField* CPbk2ContactEditorDTMFField::NewLC |
|
66 ( CPbk2PresentationContactField& aContactField, |
|
67 MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
68 CPbk2IconInfoContainer& aIconInfoContainer ) |
|
69 { |
|
70 CPbk2ContactEditorDTMFField* self = |
|
71 new ( ELeave ) CPbk2ContactEditorDTMFField( aContactField, |
|
72 aUiBuilder, aIconInfoContainer ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // -------------------------------------------------------------------------- |
|
79 // CPbk2ContactEditorDTMFField::ConstructL |
|
80 // -------------------------------------------------------------------------- |
|
81 // |
|
82 inline void CPbk2ContactEditorDTMFField::ConstructL() |
|
83 { |
|
84 // Create and insert a line in the dialog |
|
85 iControl = static_cast<CEikEdwin*>(iUiBuilder.CreateLineL( |
|
86 FieldLabel(), ControlId(), EEikCtEdwin)); |
|
87 |
|
88 // Control is now owned by the dialog |
|
89 TInt maxFieldLength = iContactField.MaxDataLength(); |
|
90 AknEditUtils::ConstructEditingL(iControl, maxFieldLength, |
|
91 maxFieldLength, EAknEditorTextCase | EAknEditorCharactersUpperCase |
|
92 | EAknEditorCharactersLowerCase, EAknEditorAlignLeft, |
|
93 ETrue, ETrue, EFalse); |
|
94 |
|
95 // Get text |
|
96 TPtrC dataPtr(MVPbkContactFieldTextData::Cast( |
|
97 iContactField.FieldData()).Text()); |
|
98 HBufC* textBuf = HBufC::NewLC(dataPtr.Length()); |
|
99 TPtr text = textBuf->Des(); |
|
100 text = dataPtr.Left(maxFieldLength); |
|
101 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(text); |
|
102 |
|
103 // Set input capabilities and character modes |
|
104 if (iContactField.FieldProperty().EditMode() == EPbk2FieldEditModeNumeric) |
|
105 { |
|
106 iControl->SetAknEditorNumericKeymap(EAknEditorStandardNumberModeKeymap); |
|
107 iControl->SetAknEditorInputMode(EAknEditorNumericInputMode); |
|
108 iControl->SetAknEditorAllowedInputModes(EAknEditorNumericInputMode); |
|
109 iControl->SetAknEditorSpecialCharacterTable(0); |
|
110 } |
|
111 |
|
112 // Set formatted text to editor control |
|
113 iControl->SetTextL(&text); |
|
114 // SetTextL method above copied the text to the control, |
|
115 // so it is safe to destroy the buffer |
|
116 CleanupStack::PopAndDestroy(textBuf); |
|
117 |
|
118 iUiBuilder.LoadBitmapToFieldL |
|
119 ( iContactField.FieldProperty(), iIconInfoContainer, ControlId() ); |
|
120 |
|
121 // Place cursor to the end of the line |
|
122 iControl->AddFlagToUserFlags(CEikEdwin::EJustAutoCurEnd); |
|
123 |
|
124 iControl->CreateTextViewL(); |
|
125 iCaptionedCtrl = iUiBuilder.LineControl(ControlId()); |
|
126 iCaptionedCtrl->SetTakesEnterKey(ETrue); |
|
127 } |
|
128 |
|
129 // -------------------------------------------------------------------------- |
|
130 // CPbk2ContactEditorDTMFField::Control |
|
131 // -------------------------------------------------------------------------- |
|
132 // |
|
133 CEikEdwin* CPbk2ContactEditorDTMFField::Control() const |
|
134 { |
|
135 return iControl; |
|
136 } |
|
137 |
|
138 // -------------------------------------------------------------------------- |
|
139 // CPbk2ContactEditorDTMFField::SaveFieldL |
|
140 // -------------------------------------------------------------------------- |
|
141 // |
|
142 void CPbk2ContactEditorDTMFField::SaveFieldL() |
|
143 { |
|
144 iContactDataHasChanged = EFalse; |
|
145 |
|
146 MVPbkContactFieldTextData& data = |
|
147 MVPbkContactFieldTextData::Cast(iContactField.FieldData()); |
|
148 TPtrC curText(data.Text()); |
|
149 |
|
150 HBufC* text = iControl->GetTextInHBufL(); |
|
151 if (text) |
|
152 { |
|
153 TPtr number = text->Des(); |
|
154 AknTextUtils::ConvertDigitsTo(number, EDigitTypeWestern); |
|
155 if (curText.Compare(*text)) |
|
156 { |
|
157 CleanupStack::PushL(text); |
|
158 data.SetTextL(*text); |
|
159 CleanupStack::PopAndDestroy(text); |
|
160 iContactDataHasChanged = ETrue; |
|
161 } |
|
162 else |
|
163 { |
|
164 delete text; |
|
165 } |
|
166 } |
|
167 else if (curText.Length() > 0) |
|
168 { |
|
169 data.SetTextL(KNullDesC); |
|
170 iContactDataHasChanged = ETrue; |
|
171 } |
|
172 } |
|
173 |
|
174 // -------------------------------------------------------------------------- |
|
175 // CPbk2ContactEditorDTMFField::ActivateL |
|
176 // -------------------------------------------------------------------------- |
|
177 // |
|
178 void CPbk2ContactEditorDTMFField::ActivateL() |
|
179 { |
|
180 iCaptionedCtrl->ActivateL(); |
|
181 } |
|
182 |
|
183 // -------------------------------------------------------------------------- |
|
184 // CPbk2ContactEditorDTMFField::AcceptL |
|
185 // -------------------------------------------------------------------------- |
|
186 // |
|
187 void CPbk2ContactEditorDTMFField::AcceptL |
|
188 (MPbk2ContactEditorFieldVisitor& aVisitor) |
|
189 { |
|
190 aVisitor.VisitL(*this); |
|
191 } |
|
192 |
|
193 // End of File |