|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Interface to Alf Objects |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef _GLXMULMODELPROVIDERBASE_H_ |
|
22 #define _GLXMULMODELPROVIDERBASE_H_ |
|
23 |
|
24 #include<e32base.h> // Container Base Class |
|
25 #include <alf/ialfwidgeteventhandler.h> // The interface for event handlers used by widget controls |
|
26 #include <mglxmedialistobserver.h> // Observes for changes in media list |
|
27 #include <mul/imulmodel.h> // An interface for the data model |
|
28 #include <mul/imulmodelprovider.h> // An interface for requesting the data provider for data |
|
29 #include <mul/imulwidget.h> |
|
30 //constants |
|
31 static const TInt LAST_INDEX = -1; |
|
32 |
|
33 class CAlfEnv; // This is the UI Accelerator Toolkit environment object |
|
34 class CGlxBinding; // The binding is created by the binding set factory |
|
35 class MGlxBoundCommand; // Handles user commands |
|
36 class TGlxMedia; // Reference to a media item in the item pool |
|
37 class CGlxNavigationalState; // Class that stores the navigational state of the application |
|
38 |
|
39 namespace Alf |
|
40 { |
|
41 class IMulModel; // An interface for the data model |
|
42 class IMulWidget; // An interface for all Multimedia widgets |
|
43 class MulVisualItem; // Client need to use this class to add data in data model |
|
44 } |
|
45 |
|
46 NONSHARABLE_CLASS( CGlxMulModelProviderBase ) : public CBase, public Alf::IAlfWidgetEventHandler, |
|
47 public MGlxMediaListObserver, public Alf::IMulModelProvider |
|
48 { |
|
49 protected: |
|
50 |
|
51 /** |
|
52 * Constructor |
|
53 * @param aWidget The widget to which the model is to be set |
|
54 */ |
|
55 CGlxMulModelProviderBase( Alf::IMulWidget& aWidget ); |
|
56 |
|
57 /** |
|
58 * BaseConstructL |
|
59 * @param aEnv Alf environment |
|
60 * @param aDefaultTemplate The default template of the widget |
|
61 */ |
|
62 void BaseConstructL( CAlfEnv& aEnv, Alf::mulwidget::TLogicalTemplate aDefaultTemplate, TInt aDataWindowSize ); |
|
63 |
|
64 /** |
|
65 * Destructor |
|
66 */ |
|
67 ~CGlxMulModelProviderBase(); |
|
68 /** |
|
69 * CreateModelL |
|
70 */ |
|
71 void CreateModelL(); |
|
72 /** |
|
73 * InsertItemsL |
|
74 * @param aIndex Start index |
|
75 * @param aCount Number of items to insert |
|
76 * @param aMediaListFocusIndex Focus Index to set in Model |
|
77 */ |
|
78 void InsertItemsL( TInt aIndex, TInt aCount, TInt aMediaListFocusIndex = NULL ); |
|
79 |
|
80 /** |
|
81 * RemoveItem |
|
82 * @param aAtIndex media list index |
|
83 */ |
|
84 void RemoveItems( TInt aIndex, TInt aCount ); |
|
85 |
|
86 /** |
|
87 * UpdateItemL |
|
88 * @param aBinding Binding used to update the item |
|
89 * @param aMedia media item which has the updated data |
|
90 * @param aAtIndex media list index |
|
91 */ |
|
92 void SetDataT( const CGlxBinding& aBinding, const TGlxMedia& aMedia, |
|
93 TInt aAtIndex ); |
|
94 |
|
95 /// @todo docs |
|
96 void UpdateItems( TInt aIndex, TInt aCount ); |
|
97 |
|
98 /** |
|
99 * FocusIndex |
|
100 */ |
|
101 TInt FocusIndex() const; |
|
102 |
|
103 /** |
|
104 * BoundCommand |
|
105 *@param aVisualItemIndex index of visual item |
|
106 *@return MGlxBoundCommand for that visual item |
|
107 */ |
|
108 MGlxBoundCommand* BoundCommand( TInt aVisualItemIndex ) const; |
|
109 |
|
110 // @todo docs |
|
111 void SetFocusIndex( TInt aIndex ); |
|
112 |
|
113 void AddWidgetEventHandler(); |
|
114 /** |
|
115 * HandleOrientationChanged |
|
116 * Icon Size change notification to be implemented dependent on Orientation |
|
117 */ |
|
118 virtual void HandleOrientationChanged(); |
|
119 |
|
120 private: |
|
121 |
|
122 /** |
|
123 * CreateItemT |
|
124 * @param aBinding Binding used to update the item |
|
125 * @param aMedia media item which has the updated data |
|
126 * @param aIsFocused |
|
127 */ |
|
128 std::auto_ptr<Alf::MulVisualItem> CGlxMulModelProviderBase::CreateItemT( const CGlxBinding& aBinding, |
|
129 const TGlxMedia& aMedia, TBool aIsFocused ); |
|
130 /** |
|
131 * IsFocused |
|
132 * @param aIndex Media list index |
|
133 */ |
|
134 TBool IsFocused( TInt aIndex ) const; |
|
135 |
|
136 // From MGlxMediaListObserver |
|
137 void HandleItemAddedL( TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList ); |
|
138 void HandleItemRemovedL( TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList ); |
|
139 void HandleAttributesAvailableL( TInt aItemIndex, |
|
140 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList ); |
|
141 void HandleFocusChangedL( NGlxListDefs::TFocusChangeType aType, |
|
142 TInt aNewIndex, TInt aOldIndex, MGlxMediaList* aList ); |
|
143 void HandleItemSelectedL(TInt aIndex, TBool aSelected, MGlxMediaList* aList ); |
|
144 void HandleMessageL( const CMPXMessage& aMessage, MGlxMediaList* aList ); |
|
145 void HandleError( TInt aError ); |
|
146 void HandleCommandCompleteL( TAny* /*aSessionId*/, CMPXCommand* aCommandResult, TInt aError, |
|
147 MGlxMediaList* aList ); |
|
148 void HandleMediaL( TInt aListIndex, MGlxMediaList* aList ); |
|
149 void HandleItemModifiedL( const RArray<TInt>& aItemIndexes, MGlxMediaList* aList ); |
|
150 |
|
151 // From IAlfWidgetEventHandler |
|
152 bool accept( Alf::CAlfWidgetControl& aControl, const TAlfEvent& aEvent ) const; |
|
153 Alf::AlfEventStatus offerEvent( Alf::CAlfWidgetControl& aControl, const TAlfEvent& aEvent ); |
|
154 void setActiveStates( unsigned int /*aStates*/ ); |
|
155 void setEventHandlerData( const Alf::AlfWidgetEventHandlerInitData& /*aData*/ ); |
|
156 Alf::AlfWidgetEventHandlerInitData* eventHandlerData(); |
|
157 Alf::IAlfInterfaceBase* makeInterface(const Alf::IfId& /*aType */); |
|
158 AlfEventHandlerType eventHandlerType() ; |
|
159 AlfEventHandlerExecutionPhase eventExecutionPhase() ; |
|
160 |
|
161 /** |
|
162 * HandleFocusChanged |
|
163 * Focus change notification to implemented class |
|
164 */ |
|
165 virtual void HandleFocusChanged( TInt aNewFocusIndex, TInt aPreviousFocusIndex ); |
|
166 |
|
167 /** |
|
168 * Item |
|
169 *@param aIndex index of visual item |
|
170 *@return MulVisualItem the visual item at that index |
|
171 */ |
|
172 const Alf::MulVisualItem& Item( TInt aIndex ) const; |
|
173 |
|
174 private: |
|
175 //The widget to which the model will be set |
|
176 /// Never expose this widget to any other class so that the osn-symbian interface |
|
177 /// is minimised to here. (i.e., try/catch vs. trap/leave) |
|
178 Alf::IMulWidget& iWidget; |
|
179 |
|
180 //Owned: Model |
|
181 /// Never expose this model to any other class so that the osn-symbian interface |
|
182 /// is minimised to here. (i.e., try/catch vs. trap/leave) |
|
183 Alf::IMulModel* iModel; |
|
184 |
|
185 TBool iWithinFocusChangeCall; |
|
186 |
|
187 //previous focus index |
|
188 TInt iPreviousFocusIndex; |
|
189 |
|
190 CAlfEnv* iEnv; |
|
191 |
|
192 Alf::mulwidget::TLogicalTemplate iDefaultTemplate; |
|
193 |
|
194 TInt iDataWindowSize; |
|
195 |
|
196 // Create navigational state |
|
197 CGlxNavigationalState* iNavigationalState; |
|
198 }; |
|
199 |
|
200 #endif // _GLXMULMODELPROVIDERBASE_H_ |