void OrganizerTodoTimeTransform::transformToEntryL(const QOrganizerItem& item, CCalEntry* entry) { if(item.type() == QOrganizerItemType::TypeTodo || item.type() == QOrganizerItemType::TypeTodoOccurrence) { QOrganizerTodoTime range = item.detail<QOrganizerTodoTime>(); // Nothing to do? if (range.isEmpty()) return; // On some platforms symbian calendar server does not leave // when start date is more than due date. So make the check here. if (range.startDateTime().isValid() && range.dueDateTime().isValid()) { if (range.startDateTime() > range.dueDateTime()) User::Leave(KErrArgument); } entry->SetStartAndEndTimeL(toTCalTimeL(range.startDateTime()), toTCalTimeL(range.dueDateTime())); } }
void tst_QOrganizerItemDetails::todoTime() { QOrganizerTodoTime r; QOrganizerTodo t; QVERIFY(r.isEmpty()); QVERIFY(!r.isAllDay()); r.setStartDateTime(QDateTime(QDate(2010, 10, 13))); QVERIFY(r.startDateTime() == QDateTime(QDate(2010, 10, 13))); QVERIFY(!r.isAllDay()); r.setAllDay(true); QVERIFY(r.isAllDay()); r.setDueDateTime(QDateTime(QDate(2010, 10, 14))); QVERIFY(r.dueDateTime() == QDateTime(QDate(2010, 10, 14))); // add QOrganizerTodoTime r2; r2.setStartDateTime(QDateTime(QDate(2010, 10, 23))); r2.setDueDateTime(QDateTime(QDate(2010, 10, 24))); QVERIFY(t.saveDetail(&r)); QVERIFY(t.details(QOrganizerItemDetail::TypeTodoTime).size() == 1); QVERIFY(t.detail(QOrganizerItemDetail::TypeTodoTime) == r); QVERIFY(t.saveDetail(&r2)); // note that we don't enforce uniqueness in organizeritem; that's done by the manager! QVERIFY(t.details(QOrganizerItemDetail::TypeTodoTime).size() == 2); QVERIFY(t.removeDetail(&r2)); QVERIFY(t.details(QOrganizerItemDetail::TypeTodoTime).size() == 1); QVERIFY(t.detail(QOrganizerItemDetail::TypeTodoTime) == r); // update r.setAllDay(false); QVERIFY(t.detail(QOrganizerItemDetail::TypeTodoTime) != r); QVERIFY(t.saveDetail(&r)); QVERIFY(t.detail(QOrganizerItemDetail::TypeTodoTime) == r); QVERIFY(t.details(QOrganizerItemDetail::TypeTodoTime).size() == 1); // remove QVERIFY(t.removeDetail(&r)); QVERIFY(t.details(QOrganizerItemDetail::TypeTodoTime).size() == 0); }
/*! Returns the date time by which the task should be completed. For all-day tasks, the time part is meaningless. */ QDateTime QOrganizerTodoOccurrence::dueDateTime() const { QOrganizerTodoTime ttr = detail(QOrganizerItemDetail::TypeTodoTime); return ttr.dueDateTime(); }