25 #include "hnmdevent.h" |
25 #include "hnmdevent.h" |
26 #include "hnmenuitemmodel.h" |
26 #include "hnmenuitemmodel.h" |
27 #include "hnconditionfactory.h" |
27 #include "hnconditionfactory.h" |
28 |
28 |
29 // ======== MEMBER FUNCTIONS ======== |
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 TBool CHnMdMenuItem::IsMenuItemElementName( const TDesC8& aNameToCompare ) |
|
36 { |
|
37 return !aNameToCompare.Compare( KMenuItemElementName8 ) |
|
38 || !aNameToCompare.Compare( KMenuItemSpecificElementName8 ) |
|
39 || !aNameToCompare.Compare( KMenuItemActionElementName8 ); |
|
40 } |
30 |
41 |
31 // --------------------------------------------------------------------------- |
42 // --------------------------------------------------------------------------- |
32 // |
43 // |
33 // --------------------------------------------------------------------------- |
44 // --------------------------------------------------------------------------- |
34 // |
45 // |
54 aMenuModel->AppendChildMenuL( menu ); |
65 aMenuModel->AppendChildMenuL( menu ); |
55 } |
66 } |
56 } |
67 } |
57 aMenuModel->SetCommand( iEvent ); |
68 aMenuModel->SetCommand( iEvent ); |
58 aMenuModel->SetPosition( iPosition ); |
69 aMenuModel->SetPosition( iPosition ); |
59 aMenuModel->SetItemSpecific( iSpecific ); |
70 aMenuModel->SetMenuItemType( iType ); |
60 } |
71 } |
61 |
72 |
62 // --------------------------------------------------------------------------- |
73 // --------------------------------------------------------------------------- |
63 // ConstructL takes as an argument an item xml element. It iterates through |
74 // ConstructL takes as an argument an item xml element. It iterates through |
64 // item elements in order to find menuitems. |
75 // item elements in order to find menuitems. |
65 // --------------------------------------------------------------------------- |
76 // --------------------------------------------------------------------------- |
66 // |
77 // |
67 void CHnMdMenuItem::CreatePropertiesL( TXmlEngElement aElement, |
78 void CHnMdMenuItem::CreatePropertiesL( TXmlEngElement aElement, |
68 THnMdCommonPointers* /* aCmnPtrs */ ) |
79 THnMdCommonPointers* /* aCmnPtrs */ ) |
69 { |
80 { |
70 iSpecific = !aElement.Name().Compare( KMenuItemSpecificElementName8 ); |
81 iType = CHnMenuItemModel::EItemApplication; |
|
82 if ( !aElement.Name().Compare( KMenuItemSpecificElementName8 ) ) |
|
83 { |
|
84 iType = CHnMenuItemModel::EItemSpecific; |
|
85 } |
|
86 else if ( !aElement.Name().Compare( KMenuItemActionElementName8 ) ) |
|
87 { |
|
88 iType = CHnMenuItemModel::EItemAction; |
|
89 } |
71 |
90 |
72 // name |
91 // name |
73 HBufC* name = HnConvUtils::Str8ToStrLC( |
92 HBufC* name = HnConvUtils::Str8ToStrLC( |
74 aElement.AttributeValueL( KName8 ) ); |
93 aElement.AttributeValueL( KName8 ) ); |
75 iName.Assign(name); |
94 iName.Assign(name); |
110 TInt count = children.Count(); |
129 TInt count = children.Count(); |
111 |
130 |
112 for ( TInt i = 0; i < count; i++ ) |
131 for ( TInt i = 0; i < count; i++ ) |
113 { |
132 { |
114 TXmlEngElement child = children.Next(); |
133 TXmlEngElement child = children.Next(); |
115 if ( !child.Name().Compare( KMenuItemElementName8 ) |
134 if ( IsMenuItemElementName( child.Name() ) ) |
116 || !child.Name().Compare( KMenuItemSpecificElementName8 ) ) |
|
117 { |
135 { |
118 AppendChildItemL( CHnMdMenuItem::NewL( child, aCmnPtrs ) ); |
136 AppendChildItemL( CHnMdMenuItem::NewL( child, aCmnPtrs ) ); |
119 } |
137 } |
120 } |
138 } |
121 CleanupStack::PopAndDestroy( &children ); |
139 CleanupStack::PopAndDestroy( &children ); |
127 // --------------------------------------------------------------------------- |
145 // --------------------------------------------------------------------------- |
128 // |
146 // |
129 void CHnMdMenuItem::ConstructL( TXmlEngElement aElement, |
147 void CHnMdMenuItem::ConstructL( TXmlEngElement aElement, |
130 THnMdCommonPointers* aCmnPtrs ) |
148 THnMdCommonPointers* aCmnPtrs ) |
131 { |
149 { |
132 if ( !aElement.Name().Compare( KMenuItemElementName8 ) |
150 if ( IsMenuItemElementName( aElement.Name() ) ) |
133 || !aElement.Name().Compare( KMenuItemSpecificElementName8 ) ) |
|
134 { // this is an ordinary menu item |
151 { // this is an ordinary menu item |
135 CreatePropertiesL( aElement, aCmnPtrs ); |
152 CreatePropertiesL( aElement, aCmnPtrs ); |
136 CreateChildrenL( aElement, aCmnPtrs ); // in case there are subitems |
153 CreateChildrenL( aElement, aCmnPtrs ); // in case there are subitems |
137 } |
154 } |
138 else |
155 else |