Esempio n. 1
0
//! [1]
void Window::editNewTodo()
{
    QOrganizerTodo newTodo;
    newTodo.setPriority(QOrganizerItemPriority::HighPriority);
    newTodo.setStatus(QOrganizerTodoProgress::StatusNotStarted);
    QDateTime currentDateTime(calendarWidget->selectedDate(),
        QTime::currentTime());
    newTodo.setStartDateTime(currentDateTime);
    newTodo.setDueDateTime(currentDateTime.addSecs(60*60));

    todoEditor->editTodo(newTodo);

    stackedWidget->setCurrentWidget(todoEditor);
}
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;
}