20 #include <mpxmessageprogressdefs.h> |
20 #include <mpxmessageprogressdefs.h> |
21 |
21 |
22 #include <glxfilterfactory.h> |
22 #include <glxfilterfactory.h> |
23 #include <glxcollectionpluginall.hrh> |
23 #include <glxcollectionpluginall.hrh> |
24 #include <mglxmedialist.h> |
24 #include <mglxmedialist.h> |
25 #include <glxcommandfactory.h> |
|
26 #include <glxmpxcommandhandler.h> |
25 #include <glxmpxcommandhandler.h> |
27 #include <glxfetchcontextremover.h> |
26 #include <glxfetchcontextremover.h> |
28 #include <glxmedialistiterator.h> |
27 #include <glxmedialistiterator.h> |
29 #include <glxattributecontext.h> |
28 #include <glxattributecontext.h> |
30 #include <glxattributeretriever.h> |
29 #include <glxattributeretriever.h> |
38 #include "OstTraceDefinitions.h" |
37 #include "OstTraceDefinitions.h" |
39 #ifdef OST_TRACE_COMPILER_IN_USE |
38 #ifdef OST_TRACE_COMPILER_IN_USE |
40 #include "glxmpxcommandhandlerTraces.h" |
39 #include "glxmpxcommandhandlerTraces.h" |
41 #endif |
40 #endif |
42 |
41 |
|
42 #include <hbaction.h> |
|
43 |
43 GlxMpxCommandHandler::GlxMpxCommandHandler() : |
44 GlxMpxCommandHandler::GlxMpxCommandHandler() : |
44 iProgressComplete(EFalse) |
45 iProgressComplete(EFalse) |
45 { |
46 { |
46 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_GLXMPXCOMMANDHANDLER_ENTRY ); |
47 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_GLXMPXCOMMANDHANDLER_ENTRY ); |
47 iMediaList = NULL; |
48 iMediaList = NULL; |
64 { |
65 { |
65 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_EXECUTECOMMAND_ENTRY ); |
66 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_EXECUTECOMMAND_ENTRY ); |
66 int aHierarchyId = 0; |
67 int aHierarchyId = 0; |
67 TGlxFilterItemType aFilterType = EGlxFilterImage; |
68 TGlxFilterItemType aFilterType = EGlxFilterImage; |
68 |
69 |
69 //CreateMediaListL(aCollectionId, aHierarchyId,aFilterType); |
|
70 if (collectionId != KGlxAlbumsMediaId) |
70 if (collectionId != KGlxAlbumsMediaId) |
71 { |
71 { |
72 OstTrace0( TRACE_NORMAL, DUP2_GLXMPXCOMMANDHANDLER_EXECUTECOMMAND, "GlxMpxCommandHandler::executeCommand::CreateMediaListL" ); |
72 OstTrace0( TRACE_NORMAL, DUP2_GLXMPXCOMMANDHANDLER_EXECUTECOMMAND, "GlxMpxCommandHandler::executeCommand::CreateMediaListL" ); |
73 CreateMediaListL(collectionId, aHierarchyId, aFilterType); |
73 CreateMediaListL(collectionId, aHierarchyId, aFilterType); |
74 } |
74 } |
79 CreateMediaListAlbumItemL(collectionId, aHierarchyId, aFilterType); |
79 CreateMediaListAlbumItemL(collectionId, aHierarchyId, aFilterType); |
80 } |
80 } |
81 |
81 |
82 TBool consume = ETrue; |
82 TBool consume = ETrue; |
83 iProgressComplete = EFalse; |
83 iProgressComplete = EFalse; |
|
84 mProgressDialog = NULL; |
84 //Execute Command |
85 //Execute Command |
85 DoExecuteCommandL(commandId, *iMediaList, consume); |
86 DoExecuteCommandL(commandId, *iMediaList, consume); |
86 //Create MPX command if any |
87 mCommandId = commandId; |
87 consume = ConfirmationNoteL(*iMediaList); |
88 ConfirmationNoteL(*iMediaList); |
88 if(consume) |
89 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_EXECUTECOMMAND_EXIT ); |
89 { |
90 } |
90 CMPXCommand* command = CreateCommandL(commandId, *iMediaList, consume); |
91 |
|
92 void GlxMpxCommandHandler::executeMpxCommand(bool execute) |
|
93 { |
|
94 if(execute && !iMediaList->IsCommandActive()) |
|
95 { |
|
96 TBool consume = ETrue; |
|
97 CMPXCommand* command = CreateCommandL(mCommandId, *iMediaList, consume); |
91 if (command) |
98 if (command) |
92 { |
99 { |
93 command->SetTObjectValueL<TAny*> (KMPXCommandGeneralSessionId, |
100 command->SetTObjectValueL<TAny*> (KMPXCommandGeneralSessionId, |
94 static_cast<TAny*> (this)); |
101 static_cast<TAny*> (this)); |
95 iMediaList->AddMediaListObserverL(this); |
102 iMediaList->AddMediaListObserverL(this); |
96 iMediaList->CommandL(*command); |
103 iMediaList->CommandL(*command); |
97 ProgressNoteL(commandId); |
104 |
|
105 if(iMediaList->SelectionCount() > 1) |
|
106 { |
|
107 ProgressNoteL(mCommandId); |
|
108 } |
98 } |
109 } |
99 } |
110 } |
100 else //command cancelled,so unmark all items |
111 else //command cancelled,so unmark all items |
101 { |
112 { |
102 MGlxMediaList::UnmarkAllL(*iMediaList); |
113 MGlxMediaList::UnmarkAllL(*iMediaList); |
103 } |
114 } |
104 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_EXECUTECOMMAND_EXIT ); |
115 |
105 } |
116 } |
106 |
117 |
107 // --------------------------------------------------------------------------- |
118 // --------------------------------------------------------------------------- |
108 // CreateMediaListL() |
119 // CreateMediaListL() |
109 // Creates a collection path |
120 // Creates a collection path |
345 else if (iProgressComplete) |
356 else if (iProgressComplete) |
346 { |
357 { |
347 DismissProgressNoteL(); |
358 DismissProgressNoteL(); |
348 iMediaList->RemoveMediaListObserver(this); |
359 iMediaList->RemoveMediaListObserver(this); |
349 CompletionNoteL(); |
360 CompletionNoteL(); |
|
361 iProgressComplete = EFalse; |
350 } |
362 } |
351 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_TRYEXITL_EXIT ); |
363 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_TRYEXITL_EXIT ); |
352 } |
364 } |
353 |
365 |
354 // ----------------------------------------------------------------------------- |
366 // ----------------------------------------------------------------------------- |
392 |
404 |
393 void GlxMpxCommandHandler::ProgressNoteL(TInt /*aCommandId*/) |
405 void GlxMpxCommandHandler::ProgressNoteL(TInt /*aCommandId*/) |
394 { |
406 { |
395 mProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
407 mProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
396 mProgressDialog->setText(ProgressTextL()); |
408 mProgressDialog->setText(ProgressTextL()); |
397 mProgressDialog->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); |
|
398 mProgressDialog->show(); |
409 mProgressDialog->show(); |
399 } |
410 } |
400 |
411 |
401 void GlxMpxCommandHandler::DismissProgressNoteL() |
412 void GlxMpxCommandHandler::DismissProgressNoteL() |
402 { |
413 { |
403 mProgressDialog->close(); |
414 if(mProgressDialog) |
404 delete mProgressDialog; |
415 { |
405 mProgressDialog = NULL; |
416 mProgressDialog->close(); |
406 } |
417 delete mProgressDialog; |
407 |
418 mProgressDialog = NULL; |
408 bool GlxMpxCommandHandler::ConfirmationNoteL(MGlxMediaList& aMediaList) const |
419 } |
|
420 } |
|
421 |
|
422 void GlxMpxCommandHandler::ConfirmationNoteL(MGlxMediaList& aMediaList) |
409 { |
423 { |
410 TInt selectionCount = aMediaList.SelectionCount(); |
424 TInt selectionCount = aMediaList.SelectionCount(); |
411 |
425 |
412 // If media list is not empty, treat focused item as selected |
426 // If media list is not empty, treat focused item as selected |
413 // At this point can assume that the command was disabled |
427 // At this point can assume that the command was disabled |
416 { |
430 { |
417 selectionCount = 1; |
431 selectionCount = 1; |
418 } |
432 } |
419 |
433 |
420 // Show confirmation note |
434 // Show confirmation note |
421 bool confirmed = true; |
|
422 if ( selectionCount == 1 ) |
435 if ( selectionCount == 1 ) |
423 { |
436 { |
424 confirmed = ConfirmationNoteSingleL(aMediaList); |
437 ConfirmationNoteSingleL(aMediaList); |
425 } |
438 } |
426 else |
439 else |
427 { |
440 { |
428 confirmed = ConfirmationNoteMultipleL(aMediaList); |
441 ConfirmationNoteMultipleL(aMediaList); |
429 } |
442 } |
430 |
443 } |
431 return confirmed; |
444 |
432 } |
445 void GlxMpxCommandHandler::ConfirmationNoteSingleL(MGlxMediaList& aMediaList) |
433 |
446 { |
434 bool GlxMpxCommandHandler::ConfirmationNoteSingleL(MGlxMediaList& aMediaList) const |
|
435 { |
|
436 bool confirmAction = true; |
|
437 |
|
438 QString qtText = ConfirmationTextL(); |
447 QString qtText = ConfirmationTextL(); |
439 |
448 |
440 if(!qtText.isEmpty ()) |
449 if(!qtText.isEmpty ()) |
441 { |
450 { |
442 // create fetch context |
451 // create fetch context |
470 const TDesC& itemName = media->ValueText(KMPXMediaGeneralTitle); |
479 const TDesC& itemName = media->ValueText(KMPXMediaGeneralTitle); |
471 QString qtItemName = QString::fromUtf16(itemName.Ptr(),itemName.Length()); |
480 QString qtItemName = QString::fromUtf16(itemName.Ptr(),itemName.Length()); |
472 qtText.append(QString("%1").arg(qtItemName)); |
481 qtText.append(QString("%1").arg(qtItemName)); |
473 } |
482 } |
474 // (else) If error, assume confirmed anyway |
483 // (else) If error, assume confirmed anyway |
475 |
484 CleanupStack::PopAndDestroy(attributeContext); |
476 CleanupStack::PopAndDestroy(attributeContext); |
485 HbMessageBox::question(qtText, this, SLOT(messageDialogClose(HbAction*))); |
477 |
486 } |
478 HbMessageBox box(HbMessageBox::MessageTypeQuestion); |
487 else{ |
479 box.setDismissPolicy(HbDialog::NoDismiss); |
488 executeMpxCommand(true); |
480 |
489 } |
481 // Set timeout to zero to wait user to either click Ok or Cancel |
490 } |
482 box.setTimeout(HbDialog::NoTimeout); |
491 |
483 |
492 void GlxMpxCommandHandler::ConfirmationNoteMultipleL(MGlxMediaList& /*aMediaList*/) |
484 box.setText(qtText); |
493 { |
485 HbAction *action = box.exec(); |
|
486 if(action != box.primaryAction()) |
|
487 { |
|
488 confirmAction = false; |
|
489 } |
|
490 } |
|
491 return confirmAction; |
|
492 } |
|
493 |
|
494 bool GlxMpxCommandHandler::ConfirmationNoteMultipleL(MGlxMediaList& /*aMediaList*/) const |
|
495 { |
|
496 bool confirmAction = true; |
|
497 |
|
498 QString qtText = ConfirmationTextL(true); |
494 QString qtText = ConfirmationTextL(true); |
499 if(!qtText.isEmpty ()) |
495 if(!qtText.isEmpty ()) |
500 { |
496 { |
501 HbMessageBox box(HbMessageBox::MessageTypeQuestion); |
497 HbMessageBox::question(qtText, this, SLOT(messageDialogClose(HbAction*))); |
502 box.setDismissPolicy(HbDialog::NoDismiss); |
|
503 // Set timeout to zero to wait user to either click Ok or Cancel |
|
504 box.setTimeout(HbDialog::NoTimeout); |
|
505 box.setText(qtText); |
|
506 HbAction *action = box.exec(); |
|
507 if(action != box.primaryAction()) |
|
508 { |
|
509 confirmAction = false; |
|
510 } |
|
511 } |
498 } |
512 return confirmAction; |
499 else{ |
513 } |
500 executeMpxCommand(true); |
514 |
501 } |
|
502 } |
|
503 |
|
504 void GlxMpxCommandHandler::messageDialogClose(HbAction* action) |
|
505 { |
|
506 HbMessageBox *dlg = static_cast<HbMessageBox*>(sender()); |
|
507 if(action == dlg->actions().at(0)) |
|
508 { |
|
509 executeMpxCommand(true); |
|
510 } |
|
511 else |
|
512 { |
|
513 // Cancellation is done. |
|
514 executeMpxCommand(false); |
|
515 } |
|
516 } |
|
517 |
|
518 |
515 QString GlxMpxCommandHandler::ConfirmationTextL(bool /*multiSelection */) const |
519 QString GlxMpxCommandHandler::ConfirmationTextL(bool /*multiSelection */) const |
516 { |
520 { |
517 return QString(); |
521 return QString(); |
518 } |
522 } |