20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include "CxSPSortView.h" |
21 #include "CxSPSortView.h" |
22 #include "CxSPSortViewControl.h" |
22 #include "CxSPSortViewControl.h" |
23 |
23 |
24 // System includes |
24 // System includes |
|
25 #include <eiklbi.h> |
|
26 #include <eiklbx.h> |
|
27 #include <AknUtils.h> |
25 #include <AknGlobalNote.h> |
28 #include <AknGlobalNote.h> |
26 #include <aknnavi.h> |
29 #include <aknnavi.h> |
27 #include <aknnavide.h> |
30 #include <aknnavide.h> |
28 #include <StringLoader.h> |
31 #include <StringLoader.h> |
29 #include <eikbtgpc.h> |
32 #include <eikbtgpc.h> |
114 break; |
117 break; |
115 } |
118 } |
116 case EExtensionManagerCmdMove: // Move softkey |
119 case EExtensionManagerCmdMove: // Move softkey |
117 { |
120 { |
118 iContainer->SetCurrentItemMarkedL( ETrue ); |
121 iContainer->SetCurrentItemMarkedL( ETrue ); |
119 iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL ); |
122 UpdateCbasL( R_AVKON_SOFTKEYS_OK_CANCEL ); |
120 iView.Cba()->DrawDeferred(); |
|
121 break; |
123 break; |
122 } |
124 } |
123 case EAknSoftkeyOk: // Ok softkey |
125 case EAknSoftkeyOk: // Ok softkey |
124 { |
126 { |
125 iContainer->MoveMarkedItemL(); |
127 iContainer->MoveMarkedItemL(); |
126 iView.Cba()->SetCommandSetL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
128 UpdateCbasL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
127 iView.Cba()->DrawDeferred(); |
|
128 break; |
129 break; |
129 } |
130 } |
130 case EAknSoftkeyCancel: // Cancel softkey |
131 case EAknSoftkeyCancel: // Cancel softkey |
131 { |
132 { |
132 iContainer->SetCurrentItemMarkedL( EFalse ); |
133 iContainer->SetCurrentItemMarkedL( EFalse ); |
133 iView.Cba()->SetCommandSetL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
134 UpdateCbasL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
134 iView.Cba()->DrawDeferred(); |
135 |
135 break; |
136 break; |
136 } |
137 } |
137 default: |
138 default: |
138 { |
139 { |
139 Pbk2AppUi()->HandleCommandL( aCommand ); |
140 Pbk2AppUi()->HandleCommandL( aCommand ); |
161 NotifyViewActivationL( iView.Id() ); |
162 NotifyViewActivationL( iView.Id() ); |
162 } |
163 } |
163 |
164 |
164 if (!iContainer) |
165 if (!iContainer) |
165 { |
166 { |
166 iContainer = CxSPSortViewControl::NewL( iViewIdChanger, iExtensions ); |
167 iContainer = CxSPSortViewControl::NewL( iViewIdChanger, iExtensions, iView ); |
167 CCoeEnv::Static()->AppUi()->AddToStackL( iView, iContainer ); |
168 CCoeEnv::Static()->AppUi()->AddToStackL( iView, iContainer ); |
168 iContainer->SetMopParent( &iView ); |
169 iContainer->SetMopParent( &iView ); |
169 iContainer->SetRect( iView.ClientRect() ); |
170 iContainer->SetRect( iView.ClientRect() ); |
|
171 |
|
172 CCoeControl& ctrl=iContainer->ComponentControl(); |
|
173 CEikListBox& listbox=static_cast <CEikListBox&> (ctrl); |
|
174 listbox.SetListBoxObserver( this ); |
|
175 |
170 iContainer->ActivateL(); |
176 iContainer->ActivateL(); |
171 |
177 |
172 // Load the default cba for the sort view |
178 UpdateCbasL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
173 iView.Cba()->SetCommandSetL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
179 |
174 |
|
175 // Invoke DrawNow() to avoid the cba flicker |
180 // Invoke DrawNow() to avoid the cba flicker |
176 iView.Cba()->DrawNow(); |
181 iView.Cba()->DrawNow(); |
177 } |
182 } |
178 |
183 |
179 // Commit application-wide state changes |
184 // Commit application-wide state changes |
191 iNaviDecorator = np->CreateNavigationLabelL(); |
196 iNaviDecorator = np->CreateNavigationLabelL(); |
192 np->PushL( *iNaviDecorator ); |
197 np->PushL( *iNaviDecorator ); |
193 sp->DrawNow(); |
198 sp->DrawNow(); |
194 } |
199 } |
195 |
200 |
|
201 void CxSPSortView::UpdateCbasL( TInt aResourceId ) |
|
202 { |
|
203 CCoeControl& ctrl=iContainer->ComponentControl(); |
|
204 CEikListBox& listbox=static_cast <CEikListBox&> (ctrl); |
|
205 |
|
206 TBool noItemHightLighted = listbox.View()->ItemDrawer()->Flags() & CListItemDrawer::ESingleClickDisabledHighlight; |
|
207 |
|
208 if ( aResourceId == R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ) |
|
209 { |
|
210 if ( noItemHightLighted ) |
|
211 { |
|
212 // Load the default cba for the sort view |
|
213 iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_BACK ); |
|
214 } |
|
215 else |
|
216 { |
|
217 // Load the default cba for the sort view |
|
218 iView.Cba()->SetCommandSetL( R_EXTENSION_MANAGER_SORT_VIEW_SOFTKEYS ); |
|
219 } |
|
220 iView.Cba()->DrawDeferred(); |
|
221 } |
|
222 else if ( aResourceId == R_AVKON_SOFTKEYS_OK_CANCEL ) |
|
223 { |
|
224 if ( noItemHightLighted ) |
|
225 { |
|
226 // Load the default cba for the sort view |
|
227 iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_CANCEL ); |
|
228 } |
|
229 else |
|
230 { |
|
231 // Load the default cba for the sort view |
|
232 iView.Cba()->SetCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL ); |
|
233 } |
|
234 iView.Cba()->DrawDeferred(); |
|
235 } |
|
236 |
|
237 } |
|
238 |
196 void CxSPSortView::DoDeactivate() |
239 void CxSPSortView::DoDeactivate() |
197 { |
240 { |
198 if (iContainer) |
241 if (iContainer) |
199 { |
242 { |
200 CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer ); |
243 CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer ); |
221 { |
264 { |
222 iContainer->SetRect( iView.ClientRect() ); |
265 iContainer->SetRect( iView.ClientRect() ); |
223 } |
266 } |
224 } |
267 } |
225 |
268 |
|
269 void CxSPSortView::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
|
270 { |
|
271 if( AknLayoutUtils::PenEnabled() ) |
|
272 { |
|
273 switch ( aEventType ) |
|
274 { |
|
275 case EEventItemSingleClicked: |
|
276 { |
|
277 CCoeControl& ctrl=iContainer->ComponentControl(); |
|
278 CEikListBox& listbox=static_cast <CEikListBox&> (ctrl); |
|
279 const CListBoxView::CSelectionIndexArray* inds = listbox.SelectionIndexes(); |
|
280 TInt count = inds->Count(); |
|
281 |
|
282 if ( count <= 0 ) |
|
283 { |
|
284 HandleCommandL( EExtensionManagerCmdMove ); |
|
285 } |
|
286 else |
|
287 { |
|
288 HandleCommandL( EAknSoftkeyOk ); |
|
289 } |
|
290 break; |
|
291 } |
|
292 default: |
|
293 break; |
|
294 } |
|
295 } |
|
296 } |
|
297 |
226 void CxSPSortView::GlobalNoteClosed( const TInt aResult ) |
298 void CxSPSortView::GlobalNoteClosed( const TInt aResult ) |
227 { |
299 { |
228 PBK2_DEBUG_PRINT( |
300 PBK2_DEBUG_PRINT( |
229 PBK2_DEBUG_STRING("CxSPSortView::GlobalNoteClosed [%i]"), aResult ); |
301 PBK2_DEBUG_STRING("CxSPSortView::GlobalNoteClosed [%i]"), aResult ); |
230 |
302 |