void tst_QOrganizerItemDetails::eventTime() { QOrganizerEventTime r; QOrganizerEvent e; 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.setEndDateTime(QDateTime(QDate(2010, 10, 14))); QVERIFY(r.endDateTime() == QDateTime(QDate(2010, 10, 14))); // add QOrganizerEventTime r2; r2.setStartDateTime(QDateTime(QDate(2010, 10, 23))); r2.setEndDateTime(QDateTime(QDate(2010, 10, 24))); QVERIFY(e.saveDetail(&r)); QVERIFY(e.details(QOrganizerItemDetail::TypeEventTime).size() == 1); QVERIFY(e.detail(QOrganizerItemDetail::TypeEventTime) == r); QVERIFY(e.saveDetail(&r2)); // note that we don't enforce uniqueness in organizeritem; that's done by the manager! QVERIFY(e.details(QOrganizerItemDetail::TypeEventTime).size() == 2); QVERIFY(e.removeDetail(&r2)); QVERIFY(e.details(QOrganizerItemDetail::TypeEventTime).size() == 1); QVERIFY(e.detail(QOrganizerItemDetail::TypeEventTime) == r); // update r.setAllDay(false); QVERIFY(e.detail(QOrganizerItemDetail::TypeEventTime) != r); QVERIFY(e.saveDetail(&r)); QVERIFY(e.detail(QOrganizerItemDetail::TypeEventTime) == r); QVERIFY(e.details(QOrganizerItemDetail::TypeEventTime).size() == 1); // remove QVERIFY(e.removeDetail(&r)); QVERIFY(e.details(QOrganizerItemDetail::TypeEventTime).size() == 0); }
void tst_QOrganizerItemDetails::recurrence() { QOrganizerItemRecurrence r; QOrganizerEvent e; QOrganizerRecurrenceRule testRule; testRule.setFrequency(QOrganizerRecurrenceRule::Weekly); testRule.setLimit(4); QSet<QOrganizerRecurrenceRule> rrules; rrules << testRule; QOrganizerRecurrenceRule exrule; exrule.setFrequency(QOrganizerRecurrenceRule::Daily); testRule.setLimit(12); QSet<QOrganizerRecurrenceRule> exrules; exrules << exrule; QSet<QDate> rdates, exdates; rdates << QDate(2010, 10, 13); exdates << QDate(2010, 11, 17) << QDate(2010, 11, 20); QVERIFY(e.details(QOrganizerItemDetail::TypeRecurrence).size() == 0); r.setRecurrenceRules(rrules); QVERIFY(r.recurrenceRules() == rrules); QVERIFY(r.recurrenceDates().isEmpty()); QVERIFY(r.exceptionRules().isEmpty()); r.setExceptionRules(exrules); QVERIFY(r.recurrenceRules() == rrules); QVERIFY(r.exceptionRules() == exrules); QVERIFY(r.exceptionDates().isEmpty()); r.setRecurrenceDates(rdates); QVERIFY(r.recurrenceDates() == rdates); QVERIFY(r.exceptionDates().isEmpty()); QVERIFY(r.recurrenceRules() == rrules); QVERIFY(r.exceptionRules() == exrules); r.setExceptionDates(exdates); QVERIFY(r.recurrenceDates() == rdates); QVERIFY(r.exceptionDates() == exdates); QVERIFY(r.recurrenceRules() == rrules); QVERIFY(r.exceptionRules() == exrules); // now save. QVERIFY(e.saveDetail(&r)); QVERIFY(e.details(QOrganizerItemDetail::TypeRecurrence).size() == 1); QVERIFY(e.detail(QOrganizerItemDetail::TypeRecurrence) == r); // update exdates << QDate(2010, 10, 17); r.setExceptionDates(exdates); QVERIFY(e.detail(QOrganizerItemDetail::TypeRecurrence) != r); QVERIFY(e.saveDetail(&r)); QVERIFY(e.detail(QOrganizerItemDetail::TypeRecurrence) == r); QVERIFY(e.details(QOrganizerItemDetail::TypeRecurrence).size() == 1); // should update, not add another. // remove. QVERIFY(e.removeDetail(&r)); QVERIFY(e.details(QOrganizerItemDetail::TypeRecurrence).size() == 0); }