Exemplo n.º 1
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)
    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;
            }
        }
    }
Exemplo n.º 2
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;
    }