|
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 URL field. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2ContactEditorUrlField.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include <MPbk2FieldProperty.h> |
|
23 #include "MPbk2ContactEditorUiBuilder.h" |
|
24 #include <CPbk2PresentationContactField.h> |
|
25 |
|
26 // Virtual Phonebook |
|
27 #include <MVPbkContactFieldTextData.h> |
|
28 #include <MVPbkContactFieldUriData.h> |
|
29 |
|
30 // System includes |
|
31 #include <eikcapc.h> |
|
32 #include <eikedwin.h> |
|
33 #include <AknUtils.h> |
|
34 |
|
35 /// Unnamed namespace for local definitions |
|
36 namespace { |
|
37 |
|
38 // CONSTANTS |
|
39 _LIT(KHttp, "http://"); |
|
40 |
|
41 } /// namespace |
|
42 |
|
43 |
|
44 // -------------------------------------------------------------------------- |
|
45 // CPbk2ContactEditorUrlField::CPbk2ContactEditorUrlField |
|
46 // -------------------------------------------------------------------------- |
|
47 // |
|
48 inline CPbk2ContactEditorUrlField::CPbk2ContactEditorUrlField |
|
49 ( CPbk2PresentationContactField& aContactField, |
|
50 MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
51 CPbk2IconInfoContainer& aIconInfoContainer ) : |
|
52 CPbk2ContactEditorTextField( aContactField, aUiBuilder, |
|
53 aIconInfoContainer ) |
|
54 { |
|
55 } |
|
56 |
|
57 // -------------------------------------------------------------------------- |
|
58 // CPbk2ContactEditorUrlField::~CPbk2ContactEditorUrlField |
|
59 // -------------------------------------------------------------------------- |
|
60 // |
|
61 CPbk2ContactEditorUrlField::~CPbk2ContactEditorUrlField() |
|
62 { |
|
63 } |
|
64 |
|
65 // -------------------------------------------------------------------------- |
|
66 // CPbk2ContactEditorUrlField::NewLC |
|
67 // -------------------------------------------------------------------------- |
|
68 // |
|
69 CPbk2ContactEditorUrlField* CPbk2ContactEditorUrlField::NewLC |
|
70 ( CPbk2PresentationContactField& aContactField, |
|
71 MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
72 CPbk2IconInfoContainer& aIconInfoContainer ) |
|
73 { |
|
74 CPbk2ContactEditorUrlField* self = |
|
75 new ( ELeave ) CPbk2ContactEditorUrlField( aContactField, aUiBuilder, |
|
76 aIconInfoContainer ); |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 return self; |
|
80 } |
|
81 |
|
82 // -------------------------------------------------------------------------- |
|
83 // CPbk2ContactEditorUrlField::ConstructL |
|
84 // -------------------------------------------------------------------------- |
|
85 // |
|
86 inline void CPbk2ContactEditorUrlField::ConstructL() |
|
87 { |
|
88 // Create and insert a line in the dialog |
|
89 iControl = static_cast<CEikEdwin*>(iUiBuilder.CreateLineL( |
|
90 FieldLabel(), ControlId(), EEikCtEdwin)); |
|
91 |
|
92 // Control is now owned by the dialog |
|
93 TInt maxFieldLength = iContactField.MaxDataLength(); |
|
94 AknEditUtils::ConstructEditingL(iControl, maxFieldLength, |
|
95 maxFieldLength, EAknEditorTextCase | EAknEditorCharactersUpperCase |
|
96 | EAknEditorCharactersLowerCase, EAknEditorAlignLeft, |
|
97 ETrue, ETrue, EFalse); |
|
98 |
|
99 // T9 should be deactivated in all contact editors always |
|
100 DeactivateT9(iContactField.FieldProperty().EditMode()); |
|
101 |
|
102 if (iContactField.FieldProperty().EditMode() == |
|
103 EPbk2FieldEditModeLatinOnly) |
|
104 { |
|
105 iControl->SetAknEditorSpecialCharacterTable( |
|
106 R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG ); |
|
107 } |
|
108 |
|
109 switch (iContactField.FieldProperty().DefaultCase()) |
|
110 { |
|
111 case EPbk2FieldDefaultCaseLower: |
|
112 { |
|
113 iControl->SetAknEditorCase(EAknEditorLowerCase); |
|
114 break; |
|
115 } |
|
116 case EPbk2FieldDefaultCaseText: |
|
117 { |
|
118 iControl->SetAknEditorCase(EAknEditorTextCase); |
|
119 break; |
|
120 } |
|
121 default: |
|
122 { |
|
123 // Do nothing |
|
124 break; |
|
125 } |
|
126 } |
|
127 |
|
128 // Get text |
|
129 TPtrC text(MVPbkContactFieldTextData::Cast( |
|
130 iContactField.FieldData()).Text()); |
|
131 |
|
132 if (text.Length() == 0) |
|
133 { |
|
134 // Insert http:// prefix to URL fields |
|
135 iControl->SetTextL(&KHttp()); |
|
136 } |
|
137 else |
|
138 { |
|
139 iControl->SetTextL(&text); |
|
140 } |
|
141 |
|
142 iUiBuilder.LoadBitmapToFieldL |
|
143 ( iContactField.FieldProperty(), iIconInfoContainer, ControlId() ); |
|
144 |
|
145 |
|
146 // Place cursor to the end of the line |
|
147 iControl->AddFlagToUserFlags(CEikEdwin::EJustAutoCurEnd); |
|
148 |
|
149 // CreateTextViewL() is flagged as deprecated but if it is not |
|
150 // called here the ActivateL() below crashes sometimes. |
|
151 iControl->CreateTextViewL(); |
|
152 iCaptionedCtrl = iUiBuilder.LineControl(ControlId()); |
|
153 iCaptionedCtrl->SetTakesEnterKey(EFalse); |
|
154 } |
|
155 |
|
156 // End of File |