calendarui/views/src/calennativeview.cpp
changeset 50 579cc610882e
parent 49 5de72ea7a065
child 58 ef813d54df51
equal deleted inserted replaced
49:5de72ea7a065 50:579cc610882e
    49 {
    49 {
    50 	setTitle(hbTrId("txt_calendar_title_calendar"));
    50 	setTitle(hbTrId("txt_calendar_title_calendar"));
    51 
    51 
    52 	// Create services API and register for notifications
    52 	// Create services API and register for notifications
    53 	RArray<TCalenNotification> notificationArray;
    53 	RArray<TCalenNotification> notificationArray;
       
    54 	CleanupClosePushL(notificationArray);
    54 
    55 
    55 	notificationArray.Append(ECalenNotifySystemTimeChanged);
    56 	notificationArray.Append(ECalenNotifySystemTimeChanged);
    56 	notificationArray.Append(ECalenNotifySystemLocaleChanged);
    57 	notificationArray.Append(ECalenNotifySystemLocaleChanged);
    57 	notificationArray.Append(ECalenNotifyContextChanged);
    58 	notificationArray.Append(ECalenNotifyContextChanged);
    58 
    59 
    59 	mServices.RegisterForNotificationsL(this, notificationArray);
    60 	mServices.RegisterForNotificationsL(this, notificationArray);
    60 
    61 
    61 	notificationArray.Reset();
    62 	CleanupStack::PopAndDestroy(&notificationArray);
    62 }
    63 }
    63 
    64 
    64 /*!
    65 /*!
    65  Destructor
    66  Destructor
    66  */
    67  */
   103 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   104 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   104 	popUp->setTimeout(HbDialog::NoTimeout);
   105 	popUp->setTimeout(HbDialog::NoTimeout);
   105 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   106 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   106 	popUp->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_opt_go_to_date")));
   107 	popUp->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_opt_go_to_date")));
   107 	
   108 	
   108 	// Get the current date.
       
   109 	QDateTime currentDateTime = CalenDateUtils::today();
       
   110 	QDate currentDate = currentDateTime.date();
       
   111 	if(mDatePicker) {
   109 	if(mDatePicker) {
   112 		mDatePicker = NULL;
   110 		mDatePicker = NULL;
   113 	}
   111 	}
   114 	mDatePicker = new HbDateTimePicker(currentDate, popUp);
   112 	mDatePicker = new HbDateTimePicker(QDate::currentDate(), popUp);
   115 	// Set the date range.
   113 	// Set the date range.
   116 	mDatePicker->setMinimumDate(CalenDateUtils::minTime().date());
   114 	mDatePicker->setMinimumDate(CalenDateUtils::minTime().date());
   117 	mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date());
   115 	mDatePicker->setMaximumDate(CalenDateUtils::maxTime().date());
   118 	mDatePicker->setDate(currentDate);
   116 	mDatePicker->setDate(QDate::currentDate());
   119 	
   117 	
   120 	popUp->setContentWidget(mDatePicker);
   118 	popUp->setContentWidget(mDatePicker);
   121 	HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok"));
   119 	HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok"));
   122 	popUp->addAction(okAction);
   120 	popUp->addAction(okAction);
   123 	connect(okAction, SIGNAL(triggered()), this, SLOT(goToSelectedDate()));
   121 	connect(okAction, SIGNAL(triggered()), this, SLOT(goToSelectedDate()));
   135 	// Check if the selected date is within the range.
   133 	// Check if the selected date is within the range.
   136 	if (selectedDate.isValid() &&
   134 	if (selectedDate.isValid() &&
   137 	        selectedDate >= CalenDateUtils::minTime().date() &&
   135 	        selectedDate >= CalenDateUtils::minTime().date() &&
   138 	        selectedDate <= CalenDateUtils::maxTime().date()) {
   136 	        selectedDate <= CalenDateUtils::maxTime().date()) {
   139 		MCalenContext& context = mServices.Context();
   137 		MCalenContext& context = mServices.Context();
   140 		QDateTime contextDate = context.focusDateAndTimeL();
   138 		QDateTime contextDate = context.focusDateAndTime();
   141 
   139 
   142 		//Set the selected date to contextDate.
   140 		//Set the selected date to contextDate.
   143 		contextDate.setDate(selectedDate);
   141 		contextDate.setDate(selectedDate);
   144 		context.setFocusDateAndTimeL(contextDate, KCalenMonthViewUidValue);
   142 		context.setFocusDateAndTime(contextDate);
   145 	}
   143 	}
   146 	refreshViewOnGoToDate();
   144 	refreshViewOnGoToDate();
   147 }
   145 }
   148 
   146 
   149 /*!
   147 /*!