calendarui/caleneditor/src/caleneditorrepeatfield.cpp
changeset 70 a5ed90760192
parent 64 1881ad52dc45
child 75 7ac58b2aae6f
equal deleted inserted replaced
64:1881ad52dc45 70:a5ed90760192
   244 	Removes the repeat until item from the model
   244 	Removes the repeat until item from the model
   245 	and removed the connection for date picker launch too.
   245 	and removed the connection for date picker launch too.
   246  */
   246  */
   247 void CalenEditorRepeatField::removeRepeatUntilItem()
   247 void CalenEditorRepeatField::removeRepeatUntilItem()
   248 {
   248 {
       
   249 	OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_REMOVEREPEATUNTILITEM_ENTRY );
   249 	mRepeatRuleType = AgendaRepeatRule::InvalidRule;
   250 	mRepeatRuleType = AgendaRepeatRule::InvalidRule;
   250 	if (mRepeatUntilItemAdded) {
   251 	if (mRepeatUntilItemAdded) {
   251 		mEditorForm->removeConnection(mCustomRepeatUntilItem, SIGNAL(clicked()),
   252 		mEditorForm->removeConnection(mCustomRepeatUntilItem, SIGNAL(clicked()),
   252 	                                this, SLOT(launchRepeatUntilDatePicker()));
   253 	                                this, SLOT(launchRepeatUntilDatePicker()));
   253 		QModelIndex repeatIndex =
   254 		QModelIndex repeatIndex =
   256 		                              mCalenEditorModel->index(
   257 		                              mCalenEditorModel->index(
   257 		                              repeatIndex.row()+ 1, 0));
   258 		                              repeatIndex.row()+ 1, 0));
   258 		mRepeatUntilItemAdded = false;
   259 		mRepeatUntilItemAdded = false;
   259 		mCustomRepeatUntilItem = 0;
   260 		mCustomRepeatUntilItem = 0;
   260 	}
   261 	}
       
   262 	OstTraceFunctionExit0( CALENEDITORREPEATFIELD_REMOVEREPEATUNTILITEM_EXIT );
   261 }
   263 }
   262 
   264 
   263 /*!
   265 /*!
   264 	Triggerd from tapping on reminder item.
   266 	Triggerd from tapping on reminder item.
   265 	Handles the reminder time change and updates the same in the event.
   267 	Handles the reminder time change and updates the same in the event.
   266 	\param index The new index chosen in the reminder list.
   268 	\param index The new index chosen in the reminder list.
   267  */
   269  */
   268 void CalenEditorRepeatField::handleRepeatIndexChanged(int index)
   270 void CalenEditorRepeatField::handleRepeatIndexChanged(int index)
   269 {
   271 {
   270 	OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_HANDLEREPEATINDEXCHANGED_ENTRY );
   272 	OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_HANDLEREPEATINDEXCHANGED_ENTRY );
   271 	mIsBiWeekly = false;
       
   272 	mIsWorkdays = false;
       
   273 
   273 
   274 	HbExtendedLocale locale = HbExtendedLocale::system();
   274 	HbExtendedLocale locale = HbExtendedLocale::system();
   275 	// Get the user role we have set for this index
   275 	// Get the user role we have set for this index
   276 	QVariant role = mRepeatComboBox->itemData(index, userRole);
   276 	QVariant role = mRepeatComboBox->itemData(index, userRole);
   277 	int value = role.toInt();
   277 	int value = role.toInt();
   289 	}else {
   289 	}else {
   290 		// No change in repeat value
   290 		// No change in repeat value
   291 		repeatPropertyChange = false;
   291 		repeatPropertyChange = false;
   292 	}
   292 	}
   293 	QDate repeatUntilDate = mRepeatUntilDate;
   293 	QDate repeatUntilDate = mRepeatUntilDate;
       
   294 	int itemIndex = CalenEditorPrivate::RepeatUntilItem;
       
   295 	if (!mCalenEditor->isReminderTimeForAllDayAdded()) {
       
   296 		itemIndex -= 1;
       
   297 	}
   294 	// Update the repeat type only if its has been changed
   298 	// Update the repeat type only if its has been changed
   295 	// ie. if the previous repeatrole is different from the current repeat role
   299 	// ie. if the previous repeatrole is different from the current repeat role
   296 	if (value != mRepeatRoleValue) {
   300 	if (value != mRepeatRoleValue) {
   297 		mRepeatRoleValue = value;
   301 		mRepeatRoleValue = value;
       
   302 		mIsBiWeekly = false;
       
   303 		mIsWorkdays = false;
   298 		switch (value) {
   304 		switch (value) {
   299 			case DailyRole: {
   305 			case DailyRole: {
   300 				if (!mRepeatUntilItemAdded) {
   306 				if (!mRepeatUntilItemAdded) {
   301 					insertRepeatUntilItem();
   307 					insertRepeatUntilItem();
   302 				}
   308 				}
   399 	}
   405 	}
   400 	// Depending on repeatPropertyChange value and the repeatuntil date change 
   406 	// Depending on repeatPropertyChange value and the repeatuntil date change 
   401 	// the reminder choices are updated 
   407 	// the reminder choices are updated 
   402 	if(repeatPropertyChange || repeatUntilDate != mRepeatUntilDate) {
   408 	if(repeatPropertyChange || repeatUntilDate != mRepeatUntilDate) {
   403 		mCalenEditor->updateReminderChoices();
   409 		mCalenEditor->updateReminderChoices();
   404 		// Once the entry is changed from  non repeating to repeating 
   410 
   405 		// and if the alarm set is off 
   411 		// Once the entry is changed from  non repeating to repeating we scroll to the repeat until item.
   406 		// Then change the reminder option to the default 'one day before' 
   412 		if(repeatPropertyChange && mRepeatUntilItemAdded) {
   407 		// if the option is valid
   413 			mEditorForm->scrollTo(mCalenEditorModel->index(itemIndex, 0), HbAbstractItemView::EnsureVisible);
   408 		if (mCalenEditor->isAllDayEvent() && 
   414 			
   409 					repeatPropertyChange && mRepeatUntilItemAdded) {
   415 			// Once the entry is changed from  non repeating to repeating 
   410 			if(!mCalenEditor->isReminderTimeForAllDayAdded() &&
   416 			// and if the alarm set is off 
   411 					mCalenEditor->getReminderCount() >= 3) {
   417 			// Then change the reminder option to the default 'one day before' 
   412 				mCalenEditor->setCurrentIndexOfReminderField(
   418 			// if the option is valid
       
   419 			if (mCalenEditor->isAllDayEvent()) {
       
   420 				if(!mCalenEditor->isReminderTimeForAllDayAdded() &&
       
   421 						mCalenEditor->getReminderCount() >= 3) {
       
   422 					mCalenEditor->setCurrentIndexOfReminderField(
   413 							CalenEditorReminderField::ReminderOneDayBefore);
   423 							CalenEditorReminderField::ReminderOneDayBefore);
       
   424 				}
   414 			}
   425 			}
   415 		}
   426 		}
   416 	}
   427 	}
   417 	OstTraceFunctionExit0( CALENEDITORREPEATFIELD_HANDLEREPEATINDEXCHANGED_EXIT );
   428 	OstTraceFunctionExit0( CALENEDITORREPEATFIELD_HANDLEREPEATINDEXCHANGED_EXIT );
   418 }
   429 }
   456 		QString dateString = locale.format(
   467 		QString dateString = locale.format(
   457 				mCalenEditor->editedEntry()->repeatRule().until().date(),
   468 				mCalenEditor->editedEntry()->repeatRule().until().date(),
   458 				r_qtn_date_usual_with_zero);
   469 				r_qtn_date_usual_with_zero);
   459 		mCustomRepeatUntilItem->setContentWidgetData("text", dateString);
   470 		mCustomRepeatUntilItem->setContentWidgetData("text", dateString);
   460 	}
   471 	}
   461 	//Scroll to repeat until item added
       
   462 	mEditorForm->scrollTo(mCalenEditorModel->index(index, 0), HbAbstractItemView::EnsureVisible);
       
   463 	OstTraceFunctionExit0( CALENEDITORREPEATFIELD_INSERTREPEATUNTILITEM_EXIT );
   472 	OstTraceFunctionExit0( CALENEDITORREPEATFIELD_INSERTREPEATUNTILITEM_EXIT );
   464 }
   473 }
   465 
   474 
   466 /*!
   475 /*!
   467 	 Informs if repeat until item has been added or not
   476 	 Informs if repeat until item has been added or not
   479  */
   488  */
   480 void CalenEditorRepeatField::launchRepeatUntilDatePicker()
   489 void CalenEditorRepeatField::launchRepeatUntilDatePicker()
   481 {
   490 {
   482 	OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_LAUNCHREPEATUNTILDATEPICKER_ENTRY );
   491 	OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_LAUNCHREPEATUNTILDATEPICKER_ENTRY );
   483 	HbDialog *popUp = new HbDialog();
   492 	HbDialog *popUp = new HbDialog();
       
   493 	// Set the parent for the dialog
       
   494 	// Once the parent object is deleted the dialog will also be deleted
       
   495 	popUp->setParent(this);
   484 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   496 	popUp->setDismissPolicy(HbDialog::NoDismiss);
   485 	popUp->setTimeout(HbDialog::NoTimeout);
   497 	popUp->setTimeout(HbDialog::NoTimeout);
   486 	popUp->setHeadingWidget( new HbLabel(
   498 	popUp->setHeadingWidget( new HbLabel(
   487 									hbTrId("txt_calendar_title_repeat_until")));
   499 									hbTrId("txt_calendar_title_repeat_until")));
   488 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   500 	popUp->setAttribute( Qt::WA_DeleteOnClose, true );
   723 	OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_SAVEREPEATRULE_ENTRY );
   735 	OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_SAVEREPEATRULE_ENTRY );
   724 	// saves repeat type of entry.
   736 	// saves repeat type of entry.
   725 	if (mRepeatRuleType != AgendaRepeatRule::InvalidRule) {
   737 	if (mRepeatRuleType != AgendaRepeatRule::InvalidRule) {
   726 		AgendaRepeatRule repeatRule(mRepeatRuleType);
   738 		AgendaRepeatRule repeatRule(mRepeatRuleType);
   727 
   739 
       
   740 		//Set the week start day in the repeat rule.
       
   741 		HbExtendedLocale locale = HbExtendedLocale::system();
       
   742 		AgendaRepeatRule::Day wkStart = (AgendaRepeatRule::Day)locale.startOfWeek();
       
   743 		repeatRule.setWeekStart(wkStart);
       
   744 
   728 		//TODO : Set the repeat from and to dates
   745 		//TODO : Set the repeat from and to dates
   729 		QVariant dateVariant =
   746 		QVariant dateVariant =
   730 				mCustomRepeatUntilItem->contentWidgetData("text");
   747 				mCustomRepeatUntilItem->contentWidgetData("text");
   731 		QString dateString = dateVariant.toString();
   748 		QString dateString = dateVariant.toString();
   732 		QDate untilDate = QDate::fromString(dateString, "dd/MM/yyyy");
   749 		QDate untilDate = QDate::fromString(dateString, "dd/MM/yyyy");