calendarui/controller/src/calendeleteui.cpp
changeset 77 b0711afde476
parent 58 ef813d54df51
child 80 fa7c359294fa
equal deleted inserted replaced
68:a5a1242fd2e8 77:b0711afde476
   102 //
   102 //
   103 void CalenDeleteUi::ConstructL()
   103 void CalenDeleteUi::ConstructL()
   104     {
   104     {
   105     OstTraceFunctionEntry0( CALENDELETEUI_CONSTRUCTL_ENTRY );
   105     OstTraceFunctionEntry0( CALENDELETEUI_CONSTRUCTL_ENTRY );
   106     
   106     
   107     iController.RegisterForNotificationsL( this, ECalenNotifyCancelDelete );
   107     RArray<TCalenNotification> notifications;
       
   108     notifications.Append(ECalenNotifyCancelDelete);
       
   109     notifications.Append(ECalenNotifyCloseDialogs);
       
   110     
       
   111     iController.RegisterForNotificationsL( this, notifications );
       
   112     
       
   113     notifications.Close();
       
   114     
   108     iMoreEntriesToDelete = EFalse;
   115     iMoreEntriesToDelete = EFalse;
   109     iDisplayQuery = EFalse;
   116     iDisplayQuery = EFalse;
   110     iEntriesToDelete = KEntriesToDelete;
   117     iEntriesToDelete = KEntriesToDelete;
   111     
   118     
   112     OstTraceFunctionExit0( CALENDELETEUI_CONSTRUCTL_EXIT );
   119     OstTraceFunctionExit0( CALENDELETEUI_CONSTRUCTL_EXIT );
   130             MCalenContext& context = iController.context();
   137             MCalenContext& context = iController.context();
   131             // reset the multiple contexts
   138             // reset the multiple contexts
   132             context.resetMultipleContextIds();          
   139             context.resetMultipleContextIds();          
   133            
   140            
   134             }
   141             }
       
   142         }
       
   143     else if (aNotification == ECalenNotifyCloseDialogs )
       
   144         {
       
   145     	// Emit the signal to close all the dialogs which are already opened
       
   146     	emit closeDialogs();
   135         }
   147         }
   136     
   148     
   137     OstTraceFunctionExit0( CALENDELETEUI_HANDLENOTIFICATION_EXIT );
   149     OstTraceFunctionExit0( CALENDELETEUI_HANDLENOTIFICATION_EXIT );
   138     }
   150     }
   139 
   151 
   383 	{
   395 	{
   384     OstTraceFunctionEntry0( CALENDELETEUI_DATEQUERY_ENTRY );
   396     OstTraceFunctionEntry0( CALENDELETEUI_DATEQUERY_ENTRY );
   385     
   397     
   386 	// Create a popup with datepicker to select the date.
   398 	// Create a popup with datepicker to select the date.
   387 	HbDialog *popUp = new HbDialog();
   399 	HbDialog *popUp = new HbDialog();
       
   400 	popUp->setParent(this);
   388 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   401 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   389 	popUp->setTimeout(HbDialog::NoTimeout );
   402 	popUp->setTimeout(HbDialog::NoTimeout );
   390 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   403 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   391 	popUp->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_set_date")));
   404 	popUp->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_set_date")));
   392 	
   405 	
   404 	mDeleteAction = new HbAction(
   417 	mDeleteAction = new HbAction(
   405 						hbTrId("txt_common_button_delete"), popUp);
   418 						hbTrId("txt_common_button_delete"), popUp);
   406 	popUp->addAction(mDeleteAction);
   419 	popUp->addAction(mDeleteAction);
   407 	mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"),popUp);
   420 	mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"),popUp);
   408 	popUp->addAction(mCancelAction);
   421 	popUp->addAction(mCancelAction);
       
   422 	// Close the popup once closeDialogs() is received
       
   423 	connect(this, SIGNAL(closeDialogs()), popUp, SLOT(close()));
   409 	// Show the popup
   424 	// Show the popup
   410 	popUp->open(this, SLOT(handleDateQuery(HbAction*)));
   425 	popUp->open(this, SLOT(handleDateQuery(HbAction*)));
   411 	
   426 	
   412 	OstTraceFunctionExit0( CALENDELETEUI_DATEQUERY_EXIT );
   427 	OstTraceFunctionExit0( CALENDELETEUI_DATEQUERY_EXIT );
   413 	}
   428 	}
   447 				iController.BroadcastNotification(ECalenNotifyDeleteFailed);
   462 				iController.BroadcastNotification(ECalenNotifyDeleteFailed);
   448 			}
   463 			}
   449 		}
   464 		}
   450 	}else {
   465 	}else {
   451 		// User pressed cancel
   466 		// User pressed cancel
   452 		handleDeleteCancel();
   467 		iController.BroadcastNotification(ECalenNotifyDeleteFailed);
   453 	}
   468 	}
   454 	// Reset the member variables
   469 	// Reset the member variables
   455 	mDeleteAction = NULL;
   470 	mDeleteAction = NULL;
   456 	mCancelAction = NULL;
   471 	mCancelAction = NULL;
   457 	
   472 	
   466 void CalenDeleteUi::showRepeatingEntryDeleteQuery()
   481 void CalenDeleteUi::showRepeatingEntryDeleteQuery()
   467 {
   482 {
   468     OstTraceFunctionEntry0( CALENDELETEUI_SHOWREPEATINGENTRYDELETEQUERY_ENTRY );
   483     OstTraceFunctionEntry0( CALENDELETEUI_SHOWREPEATINGENTRYDELETEQUERY_ENTRY );
   469     
   484     
   470     HbDialog *popUp = new HbDialog();
   485     HbDialog *popUp = new HbDialog();
       
   486     popUp->setParent(this);
   471     popUp->setDismissPolicy(HbDialog::NoDismiss);
   487     popUp->setDismissPolicy(HbDialog::NoDismiss);
   472     popUp->setTimeout(HbDialog::NoTimeout);
   488     popUp->setTimeout(HbDialog::NoTimeout);
   473     popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   489     popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   474     
   490     
   475     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
   491     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
   489     popUp->setContentWidget(editWidget);
   505     popUp->setContentWidget(editWidget);
   490     popUp->setHeadingWidget(new HbLabel(
   506     popUp->setHeadingWidget(new HbLabel(
   491 						hbTrId("txt_calendar_title_delete_repeated_entry")));
   507 						hbTrId("txt_calendar_title_delete_repeated_entry")));
   492 
   508 
   493     // Add cancel action
   509     // Add cancel action
   494     HbAction *cancelAction = new HbAction(
   510     mCancelAction = new HbAction(
   495 							hbTrId("txt_common_button_cancel_singledialog"));
   511 					hbTrId("txt_common_button_cancel_singledialog"));
   496     popUp->addAction(cancelAction);
   512     popUp->addAction(mCancelAction);
   497     connect(editButtonList, SIGNAL(itemSelected(int)), this,
   513     connect(editButtonList, SIGNAL(itemSelected(int)), this,
   498 										SLOT(handleRepeatedEntryDelete(int)));
   514 										SLOT(handleRepeatedEntryDelete(int)));
   499     connect(editButtonList, SIGNAL(itemSelected(int)), popUp, SLOT(close()));
   515     connect(editButtonList, SIGNAL(itemSelected(int)), popUp, SLOT(close()));
   500     connect(cancelAction, SIGNAL(triggered()), this, 
   516     // Close the popup once closeDialogs() is received
   501 										SLOT(handleDeleteCancel()));
   517     connect(this, SIGNAL(closeDialogs()), popUp, SLOT(close()));
   502     
       
   503     // Show the popup
   518     // Show the popup
   504     popUp->open();
   519     popUp->open(this, SLOT(handleCancelAndClose(HbAction*)));
   505     
   520     
   506     OstTraceFunctionExit0( CALENDELETEUI_SHOWREPEATINGENTRYDELETEQUERY_EXIT );
   521     OstTraceFunctionExit0( CALENDELETEUI_SHOWREPEATINGENTRYDELETEQUERY_EXIT );
   507 }
   522 }
   508 
   523 
   509 // ----------------------------------------------------------------------------
   524 // ----------------------------------------------------------------------------
   510 // CalenDeleteUi::handleDeleteCancel
   525 // CalenDeleteUi::handleCancelAndClose
   511 // Handles the cancel action
   526 // Handles the cancel action and the close of the popup
   512 // (other items were commented in a header).
   527 // (other items were commented in a header).
   513 // ----------------------------------------------------------------------------
   528 // ----------------------------------------------------------------------------
   514 //
   529 //
   515 void CalenDeleteUi::handleDeleteCancel()
   530 void CalenDeleteUi::handleCancelAndClose(HbAction* action)
   516 {
   531 {
   517     OstTraceFunctionEntry0( CALENDELETEUI_HANDLEDELETECANCEL_ENTRY );
   532 	OstTraceFunctionEntry0( CALENDELETEUI_HANDLECANCELANDCLOSE_ENTRY );
   518     
   533 	if(action == mCancelAction || !action) {
   519 	iController.BroadcastNotification(ECalenNotifyDeleteFailed);
   534 		// If the user presses cancel button broadcast ECalenNotifyDeleteFailed
   520 	
   535 		// Action will be null if the popup is closed by itself 
   521 	OstTraceFunctionExit0( CALENDELETEUI_HANDLEDELETECANCEL_EXIT );
   536 		// without pressing any buttons. So in this case also notification 
       
   537 		// has to be broadcasted as ECalenNotifyDeleteFailed
       
   538 		
       
   539 		iController.BroadcastNotification(ECalenNotifyDeleteFailed);
       
   540 	}
       
   541 	mCancelAction = NULL;
       
   542 	OstTraceFunctionExit0( CALENDELETEUI_HANDLECANCELANDCLOSE_EXIT );
   522 }
   543 }
   523 
   544 
   524 void CalenDeleteUi::handleRepeatedEntryDelete(int index)
   545 void CalenDeleteUi::handleRepeatedEntryDelete(int index)
   525 {
   546 {
   526     OstTraceFunctionEntry0( CALENDELETEUI_HANDLEREPEATEDENTRYDELETE_ENTRY );
   547     OstTraceFunctionEntry0( CALENDELETEUI_HANDLEREPEATEDENTRYDELETE_ENTRY );
   563                                                      const int count)
   584                                                      const int count)
   564     {
   585     {
   565     OstTraceFunctionEntry0( CALENDELETEUI_SHOWDELETEQUERY_ENTRY );
   586     OstTraceFunctionEntry0( CALENDELETEUI_SHOWDELETEQUERY_ENTRY );
   566     
   587     
   567     HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   588     HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
       
   589     popup->setParent(this);
   568     popup->setDismissPolicy(HbDialog::NoDismiss);
   590     popup->setDismissPolicy(HbDialog::NoDismiss);
   569     popup->setTimeout(HbDialog::NoTimeout);
   591     popup->setTimeout(HbDialog::NoTimeout);
   570     popup->setAttribute( Qt::WA_DeleteOnClose, true );
   592     popup->setAttribute( Qt::WA_DeleteOnClose, true );
   571     
   593     
   572     QString text = 0;
   594     QString text = 0;
   613     mDeleteAction = new HbAction(
   635     mDeleteAction = new HbAction(
   614 						hbTrId("txt_common_button_delete"), popup);
   636 						hbTrId("txt_common_button_delete"), popup);
   615     popup->addAction(mDeleteAction);
   637     popup->addAction(mDeleteAction);
   616     mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"), popup); 
   638     mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"), popup); 
   617     popup->addAction(mCancelAction);
   639     popup->addAction(mCancelAction);
       
   640     // Close the popup once closeDialogs() is received
       
   641     connect(this, SIGNAL(closeDialogs()), popup, SLOT(close()));
       
   642     // Show the popup
   618     popup->open(this, SLOT(handleDeletion(HbAction*)));
   643     popup->open(this, SLOT(handleDeletion(HbAction*)));
   619     
   644     
   620     OstTraceFunctionExit0( CALENDELETEUI_SHOWDELETEQUERY_EXIT );
   645     OstTraceFunctionExit0( CALENDELETEUI_SHOWDELETEQUERY_EXIT );
   621     }
   646     }
   622 
   647 
   681 			
   706 			
   682 			default:
   707 			default:
   683 				break;
   708 				break;
   684 				
   709 				
   685 		}
   710 		}
   686 	} else {
   711 	} else if(!action || action == mCancelAction ) {
   687 		// If the user presses cancel button the notification will be
   712 		// Action will be null if the popup is closed by itself 
   688 		// ECalenNotifyDeleteFailed as default.
   713 		// without pressing any buttons. So in this case also notification 
       
   714 		// has to be broadcasted as ECalenNotifyDeleteFailed
       
   715 		// If the user presses cancel button also the same has to happen
   689 		// Notify the status
   716 		// Notify the status
   690 		iController.BroadcastNotification(notification);
   717 		iController.BroadcastNotification(notification);
   691 	}
   718 	}
   692 	
   719 	
   693 	// Reset the member variables
   720 	// Reset the member variables