Ejemplo n.º 1
0
QT_BEGIN_NAMESPACE_ORGANIZER

/*!
    \class QOrganizerTodoOccurrence
    \brief The QOrganizerTodoOccurrence class provides an occurrence of a task which should be completed
    \inmodule QtOrganizer
    \ingroup organizer-items

    A todo occurrence is a specific instance of a todo item.  An occurrence
    which is retrieved from a manager may not actually be persisted in that
    manager (for example, it may be generated automatically from the
    recurrence rule of the parent todo stored in the manager), in which case
    it will have a zero-id and differ from the parent todo only in its start
    date.  Alternatively, it may be persisted in the manager (that is, the
    client has saved the occurrence previously) where it is stored as an exception
    to its parent todo.
 */

/*!
    Sets the date time at which the task should be started to \a startDateTime.  For all-day tasks,
    the time part can be set to any valid value.
 */
void QOrganizerTodoOccurrence::setStartDateTime(const QDateTime &startDateTime)
{
    QOrganizerTodoTime ttr = detail(QOrganizerItemDetail::TypeTodoTime);
    ttr.setStartDateTime(startDateTime);
    saveDetail(&ttr);
}
void OrganizerItemTransform::addTodoPostSaveDetails(QOrganizerItem *item, CTodo *ctodo)
{
    // Priority
    int tempint = ctodo->getPriority();
    if (tempint != -1) {
        QOrganizerItemPriority priority = item->detail<QOrganizerItemPriority>();
        priority.setPriority(static_cast<QOrganizerItemPriority::Priority>(tempint)); // assume that the saved priority is vCal compliant.
        item->saveDetail(&priority);
    }

    // Date start
    QDateTime tempdt = QDateTime::fromTime_t(ctodo->getDateStart());
    if (!tempdt.isNull()) {
        QOrganizerTodoTime todoTime = item->detail<QOrganizerTodoTime>();
        todoTime.setStartDateTime(tempdt);
        item->saveDetail(&todoTime);
    }

    // Due
    tempdt = QDateTime::fromTime_t(ctodo->getDue());
    if (!tempdt.isNull()) {
        QOrganizerTodoTime todoTime = item->detail<QOrganizerTodoTime>();
        todoTime.setDueDateTime(tempdt);
        item->saveDetail(&todoTime);
    }

    // Completed time
    tempdt = QDateTime::fromTime_t(ctodo->getCompleted());
    if (!tempdt.isNull()) {
        QOrganizerTodoProgress todoProgress = item->detail<QOrganizerTodoProgress>();
        todoProgress.setFinishedDateTime(tempdt);
        item->saveDetail(&todoProgress);
    }

    // Percent complete
    tempint = ctodo->getPercentComplete();
    if (!tempdt.isNull()) {
        QOrganizerTodoProgress todoProgress = item->detail<QOrganizerTodoProgress>();
        todoProgress.setPercentageComplete(tempint);
        item->saveDetail(&todoProgress);
    }

    // Status
    QOrganizerTodoProgress todoProgress = item->detail<QOrganizerTodoProgress>();
    todoProgress.setStatus(static_cast<QOrganizerTodoProgress::Status>(ctodo->getStatus()));
    item->saveDetail(&todoProgress);

    // Timestamps
    time_t createdTime = ctodo->getCreatedTime();
    time_t lastModifiedTime = ctodo->getLastModified();

    if (createdTime || lastModifiedTime) {
        QOrganizerItemTimestamp timeStamps = item->detail<QOrganizerItemTimestamp>();
        timeStamps.setCreated(QDateTime::fromTime_t(createdTime));
        timeStamps.setLastModified(QDateTime::fromTime_t(lastModifiedTime));
        item->saveDetail(&timeStamps);
    }
}
Ejemplo n.º 3
0
void DayPage::refresh()
{

    m_dateLabel->setText(m_day.toString());
    m_itemList->clear();

    // Today's item
    QList<QOrganizerItem> items = m_manager->items(QDateTime(m_day), QDateTime(m_day, QTime(23, 59, 59)));

    foreach (const QOrganizerItem &item, items)
    {
        QOrganizerEventTime eventTime = item.detail<QOrganizerEventTime>();
        if (!eventTime.isEmpty()) {
            QString time = eventTime.startDateTime().time().toString("hh:mm");
            QListWidgetItem* listItem = new QListWidgetItem();
            if (item.type() == QOrganizerItemType::TypeEventOccurrence)
                listItem->setText(QString("Event occurrence:%1-%2").arg(time).arg(item.displayLabel()));
            else
                listItem->setText(QString("Event:%1-%2").arg(time).arg(item.displayLabel()));
            QVariant data = QVariant::fromValue<QOrganizerItem>(item);
            listItem->setData(ORGANIZER_ITEM_ROLE, data);
            m_itemList->addItem(listItem);
        }
        
        QOrganizerTodoTime todoTime = item.detail<QOrganizerTodoTime>();
        if (!todoTime.isEmpty()) {
            QString time = todoTime.startDateTime().time().toString("hh:mm");
            QListWidgetItem* listItem = new QListWidgetItem();
            listItem->setText(QString("Todo:%1-%2").arg(time).arg(item.displayLabel()));
            QVariant data = QVariant::fromValue<QOrganizerItem>(item);
            listItem->setData(ORGANIZER_ITEM_ROLE, data);
            m_itemList->addItem(listItem);
        }

        QOrganizerJournalTime journalTime = item.detail<QOrganizerJournalTime>();
        if (!journalTime.isEmpty()) {
            QString time = journalTime.entryDateTime().time().toString("hh:mm");
            QListWidgetItem* listItem = new QListWidgetItem();
            listItem->setText(QString("Journal:%1-%2").arg(time).arg(item.displayLabel()));
            QVariant data = QVariant::fromValue<QOrganizerItem>(item);
            listItem->setData(ORGANIZER_ITEM_ROLE, data);
            m_itemList->addItem(listItem);
        }
        
        // TODO: other item types
    }
void OrganizerTodoTimeTransform::transformToDetailL(const CCalInstance& instance, QOrganizerItem *itemOccurrence)
{
    if (itemOccurrence->type() == QOrganizerItemType::TypeTodo
        || itemOccurrence->type() == QOrganizerItemType::TypeTodoOccurrence)
    {
        TCalTime startTime = instance.StartTimeL();
        TCalTime endTime = instance.EndTimeL();

        QOrganizerTodoTime range;
        if (startTime.TimeUtcL() != Time::NullTTime())
            range.setStartDateTime(toQDateTimeL(startTime));
        if (endTime.TimeUtcL() != Time::NullTTime())
            range.setDueDateTime(toQDateTimeL(endTime));
        
        if (!range.isEmpty())
            itemOccurrence->saveDetail(&range);
    }
}
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()));
    }
}
Ejemplo n.º 6
0
/*!
    Sets the date time by which the task should be completed to \a dueDateTime.  For all-day tasks,
    the time part can be set to any valid value.
 */
void QOrganizerTodoOccurrence::setDueDateTime(const QDateTime &dueDateTime)
{
    QOrganizerTodoTime ttr = detail(QOrganizerItemDetail::TypeTodoTime);
    ttr.setDueDateTime(dueDateTime);
    saveDetail(&ttr);
}
Ejemplo n.º 7
0
/*!
    Returns the date time at which the task should be started.  For all-day tasks, the time part is
    meaningless.
 */
QDateTime QOrganizerTodoOccurrence::startDateTime() const
{
    QOrganizerTodoTime ttr = detail(QOrganizerItemDetail::TypeTodoTime);
    return ttr.startDateTime();
}
Ejemplo n.º 8
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);
}