|
1 /* |
|
2 * Copyright (c) 2007-2008 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "hnmduimappingelement.h" |
|
20 #include "hnmdkeyfactory.h" |
|
21 #include "hnmdbasekey.h" |
|
22 #include "hnconvutils.h" |
|
23 #include "menudebug.h" |
|
24 #include "hnitemmodel.h" |
|
25 #include "bautils.h" |
|
26 #include "hnglobals.h" |
|
27 #include "hnmdvaluebase.h" |
|
28 #include "hnmdmodel.h" |
|
29 #include "hninterface.h" |
|
30 #include "hnconditioninterface.h" |
|
31 #include "hnattributebase.h" |
|
32 #include "hnattributeimage.h" |
|
33 #include "hnconditionfactory.h" |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 void CHnMdUiMappingElement::ConstructL( const TXmlEngElement& aElement, |
|
42 THnMdCommonPointers* aCmnPtrs ) |
|
43 { |
|
44 ASSERT( !aElement.Name().Compare( KOutputElementItem8 ) ); |
|
45 |
|
46 // set alias |
|
47 SetAliasL( aElement.AttributeNodeL( KAliasAttrName8 ) ); |
|
48 |
|
49 // set condition |
|
50 if( aElement.AttributeValueL( KMenuConditionAttrName8 ).Length() ) |
|
51 { |
|
52 iCondition = HnConditionFactory::NewL( |
|
53 aElement.AttributeNodeL( KMenuConditionAttrName8 ) ); |
|
54 } |
|
55 |
|
56 // common pointers |
|
57 iCmnPtrs = aCmnPtrs; |
|
58 |
|
59 if ( aElement.IsSimpleTextContents() == EFalse && |
|
60 aElement.HasChildNodes() ) |
|
61 { |
|
62 // get child element from output and pass to set value |
|
63 RXmlEngNodeList< TXmlEngElement > childElements; |
|
64 CleanupClosePushL( childElements ); |
|
65 aElement.GetChildElements( childElements ); |
|
66 TXmlEngElement childElement = childElements.Next(); |
|
67 // it could be text/image node |
|
68 SetValueL( childElement, aCmnPtrs ); |
|
69 CleanupStack::PopAndDestroy( &childElements ); |
|
70 } |
|
71 else |
|
72 { |
|
73 // handle output node |
|
74 SetValueL( aElement, aCmnPtrs ); |
|
75 } |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 const TDesC8& CHnMdUiMappingElement::Alias() const |
|
83 { |
|
84 return iAlias; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CHnMdUiMappingElement::SetAliasL( const TXmlEngAttr& aName ) |
|
92 { |
|
93 iAlias.Close(); |
|
94 iAlias.CreateL( aName.Value() ); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 void CHnMdUiMappingElement::SetValueL( const TXmlEngElement& aValue, |
|
102 THnMdCommonPointers* aCmnPtrs ) |
|
103 { |
|
104 delete iValue; |
|
105 iValue = NULL; |
|
106 iValue = CHnMdValueBase::CreateL( aValue, aCmnPtrs ); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 CHnMdUiMappingElement* CHnMdUiMappingElement::NewL( TXmlEngElement aElement, |
|
114 THnMdCommonPointers* aCmnPtrs ) |
|
115 { |
|
116 CHnMdUiMappingElement* self = CHnMdUiMappingElement::NewLC( aElement, |
|
117 aCmnPtrs ); |
|
118 CleanupStack::Pop( self ); |
|
119 return self; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CHnMdUiMappingElement* CHnMdUiMappingElement::NewLC( TXmlEngElement aElement, |
|
127 THnMdCommonPointers* aCmnPtrs ) |
|
128 { |
|
129 CHnMdUiMappingElement* self = new( ELeave ) CHnMdUiMappingElement; |
|
130 CleanupStack::PushL( self ); |
|
131 self->ConstructL( aElement, aCmnPtrs ); |
|
132 return self; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 CHnMdUiMappingElement::CHnMdUiMappingElement() |
|
140 { |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 CHnMdUiMappingElement::~CHnMdUiMappingElement() |
|
148 { |
|
149 iAlias.Close(); |
|
150 delete iValue; |
|
151 delete iCondition; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 TBool CHnMdUiMappingElement::FillGraphicalItemL( CHnItemModel* aItemModel , |
|
159 const CLiwGenericParamList& aQueriesResultsList, TInt aPos ) |
|
160 { |
|
161 TBool ret = EFalse; |
|
162 CHnAttributeBase* attr = iValue->CreateAttributeL( |
|
163 &aQueriesResultsList, aPos ); |
|
164 |
|
165 if( attr ) |
|
166 { |
|
167 CleanupStack::PushL( attr ); |
|
168 attr->SetNameL( iAlias ); |
|
169 aItemModel->SetAttributeL( attr ); |
|
170 CleanupStack::Pop( attr ); |
|
171 ret = ETrue; |
|
172 } |
|
173 |
|
174 return ret; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 TBool CHnMdUiMappingElement::IsValidL( |
|
182 const CLiwGenericParamList& aQueryResults, TInt aPos ) |
|
183 { |
|
184 TBool ret( EFalse ); |
|
185 |
|
186 if( !iCondition || iCondition->ResultL( aQueryResults, aPos ) ) |
|
187 { |
|
188 ret = ETrue; |
|
189 } |
|
190 |
|
191 return ret; |
|
192 } |
|
193 |