calendarui/caleneditor/src/caleneditordatahandler.cpp
changeset 51 0b38fc5b94c6
parent 23 fd30d51f876b
child 55 2c54b51f39c4
equal deleted inserted replaced
46:ecd7b9840282 51:0b38fc5b94c6
    22 
    22 
    23 // User Includes
    23 // User Includes
    24 #include "caleneditordatahandler.h"
    24 #include "caleneditordatahandler.h"
    25 #include "calendateutils.h"
    25 #include "calendateutils.h"
    26 #include "agendaentry.h"
    26 #include "agendaentry.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "caleneditordatahandlerTraces.h"
       
    30 #endif
       
    31 
    27 
    32 
    28 /*!
    33 /*!
    29 	\class CalenEditorDataHandler
    34 	\class CalenEditorDataHandler
    30  */
    35  */
    31 /*!
    36 /*!
    35 CalenEditorDataHandler::CalenEditorDataHandler(CalenEditorPrivate* calenEditor,
    40 CalenEditorDataHandler::CalenEditorDataHandler(CalenEditorPrivate* calenEditor,
    36                                                AgendaEntry* editedEntry, 
    41                                                AgendaEntry* editedEntry, 
    37                     	                       AgendaEntry* originalEntry)
    42                     	                       AgendaEntry* originalEntry)
    38 : mCalenEditor(calenEditor),mEditedEntry(editedEntry), mOriginalEntry(originalEntry)
    43 : mCalenEditor(calenEditor),mEditedEntry(editedEntry), mOriginalEntry(originalEntry)
    39 {
    44 {
       
    45 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_CALENEDITORDATAHANDLER_ENTRY );
    40 	
    46 	
       
    47 	OstTraceFunctionExit0( CALENEDITORDATAHANDLER_CALENEDITORDATAHANDLER_EXIT );
    41 }
    48 }
    42 
    49 
    43 /*!
    50 /*!
    44 	 Destructor
    51 	 Destructor
    45  */
    52  */
    46 CalenEditorDataHandler::~CalenEditorDataHandler()
    53 CalenEditorDataHandler::~CalenEditorDataHandler()
    47 {
    54 {
       
    55 	OstTraceFunctionEntry0( DUP1_CALENEDITORDATAHANDLER_CALENEDITORDATAHANDLER_ENTRY );
    48 	// Nothing Yet
    56 	// Nothing Yet
       
    57 	OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_CALENEDITORDATAHANDLER_EXIT );
    49 }
    58 }
    50 
    59 
    51 /*!
    60 /*!
    52 	 Returns pointer for edited entry
    61 	 Returns pointer for edited entry
    53 	 \return pointer for edited entry
    62 	 \return pointer for edited entry
    54  */
    63  */
    55 AgendaEntry* CalenEditorDataHandler::editedEntry()
    64 AgendaEntry* CalenEditorDataHandler::editedEntry()
    56 {
    65 {
       
    66 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_EDITEDENTRY_ENTRY );
       
    67 	OstTraceFunctionExit0( CALENEDITORDATAHANDLER_EDITEDENTRY_EXIT );
    57 	return mEditedEntry;
    68 	return mEditedEntry;
    58 }
    69 }
    59 
    70 
    60 /*!
    71 /*!
    61 	 Returns pointer for original entry
    72 	 Returns pointer for original entry
    62 	 \return pointer for original entry
    73 	 \return pointer for original entry
    63  */
    74  */
    64 AgendaEntry* CalenEditorDataHandler::originalEntry()
    75 AgendaEntry* CalenEditorDataHandler::originalEntry()
    65 {
    76 {
       
    77 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ORIGINALENTRY_ENTRY );
       
    78 	OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ORIGINALENTRY_EXIT );
    66 	return mOriginalEntry;
    79 	return mOriginalEntry;
    67 }
    80 }
    68 
    81 
    69 /*!
    82 /*!
    70 	 Checks if user entered data violates the permitted attributes
    83 	 Checks if user entered data violates the permitted attributes
    71 	 \return Error Error indicating the violated parameter
    84 	 \return Error Error indicating the violated parameter
    72  */
    85  */
    73 CalenEditorPrivate::Error CalenEditorDataHandler::checkErrorsForThisAndAll()
    86 CalenEditorPrivate::Error CalenEditorDataHandler::checkErrorsForThisAndAll()
    74 {
    87 {
       
    88 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_CHECKERRORSFORTHISANDALL_ENTRY );
    75 	//TODO :  Remove implementation once handle all repeating errors
    89 	//TODO :  Remove implementation once handle all repeating errors
    76 	const QDateTime startTime = mEditedEntry->startTime();
    90 	const QDateTime startTime = mEditedEntry->startTime();
    77 	const QDateTime endTime = mEditedEntry->endTime();
    91 	const QDateTime endTime = mEditedEntry->endTime();
    78 
    92 
    79 	// Repeating entry checks:
    93 	// Repeating entry checks:
   107 			// original rule is valid and new rule will not be created
   121 			// original rule is valid and new rule will not be created
   108 			repeatStartDay = mOriginalEntry->repeatRule().repeatRuleStart();
   122 			repeatStartDay = mOriginalEntry->repeatRule().repeatRuleStart();
   109 		}
   123 		}
   110 
   124 
   111 		if (durationGreaterThanRepeatIntervalError()) {
   125 		if (durationGreaterThanRepeatIntervalError()) {
       
   126 			OstTraceFunctionExit0( CALENEDITORDATAHANDLER_CHECKERRORSFORTHISANDALL_EXIT );
   112 			return CalenEditorPrivate::
   127 			return CalenEditorPrivate::
   113 							CalenEditorErrorDurationGreaterThanRepeatInterval;
   128 							CalenEditorErrorDurationGreaterThanRepeatInterval;
   114 		}
   129 		}
       
   130 		OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_CHECKERRORSFORTHISANDALL_EXIT );
   115 		return CalenEditorPrivate::CalenEditorErrorNone;
   131 		return CalenEditorPrivate::CalenEditorErrorNone;
   116 	}
   132 	}
       
   133 	OstTraceFunctionExit0( DUP2_CALENEDITORDATAHANDLER_CHECKERRORSFORTHISANDALL_EXIT );
   117 	return CalenEditorPrivate::CalenEditorErrorNone;
   134 	return CalenEditorPrivate::CalenEditorErrorNone;
   118 }
   135 }
   119 
   136 
   120 /*!
   137 /*!
   121 	Returns true if the entry has been modified, false otherwise.
   138 	Returns true if the entry has been modified, false otherwise.
   122 	\return true if the entry has been modified, false otherwise.
   139 	\return true if the entry has been modified, false otherwise.
   123  */
   140  */
   124 bool CalenEditorDataHandler::isEdited() const
   141 bool CalenEditorDataHandler::isEdited() const
   125 {
   142 {
       
   143 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISEDITED_ENTRY );
   126 	return (isSummaryEdited() ||
   144 	return (isSummaryEdited() ||
   127 			isAllDayEdited() ||
   145 			isAllDayEdited() ||
   128 			isLocationEdited() ||
   146 			isLocationEdited() ||
   129 			isStartDateTimeEdited() ||
   147 			isStartDateTimeEdited() ||
   130 			isEndDateTimeEdited() ||
   148 			isEndDateTimeEdited() ||
   137 	Returns true if the summary has been edited, false otherwise.
   155 	Returns true if the summary has been edited, false otherwise.
   138 	\return true if the summary has been edited, false otherwise.
   156 	\return true if the summary has been edited, false otherwise.
   139  */
   157  */
   140 bool CalenEditorDataHandler::isSummaryEdited() const
   158 bool CalenEditorDataHandler::isSummaryEdited() const
   141 {
   159 {
       
   160 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISSUMMARYEDITED_ENTRY );
   142 	return (mOriginalEntry->summary() != mEditedEntry->summary());
   161 	return (mOriginalEntry->summary() != mEditedEntry->summary());
   143 }
   162 }
   144 
   163 
   145 /*!
   164 /*!
   146 	Returns true if the all day has been edited, false otherwise.
   165 	Returns true if the all day has been edited, false otherwise.
   147 	\return true if the all day has been edited, false otherwise.
   166 	\return true if the all day has been edited, false otherwise.
   148  */
   167  */
   149 bool CalenEditorDataHandler::isAllDayEdited() const
   168 bool CalenEditorDataHandler::isAllDayEdited() const
   150 {
   169 {
       
   170 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISALLDAYEDITED_ENTRY );
   151 	HbDataFormModelItem* alldayItem = mCalenEditor->allDayCheckBoxItem();
   171 	HbDataFormModelItem* alldayItem = mCalenEditor->allDayCheckBoxItem();
   152 	if (alldayItem) {
   172 	if (alldayItem) {
   153 		if (mOriginalEntry->type() == AgendaEntry::TypeEvent) {
   173 		if (mOriginalEntry->type() == AgendaEntry::TypeEvent) {
   154 			if (alldayItem->contentWidgetData("checkState")
   174 			if (alldayItem->contentWidgetData("checkState")
   155 			        == Qt::Checked) {
   175 			        == Qt::Checked) {
       
   176 				OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT );
   156 				return false;
   177 				return false;
   157 			} else {
   178 			} else {
       
   179 				OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT );
   158 				return true;
   180 				return true;
   159 			}
   181 			}
   160 		} else if (mOriginalEntry->type() == AgendaEntry::TypeAppoinment) {
   182 		} else if (mOriginalEntry->type() == AgendaEntry::TypeAppoinment) {
   161 			if (alldayItem->contentWidgetData("checkState")
   183 			if (alldayItem->contentWidgetData("checkState")
   162 			        == Qt::Checked) {
   184 			        == Qt::Checked) {
       
   185 				OstTraceFunctionExit0( DUP2_CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT );
   163 				return true;
   186 				return true;
   164 			} else {
   187 			} else {
       
   188 				OstTraceFunctionExit0( DUP3_CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT );
   165 				return false;
   189 				return false;
   166 			}
   190 			}
   167 		}
   191 		}
   168 	}
   192 	}
       
   193 	OstTraceFunctionExit0( DUP4_CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT );
   169 	return false;
   194 	return false;
   170 }
   195 }
   171 
   196 
   172 /*!
   197 /*!
   173 	Returns true if the location has been edited, false otherwise.
   198 	Returns true if the location has been edited, false otherwise.
   174 	\return true if the location has been edited, false otherwise.
   199 	\return true if the location has been edited, false otherwise.
   175  */
   200  */
   176 bool CalenEditorDataHandler::isLocationEdited() const
   201 bool CalenEditorDataHandler::isLocationEdited() const
   177 {
   202 {
       
   203 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISLOCATIONEDITED_ENTRY );
   178 	return (mOriginalEntry->location() != mEditedEntry->location());
   204 	return (mOriginalEntry->location() != mEditedEntry->location());
   179 }
   205 }
   180 
   206 
   181 /*!
   207 /*!
   182 	Returns true if the start date/time has been edited, false otherwise.
   208 	Returns true if the start date/time has been edited, false otherwise.
   183 	\return true if the start date/time has been edited, false otherwise.
   209 	\return true if the start date/time has been edited, false otherwise.
   184  */
   210  */
   185 bool CalenEditorDataHandler::isStartDateTimeEdited() const
   211 bool CalenEditorDataHandler::isStartDateTimeEdited() const
   186 {
   212 {
       
   213 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISSTARTDATETIMEEDITED_ENTRY );
   187 	return (mOriginalEntry->startTime() != mEditedEntry->startTime());
   214 	return (mOriginalEntry->startTime() != mEditedEntry->startTime());
   188 }
   215 }
   189 
   216 
   190 /*!
   217 /*!
   191 	Returns true if the end date/time has been edited, false otherwise.
   218 	Returns true if the end date/time has been edited, false otherwise.
   192 	\return true if the end date/time has been edited, false otherwise.
   219 	\return true if the end date/time has been edited, false otherwise.
   193  */
   220  */
   194 bool CalenEditorDataHandler::isEndDateTimeEdited() const
   221 bool CalenEditorDataHandler::isEndDateTimeEdited() const
   195 {
   222 {
       
   223 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISENDDATETIMEEDITED_ENTRY );
   196 	return (mOriginalEntry->endTime() != mEditedEntry->endTime());
   224 	return (mOriginalEntry->endTime() != mEditedEntry->endTime());
   197 }
   225 }
   198 
   226 
   199 /*!
   227 /*!
   200 	Returns true if the alarm has been edited, false otherwise.
   228 	Returns true if the alarm has been edited, false otherwise.
   201 	\return true if the alarm has been edited, false otherwise.
   229 	\return true if the alarm has been edited, false otherwise.
   202  */
   230  */
   203 bool CalenEditorDataHandler::isAlarmEdited() const
   231 bool CalenEditorDataHandler::isAlarmEdited() const
   204 {
   232 {
       
   233 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISALARMEDITED_ENTRY );
   205 	return (mOriginalEntry->alarm() != mEditedEntry->alarm());
   234 	return (mOriginalEntry->alarm() != mEditedEntry->alarm());
   206 }
   235 }
   207 
   236 
   208 /*!
   237 /*!
   209 	Returns true if the repeat rule has been edited, false otherwise.
   238 	Returns true if the repeat rule has been edited, false otherwise.
   210 	\return true if the repeat rule has been edited, false otherwise.
   239 	\return true if the repeat rule has been edited, false otherwise.
   211  */
   240  */
   212 bool CalenEditorDataHandler::isRepeatRuleEdited() const
   241 bool CalenEditorDataHandler::isRepeatRuleEdited() const
   213 {
   242 {
       
   243 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISREPEATRULEEDITED_ENTRY );
   214 	if ((mOriginalEntry->repeatRule().type() == AgendaRepeatRule::InvalidRule)
   244 	if ((mOriginalEntry->repeatRule().type() == AgendaRepeatRule::InvalidRule)
   215 	        && (mEditedEntry->repeatRule().type()
   245 	        && (mEditedEntry->repeatRule().type()
   216 	                == AgendaRepeatRule::InvalidRule)) {
   246 	                == AgendaRepeatRule::InvalidRule)) {
       
   247 		OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ISREPEATRULEEDITED_EXIT );
   217 		return false;
   248 		return false;
   218 	} else {
   249 	} else {
   219 		return ((mOriginalEntry->repeatRule().type() != 
   250 		return ((mOriginalEntry->repeatRule().type() != 
   220 				mEditedEntry->repeatRule().type())
   251 				mEditedEntry->repeatRule().type())
   221 				|| (mOriginalEntry->repeatRule().until().date() != 
   252 				|| (mOriginalEntry->repeatRule().until().date() != 
   227 	Returns true if the Description field has been edited, false otherwise.
   258 	Returns true if the Description field has been edited, false otherwise.
   228 	\return true if the Description field has been edited, false otherwise.
   259 	\return true if the Description field has been edited, false otherwise.
   229  */
   260  */
   230 bool CalenEditorDataHandler::isDescriptionEdited() const
   261 bool CalenEditorDataHandler::isDescriptionEdited() const
   231 {
   262 {
       
   263 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISDESCRIPTIONEDITED_ENTRY );
   232 	return (mOriginalEntry->description() != mEditedEntry->description());
   264 	return (mOriginalEntry->description() != mEditedEntry->description());
   233 }
   265 }
   234 
   266 
   235 /*!
   267 /*!
   236 	Returns true if any of the non-text items (e.g. time fields) of the entry
   268 	Returns true if any of the non-text items (e.g. time fields) of the entry
   237 	have been edited, false otherwise.
   269 	have been edited, false otherwise.
   238 	\return true if any of the non text items edited,false otherwise.
   270 	\return true if any of the non text items edited,false otherwise.
   239  */
   271  */
   240 bool CalenEditorDataHandler::nonTextItemsEdited() const
   272 bool CalenEditorDataHandler::nonTextItemsEdited() const
   241 {
   273 {
       
   274 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_NONTEXTITEMSEDITED_ENTRY );
   242 	return (isAllDayEdited() ||
   275 	return (isAllDayEdited() ||
   243 			isStartDateTimeEdited() ||
   276 			isStartDateTimeEdited() ||
   244 			isEndDateTimeEdited() ||
   277 			isEndDateTimeEdited() ||
   245 			isAlarmEdited() ||
   278 			isAlarmEdited() ||
   246 			isRepeatRuleEdited());
   279 			isRepeatRuleEdited());
   251 	false otherwise.
   284 	false otherwise.
   252 	\return true if text items are all empty,false otherwise.
   285 	\return true if text items are all empty,false otherwise.
   253  */
   286  */
   254 bool CalenEditorDataHandler::areTextItemsEmpty() const
   287 bool CalenEditorDataHandler::areTextItemsEmpty() const
   255 {
   288 {
       
   289 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ARETEXTITEMSEMPTY_ENTRY );
   256 	return (mEditedEntry->summary().isEmpty()
   290 	return (mEditedEntry->summary().isEmpty()
   257 	        && mEditedEntry->location().isEmpty()
   291 	        && mEditedEntry->location().isEmpty()
   258 	        && mEditedEntry->description().isEmpty());
   292 	        && mEditedEntry->description().isEmpty());
   259 }
   293 }
   260 
   294 
   263 	false otherwise.
   297 	false otherwise.
   264 	\return true if summary & location items are cleared,false otherwise.
   298 	\return true if summary & location items are cleared,false otherwise.
   265  */
   299  */
   266 bool CalenEditorDataHandler::areTextItemsCleared() const
   300 bool CalenEditorDataHandler::areTextItemsCleared() const
   267 {
   301 {
       
   302 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ARETEXTITEMSCLEARED_ENTRY );
   268 	if (mEditedEntry->summary().isEmpty() &&
   303 	if (mEditedEntry->summary().isEmpty() &&
   269 			mEditedEntry->location().isEmpty() &&
   304 			mEditedEntry->location().isEmpty() &&
   270 			mEditedEntry->description().isEmpty()) {
   305 			mEditedEntry->description().isEmpty()) {
   271 		if (isSummaryEmptied() 
   306 		if (isSummaryEmptied() 
   272 				|| isLocationEmptied() 
   307 				|| isLocationEmptied() 
   273 				|| isDescriptionEmptied()) {
   308 				|| isDescriptionEmptied()) {
       
   309 			OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ARETEXTITEMSCLEARED_EXIT );
   274 			return true;
   310 			return true;
   275 		}
   311 		}
   276 	}
   312 	}
       
   313 	OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_ARETEXTITEMSCLEARED_EXIT );
   277 	return false;
   314 	return false;
   278 }
   315 }
   279 
   316 
   280 /*!
   317 /*!
   281 	Returns true the summary was not empty in original && is empty
   318 	Returns true the summary was not empty in original && is empty
   282 	in the edited note,false otherwise
   319 	in the edited note,false otherwise
   283 	\return true if summary is cleared in edited note,false otherwise
   320 	\return true if summary is cleared in edited note,false otherwise
   284  */
   321  */
   285 bool CalenEditorDataHandler::isSummaryEmptied() const
   322 bool CalenEditorDataHandler::isSummaryEmptied() const
   286 {
   323 {
       
   324 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISSUMMARYEMPTIED_ENTRY );
   287 	return (!mOriginalEntry->summary().isEmpty()
   325 	return (!mOriginalEntry->summary().isEmpty()
   288 	        && mEditedEntry->summary().isEmpty());
   326 	        && mEditedEntry->summary().isEmpty());
   289 }
   327 }
   290 
   328 
   291 /*!
   329 /*!
   293 	in the edited note,false otherwise
   331 	in the edited note,false otherwise
   294 	\return true if location is cleared in edited note,false otherwise
   332 	\return true if location is cleared in edited note,false otherwise
   295  */
   333  */
   296 bool CalenEditorDataHandler::isLocationEmptied() const
   334 bool CalenEditorDataHandler::isLocationEmptied() const
   297 {
   335 {
       
   336 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISLOCATIONEMPTIED_ENTRY );
   298 	return (!mOriginalEntry->location().isEmpty()
   337 	return (!mOriginalEntry->location().isEmpty()
   299 	        && mEditedEntry->location().isEmpty());
   338 	        && mEditedEntry->location().isEmpty());
   300 }
   339 }
   301 
   340 
   302 /*!
   341 /*!
   304 	in the edited note,false otherwise
   343 	in the edited note,false otherwise
   305 	\return true if description is cleared in edited note,false otherwise
   344 	\return true if description is cleared in edited note,false otherwise
   306  */
   345  */
   307 bool CalenEditorDataHandler::isDescriptionEmptied() const
   346 bool CalenEditorDataHandler::isDescriptionEmptied() const
   308 {
   347 {
       
   348 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISDESCRIPTIONEMPTIED_ENTRY );
   309 	return (!mOriginalEntry->description().isEmpty()
   349 	return (!mOriginalEntry->description().isEmpty()
   310 	        && mEditedEntry->description().isEmpty());
   350 	        && mEditedEntry->description().isEmpty());
   311 }
   351 }
   312 
   352 
   313 /*!
   353 /*!
   316 	\return enum Action
   356 	\return enum Action
   317  */
   357  */
   318 CalenEditorPrivate::Action CalenEditorDataHandler::shouldSaveOrDeleteOrDoNothing(bool launchCalendar) 
   358 CalenEditorPrivate::Action CalenEditorDataHandler::shouldSaveOrDeleteOrDoNothing(bool launchCalendar) 
   319 																		const
   359 																		const
   320 {
   360 {
       
   361 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_ENTRY );
   321 	// Need to save the entry if third party calls editor to launch the
   362 	// Need to save the entry if third party calls editor to launch the
   322 	// calendar after that. So, that entry will be new entry adn we assume
   363 	// calendar after that. So, that entry will be new entry adn we assume
   323 	// that client launches editor with some prefilled text items
   364 	// that client launches editor with some prefilled text items
   324 	if (!isEdited() && !launchCalendar) {
   365 	if (!isEdited() && !launchCalendar) {
   325 		// Not edited at all OR
   366 		// Not edited at all OR
   326 		// Only added space characters to text fields but not
   367 		// Only added space characters to text fields but not
   327 		// edited the non-text items
   368 		// edited the non-text items
   328 		// no need to save the entry
   369 		// no need to save the entry
       
   370 		OstTraceFunctionExit0( CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT );
   329 		return CalenEditorPrivate::ActionNothing;
   371 		return CalenEditorPrivate::ActionNothing;
   330 	}
   372 	}
   331 	// new entry is edited
   373 	// new entry is edited
   332 	if (mCalenEditor->isNewEntry()) {
   374 	if (mCalenEditor->isNewEntry()) {
   333 		// Subject && Location && Description are text items.
   375 		// Subject && Location && Description are text items.
   334 		// If text items as a whole is not empty, we can save the note
   376 		// If text items as a whole is not empty, we can save the note
   335 		// If text items as a whole is empty, we can still save the note
   377 		// If text items as a whole is empty, we can still save the note
   336 		// since we edited "non-text" fields
   378 		// since we edited "non-text" fields
   337 		if (!nonTextItemsEdited() && areTextItemsEmpty()) {
   379 		if (!nonTextItemsEdited() && areTextItemsEmpty()) {
       
   380 			OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT );
   338 			return CalenEditorPrivate::ActionNothing;
   381 			return CalenEditorPrivate::ActionNothing;
   339 		} else {
   382 		} else {
       
   383 			OstTraceFunctionExit0( DUP2_CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT );
   340 			return CalenEditorPrivate::ActionSave;
   384 			return CalenEditorPrivate::ActionSave;
   341 		}
   385 		}
   342 	}
   386 	}
   343 	if (areTextItemsCleared() && !nonTextItemsEdited()) {
   387 	if (areTextItemsCleared() && !nonTextItemsEdited()) {
   344 		// ***** edited entry + text items emptied + non-text items not edited
   388 		// ***** edited entry + text items emptied + non-text items not edited
   345 		// Even if user may have edited non-text fields, 
   389 		// Even if user may have edited non-text fields, 
   346 		// delete the note 
   390 		// delete the note 
       
   391 		OstTraceFunctionExit0( DUP3_CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT );
   347 		return CalenEditorPrivate::ActionDelete;
   392 		return CalenEditorPrivate::ActionDelete;
   348 	}
   393 	}
   349 	// Save the note, since the text fields contain something
   394 	// Save the note, since the text fields contain something
       
   395 	OstTraceFunctionExit0( DUP4_CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT );
   350 	return CalenEditorPrivate::ActionSave;
   396 	return CalenEditorPrivate::ActionSave;
   351 }
   397 }
   352 
   398 
   353 /*!
   399 /*!
   354 	Returns true if the duration of instances of the meeting is greater than
   400 	Returns true if the duration of instances of the meeting is greater than
   356 	\return true if duration of meeting is greater than repeat period, false
   402 	\return true if duration of meeting is greater than repeat period, false
   357 	otherwise
   403 	otherwise
   358  */
   404  */
   359 bool CalenEditorDataHandler::durationGreaterThanRepeatIntervalError() const
   405 bool CalenEditorDataHandler::durationGreaterThanRepeatIntervalError() const
   360 {
   406 {
       
   407 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_DURATIONGREATERTHANREPEATINTERVALERROR_ENTRY );
   361 	bool isError = false;
   408 	bool isError = false;
   362 	switch (mEditedEntry->repeatRule().type()) {
   409 	switch (mEditedEntry->repeatRule().type()) {
   363 		case AgendaRepeatRule::DailyRule: {
   410 		case AgendaRepeatRule::DailyRule: {
   364 			int durationDays =
   411 			int durationDays =
   365 			        mEditedEntry->startTime().daysTo(mEditedEntry->endTime());
   412 			        mEditedEntry->startTime().daysTo(mEditedEntry->endTime());
   393 		default:
   440 		default:
   394 			// Not repeating, no error
   441 			// Not repeating, no error
   395 			isError = false;
   442 			isError = false;
   396 			break;
   443 			break;
   397 	}
   444 	}
       
   445 	OstTraceFunctionExit0( CALENEDITORDATAHANDLER_DURATIONGREATERTHANREPEATINTERVALERROR_EXIT );
   398 	return isError;
   446 	return isError;
   399 }
   447 }
   400 
   448 
   401 /*!
   449 /*!
   402 	Check the alarm fields for errors.
   450 	Check the alarm fields for errors.
   403 	\return the error if found, or CalenEditorErrorNone if no error found.
   451 	\return the error if found, or CalenEditorErrorNone if no error found.
   404  */
   452  */
   405 CalenEditorPrivate::Error CalenEditorDataHandler::checkAlarmFieldsForErrors(
   453 CalenEditorPrivate::Error CalenEditorDataHandler::checkAlarmFieldsForErrors(
   406 															bool series) const
   454 															bool series) const
   407 {
   455 {
       
   456 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_CHECKALARMFIELDSFORERRORS_ENTRY );
   408 	CalenEditorPrivate::Error error = CalenEditorPrivate::CalenEditorErrorNone;
   457 	CalenEditorPrivate::Error error = CalenEditorPrivate::CalenEditorErrorNone;
   409 	// If alarm not active, no check
   458 	// If alarm not active, no check
   410 	if (!mEditedEntry->alarm().isNull()) {
   459 	if (!mEditedEntry->alarm().isNull()) {
   411 		int alarm = mEditedEntry->alarm().timeOffset();
   460 		int alarm = mEditedEntry->alarm().timeOffset();
   412 		QDateTime startTime = mEditedEntry->startTime();
   461 		QDateTime startTime = mEditedEntry->startTime();
   422 				// dont let non-repeating future entries have alarms in past
   471 				// dont let non-repeating future entries have alarms in past
   423 				error = CalenEditorPrivate::CalenEditorErrorAlarmTimePast;
   472 				error = CalenEditorPrivate::CalenEditorErrorAlarmTimePast;
   424 			}
   473 			}
   425 		}
   474 		}
   426 	}
   475 	}
       
   476 	OstTraceFunctionExit0( CALENEDITORDATAHANDLER_CHECKALARMFIELDSFORERRORS_EXIT );
   427 	return error;
   477 	return error;
   428 }
   478 }
   429 
   479 
   430 /*!
   480 /*!
   431 	Checks if AlarmTime is 31 days from StartTime, 
   481 	Checks if AlarmTime is 31 days from StartTime, 
   437  */
   487  */
   438 bool CalenEditorDataHandler::isAlarmInAcceptablePeriod(CalenEditorPrivate::Error &error,
   488 bool CalenEditorDataHandler::isAlarmInAcceptablePeriod(CalenEditorPrivate::Error &error,
   439 										const QDateTime &alarmTime,
   489 										const QDateTime &alarmTime,
   440 										const QDateTime &startTime) const
   490 										const QDateTime &startTime) const
   441 {
   491 {
       
   492 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISALARMINACCEPTABLEPERIOD_ENTRY );
   442 	QDateTime upperLimit = startTime;
   493 	QDateTime upperLimit = startTime;
   443 
   494 
   444 	QDateTime lowerLimit = startTime.addDays(-31);
   495 	QDateTime lowerLimit = startTime.addDays(-31);
   445 	bool acceptable = true;
   496 	bool acceptable = true;
   446 	if (alarmTime < lowerLimit) {
   497 	if (alarmTime < lowerLimit) {
   450 		if (alarmTime > upperLimit) {
   501 		if (alarmTime > upperLimit) {
   451 			acceptable = false;
   502 			acceptable = false;
   452 			error = CalenEditorPrivate::CalenEditorErrorAlarmTimeLaterThanNote;
   503 			error = CalenEditorPrivate::CalenEditorErrorAlarmTimeLaterThanNote;
   453 		}
   504 		}
   454 	}
   505 	}
       
   506 	OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ISALARMINACCEPTABLEPERIOD_EXIT );
   455 	return acceptable;
   507 	return acceptable;
   456 }
   508 }
   457 
   509 
   458 /*!
   510 /*!
   459 	Display the given error msg
   511 	Display the given error msg
   460 	\param error Error value for which message has to be displayed
   512 	\param error Error value for which message has to be displayed
   461  */
   513  */
   462 void CalenEditorDataHandler::displayErrorMsg(int error)
   514 void CalenEditorDataHandler::displayErrorMsg(int error)
   463 {
   515 {
       
   516 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_DISPLAYERRORMSG_ENTRY );
   464 	QString errorMsg = QString::Null();
   517 	QString errorMsg = QString::Null();
   465 
   518 
   466 	switch (error) {
   519 	switch (error) {
   467 		case CalenEditorPrivate::CalenEditorErrorAlarmTimeLaterThanNote:
   520 		case CalenEditorPrivate::CalenEditorErrorAlarmTimeLaterThanNote:
   468 			errorMsg.append( hbTrId(
   521 			errorMsg.append( hbTrId(
   492 			break;
   545 			break;
   493 	}
   546 	}
   494 	if (!errorMsg.isNull()) {
   547 	if (!errorMsg.isNull()) {
   495 		HbMessageBox::information(errorMsg);
   548 		HbMessageBox::information(errorMsg);
   496 	}
   549 	}
       
   550 	OstTraceFunctionExit0( CALENEDITORDATAHANDLER_DISPLAYERRORMSG_EXIT );
   497 }
   551 }
   498 
   552 
   499 /*!
   553 /*!
   500 	 Displays error message related to repeat fields
   554 	 Displays error message related to repeat fields
   501  */
   555  */
   502 void CalenEditorDataHandler::dispalyErrorMsgByRepeatType()
   556 void CalenEditorDataHandler::dispalyErrorMsgByRepeatType()
   503 {
   557 {
       
   558 	OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_DISPALYERRORMSGBYREPEATTYPE_ENTRY );
   504 	QString errorMsg = QString::Null();
   559 	QString errorMsg = QString::Null();
   505 
   560 
   506 	int durationDays =
   561 	int durationDays =
   507 	        mEditedEntry->startTime().daysTo(mEditedEntry->endTime());
   562 	        mEditedEntry->startTime().daysTo(mEditedEntry->endTime());
   508 	int numDaysEntrySpan = durationDays + 1;
   563 	int numDaysEntrySpan = durationDays + 1;
   532 			break;
   587 			break;
   533 	}
   588 	}
   534 	if (!errorMsg.isNull()) {
   589 	if (!errorMsg.isNull()) {
   535 		HbMessageBox::information(errorMsg.arg(numDaysEntrySpan));
   590 		HbMessageBox::information(errorMsg.arg(numDaysEntrySpan));
   536 	}
   591 	}
       
   592 	OstTraceFunctionExit0( CALENEDITORDATAHANDLER_DISPALYERRORMSGBYREPEATTYPE_EXIT );
   537 }
   593 }
   538 
   594 
   539 // End of file	--Don't remove this.
   595 // End of file	--Don't remove this.