204 * mediaListAdaptor = |
204 * mediaListAdaptor = |
205 static_cast<CGlxMediaListAdaptor*> (listBox->Model()->ItemTextArray()); |
205 static_cast<CGlxMediaListAdaptor*> (listBox->Model()->ItemTextArray()); |
206 |
206 |
207 TBool staticItemSelected = EFalse; |
207 TBool staticItemSelected = EFalse; |
208 TInt currItemIndx = listBox->View()->CurrentItemIndex(); |
208 TInt currItemIndx = listBox->View()->CurrentItemIndex(); |
|
209 GLX_LOG_INFO1("Glx Pop-up listbox - HandleListBoxEventL() currItemIndx=%d", |
|
210 currItemIndx); |
209 |
211 |
210 switch (aEventType) |
212 switch (aEventType) |
211 { |
213 { |
212 case EEventItemClicked: |
214 case EEventItemClicked: |
213 case EEventItemSingleClicked: |
215 case EEventItemSingleClicked: |
214 { |
216 { |
215 |
217 if (mediaListAdaptor->MultiSelectionEnabled() && currItemIndx |
216 if (mediaListAdaptor->MultiSelectionEnabled() && currItemIndx >= 0) |
218 >= 0) |
217 { |
219 { |
218 const TGlxMedia& item = mediaListAdaptor->MediaList()->Item( |
220 const TGlxMedia& item = mediaListAdaptor->MediaList()->Item( |
219 currItemIndx); |
221 currItemIndx); |
220 |
222 |
221 //Check if media item is user-defined or static |
223 //Check if media item is user-defined or static |
222 staticItemSelected = item.IsStatic(); |
224 staticItemSelected = item.IsStatic(); |
223 mediaListAdaptor->SetStaticItemSelected(staticItemSelected); |
225 mediaListAdaptor->SetStaticItemSelected(staticItemSelected); |
224 if (!staticItemSelected) |
226 if (!staticItemSelected) |
225 { |
227 { |
226 //Mark or UnMark the user-defined item |
228 //Mark or UnMark the user-defined item |
227 TBool isMarked = listBox->View()->ItemIsSelected(currItemIndx); |
229 TBool isMarked = listBox->View()->ItemIsSelected( |
|
230 currItemIndx); |
228 (isMarked == (TBool) ETrue) ? (listBox->View()->DeselectItem( |
231 (isMarked == (TBool) ETrue) ? (listBox->View()->DeselectItem( |
229 currItemIndx)) |
232 currItemIndx)) |
230 : (listBox->View()->SelectItemL(currItemIndx)); |
233 : (listBox->View()->SelectItemL(currItemIndx)); |
231 } |
234 } |
232 |
235 |
233 //Show Command Set based on selected items |
236 //Show Command Set based on selected items |
234 TInt selectCount = listBox->View()->SelectionIndexes()->Count(); |
237 TInt selectCount = |
235 CEikButtonGroupContainer* cbaContainer = ButtonGroupContainer(); |
238 listBox->View()->SelectionIndexes()->Count(); |
|
239 CEikButtonGroupContainer* cbaContainer = |
|
240 ButtonGroupContainer(); |
236 //Show 'OK' only if a static item or more than |
241 //Show 'OK' only if a static item or more than |
237 //1 user-defined item is selected |
242 //1 user-defined item is selected |
238 if(staticItemSelected || selectCount) |
243 if (staticItemSelected || selectCount) |
239 { |
244 { |
240 cbaContainer->SetCommandSetL(R_GLX_SOFTKEYS_OK_CANCEL); |
245 cbaContainer->SetCommandSetL(R_GLX_SOFTKEYS_OK_CANCEL); |
241 } |
246 } |
242 else |
247 else |
243 { |
248 { |
251 //Forward for default processing, if static item is selected(i.e. For Tags) |
256 //Forward for default processing, if static item is selected(i.e. For Tags) |
252 //or if List Box's Multiple selection is Disabled(i.e. For Albums) |
257 //or if List Box's Multiple selection is Disabled(i.e. For Albums) |
253 if (staticItemSelected |
258 if (staticItemSelected |
254 || (!mediaListAdaptor->MultiSelectionEnabled())) |
259 || (!mediaListAdaptor->MultiSelectionEnabled())) |
255 { |
260 { |
256 CAknPopupList::HandleListBoxEventL( aListBox, aEventType); |
261 CAknPopupList::HandleListBoxEventL(aListBox, aEventType); |
257 } |
262 } |
258 |
263 |
259 //After Scrolling, then Select "New Tag" i.e Static item is selected |
264 //After Scrolling, then Select "New Tag" i.e Static item is selected |
260 if (staticItemSelected) |
265 if (staticItemSelected) |
261 { |
266 { |
264 |
269 |
265 break; |
270 break; |
266 } |
271 } |
267 case EEventEnterKeyPressed: |
272 case EEventEnterKeyPressed: |
268 { |
273 { |
269 //Check for MultipleSelection is Disbaled |
274 // Check for multiselection is disbaled(i.e. for Albums) |
270 if (!(mediaListAdaptor->MultiSelectionEnabled())) |
275 // and valid index |
|
276 if (!(mediaListAdaptor->MultiSelectionEnabled()) && currItemIndx |
|
277 >= 0) |
271 { |
278 { |
272 //Set if its a static item |
279 //Set if its a static item |
273 const TGlxMedia& item = mediaListAdaptor->MediaList()->Item( |
280 const TGlxMedia& item = mediaListAdaptor->MediaList()->Item( |
274 currItemIndx); |
281 currItemIndx); |
275 mediaListAdaptor->SetStaticItemSelected(item.IsStatic()); |
282 mediaListAdaptor->SetStaticItemSelected(item.IsStatic()); |
276 } |
283 } |
277 CAknPopupList::HandleListBoxEventL( aListBox, aEventType); |
284 CAknPopupList::HandleListBoxEventL(aListBox, aEventType); |
278 break; |
285 break; |
279 } |
286 } |
280 default: |
287 default: |
281 { |
288 { |
282 CAknPopupList::HandleListBoxEventL( aListBox, aEventType); |
289 CAknPopupList::HandleListBoxEventL(aListBox, aEventType); |
283 break; |
290 break; |
284 } |
291 } |
285 } |
292 } |
286 } |
293 } |
287 |
294 |
313 const TGlxMedia& item = mediaListAdaptor->MediaList()->Item( |
320 const TGlxMedia& item = mediaListAdaptor->MediaList()->Item( |
314 changedItemIndex); |
321 changedItemIndex); |
315 mediaListAdaptor->SetStaticItemSelected( item.IsStatic() ); |
322 mediaListAdaptor->SetStaticItemSelected( item.IsStatic() ); |
316 } |
323 } |
317 } |
324 } |
318 |
|
319 //Forward for default processing |
325 //Forward for default processing |
320 CAknPopupList::HandlePointerEventL( aPointerEvent); |
326 CAknPopupList::HandlePointerEventL( aPointerEvent); |
321 |
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CGlxSingleGraphicPopupMenuStyleListBox::OfferKeyEventL |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 TKeyResponse CGlxSingleGraphicPopupMenuStyleListBox::OfferKeyEventL( |
|
334 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
335 { |
|
336 TRACER("CGlxSingleGraphicPopupMenuStyleListBox::OfferKeyEventL"); |
|
337 |
|
338 //Based on the selected item index, disable the MultipleSelection flag |
|
339 //to stop the flickering of 'marked box', when Highlighted 'New Tag' is selected. |
|
340 CGlxMediaListAdaptor* mediaListAdaptor = |
|
341 static_cast<CGlxMediaListAdaptor*> (Model()->ItemTextArray()); |
|
342 TInt currItemIndx = View()->CurrentItemIndex(); |
|
343 GLX_LOG_INFO1("Glx Pop-up listbox - OfferKeyEventL(1) currItemIndx=%d", |
|
344 currItemIndx); |
|
345 |
|
346 if (mediaListAdaptor->MultiSelectionEnabled() && currItemIndx >= 0) |
|
347 { |
|
348 const TGlxMedia& oldItem = mediaListAdaptor->MediaList()->Item( |
|
349 currItemIndx); |
|
350 if (oldItem.IsStatic()) |
|
351 { |
|
352 iListBoxFlags &= (~EMultipleSelection); // turn off multiple selection |
|
353 } |
|
354 else |
|
355 { |
|
356 iListBoxFlags |= EMultipleSelection; // turn on multiple selection |
|
357 } |
|
358 } |
|
359 |
|
360 //Forward for default processing |
|
361 TKeyResponse response = |
|
362 CAknSingleGraphicPopupMenuStyleListBox::OfferKeyEventL(aKeyEvent, |
|
363 aType); |
|
364 |
|
365 currItemIndx = View()->CurrentItemIndex(); |
|
366 GLX_LOG_INFO1("Glx Pop-up listbox - OfferKeyEventL(2) currItemIndx=%d", |
|
367 currItemIndx); |
|
368 //Check if 'Enter'/'Ok' key was consumed for 'MultipleSelection' List Box i.e for Tags |
|
369 if ((response == EKeyWasConsumed) && ((aKeyEvent.iCode == EKeyEnter) |
|
370 || (aKeyEvent.iCode == EKeyOK)) |
|
371 && mediaListAdaptor->MultiSelectionEnabled() && currItemIndx >= 0) |
|
372 { |
|
373 //current selected item |
|
374 const TGlxMedia& item = mediaListAdaptor->MediaList()->Item( |
|
375 currItemIndx); |
|
376 TBool staticItemSelected = item.IsStatic(); |
|
377 mediaListAdaptor->SetStaticItemSelected(staticItemSelected); |
|
378 |
|
379 TInt selectCount = View()->SelectionIndexes()->Count(); |
|
380 CEikButtonGroupContainer* cbaContainer = |
|
381 CEikButtonGroupContainer::Current(); |
|
382 //Check if selected Item is static or other item is selected |
|
383 if (staticItemSelected || selectCount) |
|
384 { |
|
385 cbaContainer->SetCommandSetL(R_GLX_SOFTKEYS_OK_CANCEL); |
|
386 } |
|
387 //no item is selected |
|
388 else |
|
389 { |
|
390 cbaContainer->SetCommandSetL(R_AVKON_SOFTKEYS_CANCEL); |
|
391 } |
|
392 cbaContainer->DrawDeferred(); |
|
393 |
|
394 //Enter Key is Pressed and Static Item is selected |
|
395 if (staticItemSelected) |
|
396 { |
|
397 //Report 'Enter' key is pressed to ListBox observers |
|
398 ReportListBoxEventL(MEikListBoxObserver::EEventEnterKeyPressed); |
|
399 } |
|
400 } |
|
401 |
|
402 return response; |
322 } |
403 } |
323 |
404 |
324 // --------------------------------------------------------------------------- |
405 // --------------------------------------------------------------------------- |
325 // Constructor |
406 // Constructor |
326 // --------------------------------------------------------------------------- |
407 // --------------------------------------------------------------------------- |
839 // |
920 // |
840 void CGlxMediaSelectionPopup::ConstructPopupListL(TBool aMultiSelection) |
921 void CGlxMediaSelectionPopup::ConstructPopupListL(TBool aMultiSelection) |
841 { |
922 { |
842 TRACER("CGlxMediaSelectionPopup::ConstructPopupListL"); |
923 TRACER("CGlxMediaSelectionPopup::ConstructPopupListL"); |
843 // create the list box |
924 // create the list box |
844 iListBox = new (ELeave) CAknSingleGraphicPopupMenuStyleListBox; |
925 iListBox = new (ELeave) CGlxSingleGraphicPopupMenuStyleListBox; |
845 |
926 |
846 // create the popup list |
927 // create the popup list |
847 iPopupList = CGlxSingleGraphicPopupMenuStyleList::NewL( iListBox, R_AVKON_SOFTKEYS_CANCEL) ; |
928 iPopupList = CGlxSingleGraphicPopupMenuStyleList::NewL( iListBox, R_AVKON_SOFTKEYS_CANCEL) ; |
848 |
929 |
849 // set the title of the popup |
930 // set the title of the popup |