void tst_QOrganizerItemDetails::guid()
{
    QOrganizerItem oi;
    QOrganizerItemGuid g1, g2;

    // test property set
    g1.setGuid("1234");
    QCOMPARE(g1.guid(), QString("1234"));
    QCOMPARE(g1.value(QOrganizerItemGuid::FieldGuid).toString(), QString("1234"));

    // test property add
    QVERIFY(oi.saveDetail(&g1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeGuid).count(), 1);
    QCOMPARE(QOrganizerItemGuid(oi.details(QOrganizerItemDetail::TypeGuid).value(0)).guid(), g1.guid());

    // test property update
    g1.setValue(101,"label1");
    g1.setGuid("12345");
    QVERIFY(oi.saveDetail(&g1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeGuid).value(0).value(101).toString(), QString("label1"));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeGuid).value(0).value(QOrganizerItemGuid::FieldGuid).toString(), QString("12345"));

    // test property remove
    QVERIFY(oi.removeDetail(&g1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeGuid).count(), 0);
    QVERIFY(oi.saveDetail(&g2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeGuid).count(), 1);
    QVERIFY(oi.removeDetail(&g2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeGuid).count(), 0);
    QVERIFY(oi.removeDetail(&g2) == false);
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeGuid).count(), 0);
}
void tst_QOrganizerItemDetails::description()
{
    QOrganizerItemDescription d1;
    QOrganizerItem oi;
    QVERIFY(d1.description().isEmpty());
    QVERIFY(d1.value(QOrganizerItemDescription::FieldDescription).isNull());
    d1.setValue(QOrganizerItemDescription::FieldDescription, "Test");
    QVERIFY(d1.value(QOrganizerItemDescription::FieldDescription) == QString("Test"));
    QVERIFY(d1.description() == QString("Test"));

    QOrganizerItemDescription d2;
    d2.setValue(QOrganizerItemDescription::FieldDescription, "Test 2");

    // test property add -- description is unique.
    QVERIFY(oi.saveDetail(&d2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeDescription).count(), 1); // count should be 1
    QVERIFY(oi.saveDetail(&d1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeDescription).count(), 1); // count should be 1

    // test property update
    d1.setDescription("Test 3");
    QVERIFY(oi.saveDetail(&d1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeDescription).count(), 1); // count should be 1
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeDescription).value(QOrganizerItemDescription::FieldDescription) == QString("Test 3"));

    // test property remove
    QVERIFY(oi.removeDetail(&d1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeDescription).count(), 0);
}
void tst_QOrganizerItemDetails::displayLabel()
{
    QOrganizerItemDisplayLabel d1;
    QOrganizerItem oi;

    QVERIFY(d1.label().isEmpty());
    QVERIFY(d1.value(QOrganizerItemDisplayLabel::FieldLabel).isNull());
    d1.setValue(QOrganizerItemDisplayLabel::FieldLabel, "Test");
    QVERIFY(d1.value(QOrganizerItemDisplayLabel::FieldLabel) == QString("Test"));
    QVERIFY(d1.label() == QString("Test"));

    QOrganizerItemDisplayLabel d2;
    d2.setValue(QOrganizerItemDisplayLabel::FieldLabel, "Test 2");

    // test property add - should update.
    QVERIFY(oi.saveDetail(&d2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeDisplayLabel).count(), 1);
    QVERIFY(oi.saveDetail(&d1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeDisplayLabel).count(), 1);

    // test property update - should update
    d1.setLabel("Test 3");
    QVERIFY(oi.saveDetail(&d1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeDisplayLabel).count(), 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeDisplayLabel).value(QOrganizerItemDisplayLabel::FieldLabel) == QString("Test 3"));

    // test property remove
    QVERIFY(oi.removeDetail(&d1)); // can remove display label.  it's unique but not required.
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeDisplayLabel).count(), 0);
}
void tst_QOrganizerItemDetails::tag()
{
    QOrganizerItem oi;
    QOrganizerItemTag t1, t2;

    // test property set
    t1.setTag("red");
    QCOMPARE(t1.tag(), QString("red"));
    QCOMPARE(t1.value(QOrganizerItemTag::FieldTag).toString(), QString("red"));

    // test property add
    QVERIFY(oi.saveDetail(&t1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTag).count(), 1);
    QCOMPARE(QOrganizerItemTag(oi.details(QOrganizerItemDetail::TypeTag).value(0)).tag(), t1.tag());
    QVERIFY(oi.saveDetail(&t2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTag).count(), 2);

    // test property update
    t1.setValue(101,"label1");
    t1.setTag("green");
    QVERIFY(oi.saveDetail(&t1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTag).value(0).value(101).toString(), QString("label1"));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTag).value(0).value(QOrganizerItemTag::FieldTag).toString(), QString("green"));

    // test property remove
    QVERIFY(oi.removeDetail(&t1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTag).count(), 1);
    QVERIFY(oi.removeDetail(&t2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTag).count(), 0);
    QVERIFY(oi.removeDetail(&t2) == false);
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTag).count(), 0);
}
void tst_QOrganizerItemDetails::location()
{
    QOrganizerItemLocation l1;
    QOrganizerItem oi;

    QVERIFY(l1.isEmpty());
    l1.setLatitude(0.12345);
    QVERIFY(!l1.isEmpty());
    QVERIFY(l1.latitude() == 0.12345);
    l1.setValue(QOrganizerItemLocation::FieldLongitude, 0.54321);
    QVERIFY(l1.longitude() == 0.54321);
    l1.setLabel("test");
    QVERIFY(l1.label() == QString("test"));

    QVERIFY(oi.details<QOrganizerItemLocation>().size() == 0);
    QVERIFY(oi.saveDetail(&l1));
    QVERIFY(oi.details<QOrganizerItemLocation>().size() == 1);
    QVERIFY(oi.detail<QOrganizerItemLocation>() == l1);

    l1.setLabel("test 2");
    QVERIFY(oi.detail<QOrganizerItemLocation>() != l1);
    QVERIFY(oi.saveDetail(&l1)); // update.
    QVERIFY(oi.details<QOrganizerItemLocation>().size() == 1); // should update, not add another.
    QVERIFY(oi.detail<QOrganizerItemLocation>() == l1);

    oi.removeDetail(&l1);
    QVERIFY(oi.details<QOrganizerItemLocation>().size() == 0);
}
void tst_QOrganizerItemDetails::audibleReminder()
{
    QOrganizerItemAudibleReminder r;
    QOrganizerItem oi;

    QVERIFY(r.isEmpty());
    QVERIFY(r.reminderType() == QOrganizerItemReminder::AudibleReminder);

    QVERIFY(r.secondsBeforeStart() == 0);
    QVERIFY(r.repetitionCount() == 0);
    QVERIFY(r.repetitionDelay() == 0);

    r.setSecondsBeforeStart(45);
    QVERIFY(!r.isEmpty());
    r.removeValue(QOrganizerItemReminder::FieldSecondsBeforeStart);
    QVERIFY(r.isEmpty());

    QOrganizerItemReminder baseR;
    baseR = r;
    QVERIFY(baseR.isEmpty());
    baseR.setSecondsBeforeStart(50);
    QVERIFY(baseR.secondsBeforeStart() == 50);
    QVERIFY(r.secondsBeforeStart() == 0);
    QVERIFY(!baseR.isEmpty());
    QVERIFY(r.isEmpty());

    r.setRepetition(3, 100);
    QVERIFY(r.repetitionCount() == 3);
    QVERIFY(r.repetitionDelay() == 100);
    QVERIFY(!r.isEmpty());

    r.setSecondsBeforeStart(30); // reminder, 30 seconds before the item is due to start.
    QVERIFY(r.secondsBeforeStart() == 30);

    // add
    QVERIFY(oi.details(QOrganizerItemDetail::TypeAudibleReminder).size() == 0);
    QVERIFY(oi.saveDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeAudibleReminder).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeAudibleReminder) == r);

    // update
    r.setSecondsBeforeStart(300);
    r.setDataUrl(QUrl("http://www.test.com"));
    QVERIFY(r.dataUrl() == QUrl("http://www.test.com"));
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeAudibleReminder) != r);
    QVERIFY(oi.saveDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeAudibleReminder).size() == 1); // should update, not add another
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeAudibleReminder) == r);

    // remove
    QVERIFY(oi.removeDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeAudibleReminder).size() == 0);
}
void tst_QOrganizerItemDetails::attendee()
{
    QOrganizerEventAttendee a;
    QOrganizerItem oi;

    QVERIFY(a.isEmpty());
    QVERIFY(a.name().isEmpty());
    QVERIFY(a.emailAddress().isEmpty());
    QVERIFY(a.attendeeId().isEmpty());
    QVERIFY(a.participationRole() == 0);
    QVERIFY(a.participationStatus() == 0);

    a.setAttendeeId("123456");
    QVERIFY(a.attendeeId() == QString("123456"));
    a.setEmailAddress("*****@*****.**");
    QVERIFY(a.emailAddress() == QString("*****@*****.**"));
    a.setName("people");
    QVERIFY(a.name() == QString("people"));
    a.setParticipationRole(QOrganizerEventAttendee::RoleRequiredParticipant);
    QVERIFY(a.participationRole() == QOrganizerEventAttendee::RoleRequiredParticipant);
    a.setParticipationStatus(QOrganizerEventAttendee::StatusAccepted);
    QVERIFY(a.participationStatus() == QOrganizerEventAttendee::StatusAccepted);
    // add
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 0);
    QVERIFY(oi.saveDetail(&a));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventAttendee) == a);
    // update
    a.setAttendeeId("54321");
    a.setName("newpeople");
    a.setEmailAddress("*****@*****.**");
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventAttendee) != a);
    QVERIFY(oi.saveDetail(&a));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventAttendee) == a);

    // add one more attendee
    QOrganizerEventAttendee a1;
    a1.setAttendeeId("777777");
    a1.setName("people1");
    a1.setEmailAddress("*****@*****.**");
    QVERIFY(oi.saveDetail(&a1));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 2);

    // remove
    QVERIFY(oi.removeDetail(&a));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 1);
    QVERIFY(oi.removeDetail(&a1));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEventAttendee).size() == 0);
}
void tst_QOrganizerItemDetails::type()
{
    QOrganizerItem oi;
    QOrganizerItemType t1, t2;

    QOrganizerEvent e;
    QOrganizerNote n;
    QOrganizerTodo t;
    QOrganizerJournal j;
    QOrganizerEventOccurrence eo;
    QOrganizerTodoOccurrence to;
    QVERIFY(e.type() == QOrganizerItemType::TypeEvent);
    QVERIFY(n.type() == QOrganizerItemType::TypeNote);
    QVERIFY(t.type() == QOrganizerItemType::TypeTodo);
    QVERIFY(j.type() == QOrganizerItemType::TypeJournal);
    QVERIFY(eo.type() == QOrganizerItemType::TypeEventOccurrence);
    QVERIFY(to.type() == QOrganizerItemType::TypeTodoOccurrence);

    // test property set
    t1.setType(QOrganizerItemType::TypeEvent);
    QCOMPARE(t1.type(), QOrganizerItemType::TypeEvent);
    QCOMPARE(static_cast<QOrganizerItemType::ItemType>(t1.value(QOrganizerItemType::FieldType).toInt()), QOrganizerItemType::TypeEvent);

    // test property add
    QVERIFY(oi.saveDetail(&t1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeItemType).count(), 1);
    QCOMPARE(QOrganizerItemType(oi.details(QOrganizerItemDetail::TypeItemType).value(0)).type(), t1.type());

    // test property update
    t1.setType(QOrganizerItemType::TypeTodo);
    QVERIFY(oi.saveDetail(&t1));
    QCOMPARE(static_cast<QOrganizerItemType::ItemType>(oi.details(QOrganizerItemDetail::TypeItemType).value(0).value(QOrganizerItemType::FieldType).toInt()), QOrganizerItemType::TypeTodo);

    // test property remove
    QVERIFY(!oi.removeDetail(&t1)); // cannot remove type
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeItemType).count(), 1);
    t2.setType(QOrganizerItemType::TypeNote);
    QVERIFY(oi.saveDetail(&t2)); // overwrites t1
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeItemType).count(), 1);
    QVERIFY(!oi.removeDetail(&t2)); // cannot remove type - "succeeds" but count remains unchanged
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeItemType).count(), 1);
    QVERIFY(!oi.removeDetail(&t2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeItemType).count(), 1);
}
void tst_QOrganizerItemDetails::emailReminder()
{
    QOrganizerItemEmailReminder r;
    QOrganizerItem oi;

    QVERIFY(r.isEmpty());
    QVERIFY(r.reminderType() == QOrganizerItemReminder::EmailReminder);

    QVERIFY(r.secondsBeforeStart() == 0);
    QVERIFY(r.repetitionCount() == 0);
    QVERIFY(r.repetitionDelay() == 0);

    r.setRepetition(3, 100);
    QVERIFY(r.repetitionCount() == 3);
    QVERIFY(r.repetitionDelay() == 100);
    QVERIFY(!r.isEmpty());

    r.setSecondsBeforeStart(30); // reminder, 30 seconds before the item is due to start.
    QVERIFY(r.secondsBeforeStart() == 30);

    // add
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEmailReminder).size() == 0);
    QVERIFY(oi.saveDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEmailReminder).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeEmailReminder) == r);

    // update
    r.setSecondsBeforeStart(300);
    r.setContents("subject", "body", QVariantList());
    r.setRecipients(QStringList() << "recipient" << "other recipient");
    QVERIFY(r.subject() == QString("subject"));
    QVERIFY(r.body() == QString("body"));
    QVERIFY(r.attachments() == QVariantList());
    QVERIFY(r.recipients() == (QStringList() << "recipient" << "other recipient"));
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeEmailReminder) != r);
    QVERIFY(oi.saveDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEmailReminder).size() == 1); // should update, not add another
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeEmailReminder) == r);

    // remove
    QVERIFY(oi.removeDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeEmailReminder).size() == 0);
}
Esempio n. 10
0
void tst_QOrganizerItemDetails::reminder()
{
    QOrganizerItemReminder r;
    QOrganizerItem oi;

    QVERIFY(r.isEmpty());
    QVERIFY(r.reminderType() == QOrganizerItemReminder::NoReminder);

    QVERIFY(r.secondsBeforeStart() == 0);
    QVERIFY(r.repetitionCount() == 0);
    QVERIFY(r.repetitionDelay() == 0);

    r.setSecondsBeforeStart(45);
    QVERIFY(!r.isEmpty());
    r.removeValue(QOrganizerItemReminder::FieldSecondsBeforeStart);
    QVERIFY(r.isEmpty());

    r.setRepetition(3, 100);
    QVERIFY(r.repetitionCount() == 3);
    QVERIFY(r.repetitionDelay() == 100);
    QVERIFY(!r.isEmpty());

    r.setSecondsBeforeStart(30); // reminder, 30 seconds before the item is due to start.
    QVERIFY(r.secondsBeforeStart() == 30);

    // add
    QVERIFY(oi.details(QOrganizerItemDetail::TypeReminder).size() == 0);
    QVERIFY(oi.saveDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeReminder).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeReminder) == r);

    // update
    r.setSecondsBeforeStart(300);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeReminder) != r);
    QVERIFY(oi.saveDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeReminder).size() == 1); // should update, not add another
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeReminder) == r);

    // remove
    QVERIFY(oi.removeDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeReminder).size() == 0);
}
Esempio n. 11
0
void tst_QOrganizerItemDetails::visualReminder()
{
    QOrganizerItemVisualReminder r;
    QOrganizerItem oi;

    QVERIFY(r.isEmpty());
    QVERIFY(r.reminderType() == QOrganizerItemReminder::VisualReminder);

    QVERIFY(r.secondsBeforeStart() == 0);
    QVERIFY(r.repetitionCount() == 0);
    QVERIFY(r.repetitionDelay() == 0);

    r.setRepetition(3, 100);
    QVERIFY(r.repetitionCount() == 3);
    QVERIFY(r.repetitionDelay() == 100);
    QVERIFY(!r.isEmpty());

    r.setSecondsBeforeStart(30); // reminder, 30 seconds before the item is due to start.
    QVERIFY(r.secondsBeforeStart() == 30);

    // add
    QVERIFY(oi.details(QOrganizerItemDetail::TypeVisualReminder).size() == 0);
    QVERIFY(oi.saveDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeVisualReminder).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeVisualReminder) == r);

    // update
    r.setSecondsBeforeStart(300);
    r.setMessage("test");
    r.setDataUrl(QUrl("http://www.test.com"));
    QVERIFY(r.message() == QString("test"));
    QVERIFY(r.dataUrl() == QUrl("http://www.test.com"));
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeVisualReminder) != r);
    QVERIFY(oi.saveDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeVisualReminder).size() == 1); // should update, not add another
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeVisualReminder) == r);

    // remove
    QVERIFY(oi.removeDetail(&r));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeVisualReminder).size() == 0);
}
Esempio n. 12
0
void tst_QOrganizerItemDetails::priority()
{
    QOrganizerItemPriority p;
    QOrganizerItem oi;

    QVERIFY(p.isEmpty());
    p.setValue(QOrganizerItemPriority::FieldPriority, QOrganizerItemPriority::VeryHighPriority);
    QVERIFY(p.priority() == QOrganizerItemPriority::VeryHighPriority);
    QVERIFY(oi.saveDetail(&p));
    QVERIFY(oi.details(QOrganizerItemDetail::TypePriority).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypePriority) == p);

    p.setPriority(QOrganizerItemPriority::VeryLowPriority);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypePriority) != p);
    QVERIFY(oi.saveDetail(&p));
    QVERIFY(oi.details(QOrganizerItemDetail::TypePriority).size() == 1); // update shouldn't add another detail.
    QVERIFY(oi.detail(QOrganizerItemDetail::TypePriority) == p);

    QVERIFY(oi.removeDetail(&p));
    QVERIFY(oi.details(QOrganizerItemDetail::TypePriority).size() == 0);
}
Esempio n. 13
0
void tst_QOrganizerItemDetails::location()
{
    QOrganizerItemLocation l1;
    QOrganizerItem oi;
    QVERIFY(l1.isEmpty());

    l1.setLatitude(89.999);
    QVERIFY(!l1.isEmpty());
    QVERIFY(l1.latitude() == 89.999);
    l1.setValue(QOrganizerItemLocation::FieldLatitude, -89.12345);
    QVERIFY(l1.value(QOrganizerItemLocation::FieldLatitude) == -89.12345);
    l1.setLatitude(-90.12345);
    l1.setLatitude(91);
    QVERIFY(l1.latitude() == -89.12345);

    l1.setLongitude(179);
    QVERIFY(l1.longitude() == 179);
    l1.setValue(QOrganizerItemLocation::FieldLongitude, -179.54321);
    QVERIFY(l1.value(QOrganizerItemLocation::FieldLongitude) == -179.54321);
    l1.setLongitude(180.1);
    l1.setLongitude(-180.1);
    QVERIFY(l1.longitude() == -179.54321);

    l1.setLabel("test");
    QVERIFY(l1.label() == QString("test"));

    QVERIFY(oi.details(QOrganizerItemDetail::TypeLocation).size() == 0);
    QVERIFY(oi.saveDetail(&l1));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeLocation).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeLocation) == l1);

    l1.setLabel("test 2");
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeLocation) != l1);
    QVERIFY(oi.saveDetail(&l1)); // update.
    QVERIFY(oi.details(QOrganizerItemDetail::TypeLocation).size() == 1); // should update, not add another.
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeLocation) == l1);

    oi.removeDetail(&l1);
    QVERIFY(oi.details(QOrganizerItemDetail::TypeLocation).size() == 0);
}
Esempio n. 14
0
void tst_QOrganizerItemDetails::classification()
{
    QOrganizerItemClassification classification;
    QOrganizerItem oi;

    QVERIFY(classification.isEmpty());

    // setters/getters
    classification.setClassification(QOrganizerItemClassification::AccessPublic);
    QVERIFY(classification.classification() == QOrganizerItemClassification::AccessPublic);
    classification.setClassification(QOrganizerItemClassification::AccessPrivate);
    QVERIFY(classification.classification() == QOrganizerItemClassification::AccessPrivate);
    classification.setClassification(QOrganizerItemClassification::AccessConfidential);
    QVERIFY(classification.classification() == QOrganizerItemClassification::AccessConfidential);

    // add
    QCOMPARE(0, oi.details(QOrganizerItemDetail::TypeClassification).size());
    QVERIFY(oi.saveDetail(&classification));
    QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeClassification).size());
    QCOMPARE(classification, static_cast<QOrganizerItemClassification>(oi.detail(QOrganizerItemDetail::TypeClassification)));

    // update
    classification.setValue(QOrganizerItemClassification::FieldClassification, QOrganizerItemClassification::AccessPrivate);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeClassification) != classification);
    QVERIFY(oi.saveDetail(&classification));
    QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeClassification).size());
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeClassification) == classification);

    // try adding another, amount of details should stay the same
    QOrganizerItemClassification classification2;
    classification2.setClassification(QOrganizerItemClassification::AccessConfidential);
    QVERIFY(oi.saveDetail(&classification2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeClassification).size(), 1);

    // remove
    QVERIFY(oi.removeDetail(&classification2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeClassification).size(), 0);
}
Esempio n. 15
0
void tst_QOrganizerItem::details()
{
    // Check that detail keys are unique, regardless of order of initialisation
    // First, construct the detail first, then the contact
    QOrganizerItemComment note;
    note.setComment("Example Note");
    QOrganizerItem keyTest;
    QVERIFY(keyTest.saveDetail(&note));
    QList<QOrganizerItemDetail> allDetails = keyTest.details();
    QList<int> detailKeys;
    foreach (const QOrganizerItemDetail& det, allDetails) {
        int currKey = det.key();
        QVERIFY(!detailKeys.contains(currKey));
        detailKeys.append(currKey);
    }
Esempio n. 16
0
void tst_QOrganizerItemDetails::parent()
{
    QOrganizerItemParent p;
    QOrganizerItem oi;

    // hrm, how to test parent local id?

    QVERIFY(p.isEmpty());
    p.setOriginalDate(QDate(2010, 10, 13));
    QVERIFY(p.originalDate() == QDate(2010, 10, 13));
    QVERIFY(!p.isEmpty());

    QVERIFY(oi.saveDetail(&p));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeParent).size() == 1);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeParent) == p);

    p.setOriginalDate(QDate(2010, 10, 14));
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeParent) != p);
    QVERIFY(oi.saveDetail(&p)); // update
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeParent) == p);

    QVERIFY(oi.removeDetail(&p));
    QVERIFY(oi.details(QOrganizerItemDetail::TypeParent).size() == 0);
}
Esempio n. 17
0
void tst_QOrganizerItemDetails::timestamp()
{
    QOrganizerItem oi;
    QOrganizerItemTimestamp t1, t2;
    QDateTime modified = QDateTime::currentDateTime();
    QDateTime created = modified.addSecs(-43);

    // test property set
    t1.setCreated(created);
    QCOMPARE(t1.created(), created);
    QCOMPARE(t1.value(QOrganizerItemTimestamp::FieldCreated).toDateTime(), created);

    // test property add
    QVERIFY(oi.saveDetail(&t1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTimestamp).count(), 1);
    QCOMPARE(QOrganizerItemTimestamp(oi.details(QOrganizerItemDetail::TypeTimestamp).value(0)).created(), t1.created());

    // test property update
    t1.setValue(101,"label1");
    t1.setLastModified(modified);
    QVERIFY(oi.saveDetail(&t1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTimestamp).value(0).value(101).toString(), QString("label1"));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTimestamp).value(0).value(QOrganizerItemTimestamp::FieldCreated).toDateTime(), created);
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTimestamp).value(0).value(QOrganizerItemTimestamp::FieldLastModified).toDateTime(), modified);

    // test property remove
    QVERIFY(oi.removeDetail(&t1));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTimestamp).count(), 0);
    t2.setCreated(created.addSecs(15));
    QVERIFY(oi.saveDetail(&t2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTimestamp).count(), 1);
    QVERIFY(oi.removeDetail(&t2));
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTimestamp).count(), 0);
    QVERIFY(oi.removeDetail(&t2) == false);
    QCOMPARE(oi.details(QOrganizerItemDetail::TypeTimestamp).count(), 0);
}
Esempio n. 18
0
    QVERIFY(details.at(0).definitionName() == QOrganizerItemType::DefinitionName);

    QOrganizerItemDetail detail = oi.detail("nonexistent");
    QVERIFY(detail.isEmpty());
    QVERIFY(detail.definitionName().isEmpty());

    // retrieve the first detail using the empty definition name accessor.
    detail = oi.detail(QString());
    QVERIFY(detail == details.at(0));

    QVERIFY(oi.details("nonexistent").count() == 0);

    // Add a detail
    QOrganizerItemLocation a;
    a.setLabel("another test address label");
    QVERIFY(oi.saveDetail(&a));
    QVERIFY(oi.isEmpty() == false);

    QVERIFY(oi.details().count() == 2);

    QVERIFY(oi.details(QOrganizerItemLocation::DefinitionName).count() == 1);
    QVERIFY(oi.details(QOrganizerItemLocation::DefinitionName, QOrganizerItemLocation::FieldLabel, QString("another test address label")).count() == 1);
    QVERIFY(oi.details(QOrganizerItemLocation::DefinitionName, QString(), QString("another test address label")).count() == oi.details(QOrganizerItemLocation::DefinitionName).count());

    QVERIFY(oi.details(QLatin1String(QOrganizerItemLocation::DefinitionName)).count() == 1);
    QVERIFY(oi.details(QLatin1String(QOrganizerItemLocation::DefinitionName), QOrganizerItemLocation::FieldLabel, QString("another test address label")).count() == 1);
    QVERIFY(oi.details(QLatin1String(QOrganizerItemLocation::DefinitionName), QString(), QString("another test address label")).count() == oi.details(QOrganizerItemLocation::DefinitionName).count());

    QVERIFY(oi.details(QOrganizerItemLocation::DefinitionName.latin1()).count() == 1);
    QVERIFY(oi.details(QOrganizerItemLocation::DefinitionName.latin1(), QOrganizerItemLocation::FieldLabel, QString("another test address label")).count() == 1);
    QVERIFY(oi.details(QOrganizerItemLocation::DefinitionName.latin1(), QString(), QString("another test address label")).count() == oi.details(QOrganizerItemLocation::DefinitionName).count());
Esempio n. 19
0
void tst_QOrganizerItemDetails::rsvp()
{
    QOrganizerEventRsvp rsvp;
    QOrganizerItem oi;

    QVERIFY(rsvp.isEmpty());
    QVERIFY(rsvp.organizerName().isEmpty());
    QVERIFY(rsvp.organizerEmail().isEmpty());
    QVERIFY(rsvp.responseDate().isNull());
    QVERIFY(!rsvp.responseDate().isValid());
    QVERIFY(rsvp.responseDeadline().isNull());
    QVERIFY(!rsvp.responseDeadline().isValid());
    QVERIFY(rsvp.participationRole() == 0);
    QVERIFY(rsvp.participationStatus() == 0);
    QVERIFY(rsvp.responseRequirement() == 0);

    rsvp.setOrganizerName("Donald Duck");
    QVERIFY(rsvp.organizerName() == QString("Donald Duck"));
    rsvp.setOrganizerEmail("*****@*****.**");
    QVERIFY(rsvp.organizerEmail() == QString("*****@*****.**"));
    QDate testDate(2010, 10, 10);
    rsvp.setResponseDate(testDate);
    QVERIFY(!rsvp.responseDate().isNull());
    QVERIFY(rsvp.responseDate().isValid());
    QCOMPARE(testDate, rsvp.responseDate());
    rsvp.setResponseDeadline(testDate);
    QVERIFY(!rsvp.responseDeadline().isNull());
    QVERIFY(rsvp.responseDeadline().isValid());
    QCOMPARE(testDate, rsvp.responseDeadline());
    rsvp.setParticipationRole(QOrganizerEventAttendee::RoleOrganizer);
    QVERIFY(rsvp.participationRole() == QOrganizerEventAttendee::RoleOrganizer);
    rsvp.setParticipationStatus(QOrganizerEventAttendee::StatusAccepted);
    QVERIFY(rsvp.participationStatus() == QOrganizerEventAttendee::StatusAccepted);
    rsvp.setResponseRequirement(QOrganizerEventRsvp::ResponseRequired);
    QVERIFY(rsvp.responseRequirement() == QOrganizerEventRsvp::ResponseRequired);

    // add
    QCOMPARE(0, oi.details(QOrganizerItemDetail::TypeEventRsvp).size());
    QVERIFY(oi.saveDetail(&rsvp));
    QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeEventRsvp).size());
    QVERIFY(rsvp == oi.detail(QOrganizerItemDetail::TypeEventRsvp));

    // update
    rsvp.setOrganizerName("Mickey Mouse");
    rsvp.setOrganizerEmail("*****@*****.**");
    QDate testDate2(2011, 11, 11);
    rsvp.setResponseDate(testDate2);
    rsvp.setResponseDeadline(testDate2);
    rsvp.setParticipationRole(QOrganizerEventAttendee::RoleChairperson);
    rsvp.setParticipationStatus(QOrganizerEventAttendee::StatusDelegated);
    rsvp.setResponseRequirement(QOrganizerEventRsvp::ResponseNotRequired);
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventRsvp) != rsvp);
    QVERIFY(oi.saveDetail(&rsvp));
    QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeEventRsvp).size());
    QVERIFY(oi.detail(QOrganizerItemDetail::TypeEventRsvp) == rsvp);

    // add another rsvp - not supported by all the backends
    QOrganizerEventRsvp rsvp2;
    rsvp2.setOrganizerName("Goofy");
    QVERIFY(oi.saveDetail(&rsvp2));
    QCOMPARE(2, oi.details(QOrganizerItemDetail::TypeEventRsvp).size());

    // remove
    QVERIFY(oi.removeDetail(&rsvp2));
    QCOMPARE(1, oi.details(QOrganizerItemDetail::TypeEventRsvp).size());
    QVERIFY(oi.removeDetail(&rsvp));
    QCOMPARE(0, oi.details(QOrganizerItemDetail::TypeEventRsvp).size());
}