|
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 <xmlengelement.h> |
|
20 #include <xmlengnodelist.h> |
|
21 |
|
22 #include "hnmdtoolbar.h" |
|
23 #include "hnmdbutton.h" |
|
24 #include "hnconvutils.h" |
|
25 #include "hnglobals.h" |
|
26 #include "hntoolbarmodel.h" |
|
27 #include "hnbuttonmodel.h" |
|
28 #include "hnattributebase.h" |
|
29 |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CHnMdToolbar* CHnMdToolbar::NewLC( TXmlEngElement aElement, |
|
38 THnMdCommonPointers* aCmnPtrs ) |
|
39 { |
|
40 CHnMdToolbar* self = new( ELeave ) CHnMdToolbar; |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL( aElement, aCmnPtrs ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CHnMdToolbar* CHnMdToolbar::NewL( TXmlEngElement aElement, |
|
51 THnMdCommonPointers* aCmnPtrs ) |
|
52 { |
|
53 CHnMdToolbar* self = CHnMdToolbar::NewLC( aElement, aCmnPtrs ); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CHnMdToolbar::EvaluateL( CHnToolbarModel* aToolbar, |
|
63 const CLiwGenericParamList& aQueryResults, |
|
64 TInt aPos ) |
|
65 { |
|
66 TInt buttonCount = iButtons.Count(); |
|
67 for( TInt i( 0 ); i < buttonCount; i++ ) |
|
68 { |
|
69 if( iButtons[ i ]->ValidateToAddL( aQueryResults, aPos ) && |
|
70 aToolbar->GetButton( iButtons[ i ]->GetIndex() ) == NULL ) |
|
71 { |
|
72 CHnButtonModel* button = CHnButtonModel::NewLC( |
|
73 iButtons[ i ]->GetIndex() ); |
|
74 |
|
75 const TDesC& helpText = iButtons[ i ]->EvaluateButtonTextL( aQueryResults, aPos ); |
|
76 button->SetHelpTextL( helpText ); |
|
77 |
|
78 button->SetEventId( iButtons[ i ]->GetEventId() ); |
|
79 button->SetDimmed( |
|
80 iButtons[ i ]->ValidateToDimmL( aQueryResults, aPos ) ); |
|
81 |
|
82 CHnAttributeBase* attributeImage = iButtons[ i ]->EvaluateIconL( aQueryResults, aPos ); |
|
83 button->SetIcon( attributeImage ); |
|
84 |
|
85 aToolbar->AddButtonL( button ); |
|
86 CleanupStack::Pop( button ); |
|
87 } |
|
88 } |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CHnMdToolbar::~CHnMdToolbar( ) |
|
96 { |
|
97 iButtons.ResetAndDestroy(); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CHnMdToolbar::CHnMdToolbar() |
|
105 { |
|
106 |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CHnMdToolbar::ConstructL( TXmlEngElement aElement, |
|
114 THnMdCommonPointers* aCmnPtrs ) |
|
115 { |
|
116 TXmlEngElement toolbarElement; |
|
117 if ( aElement.Name().Compare( KMenuToolbar8 ) != 0 ) |
|
118 { |
|
119 RXmlEngNodeList< TXmlEngElement > children; |
|
120 CleanupClosePushL( children ); |
|
121 aElement.GetChildElements( children ); |
|
122 TInt count = children.Count(); |
|
123 |
|
124 for ( TInt i = 0; i < count; i++ ) |
|
125 { |
|
126 TXmlEngElement child = children.Next(); |
|
127 if ( !child.Name().Compare( KMenuToolbar8 ) ) |
|
128 { |
|
129 CreateButtonsL( child, aCmnPtrs ); |
|
130 } |
|
131 } |
|
132 CleanupStack::PopAndDestroy( &children ); |
|
133 } |
|
134 |
|
135 |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CHnMdToolbar::CreateButtonsL( TXmlEngElement aElement, |
|
143 THnMdCommonPointers* aCmnPtrs ) |
|
144 { |
|
145 RXmlEngNodeList< TXmlEngElement > children; |
|
146 CleanupClosePushL( children ); |
|
147 aElement.GetChildElements( children ); |
|
148 TInt count = children.Count(); |
|
149 |
|
150 for ( TInt i = 0; i < count; i++ ) |
|
151 { |
|
152 TXmlEngElement child = children.Next(); |
|
153 if ( !child.Name().Compare( KMenuButton8 ) ) |
|
154 { |
|
155 CHnMdButton* button = CHnMdButton::NewLC( child, aCmnPtrs ); |
|
156 iButtons.AppendL( button ); |
|
157 CleanupStack::Pop( button ); |
|
158 } |
|
159 } |
|
160 CleanupStack::PopAndDestroy( &children ); |
|
161 } |
|
162 |