Exemple #1
0
//! [5]
void Window::refreshList()
{
    listWidget->clear();

    QOrganizerItemSortOrder sortOrder;
    sortOrder.setDetailDefinitionName(QOrganizerTodoTime::DefinitionName,
        QOrganizerTodoTime::FieldDueDateTime);

    QList<QOrganizerItem> items =
        manager->items(QOrganizerItemFilter(), QList<QOrganizerItemSortOrder>() << sortOrder);
//! [5]
    if (items.isEmpty()) {
       new QListWidgetItem("<No Todos>", listWidget);
    }
//! [6]
    foreach(QOrganizerItem item, items) {
        if (item.type() == QOrganizerItemType::TypeTodo) {
            QOrganizerTodo todo = static_cast<QOrganizerTodo>(item);
            if (todo.startDateTime() >
                    QDateTime(calendarWidget->selectedDate(), QTime(23,59)) ||
                todo.dueDateTime() <
                    QDateTime(calendarWidget->selectedDate(), QTime(0, 0)))
                continue;            

            QString display = todo.startDateTime().toString("yy/MM/dd hh:mm") +
                "-" + todo.dueDateTime().toString("yy/MM/dd hh:mm") +
                " - "+ todo.displayLabel();

            QListWidgetItem *listItem =
                new QListWidgetItem(display, listWidget);
            listItem->setData(Qt::UserRole, QVariant::fromValue(todo));
        }
    }
}
void TodoEditPage::todoChanged(QOrganizerManager *manager, const QOrganizerTodo &todo)
{
    m_manager = manager;
    m_organizerTodo = todo;
    m_subjectEdit->setText(todo.displayLabel());
    m_startTimeEdit->setDateTime(todo.startDateTime());
    m_dueTimeEdit->setDateTime(todo.dueDateTime());
    int index = m_priorityEdit->findData(QVariant(todo.priority()));
    m_priorityEdit->setCurrentIndex(index);
    index = m_priorityEdit->findData(QVariant(todo.status()));
    m_statusEdit->setCurrentIndex(index);

    // set calendar selection
    m_calendarComboBox->clear();

    // resolve metadata field that contains calendar name (if any)
    QString calendarNameMetadataKey;
    m_collections = m_manager->collections();
    if (!m_collections.isEmpty()) {
        QOrganizerCollection firstCollection = m_collections[0];
        QVariantMap metadata = firstCollection.metaData();
        QList<QString> metaDataKeys = metadata.keys();
        foreach(QString key, metaDataKeys) {
            if (key.indexOf("name", 0, Qt::CaseInsensitive) != -1) {
                calendarNameMetadataKey = key;
                break;
            }
        }
    }
Exemple #3
0
void TodoEditPage::todoChanged(QOrganizerManager *manager, const QOrganizerTodo &todo)
{
    m_manager = manager;
    m_organizerTodo = todo;
    m_subjectEdit->setText(todo.displayLabel());
    m_startTimeEdit->setDateTime(todo.startDateTime());
    m_dueTimeEdit->setDateTime(todo.dueDateTime());
    int index = m_priorityEdit->findData(QVariant(todo.priority()));
    m_priorityEdit->setCurrentIndex(index);
    index = m_priorityEdit->findData(QVariant(todo.status()));
    m_statusEdit->setCurrentIndex(index);

    // set calendar selection
    m_calendarComboBox->clear();

    // resolve metadata field that contains calendar name (if any)
    m_collections = m_manager->collections();
    int counter = 0;
    int todoCalendarIndex = -1;
    foreach(QOrganizerCollection collection, m_collections) {
        // We currently have no way of stringifying ids
        // QString visibleName = "Calendar id = " + QString::number(collection.id().localId());
        QString visibleName = collection.metaData(QOrganizerCollection::KeyName).toString();
        if (visibleName.isEmpty())
            visibleName = "Calendar " + QString::number(index);

        m_calendarComboBox->addItem(visibleName);
        if (collection.id() == todo.collectionId())
            todoCalendarIndex = counter;
        ++counter;
    }