calendarui/caleneditor/src/caleneditor_p.cpp
changeset 57 bb2d3e476f29
parent 55 2c54b51f39c4
child 64 1881ad52dc45
equal deleted inserted replaced
55:2c54b51f39c4 57:bb2d3e476f29
    48 
    48 
    49 // User includes
    49 // User includes
    50 #include <CalenLauncher>
    50 #include <CalenLauncher>
    51 #include <agendaentry.h>
    51 #include <agendaentry.h>
    52 #include <agendautil.h>
    52 #include <agendautil.h>
    53 
    53 #include <caleneditor.h>
    54 #include "caleneditor_p.h"
    54 
    55 #include "caleneditor.h"
       
    56 #include "caleneditor_p.h"
    55 #include "caleneditor_p.h"
    57 #include "caleneditorcustomitem.h"
    56 #include "caleneditorcustomitem.h"
    58 #include "calendateutils.h"
    57 #include "calendateutils.h"
    59 #include "caleneditordocloader.h"
    58 #include "caleneditordocloader.h"
    60 #include "caleneditorcommon.h"
    59 #include "caleneditorcommon.h"
    61 #include "calendateutils.h"
    60 #include "calendateutils.h"
       
    61 #include "calenagendautils.h"
    62 #include "caleneditordatahandler.h"
    62 #include "caleneditordatahandler.h"
    63 #include "caleneditorreminderfield.h"
    63 #include "caleneditorreminderfield.h"
    64 #include "caleneditorrepeatfield.h"
    64 #include "caleneditorrepeatfield.h"
    65 #include "OstTraceDefinitions.h"
    65 #include "OstTraceDefinitions.h"
    66 #ifdef OST_TRACE_COMPILER_IN_USE
    66 #ifdef OST_TRACE_COMPILER_IN_USE
    67 #include "caleneditor_pTraces.h"
    67 #include "caleneditor_pTraces.h"
    68 #endif
    68 #endif
    69 
       
    70 // Constants
       
    71 const int SecsInOneYear( 3600 );
       
    72 
       
    73 
    69 
    74 /*!
    70 /*!
    75 	\class CalenEditorPrivate
    71 	\class CalenEditorPrivate
    76 	This object loads the calendar editor view. The view is added to the top
    72 	This object loads the calendar editor view. The view is added to the top
    77 	of the HbMainWindow.
    73 	of the HbMainWindow.
   578 
   574 
   579 	if (!mNewEntry) {
   575 	if (!mNewEntry) {
   580 		AgendaEntry::Type entryType = mEditedEntry->type();
   576 		AgendaEntry::Type entryType = mEditedEntry->type();
   581 		if( entryType == AgendaEntry::TypeAppoinment) {
   577 		if( entryType == AgendaEntry::TypeAppoinment) {
   582 			headingWidget->setHeading(hbTrId("txt_calendar_subhead_meeting"));
   578 			headingWidget->setHeading(hbTrId("txt_calendar_subhead_meeting"));
   583 		}else if(entryType == AgendaEntry::TypeEvent) {
   579 		}else if(CalenAgendaUtils::isAlldayEvent(*mEditedEntry)) {
   584 			headingWidget->setHeading(hbTrId("txt_calendar_subhead_all_day_event"));
   580 			headingWidget->setHeading(hbTrId("txt_calendar_subhead_all_day_event"));
   585 		}else if (entryType == AgendaEntry::TypeTodo) {
   581 		}else if (entryType == AgendaEntry::TypeTodo) {
   586 			headingWidget->setHeading(hbTrId("txt_calendar_subhead_to_do"));
   582 			headingWidget->setHeading(hbTrId("txt_calendar_subhead_to_do"));
   587 		}
   583 		}
   588 		
   584 		
   820  */
   816  */
   821 void CalenEditorPrivate::populateSubjectItem()
   817 void CalenEditorPrivate::populateSubjectItem()
   822 {
   818 {
   823 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_POPULATESUBJECTITEM_ENTRY );
   819 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_POPULATESUBJECTITEM_ENTRY );
   824 	mSubjectItem->setContentWidgetData("text", mEditedEntry->summary());
   820 	mSubjectItem->setContentWidgetData("text", mEditedEntry->summary());
   825 	mSubjectItem->setContentWidgetData("minRows", 2);
   821 	mSubjectItem->setContentWidgetData("maxRows", MaxRowsInTextItem);
   826 	mSubjectItem->setContentWidgetData("maxRows", 4);
   822 	mSubjectItem->setContentWidgetData("maxLength", MaxCharacterLimit);
   827 	mSubjectItem->setContentWidgetData("objectName", "subjectItem");
   823 	mSubjectItem->setContentWidgetData("objectName", "subjectItem");
   828 	mCalenEditorForm->addConnection(mSubjectItem,
   824 	mCalenEditorForm->addConnection(mSubjectItem,
   829 	                                SIGNAL(textChanged(const QString)), this,
   825 	                                SIGNAL(textChanged(const QString)), this,
   830 	                                SLOT(handleSubjectChange(const QString)));
   826 	                                SLOT(handleSubjectChange(const QString)));
   831 	OstTraceFunctionExit0( CALENEDITORPRIVATE_POPULATESUBJECTITEM_EXIT );
   827 	OstTraceFunctionExit0( CALENEDITORPRIVATE_POPULATESUBJECTITEM_EXIT );
   837 void CalenEditorPrivate::populateAllDayItem()
   833 void CalenEditorPrivate::populateAllDayItem()
   838 {
   834 {
   839 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_POPULATEALLDAYITEM_ENTRY );
   835 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_POPULATEALLDAYITEM_ENTRY );
   840 	mAllDayCheckBoxItem->setContentWidgetData("text",
   836 	mAllDayCheckBoxItem->setContentWidgetData("text",
   841 									hbTrId("txt_calendar_list_all_day_event"));
   837 									hbTrId("txt_calendar_list_all_day_event"));
   842 	if (AgendaEntry::TypeEvent == mEditedEntry->type()) {
   838 	if (CalenAgendaUtils::isAlldayEvent(*mEditedEntry)) {
   843 		//If All day is enabled.
   839 		//If All day is enabled.
   844 		mAllDayCheckBoxItem->setContentWidgetData("checkState", Qt::Checked);
   840 		mAllDayCheckBoxItem->setContentWidgetData("checkState", Qt::Checked);
   845 	}
   841 	}
   846 	mAllDayCheckBoxItem->setContentWidgetData("objectName", "allDayItem");
   842 	mAllDayCheckBoxItem->setContentWidgetData("objectName", "allDayItem");
   847 	mCalenEditorForm->addConnection(mAllDayCheckBoxItem,
   843 	mCalenEditorForm->addConnection(mAllDayCheckBoxItem,
   852 }
   848 }
   853 
   849 
   854 /*!
   850 /*!
   855 	Calculates default time when Event is on same day.
   851 	Calculates default time when Event is on same day.
   856  */
   852  */
   857 QTime CalenEditorPrivate::defaultTimeSameDay()
   853 QDateTime CalenEditorPrivate::defaultTimeSameDay( )
   858 {
   854 {
   859 	QTime currentTime = QTime::currentTime();
   855 	QDateTime currentDateTime = QDateTime::currentDateTime();
   860 	
   856 	
   861 	//Start time should be one hour more than current time.
   857 	//Start time should be one hour more than current time.
   862 	currentTime = currentTime.addSecs(SecsInOneYear);
   858 	currentDateTime = currentDateTime.addSecs(SecsInOneHour);
   863 
   859 
   864 	int hour = currentTime.hour();
   860 	int hour = currentDateTime.time().hour();
   865 	int minutes = currentTime.minute();
   861 	int minutes = currentDateTime.time().minute();
   866 	bool addHour = 0;
   862 	bool addHour = 0;
   867 
   863 
   868 	//If the current time is within 15 mins after adding one hour, minutes will be rounded off to 0.
   864 	//If the current time is within 15 mins after adding one hour, minutes will be rounded off to 0.
   869 	// Like if current time is 7:14 am, plus one hour is 8:14 am and it will be rounded off to 8:00am
   865 	// Like if current time is 7:14 am, plus one hour is 8:14 am and it will be rounded off to 8:00am
   870 	//For time between 15 and 45 mins, its rounded off to 30 mins 
   866 	//For time between 15 and 45 mins, its rounded off to 30 mins 
   875 		minutes = 30;
   871 		minutes = 30;
   876 	}else {
   872 	}else {
   877 		minutes = 0;
   873 		minutes = 0;
   878 		addHour = 1;
   874 		addHour = 1;
   879 	}
   875 	}
   880 	currentTime.setHMS(hour, minutes, 0, 0);
   876 	QTime tempTime;
       
   877 	tempTime.setHMS(hour, minutes, 0, 0);
       
   878 	currentDateTime.setTime(tempTime);
       
   879 	
   881 	if (addHour) {
   880 	if (addHour) {
   882 		currentTime = currentTime.addSecs(SecsInOneYear);
   881 		currentDateTime = currentDateTime.addSecs(SecsInOneHour);
   883 	}
   882 	}
   884 	return currentTime;
   883 	
       
   884 	// After adding one hour and rounding off the minutes to current time,
       
   885 	// if midnight crossover happens return default time(8:00 am) for next day
       
   886 	if(CalenDateUtils::isOnToday(currentDateTime))
       
   887 		return currentDateTime;
       
   888 	else
       
   889 		return CalenDateUtils::defaultTime(currentDateTime);
   885 }
   890 }
   886 
   891 
   887 /*!
   892 /*!
   888 	Sets to default time, when AllDay is unchecked
   893 	Sets to default time, when AllDay is unchecked
   889  */
   894  */
   895 	
   900 	
   896 	// The default time will be 8.00 am only if its not on current day
   901 	// The default time will be 8.00 am only if its not on current day
   897 	// else the time is calculated accordingly
   902 	// else the time is calculated accordingly
   898 	bool isSameDay = CalenDateUtils::isOnToday(fromDateTime);
   903 	bool isSameDay = CalenDateUtils::isOnToday(fromDateTime);
   899 	if (isSameDay) {
   904 	if (isSameDay) {
   900 		fromDateTime.setDate(fromDateTime.date());
   905 		fromDateTime = defaultTimeSameDay();
   901 		fromDateTime.setTime(defaultTimeSameDay());
   906 	}
   902 	}
   907 	mViewFromItem->populateDateTime(fromDateTime, true);
   903 	mNewEntryDateTime = fromDateTime;
   908 	mNewEntryDateTime = fromDateTime;
   904 	toDateTime = fromDateTime.addSecs(SecsInOneYear);
   909 
       
   910 	toDateTime = fromDateTime.addSecs(SecsInOneHour);
       
   911 	mViewToItem->populateDateTime(toDateTime, false);
   905 
   912 
   906 	// Set the default start time to the event.
   913 	// Set the default start time to the event.
   907 	mEditedEntry->setStartAndEndTime(fromDateTime, toDateTime);
   914 	mEditedEntry->setStartAndEndTime(fromDateTime, toDateTime);
   908 }	
   915 }	
   909 
   916 
   949 		fromDateTime = mEditedEntry->startTime();
   956 		fromDateTime = mEditedEntry->startTime();
   950 	} else {
   957 	} else {
   951 		// Check if it is on same day and set the default time and date accordingly.
   958 		// Check if it is on same day and set the default time and date accordingly.
   952 		bool isSameDay = CalenDateUtils::isOnToday(fromDateTime);
   959 		bool isSameDay = CalenDateUtils::isOnToday(fromDateTime);
   953 		if (isSameDay) {
   960 		if (isSameDay) {
   954 			fromDateTime.setDate(fromDateTime.date());
   961 			fromDateTime = defaultTimeSameDay();
   955 			fromDateTime.setTime(defaultTimeSameDay());
       
   956 		}
   962 		}
   957 	}
   963 	}
   958 	mViewFromItem->populateDateTime(fromDateTime, true);
   964 	mViewFromItem->populateDateTime(fromDateTime, true);
   959 	mNewEntryDateTime = fromDateTime;
   965 	mNewEntryDateTime = fromDateTime;
   960 
   966 
  1020 				nextInstanceStartTime.date()) == 1)) {
  1026 				nextInstanceStartTime.date()) == 1)) {
  1021 				mViewFromItem->disableFromToDateField();
  1027 				mViewFromItem->disableFromToDateField();
  1022 			}
  1028 			}
  1023 		}
  1029 		}
  1024 	} else {
  1030 	} else {
  1025 		toDateTime = fromDateTime.addSecs(SecsInOneYear);
  1031 		toDateTime = fromDateTime.addSecs(SecsInOneHour);
  1026 	}
  1032 	}
  1027 	mViewToItem->populateDateTime(toDateTime, false);
  1033 	mViewToItem->populateDateTime(toDateTime, false);
  1028 
  1034 
  1029 	// Set the default start time to the event.
  1035 	// Set the default start time to the event.
  1030 	mEditedEntry->setStartAndEndTime(fromDateTime, toDateTime);
  1036 	mEditedEntry->setStartAndEndTime(fromDateTime, toDateTime);
  1031 	// Set the default start time to the Original entry if its a new event.
  1037 	// Set the default start time to the Original entry if its a new event.
  1032 	if (mNewEntry) {
  1038 	if (mNewEntry) {
  1033 		mOriginalEntry->setStartAndEndTime(fromDateTime, toDateTime);
  1039 		mOriginalEntry->setStartAndEndTime(fromDateTime, toDateTime);
  1034 	}
  1040 	}
  1035 	if ((mAllDayCheckBoxItem && 
  1041 	if (isAllDayEvent()) {
  1036 		(mAllDayCheckBoxItem->contentWidgetData("checkState") == Qt::Checked))
       
  1037 		|| (!mNewEntry && mEditedEntry->type() == AgendaEntry::TypeEvent)) {
       
  1038         
       
  1039         // For all-day, we need to substratc 1 minute to get the actual end time
  1042         // For all-day, we need to substratc 1 minute to get the actual end time
  1040         // as we store all-day as 12.00AM to 12.00 AM next day
  1043         // as we store all-day as 12.00AM to 12.00 AM next day
  1041         QDateTime actualEndTime = mEditedEntry->endTime().addSecs(-60);
  1044         QDateTime actualEndTime = mEditedEntry->endTime().addSecs(-60);
  1042         // Set it back to mEditedEntry
  1045         // Set it back to mEditedEntry
  1043         mEditedEntry->setStartAndEndTime(mEditedEntry->startTime(), actualEndTime);
  1046         mEditedEntry->setStartAndEndTime(mEditedEntry->startTime(), actualEndTime);
  1094 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_SAVEFROMDATETIME_ENTRY );
  1097 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_SAVEFROMDATETIME_ENTRY );
  1095 	QDateTime endTime = mEditedEntry->endTime();
  1098 	QDateTime endTime = mEditedEntry->endTime();
  1096 	// Update the end time accordingly on UI - duration will be 60 mins
  1099 	// Update the end time accordingly on UI - duration will be 60 mins
  1097 	// bydefault only while creating new entry and if it crossed the endtime
  1100 	// bydefault only while creating new entry and if it crossed the endtime
  1098 	if (mNewEntry && fromDateTime > endTime) {
  1101 	if (mNewEntry && fromDateTime > endTime) {
  1099 		endTime = fromDateTime.addSecs(SecsInOneYear);
  1102 		endTime = fromDateTime.addSecs(SecsInOneHour);
  1100 	} else { // for existing entry
  1103 	} else { // for existing entry
  1101 		// we need to see if user has moved start time beyond the end time
  1104 		// we need to see if user has moved start time beyond the end time
  1102 		// then add the duration of the meeting that was saved earlier to the 
  1105 		// then add the duration of the meeting that was saved earlier to the 
  1103 		// new start time to get the new end time
  1106 		// new start time to get the new end time
  1104 		if (fromDateTime > endTime) {
  1107 		if (fromDateTime > endTime) {
  1128 	QDate referenceDate;
  1131 	QDate referenceDate;
  1129 	
  1132 	
  1130 	// Start date or repeat until date will be the reference to decide 
  1133 	// Start date or repeat until date will be the reference to decide 
  1131 	// whether the event is in past or future.
  1134 	// whether the event is in past or future.
  1132 	if (mRepeatField && mRepeatField->isRepeatUntilItemAdded()) {
  1135 	if (mRepeatField && mRepeatField->isRepeatUntilItemAdded()) {
       
  1136 		// For repeating entries reminder options will be provided only
       
  1137 		// when the repeatuntil date is in future
  1133 		referenceDate = mRepeatField->repeatUntilDate();
  1138 		referenceDate = mRepeatField->repeatUntilDate();
  1134 	} else {
  1139 	} else {
  1135 		referenceDate = mEditedEntry->startTime().date();
  1140 		referenceDate = mEditedEntry->startTime().date();
  1136 	}
  1141 	}
  1137 	
  1142 	
  1138 	// Check if all day event or not.
  1143 	// Check if all day event or not.
  1139 	if (isAllDayEvent()) {
  1144 	if (isAllDayEvent()) {
  1140 		int currentIndex = mReminderField->currentReminderIndex();
       
  1141 		mReminderField->updateReminderChoicesForAllDay(referenceDate);
  1145 		mReminderField->updateReminderChoicesForAllDay(referenceDate);
  1142 		int numberOfReminderChoices = mReminderField->reminderItemsCount();
  1146 	} else {
  1143 		if (currentIndex >= numberOfReminderChoices) {
       
  1144 			currentIndex = 0;
       
  1145 			mReminderField->disableReminderTimeField();
       
  1146 		} 
       
  1147 		mReminderField->setCurrentIndex(currentIndex);
       
  1148 		if(currentIndex == 0 && mReminderField->isReminderTimeForAllDayAdded()) {
       
  1149 			mReminderField->removeReminderTimeField();
       
  1150 		}
       
  1151 	} else { 
       
  1152 		if ((referenceDate < QDate::currentDate())
  1147 		if ((referenceDate < QDate::currentDate())
  1153 						|| (referenceDate == QDate::currentDate()
  1148 						|| (referenceDate == QDate::currentDate()
  1154 				&& (mEditedEntry->startTime().time() < QTime::currentTime())))
  1149 				&& (mEditedEntry->startTime().time() < QTime::currentTime())))
  1155 				 {
  1150 				 {
  1156 					mReminderField->setReminderOff();
  1151 					mReminderField->setReminderOff();
  1157 		} else {
  1152 		} else {
  1158 			// Enabled implies future. If changing from future to future do not 
  1153 			// Enabled implies future. If changing from future to future do not 
  1159 			// do anything.
  1154 			// do anything.
  1160 			if (!mReminderField->isReminderFieldEnabled()) {
  1155 			if (!mReminderField->isReminderFieldEnabled()) {
  1161 				mReminderField->setReminderChoices();
  1156 				mReminderField->setReminderChoices();
       
  1157 				// Set the default alarm time 15 minutes before
       
  1158 				mReminderField->setCurrentIndex(2);
  1162 			}
  1159 			}
  1163 		}
  1160 		}
  1164 	}
  1161 	}
  1165 	OstTraceFunctionExit0( CALENEDITORPRIVATE_UPDATEREMINDERCHOICES_EXIT );
  1162 	OstTraceFunctionExit0( CALENEDITORPRIVATE_UPDATEREMINDERCHOICES_EXIT );
  1166 }
  1163 }
  1174 	QDateTime startTime = mEditedEntry->startTime();
  1171 	QDateTime startTime = mEditedEntry->startTime();
  1175 	bool fromDateChanged = false;
  1172 	bool fromDateChanged = false;
  1176 	// Update the start time accordingly on UI - duration will be 60 mins
  1173 	// Update the start time accordingly on UI - duration will be 60 mins
  1177 	// bydefault for new entry and if it crosses the starttime
  1174 	// bydefault for new entry and if it crosses the starttime
  1178 	if (mNewEntry && toDateTime < startTime) {
  1175 	if (mNewEntry && toDateTime < startTime) {
  1179 		startTime = toDateTime.addSecs(-SecsInOneYear);
  1176 		startTime = toDateTime.addSecs(-SecsInOneHour);
  1180 		fromDateChanged = true;
  1177 		fromDateChanged = true;
  1181 	} else { 
  1178 	} else { 
  1182 		// for exisitng entry
  1179 		// for exisitng entry
  1183 		// we need to see if user has moved end time before the start time
  1180 		// we need to see if user has moved end time before the start time
  1184 		// then substract the duration of the meeting that was saved earlier to 
  1181 		// then substract the duration of the meeting that was saved earlier to 
  1255 									descIndex, HbDataFormModelItem::TextItem,
  1252 									descIndex, HbDataFormModelItem::TextItem,
  1256 									QString(hbTrId(
  1253 									QString(hbTrId(
  1257 									"txt_calendar_formlabel_val_description")),
  1254 									"txt_calendar_formlabel_val_description")),
  1258 									mCalenEditorModel->invisibleRootItem());
  1255 									mCalenEditorModel->invisibleRootItem());
  1259 	mDescriptionItem->setContentWidgetData("text", mEditedEntry->description());
  1256 	mDescriptionItem->setContentWidgetData("text", mEditedEntry->description());
  1260 	mDescriptionItem->setContentWidgetData("minRows", 2);
  1257 	mDescriptionItem->setContentWidgetData("maxRows", MaxRowsInTextItem);
  1261 	mDescriptionItem->setContentWidgetData("maxRows", 4);
       
  1262 	mDescriptionItem->setContentWidgetData("objectName", "descriptionItem");
  1258 	mDescriptionItem->setContentWidgetData("objectName", "descriptionItem");
  1263 	mCalenEditorForm->addConnection(
  1259 	mCalenEditorForm->addConnection(
  1264 								mDescriptionItem,
  1260 								mDescriptionItem,
  1265 								SIGNAL(textChanged(const QString)), this,
  1261 								SIGNAL(textChanged(const QString)), this,
  1266 								SLOT(handleDescriptionChange(const QString)));
  1262 								SLOT(handleDescriptionChange(const QString)));
  1353 		if (mRepeatField->isRepeatUntilItemAdded()) {
  1349 		if (mRepeatField->isRepeatUntilItemAdded()) {
  1354 			referenceDate = mRepeatField->repeatUntilDate();
  1350 			referenceDate = mRepeatField->repeatUntilDate();
  1355 		} else {
  1351 		} else {
  1356 			referenceDate = mEditedEntry->startTime().date();
  1352 			referenceDate = mEditedEntry->startTime().date();
  1357 		}
  1353 		}
       
  1354 		// For the transition from normal entry to all day - set reminder off
       
  1355 		// This is  to avoid conflict in the reminder time as 
       
  1356 		// the index set for the normal meeting may not be valid for an allday 
       
  1357 		// Set it off before doing the reminder updation for all day
       
  1358 		mReminderField->setCurrentIndex(0);
  1358 		mReminderField->updateReminderChoicesForAllDay(referenceDate);
  1359 		mReminderField->updateReminderChoicesForAllDay(referenceDate);
  1359 		// If the reminder field is enabled and it is not off 
  1360 		// If the reminder field is enabled and it is not off 
  1360 		// it implies default alarm day and time is being displayed.
  1361 		// it implies default alarm day and time is being displayed.
  1361 		if (mReminderField->isReminderFieldEnabled() && 
  1362 		if (mReminderField->isReminderFieldEnabled() && 
  1362 					mReminderField->currentReminderIndex() != 0) {
  1363 					mReminderField->currentReminderIndex() != 0) {
  1374 		// Update Start/End Times with Edited entry values
  1375 		// Update Start/End Times with Edited entry values
  1375 		enableFromTotimeFileds(true, mEditedEntry->startTime(),
  1376 		enableFromTotimeFileds(true, mEditedEntry->startTime(),
  1376 		                       mEditedEntry->endTime());
  1377 		                       mEditedEntry->endTime());
  1377 		mReminderField->removeReminderTimeField();
  1378 		mReminderField->removeReminderTimeField();
  1378 		mReminderField->setReminderChoices();
  1379 		mReminderField->setReminderChoices();
       
  1380 		// Set the default alarm time 15 minutes before
       
  1381 		mReminderField->setCurrentIndex(2);
  1379 		updateReminderChoices();
  1382 		updateReminderChoices();
  1380 	}
  1383 	}
  1381 
  1384 
  1382 	if(!mNewEntry){
  1385 	if(!mNewEntry){
  1383 		addDiscardAction();
  1386 		addDiscardAction();
  1640 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_HANDLEDONE_ENTRY );
  1643 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_HANDLEDONE_ENTRY );
  1641 	if (mEditRange == ThisAndAll) {
  1644 	if (mEditRange == ThisAndAll) {
  1642 		mRepeatField->saveRepeatRule();
  1645 		mRepeatField->saveRepeatRule();
  1643 	}
  1646 	}
  1644 	
  1647 	
  1645  	// Set back the all day endtime back 
  1648  	// Set the all-day endtime back
  1646 	 if(mOriginalEntry->type() == AgendaEntry::TypeEvent) { 
  1649 	if(isAllDayEvent()) {
  1647 		 // The time has to be set for the allday exceptional entries and 
  1650 		// Set the all-day end time to 12:00AM to next day here only
  1648 		 // while editing all the instances of a repeating all day entry 
  1651 		// In case if user doesnt change/edit anything then, 
  1649 		 if(mEditRange == ThisOnly || 
  1652 		// we shall not show "Entry updated" popup
  1650 		 	(mAllDayCheckBoxItem && 
  1653 		QDateTime actualStartTime =
  1651 		 	mAllDayCheckBoxItem->contentWidgetData("checkState") == Qt::Checked)) {
  1654 				CalenDateUtils::beginningOfDay(mEditedEntry->startTime());
  1652  			// Set EndTime of AllDay event to 00:00:00 of next day
  1655 
  1653 			QDateTime actualEndTime = mEditedEntry->endTime().addSecs(60);
  1656 		// Set EndTime of AllDay event to 00:00:00 of next day
  1654 			mEditedEntry->setStartAndEndTime(mEditedEntry->startTime(), actualEndTime);
  1657 		QDateTime actualEndTime = mEditedEntry->endTime().addDays(1);
  1655 		}
  1658 		QTime tempEndQTime = actualEndTime.time();
       
  1659 		tempEndQTime.setHMS(0, 0, 0);
       
  1660 		actualEndTime.setTime(tempEndQTime);
       
  1661 		// Set the start and end time properly
       
  1662 		mEditedEntry->setStartAndEndTime(actualStartTime, actualEndTime);
  1656 	}
  1663 	}
  1657 	
  1664 	
  1658 	// TODO: Need to check entry status here. EntryStillExistsL
  1665 	// TODO: Need to check entry status here. EntryStillExistsL
  1659 	switch (mDataHandler->shouldSaveOrDeleteOrDoNothing(mLaunchCalendar)) {
  1666 	switch (mDataHandler->shouldSaveOrDeleteOrDoNothing(mLaunchCalendar)) {
  1660 		case CalenEditorPrivate::ActionSave:
  1667 		case CalenEditorPrivate::ActionSave:
  1694 		}
  1701 		}
  1695 	}
  1702 	}
  1696 	if (mNewEntry) {
  1703 	if (mNewEntry) {
  1697 		if(mEditedEntry->type() == AgendaEntry::TypeAppoinment) {
  1704 		if(mEditedEntry->type() == AgendaEntry::TypeAppoinment) {
  1698 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_new_meeting_saved"));
  1705 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_new_meeting_saved"));
  1699 		} else if(mEditedEntry->type() == AgendaEntry::TypeEvent) {
  1706 		} else if(isAllDayEvent()) {
  1700 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_new_all_day_event_saved"));
  1707 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_new_all_day_event_saved"));
  1701 		}
  1708 		}
  1702 	} else {
  1709 	} else {
  1703 		if(mEditedEntry->type() == AgendaEntry::TypeAppoinment) {
  1710 		if(mEditedEntry->type() == AgendaEntry::TypeAppoinment) {
  1704 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_meeting_updated"));
  1711 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_meeting_updated"));
  1705 		} else if(mEditedEntry->type() == AgendaEntry::TypeEvent) {
  1712 		} else if(isAllDayEvent()) {
  1706 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_all_day_event_updated"));
  1713 			HbNotificationDialog::launchDialog(hbTrId("txt_calendar_dpopinfo_all_day_event_updated"));
  1707 		}
  1714 		}
  1708 	}
  1715 	}
  1709 	emit q_ptr->entrySaved();
  1716 	emit q_ptr->entrySaved();
  1710 	OstTraceFunctionExit0( DUP2_CALENEDITORPRIVATE_SAVEENTRY_EXIT );
  1717 	OstTraceFunctionExit0( DUP2_CALENEDITORPRIVATE_SAVEENTRY_EXIT );
  1745  */
  1752  */
  1746 bool CalenEditorPrivate::handleAllDayToSave()
  1753 bool CalenEditorPrivate::handleAllDayToSave()
  1747 {
  1754 {
  1748     OstTraceFunctionEntry0( CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_ENTRY );
  1755     OstTraceFunctionEntry0( CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_ENTRY );
  1749 
  1756 
  1750     QDateTime tempSartTime =
  1757     // Check the state of AllDay checkBox
  1751             CalenDateUtils::beginningOfDay(mEditedEntry->startTime());
  1758     // If the all day item was not added, definitely its an instance of a 
  1752 
  1759     // repeating entry(TypeAppoinment or TypeEvent)
  1753     // Set EndTime of AllDay event to 00:00:00 of next day
  1760     // In this case the parent entry type should not be changed
  1754     QDateTime tempEndTime = mEditedEntry->endTime().addDays(1);
  1761     // so return false
  1755     QTime tempEndQTime = tempEndTime.time();
  1762 	if (!mIsAllDayItemAdded) {
  1756     tempEndQTime.setHMS(0, 0, 0);
       
  1757     tempEndTime.setTime(tempEndQTime);
       
  1758 	
       
  1759     // Check the state of AllDay checkBox and 
       
  1760     // Check whether allday event is exceptional or not.
       
  1761 	if (!mIsAllDayItemAdded && (mOriginalEntry->type() == AgendaEntry::TypeEvent)) {
       
  1762 		
       
  1763 	    // All day item was not added, return false
  1763 	    // All day item was not added, return false
  1764 	    mEditedEntry->setStartAndEndTime(tempSartTime, tempEndTime);
       
  1765 		OstTraceFunctionExit0( CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1764 		OstTraceFunctionExit0( CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1766 		return false;
  1765 		return false;
  1767 	}
  1766 	}
  1768 
  1767 
       
  1768 	// If the entry type is getting changed say TypeEvent to TypeAppoinment
       
  1769 	// or TypeAppoinment to TypeEvent then,
       
  1770 	// Clone the entry to the new type and Delete old entry from Database
       
  1771 	// So checking all the possible type conversions and other cases
       
  1772 	
  1769 	// If Creating new Entry and AllDay Box is checked.
  1773 	// If Creating new Entry and AllDay Box is checked.
  1770 	// Clone the entry to AllDay 
  1774 	// Just return false to save it.
  1771 	if (mNewEntry && (mAllDayCheckBoxItem->contentWidgetData("checkState")
  1775 	if (mNewEntry && (mAllDayCheckBoxItem->contentWidgetData("checkState")
  1772 	        == Qt::Checked)) {
  1776 															== Qt::Checked)) {
  1773 		// changes Start/End times of entry to Beginning ot the day
       
  1774 		mEditedEntry->setStartAndEndTime(tempSartTime, tempEndTime);
       
  1775 		mEditedEntry->setType(AgendaEntry::TypeEvent);
  1777 		mEditedEntry->setType(AgendaEntry::TypeEvent);
  1776 		OstTraceFunctionExit0( DUP1_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1778 		OstTraceFunctionExit0( DUP1_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1777 		return false;
  1779 		return false;
  1778 	} else if ((mAllDayCheckBoxItem->contentWidgetData("checkState")
  1780 	} else if ((mAllDayCheckBoxItem->contentWidgetData("checkState")
  1779 	        == Qt::Checked) && (mEditedEntry->type() != 
  1781 															== Qt::Checked)) {
  1780 								AgendaEntry::TypeEvent)) {
  1782 		bool isAllDayEvent = CalenAgendaUtils::isAlldayEvent(*mOriginalEntry);
  1781 		// Editing existing Meetingentry, and Alldat Box is Checked
  1783 		// Editing existing Meeting entry, and Allday Box is Checked
  1782 		// changes Start/End times of entry to Beginning ot the day
  1784 		if (!isAllDayEvent) {
  1783 		mEditedEntry->setStartAndEndTime(tempSartTime, tempEndTime);
  1785 			// Clone the entry to AllDayEntry, Delete old entry from Database
  1784 
  1786 			mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeEvent);
  1785 		// Clone the entry to AllDayEntry, Delete old entry from Database
  1787 			// For later reference for the notification popup
  1786 		mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeEvent);
  1788 			mEditedEntry->setType(AgendaEntry::TypeEvent);
  1787 		// For later reference for the notification popup
  1789 			OstTraceFunctionExit0( DUP7_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1788 		mEditedEntry->setType(AgendaEntry::TypeEvent);
  1790 			return true;
       
  1791 		}
  1789 		OstTraceFunctionExit0( DUP2_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1792 		OstTraceFunctionExit0( DUP2_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1790 		return true;
  1793 		// Return false since the entry is already an all day entry 
       
  1794 		// so cloning not required. Just save it.
       
  1795 		return false;
  1791 	} else if (mAllDayCheckBoxItem->contentWidgetData("checkState")
  1796 	} else if (mAllDayCheckBoxItem->contentWidgetData("checkState")
  1792 	        != Qt::Checked) {
  1797 															!= Qt::Checked) {
  1793              if (mEditedEntry->type() != AgendaEntry::TypeAppoinment) {
  1798 		if (mEditedEntry->type() != AgendaEntry::TypeAppoinment) {
  1794 	            // Editing existing AllDayentry, and Alldat Box is Not-Checked
  1799 			// Editing existing AllDayentry, and Allday Box is Not-Checked
  1795 	            // Clone the entry to MeetingEntry, Delete old entry from Database
  1800 			// Clone the entry to MeetingEntry, Delete old entry from Database
  1796 	            mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeAppoinment);
  1801 			mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeAppoinment);
  1797 	            // For later reference for the notification popup
  1802 			// For later reference for the notification popup
  1798 	            mEditedEntry->setType(AgendaEntry::TypeAppoinment);
  1803 			mEditedEntry->setType(AgendaEntry::TypeAppoinment);
  1799 	            OstTraceFunctionExit0( DUP3_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1804 			OstTraceFunctionExit0( DUP3_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1800 	            return true;
  1805 			return true;
  1801 	        }
  1806 		} else if (CalenAgendaUtils::isAlldayEvent(*mOriginalEntry)) {
  1802             // Check if the duration of the meeting is matching the all-day criteria
  1807 			// This else case will be executed when the original entry is
  1803             // if yes, then we need to store it as all-day instead of normal meeting
  1808 			// an all day and the entry type is still TypeAppoinment.
  1804              else if (mEditedEntry->startTime() == CalenDateUtils::beginningOfDay(mEditedEntry->startTime())) {
  1809 			// eg: Outlook synced all day entry type will be still TypeAppoinment
  1805             // Get the end time and see if it is at the beginning of the end date day
  1810 			// In this case cloning is not required but entry has to be saved.
  1806             if (mEditedEntry->endTime() == CalenDateUtils::beginningOfDay(mEditedEntry->endTime())) {
  1811 			// So return false
  1807                 // Store it as all-day
  1812 			OstTraceFunctionExit0( DUP8_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1808                 mEditedEntry->setType(AgendaEntry::TypeEvent);
  1813 			// save it
  1809                 // Check if this was an all-day earlier and now user has changed it like that
  1814 			return false;
  1810                 // or it is a new entry
  1815 		}
  1811                 if (mOriginalEntry->type() == AgendaEntry::TypeEvent ||
  1816 		// Check if the duration of the meeting is matching the all-day criteria
  1812                         mNewEntry) {
  1817 		// if yes, then we need to store it as all-day instead of normal meeting
  1813                     OstTraceFunctionExit0( DUP4_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1818 		else if (mEditedEntry->startTime() == 
  1814                     return false;
  1819 					CalenDateUtils::beginningOfDay(mEditedEntry->startTime())) {
  1815                 } else {
  1820 			// Get the end time and see if it is at the beginning of the end date day
  1816                     // It was a meeting
  1821 			if (mEditedEntry->endTime() == 
  1817                     // Clone the entry to AllDayEntry, Delete old entry from Database
  1822 					CalenDateUtils::beginningOfDay(mEditedEntry->endTime())) {
  1818                     mEditedEntry->setStartAndEndTime(tempSartTime, tempEndTime);
  1823 				// Since the start and end time matches the all day criteria
  1819                     mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeEvent);
  1824 				// Store it as all-day
  1820                     // For later reference for the notification popup
  1825 				mEditedEntry->setType(AgendaEntry::TypeEvent);
  1821                     mEditedEntry->setType(AgendaEntry::TypeEvent);
  1826 				// Check if this was an all-day earlier and now user 
  1822                     OstTraceFunctionExit0( DUP5_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1827 				// has changed it like that or it is a new entry
  1823                     return true;
  1828 				if (mOriginalEntry->type() == AgendaEntry::TypeEvent ||
  1824                 }
  1829 						mNewEntry) {
  1825             }
  1830 					OstTraceFunctionExit0( DUP4_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1826         } 
  1831 					return false;
       
  1832 				} else {
       
  1833 					// It was a meeting
       
  1834 					// Clone the entry to AllDayEntry, 
       
  1835 					// And Delete old entry from Database
       
  1836 					mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeEvent);
       
  1837 					// For later reference for the notification popup
       
  1838 					mEditedEntry->setType(AgendaEntry::TypeEvent);
       
  1839 					OstTraceFunctionExit0( DUP5_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
       
  1840 					return true;
       
  1841 				}
       
  1842 			}
       
  1843 		} 
  1827 	} 
  1844 	} 
  1828 	OstTraceFunctionExit0( DUP6_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1845 	OstTraceFunctionExit0( DUP6_CALENEDITORPRIVATE_HANDLEALLDAYTOSAVE_EXIT );
  1829 	return false;
  1846 	return false;
  1830 }
  1847 }
  1831 
  1848 
  1902 {
  1919 {
  1903 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_ISALLDAYEVENT_ENTRY );
  1920 	OstTraceFunctionEntry0( CALENEDITORPRIVATE_ISALLDAYEVENT_ENTRY );
  1904 	if (mAllDayCheckBoxItem) {
  1921 	if (mAllDayCheckBoxItem) {
  1905 		return (mAllDayCheckBoxItem->contentWidgetData("checkState") 
  1922 		return (mAllDayCheckBoxItem->contentWidgetData("checkState") 
  1906 													== Qt::Checked)? true:false;
  1923 													== Qt::Checked)? true:false;
  1907 	} else if (!mNewEntry && mEditedEntry->type() == AgendaEntry::TypeEvent) {
  1924 	} else if (!mNewEntry && CalenAgendaUtils::isAlldayEvent(*mOriginalEntry)) {
  1908 		// If editing single occurence then all day item not shown but still it 
  1925 		// This else is for exceptional entries
  1909 		// is an all day event..
  1926 		// While editing a single occurence, the type of the entry 
       
  1927 		// should not be changed so the allday item won't be shown in editor
       
  1928 		// even if its of TypeEvent or TypeAppoinment
       
  1929 		// So checking for the original entry type
  1910 		OstTraceFunctionExit0( CALENEDITORPRIVATE_ISALLDAYEVENT_EXIT );
  1930 		OstTraceFunctionExit0( CALENEDITORPRIVATE_ISALLDAYEVENT_EXIT );
  1911 		return true;;
  1931 		return true;;
  1912 	} else {
  1932 	} else {
  1913 		OstTraceFunctionExit0( DUP1_CALENEDITORPRIVATE_ISALLDAYEVENT_EXIT );
  1933 		OstTraceFunctionExit0( DUP1_CALENEDITORPRIVATE_ISALLDAYEVENT_EXIT );
  1914 		return false;
  1934 		return false;