|
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: Phonebook2 contact editor date field. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2ContactEditorDateField.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "MPbk2ContactEditorUiBuilder.h" |
|
23 #include "MPbk2ContactEditorFieldVisitor.h" |
|
24 #include <MPbk2FieldProperty.h> |
|
25 #include <CPbk2PresentationContactField.h> |
|
26 #include <Pbk2UIControls.rsg> |
|
27 |
|
28 // Virtual Phonebook |
|
29 #include <MVPbkContactFieldDateTimeData.h> |
|
30 |
|
31 // System includes |
|
32 #include <eikcapc.h> |
|
33 #include <eikmfne.h> |
|
34 #include <AknUtils.h> |
|
35 #include <barsread.h> |
|
36 |
|
37 // -------------------------------------------------------------------------- |
|
38 // CPbk2ContactEditorDateField::CPbk2ContactEditorDateField |
|
39 // -------------------------------------------------------------------------- |
|
40 // |
|
41 CPbk2ContactEditorDateField::CPbk2ContactEditorDateField |
|
42 ( CPbk2PresentationContactField& aContactField, |
|
43 MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
44 CPbk2IconInfoContainer& aIconInfoContainer ) : |
|
45 CPbk2ContactEditorFieldBase( aContactField, aUiBuilder, |
|
46 aIconInfoContainer ) |
|
47 { |
|
48 } |
|
49 |
|
50 // -------------------------------------------------------------------------- |
|
51 // CPbk2ContactEditorDateField::~CPbk2ContactEditorDateField |
|
52 // -------------------------------------------------------------------------- |
|
53 // |
|
54 CPbk2ContactEditorDateField::~CPbk2ContactEditorDateField() |
|
55 { |
|
56 } |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CPbk2ContactEditorDateField::NewLC |
|
60 // -------------------------------------------------------------------------- |
|
61 // |
|
62 CPbk2ContactEditorDateField* CPbk2ContactEditorDateField::NewLC |
|
63 ( CPbk2PresentationContactField& aContactField, |
|
64 MPbk2ContactEditorUiBuilder& aUiBuilder, |
|
65 CPbk2IconInfoContainer& aIconInfoContainer ) |
|
66 { |
|
67 CPbk2ContactEditorDateField* self = |
|
68 new ( ELeave ) CPbk2ContactEditorDateField( aContactField, |
|
69 aUiBuilder, aIconInfoContainer ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // -------------------------------------------------------------------------- |
|
76 // CPbk2ContactEditorDateField::ConstructL |
|
77 // -------------------------------------------------------------------------- |
|
78 // |
|
79 void CPbk2ContactEditorDateField::ConstructL() |
|
80 { |
|
81 // Create and insert a line in the dialog |
|
82 iControl = static_cast<CEikDateEditor*>(iUiBuilder.CreateLineL( |
|
83 FieldLabel(), ControlId(), EEikCtDateEditor)); |
|
84 |
|
85 // Control is now owned by the dialog |
|
86 TResourceReader reader; |
|
87 CCoeEnv::Static()->CreateResourceReaderLC(reader, R_PBK2_EDITOR_DATE_SETTINGS); |
|
88 TTime minimumDate = iControl->ReadDate(reader); |
|
89 TTime maximumDate = iControl->ReadDate(reader); |
|
90 CleanupStack::PopAndDestroy(); // R_PBK_EDITOR_DATE_SETTINGS |
|
91 |
|
92 TTime time = MVPbkContactFieldDateTimeData::Cast( |
|
93 iContactField.FieldData()).DateTime(); |
|
94 |
|
95 if (time == Time::NullTTime()) |
|
96 { |
|
97 time.HomeTime(); |
|
98 } |
|
99 iControl->ConstructL( minimumDate, maximumDate, time, EFalse ); |
|
100 |
|
101 iUiBuilder.LoadBitmapToFieldL |
|
102 ( iContactField.FieldProperty(), iIconInfoContainer, ControlId() ); |
|
103 |
|
104 iCaptionedCtrl = iUiBuilder.LineControl(ControlId()); |
|
105 iUiBuilder.SetEditableL(ETrue); |
|
106 } |
|
107 |
|
108 // -------------------------------------------------------------------------- |
|
109 // CPbk2ContactEditorDateField::Control |
|
110 // -------------------------------------------------------------------------- |
|
111 // |
|
112 CEikEdwin* CPbk2ContactEditorDateField::Control() const |
|
113 { |
|
114 // Can not return CEikEdwin object from here, but |
|
115 // for this class - it does not matter |
|
116 return NULL; |
|
117 } |
|
118 |
|
119 // -------------------------------------------------------------------------- |
|
120 // CPbk2ContactEditorDateField::SaveFieldL |
|
121 // -------------------------------------------------------------------------- |
|
122 // |
|
123 void CPbk2ContactEditorDateField::SaveFieldL() |
|
124 { |
|
125 iContactDataHasChanged = EFalse; |
|
126 |
|
127 const TTime dateTime = iControl->Date(); |
|
128 MVPbkContactFieldDateTimeData& data = |
|
129 MVPbkContactFieldDateTimeData::Cast(iContactField.FieldData()); |
|
130 if (data.DateTime() != dateTime) |
|
131 { |
|
132 data.SetDateTime(dateTime); |
|
133 iContactDataHasChanged = ETrue; |
|
134 } |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CPbk2ContactEditorDateField::ActivateL |
|
139 // -------------------------------------------------------------------------- |
|
140 // |
|
141 void CPbk2ContactEditorDateField::ActivateL() |
|
142 { |
|
143 iCaptionedCtrl->ActivateL(); |
|
144 } |
|
145 |
|
146 // -------------------------------------------------------------------------- |
|
147 // CPbk2ContactEditorDateField::AcceptL |
|
148 // -------------------------------------------------------------------------- |
|
149 // |
|
150 void CPbk2ContactEditorDateField::AcceptL |
|
151 (MPbk2ContactEditorFieldVisitor& aVisitor) |
|
152 { |
|
153 aVisitor.VisitL(*this); |
|
154 } |
|
155 |
|
156 // End of File |