Пример #1
0
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);
}
Пример #2
0
void tst_QOrganizerItemDetails::todoProgress()
{
    QOrganizerTodoProgress p;
    QOrganizerTodo t;

    QVERIFY(p.status() == QOrganizerTodoProgress::StatusNotStarted);
    QVERIFY(p.isEmpty());
    p.setStatus(QOrganizerTodoProgress::StatusInProgress);
    QVERIFY(!p.isEmpty());
    QVERIFY(p.status() == QOrganizerTodoProgress::StatusInProgress);

    p.setPercentageComplete(50);
    QVERIFY(p.percentageComplete() == 50);
    p.setPercentageComplete(200); // this should fail
    QVERIFY(p.percentageComplete() == 50); // value should remain unchanged.

    p.setFinishedDateTime(QDateTime(QDate(2010, 10, 13)));
    QVERIFY(p.finishedDateTime() == QDateTime(QDate(2010, 10, 13)));
    QVERIFY(p.status() != QOrganizerTodoProgress::StatusComplete); // XXX TODO: should this be automatic?
    p.setPercentageComplete(100);
    QVERIFY(p.percentageComplete() == 100);
    QVERIFY(p.status() != QOrganizerTodoProgress::StatusComplete); // XXX TODO: should this be automatic?

    // add
    QVERIFY(t.saveDetail(&p));
    QVERIFY(t.details(QOrganizerItemDetail::TypeTodoProgress).size() == 1);
    QVERIFY(t.detail(QOrganizerItemDetail::TypeTodoProgress) == p);

    // update
    p.setStatus(QOrganizerTodoProgress::StatusComplete);
    QVERIFY(p.status() == QOrganizerTodoProgress::StatusComplete);
    QVERIFY(t.detail(QOrganizerItemDetail::TypeTodoProgress) != p);
    QVERIFY(t.saveDetail(&p));
    QVERIFY(t.details(QOrganizerItemDetail::TypeTodoProgress).size() == 1); // update, not add another
    QVERIFY(t.detail(QOrganizerItemDetail::TypeTodoProgress) == p);

    // remove
    QVERIFY(t.removeDetail(&p));
    QVERIFY(t.details(QOrganizerItemDetail::TypeTodoProgress).size() == 0);
}
QOrganizerTodo OrganizerItemTransform::convertCTodoToQTodo(CTodo *ctodo)
{
    QOrganizerTodo retn;

    // Priority
    int tempint = ctodo->getPriority();
    if (tempint != -1)
        retn.setPriority(static_cast<QOrganizerItemPriority::Priority>(tempint));

    // Date start
    QDateTime tempdt = QDateTime::fromTime_t(ctodo->getDateStart());
    if (!tempdt.isNull())
        retn.setStartDateTime(tempdt);

    // Due
    tempdt = QDateTime::fromTime_t(ctodo->getDue());
    if (!tempdt.isNull())
        retn.setDueDateTime(tempdt);

    // Completed time
    tempdt = QDateTime::fromTime_t(ctodo->getCompleted());
    if (!tempdt.isNull())
        retn.setFinishedDateTime(tempdt);

    // Percent complete
    tempint = ctodo->getPercentComplete();
    if (tempint != -1)
        retn.setProgressPercentage(tempint);

    // Status
    retn.setStatus(static_cast<QOrganizerTodoProgress::Status>(ctodo->getStatus()));

    // Location geo coordinates
    QOrganizerItemLocation loc = retn.detail<QOrganizerItemLocation>();
    if(addGeoToQOIL(QString::fromStdString(ctodo->getGeo()), &loc))
        retn.saveDetail(&loc);

    return retn;
}