853 QDateTime nextInstanceStartTime; |
853 QDateTime nextInstanceStartTime; |
854 QDateTime nextInstanceEndTime; |
854 QDateTime nextInstanceEndTime; |
855 mAgendaUtil->getNextInstanceTimes(*mEditedEntry, |
855 mAgendaUtil->getNextInstanceTimes(*mEditedEntry, |
856 nextInstanceStartTime, |
856 nextInstanceStartTime, |
857 nextInstanceEndTime); |
857 nextInstanceEndTime); |
|
858 |
|
859 // If no instances earlier then set it to 01/01/1900. |
|
860 if (prevInstanceStartTime.isNull()) { |
|
861 prevInstanceStartTime.setDate(QDate(1900, 01, 01)); |
|
862 prevInstanceStartTime.setTime(QTime(0, 0, 0)); |
|
863 } |
|
864 |
|
865 // If no instances later then set it to 30/01/2100. |
|
866 if (nextInstanceEndTime.isNull()) { |
|
867 nextInstanceEndTime.setDate(QDate(2100, 12, 30)); |
|
868 nextInstanceEndTime.setTime(QTime(0, 0, 0)); |
|
869 } |
858 mViewFromItem->setDateRange( |
870 mViewFromItem->setDateRange( |
859 prevInstanceStartTime.addDays(1).date(), |
871 prevInstanceStartTime.addDays(1).date(), |
860 nextInstanceStartTime.addDays(-1).date()); |
872 nextInstanceStartTime.addDays(-1).date()); |
861 mViewToItem->setDateRange(prevInstanceEndTime.date().addDays(1), |
873 mViewToItem->setDateRange(prevInstanceEndTime.date().addDays(1), |
862 nextInstanceEndTime.date().addDays(-1)); |
874 nextInstanceEndTime.date().addDays(-1)); |
863 |
875 |
864 // If repeating daily then disable the date fields as |
876 // If repeating daily then disable the date fields as |
865 // date cannot be changed |
877 // date cannot be changed |
866 if (mEditedEntry->repeatRule().type() == AgendaRepeatRule::DailyRule) { |
878 if ((prevInstanceEndTime.date().daysTo( |
|
879 mEditedEntry->startTime().date()) == 1) && |
|
880 (mEditedEntry->endTime().date().daysTo( |
|
881 nextInstanceStartTime.date()) == 1)) { |
867 mViewFromItem->disableFromToDateField(); |
882 mViewFromItem->disableFromToDateField(); |
868 } |
883 } |
869 } |
884 } |
870 } else { |
885 } else { |
871 toDateTime = fromDateTime.addSecs(60 * 60); |
886 toDateTime = fromDateTime.addSecs(60 * 60); |
879 mOriginalEntry->setStartAndEndTime(fromDateTime, toDateTime); |
894 mOriginalEntry->setStartAndEndTime(fromDateTime, toDateTime); |
880 } |
895 } |
881 if ((mAllDayCheckBoxItem && |
896 if ((mAllDayCheckBoxItem && |
882 (mAllDayCheckBoxItem->contentWidgetData("checkState") == Qt::Checked)) |
897 (mAllDayCheckBoxItem->contentWidgetData("checkState") == Qt::Checked)) |
883 || (!mNewEntry && mEditedEntry->type() == AgendaEntry::TypeEvent)) { |
898 || (!mNewEntry && mEditedEntry->type() == AgendaEntry::TypeEvent)) { |
|
899 |
|
900 // For all-day, we need to substratc 1 minute to get the actual end time |
|
901 // as we store all-day as 12.00AM to 12.00 AM next day |
|
902 QDateTime actualEndTime = mEditedEntry->endTime().addSecs(-60); |
|
903 mViewToItem->populateDateTime(actualEndTime, false); |
|
904 |
884 // If the all day option is checked, we need to |
905 // If the all day option is checked, we need to |
885 // disable the time fields |
906 // disable the time fields |
886 enableFromTotimeFileds(false, mEditedEntry->startTime(), |
907 enableFromTotimeFileds(false, mEditedEntry->startTime(), |
887 mEditedEntry->endTime()); |
908 actualEndTime); |
888 } |
909 } |
889 } |
910 } |
890 /*! |
911 /*! |
891 Populate location item from the editor model and set it in the widget and listen |
912 Populate location item from the editor model and set it in the widget and listen |
892 text change happend in the widget. |
913 text change happend in the widget. |
1179 // AllDayCheckBox in un-checked |
1200 // AllDayCheckBox in un-checked |
1180 // Set From/To times buttons editable |
1201 // Set From/To times buttons editable |
1181 // Update Start/End Times with Edited entry values |
1202 // Update Start/End Times with Edited entry values |
1182 enableFromTotimeFileds(true, mEditedEntry->startTime(), |
1203 enableFromTotimeFileds(true, mEditedEntry->startTime(), |
1183 mEditedEntry->endTime()); |
1204 mEditedEntry->endTime()); |
|
1205 // If original entry was an All-day, then we need to save the date that |
|
1206 // is shown on the "To" date push button |
|
1207 if (mOriginalEntry->type() == AgendaEntry::TypeEvent) { |
|
1208 mEditedEntry->setStartAndEndTime(mViewFromItem->getDateTime(), |
|
1209 mViewToItem->getDateTime()); |
|
1210 } |
1184 int index; |
1211 int index; |
1185 if (mIsAllDayItemAdded) { |
1212 if (mIsAllDayItemAdded) { |
1186 index = ReminderTimeForAllDayItem; |
1213 index = ReminderTimeForAllDayItem; |
1187 } else { |
1214 } else { |
1188 index = ReminderTimeForAllDayItem - 1; |
1215 index = ReminderTimeForAllDayItem - 1; |
1400 error = mDataHandler->checkErrorsForThisAndAll(); |
1427 error = mDataHandler->checkErrorsForThisAndAll(); |
1401 if (CalenEditorPrivate::CalenEditorErrorNone == error) { |
1428 if (CalenEditorPrivate::CalenEditorErrorNone == error) { |
1402 if (!handleAllDayToSave()) { |
1429 if (!handleAllDayToSave()) { |
1403 if (mNewEntry) { |
1430 if (mNewEntry) { |
1404 mAgendaUtil->addEntry(*mEditedEntry); |
1431 mAgendaUtil->addEntry(*mEditedEntry); |
1405 } else if (mEditRange == ThisAndAll) { |
1432 } else if (mEditRange == ThisAndAll && mOriginalEntry->isRepeating()) { |
1406 mAgendaUtil->storeRepeatingEntry(*mEditedEntry, true); |
1433 mAgendaUtil->storeRepeatingEntry(*mEditedEntry, true); |
1407 } else if (!mIsChild && (mEditRange == ThisOnly)) { |
1434 } else if (!mIsChild && (mEditRange == ThisOnly)) { |
1408 // Create the new exception |
1435 // Create the new exception |
1409 mAgendaUtil->createException(*mEditedEntry); |
1436 mAgendaUtil->createException(*mEditedEntry, |
|
1437 mOriginalEntry->startTime()); |
1410 } else { |
1438 } else { |
1411 // Normal entry updation |
1439 // Normal entry updation |
1412 mAgendaUtil->updateEntry(*mEditedEntry, false); |
1440 mAgendaUtil->updateEntry(*mEditedEntry, false); |
1413 } |
1441 } |
1414 } |
1442 } |
1469 // Clone the entry to AllDay |
1497 // Clone the entry to AllDay |
1470 |
1498 |
1471 QDateTime tempSartTime = |
1499 QDateTime tempSartTime = |
1472 CalenDateUtils::beginningOfDay(mEditedEntry->startTime()); |
1500 CalenDateUtils::beginningOfDay(mEditedEntry->startTime()); |
1473 |
1501 |
1474 // Set EndTime of AllDay event to 23:59:59 |
1502 // Set EndTime of AllDay event to 00:00:00 of next day |
1475 QDateTime tempEndTime = mEditedEntry->endTime(); |
1503 QDateTime tempEndTime = mEditedEntry->endTime().addDays(1); |
1476 QTime tempEndQTime = tempEndTime.time(); |
1504 QTime tempEndQTime = tempEndTime.time(); |
1477 tempEndQTime.setHMS(23, 59, 59); |
1505 tempEndQTime.setHMS(0, 0, 0); |
1478 tempEndTime.setTime(tempEndQTime); |
1506 tempEndTime.setTime(tempEndQTime); |
1479 |
1507 |
1480 if (mNewEntry && (mAllDayCheckBoxItem->contentWidgetData("checkState") |
1508 if (mNewEntry && (mAllDayCheckBoxItem->contentWidgetData("checkState") |
1481 == Qt::Checked)) { |
1509 == Qt::Checked)) { |
1482 // changes Start/End times of entry to Beginning ot the day |
1510 // changes Start/End times of entry to Beginning ot the day |
1493 // Clone the entry to AllDayEntry, Delete old entry from Database |
1521 // Clone the entry to AllDayEntry, Delete old entry from Database |
1494 mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeEvent); |
1522 mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeEvent); |
1495 mAgendaUtil->deleteEntry(mEditedEntry->id()); |
1523 mAgendaUtil->deleteEntry(mEditedEntry->id()); |
1496 |
1524 |
1497 return true; |
1525 return true; |
1498 } else if ((mAllDayCheckBoxItem->contentWidgetData("checkState") |
1526 } else if (mAllDayCheckBoxItem->contentWidgetData("checkState") |
1499 != Qt::Checked) && (mEditedEntry->type() |
1527 != Qt::Checked) { |
1500 != AgendaEntry::TypeAppoinment)) { |
1528 if (mEditedEntry->type() != AgendaEntry::TypeAppoinment) { |
1501 // Editing exissting AllDayentry, and Alldat Box is Not-Checked |
1529 // Editing existing AllDayentry, and Alldat Box is Not-Checked |
1502 // Clone the entry to MeetingEntry, Delete old entry from Database |
1530 // Clone the entry to MeetingEntry, Delete old entry from Database |
1503 mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeAppoinment); |
1531 mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeAppoinment); |
1504 mAgendaUtil->deleteEntry(mEditedEntry->id()); |
1532 mAgendaUtil->deleteEntry(mEditedEntry->id()); |
1505 |
1533 return true; |
1506 return true; |
1534 } |
1507 } |
1535 // Check if the duration of the meeting is matching the all-day criteria |
|
1536 // if yes, then we need to store it as all-day instead of normal meeting |
|
1537 else if (mEditedEntry->startTime() == CalenDateUtils::beginningOfDay(mEditedEntry->startTime())) { |
|
1538 // Get the end time and see if it is at the beginning of the end date day |
|
1539 if (mEditedEntry->endTime() == CalenDateUtils::beginningOfDay(mEditedEntry->endTime())) { |
|
1540 // Store it as all-day |
|
1541 mEditedEntry->setType(AgendaEntry::TypeEvent); |
|
1542 // Check if this was an all-day earlier and now user has changed it like that |
|
1543 // or it is a new entry |
|
1544 if (mOriginalEntry->type() == AgendaEntry::TypeEvent || |
|
1545 mNewEntry) { |
|
1546 return false; |
|
1547 } else { |
|
1548 // It was a meeting |
|
1549 // Clone the entry to AllDayEntry, Delete old entry from Database |
|
1550 mEditedEntry->setStartAndEndTime(tempSartTime, tempEndTime); |
|
1551 mAgendaUtil->cloneEntry(*mEditedEntry, AgendaEntry::TypeEvent); |
|
1552 mAgendaUtil->deleteEntry(mEditedEntry->id()); |
|
1553 return true; |
|
1554 } |
|
1555 } |
|
1556 } |
|
1557 } |
1508 return false; |
1558 return false; |
1509 } |
1559 } |
1510 |
1560 |
1511 /*! |
1561 /*! |
1512 Enable/Disable TimeFields depending on AllDay checkbox state |
1562 Enable/Disable TimeFields depending on AllDay checkbox state |