881 currentDateTime = currentDateTime.addSecs(SecsInOneHour); |
882 currentDateTime = currentDateTime.addSecs(SecsInOneHour); |
882 } |
883 } |
883 |
884 |
884 // After adding one hour and rounding off the minutes to current time, |
885 // 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 midnight crossover happens return default time(8:00 am) for next day |
886 if(CalenDateUtils::isOnToday(currentDateTime)) |
887 if(CalenDateUtils::isOnToday(currentDateTime)) { |
|
888 OstTraceFunctionExit0( CALENEDITORPRIVATE_DEFAULTTIMESAMEDAY_EXIT ); |
887 return currentDateTime; |
889 return currentDateTime; |
888 else |
890 } else { |
889 return CalenDateUtils::defaultTime(currentDateTime); |
891 return CalenDateUtils::defaultTime(currentDateTime); |
|
892 } |
890 } |
893 } |
891 |
894 |
892 /*! |
895 /*! |
893 Sets to default time, when AllDay is unchecked |
896 Sets to default time, when AllDay is unchecked |
894 */ |
897 */ |
895 void CalenEditorPrivate::refreshTimeForUncheckAllDay() |
898 void CalenEditorPrivate::refreshTimeForUncheckAllDay() |
896 { |
899 { |
|
900 OstTraceFunctionEntry0( CALENEDITORPRIVATE_REFRESHTIMEFORUNCHECKALLDAY_ENTRY ); |
897 //Get the default time as 8:00 am from CalenDateUtils. |
901 //Get the default time as 8:00 am from CalenDateUtils. |
898 QDateTime fromDateTime = CalenDateUtils::defaultTime(mEditedEntry->startTime()); |
902 QDateTime fromDateTime = CalenDateUtils::defaultTime(mEditedEntry->startTime()); |
899 QDateTime toDateTime; |
903 QDateTime toDateTime; |
900 |
904 |
901 // The default time will be 8.00 am only if its not on current day |
905 // The default time will be 8.00 am only if its not on current day |
1448 * Handles the completion of location editing |
1455 * Handles the completion of location editing |
1449 */ |
1456 */ |
1450 void CalenEditorPrivate::handleLocationEditingFinished() |
1457 void CalenEditorPrivate::handleLocationEditingFinished() |
1451 { |
1458 { |
1452 OstTraceFunctionEntry0( CALENEDITORPRIVATE_HANDLELOCATIONEDITINGFINISHED_ENTRY ); |
1459 OstTraceFunctionEntry0( CALENEDITORPRIVATE_HANDLELOCATIONEDITINGFINISHED_ENTRY ); |
|
1460 QString trimmedLocation ; |
|
1461 trimmedLocation = mEditedEntry->location().trimmed(); |
1453 if ( !mOriginalEntry->location().isEmpty() ) |
1462 if ( !mOriginalEntry->location().isEmpty() ) |
1454 { |
1463 { |
1455 AgendaGeoValue entryGeoValue =mAgendaUtil->fetchById(mEditedEntry->id()).geoValue(); |
1464 if(!trimmedLocation .isEmpty()) |
1456 if ( !entryGeoValue.isNull() && (mEditedEntry->location()!=mOriginalEntry->location()) ) |
1465 { |
1457 { |
1466 AgendaGeoValue entryGeoValue =mAgendaUtil->fetchById(mEditedEntry->id()).geoValue(); |
1458 |
1467 if ( !entryGeoValue.isNull() && (mEditedEntry->location()!=mOriginalEntry->location()) ) |
1459 mEditedEntry->setGeoValue(entryGeoValue); |
1468 { |
1460 HbMessageBox* confirmationQuery = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
1469 |
1461 |
1470 mEditedEntry->setGeoValue(entryGeoValue); |
1462 confirmationQuery->setDismissPolicy(HbDialog::NoDismiss); |
1471 HbMessageBox* confirmationQuery = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
1463 confirmationQuery->setTimeout(HbDialog::NoTimeout); |
1472 // Set the parent for the dialog |
1464 confirmationQuery->setIconVisible(true); |
1473 // Once the editor object is deleted the dialog will also be deleted |
1465 |
1474 confirmationQuery->setParent(this); |
1466 QString displayText; |
1475 confirmationQuery->setDismissPolicy(HbDialog::NoDismiss); |
1467 displayText = displayText.append(hbTrId("txt_calendar_info_location_updated_keep_existing")); |
1476 confirmationQuery->setTimeout(HbDialog::NoTimeout); |
1468 |
1477 confirmationQuery->setIconVisible(true); |
1469 confirmationQuery->setText(displayText); |
1478 |
1470 |
1479 QString displayText; |
1471 // Remove the default actions. |
1480 displayText = displayText.append(hbTrId("txt_calendar_info_location_updated_keep_existing")); |
1472 QList<QAction *> defaultActions = confirmationQuery->actions(); |
1481 |
1473 for (int index=0;index<defaultActions.count();index++) |
1482 confirmationQuery->setText(displayText); |
1474 { |
1483 |
1475 confirmationQuery->removeAction(defaultActions[index]); |
1484 // Remove the default actions. |
1476 } |
1485 QList<QAction *> defaultActions = confirmationQuery->actions(); |
1477 |
1486 for (int index=0;index<defaultActions.count();index++) |
1478 defaultActions.clear(); |
1487 { |
1479 confirmationQuery->addAction(new HbAction(hbTrId("txt_common_button_yes"))); |
1488 confirmationQuery->removeAction(defaultActions[index]); |
1480 confirmationQuery->addAction(new HbAction(hbTrId("txt_common_button_no"))); |
1489 } |
1481 confirmationQuery->open(this, SLOT(selectEditingFinishedAction(HbAction*))); |
1490 |
1482 } |
1491 defaultActions.clear(); |
|
1492 confirmationQuery->addAction(new HbAction(hbTrId("txt_common_button_yes"))); |
|
1493 confirmationQuery->addAction(new HbAction(hbTrId("txt_common_button_no"))); |
|
1494 confirmationQuery->open(this, SLOT(selectEditingFinishedAction(HbAction*))); |
|
1495 } |
|
1496 } |
|
1497 else |
|
1498 { |
|
1499 mEditedEntry->clearGeoValue(); |
|
1500 // sets null string for the location |
|
1501 mEditedEntry->setLocation(trimmedLocation ); |
|
1502 } |
1483 } |
1503 } |
1484 OstTraceFunctionExit0( CALENEDITORPRIVATE_HANDLELOCATIONEDITINGFINISHED_EXIT ); |
1504 OstTraceFunctionExit0( CALENEDITORPRIVATE_HANDLELOCATIONEDITINGFINISHED_EXIT ); |
1485 } |
1505 } |
1486 |
1506 |
1487 /*! |
1507 /*! |
1562 closeEditor(); |
1580 closeEditor(); |
1563 OstTraceFunctionExit0( CALENEDITORPRIVATE_HANDLEDELETEACTION_EXIT ); |
1581 OstTraceFunctionExit0( CALENEDITORPRIVATE_HANDLEDELETEACTION_EXIT ); |
1564 return; |
1582 return; |
1565 }else { |
1583 }else { |
1566 // Delete entry and close editor |
1584 // Delete entry and close editor |
1567 deleteEntry(true); |
1585 // if editor is launched from Notes then don't delete entry |
|
1586 // Just exit from calendar editor |
|
1587 if (mOriginalEntry->id() > 0) { |
|
1588 // If user is editing single instanc then delete single instance |
|
1589 // else delete entry |
|
1590 if (mEditRange == ThisOnly) { |
|
1591 // User wants to delete only this occurence |
|
1592 mAgendaUtil->deleteRepeatedEntry(*mOriginalEntry, |
|
1593 AgendaUtil::ThisOnly); |
|
1594 } else { |
|
1595 // Delete the entry. |
|
1596 mAgendaUtil->deleteEntry(mOriginalEntry->id()); |
|
1597 } |
|
1598 closeEditor(); |
|
1599 } |
1568 } |
1600 } |
1569 OstTraceFunctionExit0( DUP1_CALENEDITORPRIVATE_HANDLEDELETEACTION_EXIT ); |
1601 OstTraceFunctionExit0( DUP1_CALENEDITORPRIVATE_HANDLEDELETEACTION_EXIT ); |
|
1602 } |
|
1603 |
|
1604 /*! |
|
1605 Deletes the entry based on the selection: This occurence or All occurences |
|
1606 */ |
|
1607 void CalenEditorPrivate::handleDeleteOccurence(int index) |
|
1608 { |
|
1609 OstTraceFunctionEntry0( CALENEDITORPRIVATE_HANDLEDELETEOCCURENCE_ENTRY ); |
|
1610 switch (index) { |
|
1611 case 0: |
|
1612 // User wants to delete only this occurence |
|
1613 mAgendaUtil->deleteRepeatedEntry(mEntry, AgendaUtil::ThisOnly); |
|
1614 break; |
|
1615 case 1: |
|
1616 // User wants to delete all the occurences |
|
1617 // Delete the parent entry. |
|
1618 if(isChild()) { |
|
1619 AgendaEntry entryToBeDeleted = mAgendaUtil->parentEntry(mEntry); |
|
1620 mAgendaUtil->deleteEntry(entryToBeDeleted.id()); |
|
1621 }else { |
|
1622 mAgendaUtil->deleteEntry(mOriginalEntry->id()); |
|
1623 } |
|
1624 break; |
|
1625 } |
|
1626 closeEditor(); |
|
1627 OstTraceFunctionExit0( CALENEDITORPRIVATE_HANDLEDELETEOCCURENCE_EXIT ); |
1570 } |
1628 } |
1571 |
1629 |
1572 /*! |
1630 /*! |
1573 Launches the Settings view. |
1631 Launches the Settings view. |
1574 */ |
1632 */ |
1589 closeEditor(); |
1647 closeEditor(); |
1590 OstTraceFunctionExit0( CALENEDITORPRIVATE_DISCARDCHANGES_EXIT ); |
1648 OstTraceFunctionExit0( CALENEDITORPRIVATE_DISCARDCHANGES_EXIT ); |
1591 } |
1649 } |
1592 |
1650 |
1593 /*! |
1651 /*! |
1594 * Show delete confirmation query |
1652 * Show delete confirmation query based on the entry |
1595 */ |
1653 */ |
1596 void CalenEditorPrivate::showDeleteConfirmationQuery(bool closeEditor) |
1654 void CalenEditorPrivate::showDeleteConfirmationQuery() |
1597 { |
1655 { |
1598 OstTraceFunctionEntry0( CALENEDITORPRIVATE_SHOWDELETECONFIRMATIONQUERY_ENTRY ); |
1656 OstTraceFunctionEntry0( CALENEDITORPRIVATE_SHOWDELETECONFIRMATIONQUERY_ENTRY ); |
|
1657 if(mOriginalEntry->isRepeating() || isChild()) { |
|
1658 showDeleteOccurencePopup(); |
|
1659 }else { |
|
1660 showDeletePopup(); |
|
1661 } |
|
1662 OstTraceFunctionExit0( CALENEDITORPRIVATE_SHOWDELETECONFIRMATIONQUERY_EXIT ); |
|
1663 } |
|
1664 |
|
1665 /*! |
|
1666 * Show delete confirmation query for repeated entries |
|
1667 */ |
|
1668 void CalenEditorPrivate::showDeleteOccurencePopup() |
|
1669 { |
|
1670 OstTraceFunctionEntry0( CALENEDITORPRIVATE_SHOWDELETEOCCURENCEPOPUP_ENTRY ); |
|
1671 HbDialog *popUp = new HbDialog(); |
|
1672 // Set the parent for the dialog |
|
1673 // Once the editor object is deleted the dialog will also be deleted |
|
1674 popUp->setParent(this); |
|
1675 popUp->setDismissPolicy(HbDialog::NoDismiss); |
|
1676 popUp->setTimeout(HbDialog::NoTimeout); |
|
1677 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
1678 |
|
1679 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
|
1680 HbWidget *editWidget = new HbWidget(); |
|
1681 editWidget->setLayout(layout); |
|
1682 |
|
1683 HbRadioButtonList *editButtonList = new HbRadioButtonList(); |
|
1684 |
|
1685 QStringList list; |
|
1686 list << hbTrId("txt_calendar_info_this_occurrence_only") |
|
1687 << hbTrId("txt_calendar_info_all_occurences"); |
|
1688 |
|
1689 editButtonList->setItems(list); |
|
1690 |
|
1691 layout->addItem(editButtonList); |
|
1692 |
|
1693 popUp->setContentWidget(editWidget); |
|
1694 popUp->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_delete_repeated_entry"))); |
|
1695 |
|
1696 // Create cancel action |
|
1697 HbAction *cancelAction = |
|
1698 new HbAction(hbTrId("txt_common_button_cancel_singledialog")); |
|
1699 popUp->addAction(cancelAction); |
|
1700 connect(editButtonList, SIGNAL(itemSelected(int)), popUp, SLOT(close())); |
|
1701 connect(editButtonList, SIGNAL(itemSelected(int)), this, |
|
1702 SLOT(handleDeleteOccurence(int))); |
|
1703 connect(cancelAction, SIGNAL(triggered()), this, SLOT(close())); |
|
1704 |
|
1705 // Show the popup |
|
1706 popUp->open(); |
|
1707 OstTraceFunctionExit0( CALENEDITORPRIVATE_SHOWDELETEOCCURENCEPOPUP_EXIT ); |
|
1708 } |
|
1709 |
|
1710 /*! |
|
1711 * Show delete confirmation query for non repeated entries |
|
1712 */ |
|
1713 void CalenEditorPrivate::showDeletePopup() |
|
1714 { |
|
1715 OstTraceFunctionEntry0( CALENEDITORPRIVATE_SHOWDELETEPOPUP_ENTRY ); |
1599 HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
1716 HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
1717 // Set the parent for the dialog |
|
1718 // Once the editor object is deleted the dialog will also be deleted |
|
1719 popup->setParent(this); |
1600 popup->setDismissPolicy(HbDialog::NoDismiss); |
1720 popup->setDismissPolicy(HbDialog::NoDismiss); |
1601 popup->setTimeout(HbDialog::NoTimeout); |
1721 popup->setTimeout(HbDialog::NoTimeout); |
1602 popup->setAttribute( Qt::WA_DeleteOnClose, true ); |
1722 popup->setAttribute( Qt::WA_DeleteOnClose, true ); |
1603 |
1723 |
1604 QString text = 0; |
1724 popup->setText(hbTrId("txt_calendar_info_delete_entry")); |
1605 |
1725 |
1606 switch (mOriginalEntry->type()) { |
1726 QList<QAction*> list = popup->actions(); |
1607 case AgendaEntry::TypeAppoinment: |
1727 for(int i=0; i < list.count(); i++) |
1608 case AgendaEntry::TypeEvent: { |
1728 { |
1609 if (mEditRange == ThisAndAll) { |
1729 popup->removeAction(list[i]); |
1610 text.append(hbTrId("txt_calendar_info_delete_entries")); |
1730 } |
1611 } else { |
|
1612 text.append(hbTrId("txt_calendar_info_delete_meeting")); |
|
1613 } |
|
1614 break; |
|
1615 } |
|
1616 case AgendaEntry::TypeAnniversary: { |
|
1617 text.append(hbTrId("txt_calendar_info_delete_anniversary")); |
|
1618 break; |
|
1619 } |
|
1620 } |
|
1621 |
|
1622 popup->setText(text); |
|
1623 |
|
1624 QList<QAction*> list = popup->actions(); |
|
1625 for(int i=0; i < list.count(); i++) |
|
1626 { |
|
1627 popup->removeAction(list[i]); |
|
1628 } |
|
1629 HbAction *deleteAction = new HbAction(hbTrId("txt_common_button_delete"), |
1731 HbAction *deleteAction = new HbAction(hbTrId("txt_common_button_delete"), |
1630 popup); |
1732 popup); |
1631 popup->addAction(deleteAction); |
1733 popup->addAction(deleteAction); |
1632 connect(deleteAction, SIGNAL(triggered()), this, |
1734 connect(deleteAction, SIGNAL(triggered()), this, |
1633 SLOT(handleDeleteAction())); |
1735 SLOT(handleDeleteAction())); |
1634 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel"), |
1736 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_cancel"), |
1635 popup); |
1737 popup); |
1636 // Editor should not be closed for all the cases when cancel is pressed |
1738 connect(cancelAction, SIGNAL(triggered()), this, SLOT(close())); |
1637 if(closeEditor) { |
|
1638 connect(cancelAction, SIGNAL(triggered()), this, |
|
1639 SLOT(closeEditor())); |
|
1640 } |
|
1641 popup->addAction(cancelAction); |
1739 popup->addAction(cancelAction); |
1642 popup->open(); |
1740 popup->open(); |
1643 OstTraceFunctionExit0( CALENEDITORPRIVATE_SHOWDELETECONFIRMATIONQUERY_EXIT ); |
1741 |
|
1742 OstTraceFunctionExit0( CALENEDITORPRIVATE_SHOWDELETEPOPUP_EXIT ); |
1644 } |
1743 } |
1645 |
1744 |
1646 /*! |
1745 /*! |
1647 Returns true if the entry is a child ,else false. |
1746 Returns true if the entry is a child ,else false. |
1648 \return true if the entry is a child, false otherwise. |
1747 \return true if the entry is a child, false otherwise. |
1649 */ |
1748 */ |
1650 bool CalenEditorPrivate::isChild() const |
1749 bool CalenEditorPrivate::isChild() const |
1651 { |
1750 { |
1652 OstTraceFunctionEntry0( CALENEDITORPRIVATE_ISCHILD_ENTRY ); |
1751 OstTraceFunctionEntry0( CALENEDITORPRIVATE_ISCHILD_ENTRY ); |
1653 return mEditedEntry->recurrenceId().toUTC().isNull(); |
1752 return !(mEditedEntry->recurrenceId().toUTC().isNull()); |
1654 } |
1753 } |
1655 |
1754 |
1656 /*! |
1755 /*! |
1657 Check for errors in the form. This function should only be called when the |
1756 Check for errors in the form. This function should only be called when the |
1658 user has decided they want to edit "This and all" from a prompt, or when the |
1757 user has decided they want to edit "This and all" from a prompt, or when the |