|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Definition of CalenEditorDataHandler class. |
|
16 * |
|
17 */ |
|
18 |
|
19 // System Includes |
|
20 #include <hbmessagebox.h> |
|
21 #include <hbdataformmodelitem.h> |
|
22 |
|
23 // User Includes |
|
24 #include "caleneditordatahandler.h" |
|
25 #include "calendateutils.h" |
|
26 #include "calenagendautils.h" |
|
27 #include <agendaentry.h> |
|
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "caleneditordatahandlerTraces.h" |
|
31 #endif |
|
32 |
|
33 |
|
34 /*! |
|
35 \class CalenEditorDataHandler |
|
36 */ |
|
37 /*! |
|
38 Constructor. |
|
39 */ |
|
40 |
|
41 CalenEditorDataHandler::CalenEditorDataHandler(CalenEditorPrivate* calenEditor, |
|
42 AgendaEntry* editedEntry, |
|
43 AgendaEntry* originalEntry) |
|
44 : mCalenEditor(calenEditor),mEditedEntry(editedEntry), mOriginalEntry(originalEntry) |
|
45 { |
|
46 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_CALENEDITORDATAHANDLER_ENTRY ); |
|
47 |
|
48 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_CALENEDITORDATAHANDLER_EXIT ); |
|
49 } |
|
50 |
|
51 /*! |
|
52 Destructor |
|
53 */ |
|
54 CalenEditorDataHandler::~CalenEditorDataHandler() |
|
55 { |
|
56 OstTraceFunctionEntry0( DUP1_CALENEDITORDATAHANDLER_CALENEDITORDATAHANDLER_ENTRY ); |
|
57 // Nothing Yet |
|
58 OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_CALENEDITORDATAHANDLER_EXIT ); |
|
59 } |
|
60 |
|
61 /*! |
|
62 Returns pointer for edited entry |
|
63 \return pointer for edited entry |
|
64 */ |
|
65 AgendaEntry* CalenEditorDataHandler::editedEntry() |
|
66 { |
|
67 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_EDITEDENTRY_ENTRY ); |
|
68 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_EDITEDENTRY_EXIT ); |
|
69 return mEditedEntry; |
|
70 } |
|
71 |
|
72 /*! |
|
73 Returns pointer for original entry |
|
74 \return pointer for original entry |
|
75 */ |
|
76 AgendaEntry* CalenEditorDataHandler::originalEntry() |
|
77 { |
|
78 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ORIGINALENTRY_ENTRY ); |
|
79 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ORIGINALENTRY_EXIT ); |
|
80 return mOriginalEntry; |
|
81 } |
|
82 |
|
83 /*! |
|
84 Checks if user entered data violates the permitted attributes |
|
85 \return Error Error indicating the violated parameter |
|
86 */ |
|
87 CalenEditorPrivate::Error CalenEditorDataHandler::checkErrorsForThisAndAll() |
|
88 { |
|
89 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_CHECKERRORSFORTHISANDALL_ENTRY ); |
|
90 //TODO : Remove implementation once handle all repeating errors |
|
91 const QDateTime startTime = mEditedEntry->startTime(); |
|
92 const QDateTime endTime = mEditedEntry->endTime(); |
|
93 |
|
94 // Repeating entry checks: |
|
95 if (mEditedEntry->isRepeating()) { |
|
96 // Check that repeat until date is a) later than start date |
|
97 // (for new notes) |
|
98 // b) not before start date |
|
99 // (for existing notes) |
|
100 QDateTime repeatUntilDay = mEditedEntry->repeatRule().until(); |
|
101 |
|
102 QDateTime repeatStartDay; |
|
103 |
|
104 // if new note or old note isnt repeating |
|
105 // edited.repeatUntil date must be greater than edited.start date |
|
106 // else |
|
107 // if IsRepeatRuleEdited or IsStartDateTimeEdited |
|
108 // (either one above will make a new rule in which edited.startdate |
|
109 // is the start date) |
|
110 // edited.repeatUntil must be greater than edited.start date |
|
111 // else |
|
112 // edited.repeatUntil must be greater than start date on disk |
|
113 |
|
114 if (mCalenEditor->isNewEntry() || mOriginalEntry->repeatRule().isNull() |
|
115 || isRepeatRuleEdited() || isStartDateTimeEdited()) { |
|
116 // We don't have an rrule so we can't get the rrule start date, |
|
117 // or user has edited a field that will cause new start date to be |
|
118 // used in the new rule. |
|
119 // Use the edited entry's start date. |
|
120 repeatStartDay = startTime; |
|
121 } else { |
|
122 // original rule is valid and new rule will not be created |
|
123 repeatStartDay = mOriginalEntry->repeatRule().repeatRuleStart(); |
|
124 } |
|
125 |
|
126 if (durationGreaterThanRepeatIntervalError()) { |
|
127 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_CHECKERRORSFORTHISANDALL_EXIT ); |
|
128 return CalenEditorPrivate:: |
|
129 CalenEditorErrorDurationGreaterThanRepeatInterval; |
|
130 } |
|
131 OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_CHECKERRORSFORTHISANDALL_EXIT ); |
|
132 return CalenEditorPrivate::CalenEditorErrorNone; |
|
133 } |
|
134 OstTraceFunctionExit0( DUP2_CALENEDITORDATAHANDLER_CHECKERRORSFORTHISANDALL_EXIT ); |
|
135 return CalenEditorPrivate::CalenEditorErrorNone; |
|
136 } |
|
137 |
|
138 /*! |
|
139 Returns true if the entry has been modified, false otherwise. |
|
140 \return true if the entry has been modified, false otherwise. |
|
141 */ |
|
142 bool CalenEditorDataHandler::isEdited() const |
|
143 { |
|
144 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISEDITED_ENTRY ); |
|
145 return (isSummaryEdited() || |
|
146 isAllDayEdited() || |
|
147 isLocationEdited() || |
|
148 isStartDateTimeEdited() || |
|
149 isEndDateTimeEdited() || |
|
150 isAlarmEdited() || |
|
151 isRepeatRuleEdited() || |
|
152 isDescriptionEdited()); |
|
153 } |
|
154 |
|
155 /*! |
|
156 Returns true if the summary has been edited, false otherwise. |
|
157 \return true if the summary has been edited, false otherwise. |
|
158 */ |
|
159 bool CalenEditorDataHandler::isSummaryEdited() const |
|
160 { |
|
161 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISSUMMARYEDITED_ENTRY ); |
|
162 return (mOriginalEntry->summary() != mEditedEntry->summary()); |
|
163 } |
|
164 |
|
165 /*! |
|
166 Returns true if the all day has been edited, false otherwise. |
|
167 \return true if the all day has been edited, false otherwise. |
|
168 */ |
|
169 bool CalenEditorDataHandler::isAllDayEdited() const |
|
170 { |
|
171 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISALLDAYEDITED_ENTRY ); |
|
172 HbDataFormModelItem* alldayItem = mCalenEditor->allDayCheckBoxItem(); |
|
173 if (alldayItem) { |
|
174 if (CalenAgendaUtils::isAlldayEvent(*mOriginalEntry)) { |
|
175 if (alldayItem->contentWidgetData("checkState") |
|
176 == Qt::Checked) { |
|
177 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT ); |
|
178 return false; |
|
179 } else { |
|
180 OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT ); |
|
181 return true; |
|
182 } |
|
183 } else if (mOriginalEntry->type() == AgendaEntry::TypeAppoinment) { |
|
184 if (alldayItem->contentWidgetData("checkState") |
|
185 == Qt::Checked) { |
|
186 OstTraceFunctionExit0( DUP2_CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT ); |
|
187 return true; |
|
188 } else { |
|
189 OstTraceFunctionExit0( DUP3_CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT ); |
|
190 return false; |
|
191 } |
|
192 } |
|
193 } |
|
194 OstTraceFunctionExit0( DUP4_CALENEDITORDATAHANDLER_ISALLDAYEDITED_EXIT ); |
|
195 return false; |
|
196 } |
|
197 |
|
198 /*! |
|
199 Returns true if the location has been edited, false otherwise. |
|
200 \return true if the location has been edited, false otherwise. |
|
201 */ |
|
202 bool CalenEditorDataHandler::isLocationEdited() const |
|
203 { |
|
204 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISLOCATIONEDITED_ENTRY ); |
|
205 return (mOriginalEntry->location() != mEditedEntry->location()); |
|
206 } |
|
207 |
|
208 /*! |
|
209 Returns true if the start date/time has been edited, false otherwise. |
|
210 \return true if the start date/time has been edited, false otherwise. |
|
211 */ |
|
212 bool CalenEditorDataHandler::isStartDateTimeEdited() const |
|
213 { |
|
214 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISSTARTDATETIMEEDITED_ENTRY ); |
|
215 return (mOriginalEntry->startTime() != mEditedEntry->startTime()); |
|
216 } |
|
217 |
|
218 /*! |
|
219 Returns true if the end date/time has been edited, false otherwise. |
|
220 \return true if the end date/time has been edited, false otherwise. |
|
221 */ |
|
222 bool CalenEditorDataHandler::isEndDateTimeEdited() const |
|
223 { |
|
224 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISENDDATETIMEEDITED_ENTRY ); |
|
225 return (mOriginalEntry->endTime() != mEditedEntry->endTime()); |
|
226 } |
|
227 |
|
228 /*! |
|
229 Returns true if the alarm has been edited, false otherwise. |
|
230 \return true if the alarm has been edited, false otherwise. |
|
231 */ |
|
232 bool CalenEditorDataHandler::isAlarmEdited() const |
|
233 { |
|
234 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISALARMEDITED_ENTRY ); |
|
235 return (mOriginalEntry->alarm() != mEditedEntry->alarm()); |
|
236 } |
|
237 |
|
238 /*! |
|
239 Returns true if the repeat rule has been edited, false otherwise. |
|
240 \return true if the repeat rule has been edited, false otherwise. |
|
241 */ |
|
242 bool CalenEditorDataHandler::isRepeatRuleEdited() const |
|
243 { |
|
244 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISREPEATRULEEDITED_ENTRY ); |
|
245 if ((mOriginalEntry->repeatRule().type() == AgendaRepeatRule::InvalidRule) |
|
246 && (mEditedEntry->repeatRule().type() |
|
247 == AgendaRepeatRule::InvalidRule)) { |
|
248 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ISREPEATRULEEDITED_EXIT ); |
|
249 return false; |
|
250 } else { |
|
251 return (mOriginalEntry->repeatRule() != mEditedEntry->repeatRule()); |
|
252 } |
|
253 } |
|
254 |
|
255 /*! |
|
256 Returns true if the Description field has been edited, false otherwise. |
|
257 \return true if the Description field has been edited, false otherwise. |
|
258 */ |
|
259 bool CalenEditorDataHandler::isDescriptionEdited() const |
|
260 { |
|
261 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISDESCRIPTIONEDITED_ENTRY ); |
|
262 return (mOriginalEntry->description() != mEditedEntry->description()); |
|
263 } |
|
264 |
|
265 /*! |
|
266 Returns true if any of the non-text items (e.g. time fields) of the entry |
|
267 have been edited, false otherwise. |
|
268 \return true if any of the non text items edited,false otherwise. |
|
269 */ |
|
270 bool CalenEditorDataHandler::nonTextItemsEdited() const |
|
271 { |
|
272 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_NONTEXTITEMSEDITED_ENTRY ); |
|
273 return (isAllDayEdited() || |
|
274 isStartDateTimeEdited() || |
|
275 isEndDateTimeEdited() || |
|
276 isAlarmEdited() || |
|
277 isRepeatRuleEdited()); |
|
278 } |
|
279 |
|
280 /*! |
|
281 Returns true if summary && location && description text items are all empty, |
|
282 false otherwise. |
|
283 \return true if text items are all empty,false otherwise. |
|
284 */ |
|
285 bool CalenEditorDataHandler::areTextItemsEmpty() const |
|
286 { |
|
287 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ARETEXTITEMSEMPTY_ENTRY ); |
|
288 return (mEditedEntry->summary().isEmpty() |
|
289 && mEditedEntry->location().isEmpty() |
|
290 && mEditedEntry->description().isEmpty()); |
|
291 } |
|
292 |
|
293 /*! |
|
294 Returns true if the user cleared the text in the location and summary items, |
|
295 false otherwise. |
|
296 \return true if summary & location items are cleared,false otherwise. |
|
297 */ |
|
298 bool CalenEditorDataHandler::areTextItemsCleared() const |
|
299 { |
|
300 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ARETEXTITEMSCLEARED_ENTRY ); |
|
301 if (mEditedEntry->summary().isEmpty() && |
|
302 mEditedEntry->location().isEmpty() && |
|
303 mEditedEntry->description().isEmpty()) { |
|
304 if (isSummaryEmptied() |
|
305 || isLocationEmptied() |
|
306 || isDescriptionEmptied()) { |
|
307 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ARETEXTITEMSCLEARED_EXIT ); |
|
308 return true; |
|
309 } |
|
310 } |
|
311 OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_ARETEXTITEMSCLEARED_EXIT ); |
|
312 return false; |
|
313 } |
|
314 |
|
315 /*! |
|
316 Returns true the summary was not empty in original && is empty |
|
317 in the edited note,false otherwise |
|
318 \return true if summary is cleared in edited note,false otherwise |
|
319 */ |
|
320 bool CalenEditorDataHandler::isSummaryEmptied() const |
|
321 { |
|
322 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISSUMMARYEMPTIED_ENTRY ); |
|
323 return (!mOriginalEntry->summary().isEmpty() |
|
324 && mEditedEntry->summary().isEmpty()); |
|
325 } |
|
326 |
|
327 /*! |
|
328 Returns true the location was not empty in original && is empty |
|
329 in the edited note,false otherwise |
|
330 \return true if location is cleared in edited note,false otherwise |
|
331 */ |
|
332 bool CalenEditorDataHandler::isLocationEmptied() const |
|
333 { |
|
334 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISLOCATIONEMPTIED_ENTRY ); |
|
335 return (!mOriginalEntry->location().isEmpty() |
|
336 && mEditedEntry->location().isEmpty()); |
|
337 } |
|
338 |
|
339 /*! |
|
340 Returns true the description was not empty in original && is empty |
|
341 in the edited note,false otherwise |
|
342 \return true if description is cleared in edited note,false otherwise |
|
343 */ |
|
344 bool CalenEditorDataHandler::isDescriptionEmptied() const |
|
345 { |
|
346 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISDESCRIPTIONEMPTIED_ENTRY ); |
|
347 return (!mOriginalEntry->description().isEmpty() |
|
348 && mEditedEntry->description().isEmpty()); |
|
349 } |
|
350 |
|
351 /*! |
|
352 Works out whether the entry should be deleted, saved, |
|
353 or whether no action should be taken. |
|
354 \return enum Action |
|
355 */ |
|
356 CalenEditorPrivate::Action CalenEditorDataHandler::shouldSaveOrDeleteOrDoNothing(bool launchCalendar) |
|
357 const |
|
358 { |
|
359 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_ENTRY ); |
|
360 // Need to save the entry if third party calls editor to launch the |
|
361 // calendar after that. So, that entry will be new entry adn we assume |
|
362 // that client launches editor with some prefilled text items |
|
363 if (!isEdited() && !launchCalendar) { |
|
364 // Not edited at all OR |
|
365 // Only added space characters to text fields but not |
|
366 // edited the non-text items |
|
367 // no need to save the entry |
|
368 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT ); |
|
369 return CalenEditorPrivate::ActionNothing; |
|
370 } |
|
371 // new entry is edited |
|
372 if (mCalenEditor->isNewEntry()) { |
|
373 // Subject && Location && Description are text items. |
|
374 // If text items as a whole is not empty, we can save the note |
|
375 // If text items as a whole is empty, we can still save the note |
|
376 // since we edited "non-text" fields |
|
377 if (!nonTextItemsEdited() && areTextItemsEmpty()) { |
|
378 OstTraceFunctionExit0( DUP1_CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT ); |
|
379 return CalenEditorPrivate::ActionNothing; |
|
380 } else { |
|
381 OstTraceFunctionExit0( DUP2_CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT ); |
|
382 return CalenEditorPrivate::ActionSave; |
|
383 } |
|
384 } |
|
385 if (areTextItemsCleared() && !nonTextItemsEdited()) { |
|
386 // ***** edited entry + text items emptied + non-text items not edited |
|
387 // Even if user may have edited non-text fields, |
|
388 // delete the note |
|
389 OstTraceFunctionExit0( DUP3_CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT ); |
|
390 return CalenEditorPrivate::ActionDelete; |
|
391 } |
|
392 // Save the note, since the text fields contain something |
|
393 OstTraceFunctionExit0( DUP4_CALENEDITORDATAHANDLER_SHOULDSAVEORDELETEORDONOTHING_EXIT ); |
|
394 return CalenEditorPrivate::ActionSave; |
|
395 } |
|
396 |
|
397 /*! |
|
398 Returns true if the duration of instances of the meeting is greater than |
|
399 the repeat period of the series, false otherwise. |
|
400 \return true if duration of meeting is greater than repeat period, false |
|
401 otherwise |
|
402 */ |
|
403 bool CalenEditorDataHandler::durationGreaterThanRepeatIntervalError() const |
|
404 { |
|
405 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_DURATIONGREATERTHANREPEATINTERVALERROR_ENTRY ); |
|
406 bool isError = false; |
|
407 switch (mEditedEntry->repeatRule().type()) { |
|
408 case AgendaRepeatRule::DailyRule: { |
|
409 int durationDays = |
|
410 mEditedEntry->startTime().daysTo(mEditedEntry->endTime()); |
|
411 isError = durationDays >= 1; |
|
412 } |
|
413 break; |
|
414 case AgendaRepeatRule::WeeklyRule: { |
|
415 int durationDays = |
|
416 mEditedEntry->startTime().daysTo(mEditedEntry->endTime()); |
|
417 if (mEditedEntry->repeatRule().interval() == 1) { |
|
418 isError = durationDays >= 7; |
|
419 } else { |
|
420 isError = durationDays >= 14; |
|
421 } |
|
422 } |
|
423 break; |
|
424 case AgendaRepeatRule::MonthlyRule: { |
|
425 if (mEditedEntry->endTime() |
|
426 >= (mEditedEntry->startTime().addMonths(1))) { |
|
427 isError = true; |
|
428 } |
|
429 } |
|
430 break; |
|
431 case AgendaRepeatRule::YearlyRule: { |
|
432 if (mEditedEntry->endTime() |
|
433 >= (mEditedEntry->startTime().addYears(1))) { |
|
434 isError = true; |
|
435 } |
|
436 } |
|
437 break; |
|
438 default: |
|
439 // Not repeating, no error |
|
440 isError = false; |
|
441 break; |
|
442 } |
|
443 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_DURATIONGREATERTHANREPEATINTERVALERROR_EXIT ); |
|
444 return isError; |
|
445 } |
|
446 |
|
447 /*! |
|
448 Check the alarm fields for errors. |
|
449 \return the error if found, or CalenEditorErrorNone if no error found. |
|
450 */ |
|
451 CalenEditorPrivate::Error CalenEditorDataHandler::checkAlarmFieldsForErrors( |
|
452 bool series) const |
|
453 { |
|
454 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_CHECKALARMFIELDSFORERRORS_ENTRY ); |
|
455 CalenEditorPrivate::Error error = CalenEditorPrivate::CalenEditorErrorNone; |
|
456 // If alarm not active, no check |
|
457 if (!mEditedEntry->alarm().isNull()) { |
|
458 int alarm = mEditedEntry->alarm().timeOffset(); |
|
459 QDateTime startTime = mEditedEntry->startTime(); |
|
460 QDateTime alarmTime; |
|
461 if (alarm > 0) { |
|
462 alarmTime = startTime.addSecs(-alarm * 60); |
|
463 } else { |
|
464 alarmTime = startTime.addSecs(alarm * 60); |
|
465 } |
|
466 QDateTime currentTime = CalenDateUtils::now(); |
|
467 if (isAlarmInAcceptablePeriod(error, alarmTime, startTime)) { |
|
468 if (!series && (alarmTime < currentTime)) { |
|
469 // dont let non-repeating future entries have alarms in past |
|
470 error = CalenEditorPrivate::CalenEditorErrorAlarmTimePast; |
|
471 } |
|
472 } |
|
473 } |
|
474 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_CHECKALARMFIELDSFORERRORS_EXIT ); |
|
475 return error; |
|
476 } |
|
477 |
|
478 /*! |
|
479 Checks if AlarmTime is 31 days from StartTime, |
|
480 then sets Error to CalenEditorErrorAlarmDateTooManyDaysBeforeNote and |
|
481 returns false |
|
482 Checks if AlarmTime is later StartTime, |
|
483 then sets Error to CalenEditorErrorAlarmTimeLaterThanNote and returns false |
|
484 \return true if error untouched, false otherwise |
|
485 */ |
|
486 bool CalenEditorDataHandler::isAlarmInAcceptablePeriod(CalenEditorPrivate::Error &error, |
|
487 const QDateTime &alarmTime, |
|
488 const QDateTime &startTime) const |
|
489 { |
|
490 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_ISALARMINACCEPTABLEPERIOD_ENTRY ); |
|
491 QDateTime upperLimit = startTime; |
|
492 |
|
493 QDateTime lowerLimit = startTime.addDays(-31); |
|
494 bool acceptable = true; |
|
495 if (alarmTime < lowerLimit) { |
|
496 acceptable = false; |
|
497 error = CalenEditorPrivate::CalenEditorErrorAlarmDateTooManyDaysBeforeNote; |
|
498 } else { |
|
499 if (alarmTime > upperLimit) { |
|
500 acceptable = false; |
|
501 error = CalenEditorPrivate::CalenEditorErrorAlarmTimeLaterThanNote; |
|
502 } |
|
503 } |
|
504 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_ISALARMINACCEPTABLEPERIOD_EXIT ); |
|
505 return acceptable; |
|
506 } |
|
507 |
|
508 /*! |
|
509 Display the given error msg |
|
510 \param error Error value for which message has to be displayed |
|
511 */ |
|
512 void CalenEditorDataHandler::displayErrorMsg(int error) |
|
513 { |
|
514 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_DISPLAYERRORMSG_ENTRY ); |
|
515 QString errorMsg = QString::Null(); |
|
516 |
|
517 switch (error) { |
|
518 case CalenEditorPrivate::CalenEditorErrorAlarmTimeLaterThanNote: |
|
519 errorMsg.append( hbTrId( |
|
520 "txt_calendar_dpopinfo_alarm_later_than_note")); |
|
521 break; |
|
522 case CalenEditorPrivate::CalenEditorErrorAlarmTimePast: |
|
523 errorMsg.append( hbTrId( |
|
524 "txt_calendar_dpopinfo_the_time_for_the_note_alarm")); |
|
525 break; |
|
526 case CalenEditorPrivate::CalenEditorErrorAlarmDateTooManyDaysBeforeNote: |
|
527 errorMsg.append( hbTrId( |
|
528 "txt_calendar_dpopinfo_alarm_date_is_too_past")); |
|
529 break; |
|
530 case CalenEditorPrivate::CalenEditorErrorRepeatUntilEarlierThanNote: |
|
531 errorMsg.append( hbTrId( |
|
532 "txt_calendar_dpopinfo_repeat_until_has_to_be_later")); |
|
533 break; |
|
534 case |
|
535 CalenEditorPrivate::CalenEditorErrorDurationGreaterThanRepeatInterval: |
|
536 dispalyErrorMsgByRepeatType(); |
|
537 break; |
|
538 case CalenEditorPrivate::CalenEditorErrorStopTimeEarlierThanStartTime: |
|
539 errorMsg.append( hbTrId( |
|
540 "txt_calendar_dpopinfo_note_ends_before_than_starts")); |
|
541 break; |
|
542 default: |
|
543 break; |
|
544 } |
|
545 if (!errorMsg.isNull()) { |
|
546 HbMessageBox::information(errorMsg); |
|
547 } |
|
548 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_DISPLAYERRORMSG_EXIT ); |
|
549 } |
|
550 |
|
551 /*! |
|
552 Displays error message related to repeat fields |
|
553 */ |
|
554 void CalenEditorDataHandler::dispalyErrorMsgByRepeatType() |
|
555 { |
|
556 OstTraceFunctionEntry0( CALENEDITORDATAHANDLER_DISPALYERRORMSGBYREPEATTYPE_ENTRY ); |
|
557 QString errorMsg = QString::Null(); |
|
558 |
|
559 int durationDays = |
|
560 mEditedEntry->startTime().daysTo(mEditedEntry->endTime()); |
|
561 int numDaysEntrySpan = durationDays + 1; |
|
562 // Add the text proper text ids |
|
563 switch (mEditedEntry->repeatRule().type()) { |
|
564 case AgendaRepeatRule::DailyRule: |
|
565 errorMsg.append( hbTrId( |
|
566 "txt_calendar_dpopinfo_l1_day_meeting_cant_daily")); |
|
567 break; |
|
568 case AgendaRepeatRule::WeeklyRule: |
|
569 if (mEditedEntry->repeatRule().interval() == 1) { |
|
570 errorMsg.append( hbTrId( |
|
571 "txt_calendar_dpopinfo_l1_day_meeting_cant_weekly")); |
|
572 } else { |
|
573 errorMsg.append("meeting duration is more than 2 weeks"); |
|
574 } |
|
575 break; |
|
576 case AgendaRepeatRule::MonthlyRule: |
|
577 errorMsg.append( hbTrId( |
|
578 "txt_calendar_dpopinfo_l1_day_meeting_cant_monthly")); |
|
579 break; |
|
580 case AgendaRepeatRule::YearlyRule: |
|
581 errorMsg.append( hbTrId( |
|
582 "txt_calendar_dpopinfo_l1_day_meeting_cant_yearly")); |
|
583 break; |
|
584 default: |
|
585 break; |
|
586 } |
|
587 if (!errorMsg.isNull()) { |
|
588 HbMessageBox::information(errorMsg.arg(numDaysEntrySpan)); |
|
589 } |
|
590 OstTraceFunctionExit0( CALENEDITORDATAHANDLER_DISPALYERRORMSGBYREPEATTYPE_EXIT ); |
|
591 } |
|
592 |
|
593 // End of file --Don't remove this. |