Ejemplo n.º 1
0
    QVERIFY(oi.saveDetail(&one));
    QVERIFY(ref == one);

    // Retrieve the detail again and modify it
    QOrganizerItemLocation three = oi.detail<QOrganizerItemLocation>();
    QVERIFY(ref == three);
    QVERIFY(one == three);
    three.setLabel("542343");
    QVERIFY(oi.saveDetail(&three));

    // Now see if we got any updates to ref/one
    QVERIFY(ref == one);
    QVERIFY(ref != three);

    // test saving of a detail with an empty field.
    QOrganizerItemLocation four;
    four.setLabel("");
    oi.saveDetail(&four);
    QVERIFY(oi.details(QOrganizerItemLocation::DefinitionName).count() == 2);
    QVERIFY(!four.variantValues().isEmpty()); // an empty qstring is not invalid; make sure it exists in the detail.

    // ensure that clearing a contact's details works correctly
    QOrganizerItemPriority priorityDetail;
    priorityDetail.setPriority(QOrganizerItemPriority::VeryHighPriority);
    oi.saveDetail(&priorityDetail);
    QCOMPARE(oi.detail(QOrganizerItemPriority::DefinitionName).value(QOrganizerItemPriority::FieldPriority).toInt(), static_cast<int>(QOrganizerItemPriority::VeryHighPriority));
    QVERIFY(oi.details().size() > 0);
    QVERIFY(!oi.isEmpty());
    QOrganizerItemId oldId = oi.id();
    oi.clearDetails();
    QCOMPARE(oi.details().size(), 1); // always has an item type.
Ejemplo n.º 2
0
/*!
  Sets the label of the location at which the event occurrence is held to \a location
  \since 1.1
 */
void QOrganizerEventOccurrence::setLocation(const QString& location)
{
    QOrganizerItemLocation ld = detail<QOrganizerItemLocation>();
    ld.setLabel(location);
    saveDetail(&ld);
}
Ejemplo n.º 3
0
/*!
  Returns the label of the location at which the event occurrence is held, if known
  \since 1.1
 */
QString QOrganizerEventOccurrence::location() const
{
    QOrganizerItemLocation ld = detail<QOrganizerItemLocation>();
    return ld.label();
}
void OrganizerItemTransform::fillInCommonCComponentDetails(QOrganizerItem *item, CComponent *component, bool setId)
{
    if (item) {
        // Summary
        QString tempstr = QString::fromStdString(component->getSummary());
        if (!tempstr.isEmpty())
            item->setDisplayLabel(tempstr);

        // Description
        tempstr = QString::fromStdString(component->getDescription());
        if (!tempstr.isEmpty())
            item->setDescription(tempstr);

        // Location
        tempstr = QString::fromStdString(component->getLocation());
        if(!tempstr.isEmpty()) {
            QOrganizerItemLocation il = item->detail<QOrganizerItemLocation>();
            il.setLabel(tempstr);
            item->saveDetail(&il);
        }

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

        if (createdTime || lastModifiedTime) {
            QOrganizerItemTimestamp timeStamps = item->detail<QOrganizerItemTimestamp>();
            timeStamps.setCreated(QDateTime::fromTime_t(createdTime));
            timeStamps.setLastModified(QDateTime::fromTime_t(lastModifiedTime));
            item->saveDetail(&timeStamps);
        }

        // GUid
        QOrganizerItemGuid ig = item->detail<QOrganizerItemGuid>();
        tempstr = QString::fromStdString(component->getGUid());
        if(!tempstr.isEmpty())
            ig.setGuid(tempstr);
        item->saveDetail(&ig);

        // Set component ID
        if (setId) {
            QString idString = QString::fromStdString(component->getId());
            item->setId(QOrganizerItemId(new QOrganizerItemMaemo5EngineId(idString.toUInt())));
        } else {
            item->setId(QOrganizerItemId());
        }

        // Set comments
        CComponentDetails *componentDetails = dynamic_cast<CComponentDetails*>(component);
        if (componentDetails) {
            string comments = componentDetails->getComments();
            if (!comments.empty()) {
                QStringList commentList = QString::fromStdString(comments).split('\n', QString::SkipEmptyParts);
                foreach(const QString comment, commentList)
                    item->addComment(comment);
            }
        }

        // Reminder (alarm)
        CAlarm *alarm = component->getAlarm();
        if (alarm) {
            // TODO: Only visual remainders are supported
            QOrganizerItemVisualReminder reminder = item->detail<QOrganizerItemVisualReminder>();
            reminder.setRepetition(alarm->getRepeat(), reminder.repetitionDelay());

            // Alarm time and messages can't be read with CAlarm,
            // read them straight from the alarm framework:

            // Get the cookie
            std::vector<long> cookies = alarm->getCookie();
            if (cookies.size() > 0) {
                cookie_t cookie = static_cast<cookie_t>(cookies[0]); // only one alarm supported

                alarm_event_t *eve = 0;
                if ((eve = alarmd_event_get(cookie)) != 0) {
                    QString message = QString::fromStdString(alarm_event_get_title(eve));
                    reminder.setMessage(message);
                    time_t alarmTime = alarm_event_get_trigger(eve);
                    alarm_event_delete(eve);

                    QDateTime sTime = QDateTime::fromTime_t(component->getDateStart());
                    QDateTime aTime = QDateTime::fromTime_t(alarmTime);
                    reminder.setSecondsBeforeStart(aTime.secsTo(sTime));
                }
            }

            item->saveDetail(&reminder);
        }
    }
Ejemplo n.º 5
0
/*!
    Sets the label of the location at which the event occurrence is held to \a label.
 */
void QOrganizerEventOccurrence::setLocation(const QString &label)
{
    QOrganizerItemLocation ld = detail(QOrganizerItemDetail::TypeLocation);
    ld.setLabel(label);
    saveDetail(&ld);
}
Ejemplo n.º 6
0
/*!
    Returns the label of the location at which the event occurrence is held.
 */
QString QOrganizerEventOccurrence::location() const
{
    QOrganizerItemLocation ld = detail(QOrganizerItemDetail::TypeLocation);
    return ld.label();
}