예제 #1
0
/*!
    Returns true if the \a other recurrence detail is equal to this detail; otherwise, false.

    Since the data types stored in this detail are custom data types, the base class
    operator==() doesn't know how to perform the comparison without calling this function.
    However, it means that if (in the future) a backend were to extend the detail with
    more fields, this operator== would no longer work; it'd have to be updated to compare
    the other fields also.
 */
bool QOrganizerItemRecurrence::operator==(const QOrganizerItemRecurrence &other) const
{
    return recurrenceRules() == other.recurrenceRules()
           && exceptionRules() == other.exceptionRules()
           && recurrenceDates() == other.recurrenceDates()
           && exceptionDates() == other.exceptionDates();
}
void OrganizerItemTransform::addEventPostSaveDetails(QOrganizerItem *item, CEvent *cevent)
{
    // Priority
    int tempint = cevent->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);
    }

    // Start time
    QDateTime tempdt = QDateTime::fromTime_t(cevent->getDateStart());
    if (!tempdt.isNull()) {
        QOrganizerEventTime eventTime = item->detail<QOrganizerEventTime>();
        eventTime.setStartDateTime(tempdt);
        item->saveDetail(&eventTime);
    }

    // End time
    tempdt = QDateTime::fromTime_t(cevent->getDateEnd());
    if (!tempdt.isNull()) {
        QOrganizerEventTime eventTime = item->detail<QOrganizerEventTime>();
        eventTime.setEndDateTime(tempdt);
        item->saveDetail(&eventTime);
    }

    // Recurrence
    m_recTransformer.transformToQrecurrence(cevent->getRecurrence());
    QOrganizerItemRecurrence recurrence = item->detail<QOrganizerItemRecurrence>();
    recurrence.setRecurrenceRules(m_recTransformer.recurrenceRules());
    recurrence.setExceptionRules(m_recTransformer.exceptionRules());
    recurrence.setRecurrenceDates(m_recTransformer.recurrenceDates());
    recurrence.setExceptionDates(m_recTransformer.exceptionDates());
    item->saveDetail(&recurrence);

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

    if (createdTime || lastModifiedTime) {
        QOrganizerItemTimestamp timeStamps = item->detail<QOrganizerItemTimestamp>();
        timeStamps.setCreated(QDateTime::fromTime_t(createdTime));
        timeStamps.setLastModified(QDateTime::fromTime_t(lastModifiedTime));
        item->saveDetail(&timeStamps);
    }
}
예제 #3
0
void tst_QOrganizerItemDetails::recurrence()
{
    QOrganizerItemRecurrence r;
    QOrganizerEvent e;

    QOrganizerRecurrenceRule testRule;
    testRule.setFrequency(QOrganizerRecurrenceRule::Weekly);
    testRule.setLimit(4);
    QSet<QOrganizerRecurrenceRule> rrules;
    rrules << testRule;

    QOrganizerRecurrenceRule exrule;
    exrule.setFrequency(QOrganizerRecurrenceRule::Daily);
    testRule.setLimit(12);
    QSet<QOrganizerRecurrenceRule> exrules;
    exrules << exrule;

    QSet<QDate> rdates, exdates;
    rdates << QDate(2010, 10, 13);
    exdates << QDate(2010, 11, 17) << QDate(2010, 11, 20);

    QVERIFY(e.details(QOrganizerItemDetail::TypeRecurrence).size() == 0);
    r.setRecurrenceRules(rrules);
    QVERIFY(r.recurrenceRules() == rrules);
    QVERIFY(r.recurrenceDates().isEmpty());
    QVERIFY(r.exceptionRules().isEmpty());

    r.setExceptionRules(exrules);
    QVERIFY(r.recurrenceRules() == rrules);
    QVERIFY(r.exceptionRules() == exrules);
    QVERIFY(r.exceptionDates().isEmpty());

    r.setRecurrenceDates(rdates);
    QVERIFY(r.recurrenceDates() == rdates);
    QVERIFY(r.exceptionDates().isEmpty());
    QVERIFY(r.recurrenceRules() == rrules);
    QVERIFY(r.exceptionRules() == exrules);

    r.setExceptionDates(exdates);
    QVERIFY(r.recurrenceDates() == rdates);
    QVERIFY(r.exceptionDates() == exdates);
    QVERIFY(r.recurrenceRules() == rrules);
    QVERIFY(r.exceptionRules() == exrules);

    // now save.
    QVERIFY(e.saveDetail(&r));
    QVERIFY(e.details(QOrganizerItemDetail::TypeRecurrence).size() == 1);
    QVERIFY(e.detail(QOrganizerItemDetail::TypeRecurrence) == r);

    // update
    exdates << QDate(2010, 10, 17);
    r.setExceptionDates(exdates);
    QVERIFY(e.detail(QOrganizerItemDetail::TypeRecurrence) != r);
    QVERIFY(e.saveDetail(&r));
    QVERIFY(e.detail(QOrganizerItemDetail::TypeRecurrence) == r);
    QVERIFY(e.details(QOrganizerItemDetail::TypeRecurrence).size() == 1); // should update, not add another.

    // remove.
    QVERIFY(e.removeDetail(&r));
    QVERIFY(e.details(QOrganizerItemDetail::TypeRecurrence).size() == 0);
}
예제 #4
0
/*! Returns the list of exception rules for the event */
QSet<QOrganizerRecurrenceRule> QOrganizerEvent::exceptionRules() const
{
    QOrganizerItemRecurrence rec = detail<QOrganizerItemRecurrence>();
    return rec.exceptionRules();
}
예제 #5
0
/*! Sets the given list of recurrence rules \a exrules to be the rules which define when
    the event does not occur.  Any previously specified exception rules will be cleared
    when this function is called. */
void QOrganizerEvent::setExceptionRules(const QSet<QOrganizerRecurrenceRule>& exrules)
{
    QOrganizerItemRecurrence rec = detail<QOrganizerItemRecurrence>();
    rec.setExceptionRules(exrules);
    saveDetail(&rec);
}
예제 #6
0
/*! Returns the list of dates which have been explicitly set as dates on which the event occurs */
QSet<QDate> QOrganizerEvent::recurrenceDates() const
{
    QOrganizerItemRecurrence rec = detail<QOrganizerItemRecurrence>();
    return rec.recurrenceDates();
}
예제 #7
0
/*! Sets the list of dates \a rdates to be dates on which the event occurs */
void QOrganizerEvent::setRecurrenceDates(const QSet<QDate>& rdates)
{
    QOrganizerItemRecurrence rec = detail<QOrganizerItemRecurrence>();
    rec.setRecurrenceDates(rdates);
    saveDetail(&rec);
}