|
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 Contact editor field factory class. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "PbkContactEditorFieldFactory.h" // this class |
|
22 #include "TPbkContactItemField.h" |
|
23 #include "CPbkFieldInfo.h" |
|
24 #include "CPbkContactEditorPhoneNumberField.h" |
|
25 #include "CPbkContactEditorTextField.h" |
|
26 #include "CPbkContactEditorNumberField.h" |
|
27 #include "CPbkContactEditorDateField.h" |
|
28 #include "CPbkContactEditorUrlField.h" |
|
29 #include "CPbkContactEditorEmailAddressField.h" |
|
30 #include "CPbkContactEditorReadingField.h" |
|
31 #include "CPbkContactEditorPostalCodeField.h" |
|
32 #include "CPbkContactEditorSyncField.h" |
|
33 |
|
34 /// Unnamed namespace for local definitons |
|
35 namespace { |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 |
|
39 #ifdef _DEBUG |
|
40 /// Panic codes for PbkContactEditorFieldFactory |
|
41 enum TPanicCode |
|
42 { |
|
43 EPanicUnknownControlType_CreateFieldL |
|
44 }; |
|
45 #endif // _DEBUG |
|
46 |
|
47 |
|
48 // ==================== LOCAL FUNCTIONS ==================== |
|
49 |
|
50 #ifdef _DEBUG |
|
51 void Panic(TPanicCode aReason) |
|
52 { |
|
53 _LIT(KPanicText, "PbkContactEditorFieldFactory"); |
|
54 User::Panic(KPanicText, aReason); |
|
55 } |
|
56 #endif // _DEBUG |
|
57 |
|
58 } // namespace |
|
59 |
|
60 |
|
61 // ================= MEMBER FUNCTIONS ======================= |
|
62 |
|
63 MPbkContactEditorField* PbkContactEditorFieldFactory::CreateFieldL |
|
64 (TPbkContactItemField& aField, |
|
65 MPbkContactEditorUiBuilder& aUiBuilder, |
|
66 CPbkIconInfoContainer& aIconInfoContainer) |
|
67 { |
|
68 MPbkContactEditorField* editorField = NULL; |
|
69 switch(aField.FieldInfo().CtrlType()) |
|
70 { |
|
71 case EPbkFieldCtrlTypeTextEditor: |
|
72 { |
|
73 if (aField.FieldInfo().IsPhoneNumberField() |
|
74 || aField.FieldInfo().FieldId() == EPbkFieldIdDTMFString) |
|
75 { |
|
76 editorField = CPbkContactEditorPhoneNumberField::NewL( |
|
77 aField, aUiBuilder, |
|
78 aIconInfoContainer); |
|
79 } |
|
80 else if (aField.FieldInfo().FieldId() == EPbkFieldIdURL) |
|
81 { |
|
82 editorField = CPbkContactEditorUrlField::NewL( |
|
83 aField, aUiBuilder, aIconInfoContainer); |
|
84 } |
|
85 else if (aField.FieldInfo().FieldId() == EPbkFieldIdEmailAddress) |
|
86 { |
|
87 editorField = CPbkContactEditorEmailAddressField::NewL( |
|
88 aField, aUiBuilder, aIconInfoContainer); |
|
89 } |
|
90 else if (aField.FieldInfo().FieldId() == EPbkFieldIdPostalCode) |
|
91 { |
|
92 editorField = CPbkContactEditorPostalCodeField::NewL( |
|
93 aField, aUiBuilder, aIconInfoContainer); |
|
94 } |
|
95 else if (aField.FieldInfo().IsReadingField()) |
|
96 { |
|
97 editorField = CPbkContactEditorReadingField::NewL( |
|
98 aField, aUiBuilder, aIconInfoContainer); |
|
99 } |
|
100 else |
|
101 { |
|
102 editorField = CPbkContactEditorTextField::NewL( |
|
103 aField, aUiBuilder, aIconInfoContainer); |
|
104 } |
|
105 break; |
|
106 } |
|
107 |
|
108 case EPbkFieldCtrlTypeNumberEditor: |
|
109 { |
|
110 editorField = CPbkContactEditorNumberField::NewL( |
|
111 aField, aUiBuilder, aIconInfoContainer); |
|
112 break; |
|
113 } |
|
114 |
|
115 case EPbkFieldCtrlTypeDateEditor: |
|
116 { |
|
117 editorField = CPbkContactEditorDateField::NewL( |
|
118 aField, aUiBuilder, aIconInfoContainer); |
|
119 break; |
|
120 } |
|
121 |
|
122 case EPbkFieldCtrlTypeChoiseItems: |
|
123 { |
|
124 editorField = CPbkContactEditorSyncField::NewL( |
|
125 aField, aUiBuilder, aIconInfoContainer); |
|
126 break; |
|
127 } |
|
128 |
|
129 default: |
|
130 { |
|
131 __ASSERT_DEBUG(EFalse, |
|
132 Panic(EPanicUnknownControlType_CreateFieldL)); |
|
133 break; |
|
134 } |
|
135 } |
|
136 return editorField; |
|
137 } |
|
138 |
|
139 |
|
140 // End of File |