Functions | Variables
extendedcalendar.cpp File Reference

This file is part of the API for handling calendar data and defines the ExtendedCalendar class. More...

#include "extendedcalendar.h"
#include "sqlitestorage.h"
#include "logging_p.h"
#include <KCalendarCore/CalFilter>
#include <KCalendarCore/Sorting>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <cmath>
Include dependency graph for extendedcalendar.cpp:

Functions

 if ((*iit) ->recurs())
 Private class that helps to provide binary compatibility between releases. More...
 
returnList append (ExpandedIncidence(validity, *iit))
 
bool directoryIsRW (const QString &dirPath)
 

Variables

 else
 
validity dtEnd = d->incidenceEndTime(*iit, dt, true)
 
 appended
 
return returnList
 

Detailed Description

This file is part of the API for handling calendar data and defines the ExtendedCalendar class.

This class provides a calendar cached into memory.

Author
Tero Aho <ext-t.nosp@m.ero..nosp@m.1.aho.nosp@m.@nok.nosp@m.ia.co.nosp@m.m>
Preston Brown <pbrow.nosp@m.n@kd.nosp@m.e.org>
Cornelius Schumacher <schum.nosp@m.ache.nosp@m.r@kde.nosp@m..org>

Function Documentation

◆ append()

returnList append ( ExpandedIncidence(validity, *iit)  )

◆ directoryIsRW()

bool directoryIsRW ( const QString &  dirPath)

◆ if()

if ( *iit->  recurs())

Private class that helps to provide binary compatibility between releases.

static bool expandedIncidenceSortLessThan(const ExtendedCalendar::ExpandedIncidence &e1, const ExtendedCalendar::ExpandedIncidence &e2) { if (e1.first.dtStart < e2.first.dtStart) { return true; } if (e1.first.dtStart > e2.first.dtStart) { return false; } e1 == e2 => perform secondary check based on created date return e1.second->created() < e2.second->created(); }

ExtendedCalendar::ExpandedIncidenceList ExtendedCalendar::expandRecurrences( Incidence::List *incidenceList, const QDateTime &dtStart, const QDateTime &dtEnd, int maxExpand, bool *expandLimitHit) { ExtendedCalendar::ExpandedIncidenceList returnList; Incidence::List::Iterator iit; QDateTime brokenDtStart = dtStart.addSecs(-1); const QTimeZone &tz = timeZone(); ExpandedIncidenceValidity validity;

used for comparing with entries that have broken dtEnd => we use dtStart and compare it against this instead. As this is allocated only once per iteration, it should result in significan net savings

qCDebug(lcMkcal) << "expandRecurrences" << incidenceList->size() << dtStart.toString() << dtStart.isValid() << dtEnd.toString() << dtEnd.isValid();

if (expandLimitHit)
     expandLimitHit = false;

for (iit = incidenceList->begin(); iit != incidenceList->end(); ++iit) {
    QDateTime dt = (*iit)->dtStart().toTimeSpec(Qt::LocalTime);
    QDateTime dte = (*iit)->dateTime(IncidenceBase::RoleEndRecurrenceBase);
    int appended = 0;
    int skipped = 0;
    bool brokenEnd = false;

    if ((*iit)->type() == Incidence::TypeTodo) {
        Todo::Ptr todo = (*iit).staticCast<Todo>();
        if (todo->hasDueDate()) {
            dt = todo->dtDue().toTimeSpec(Qt::LocalTime);
        }
    }

    if (!dt.isValid()) {

Just leave the dateless incidences there (they will be sorted out) validity.dtStart = dt; validity.dtEnd = d->incidenceEndTime(*iit, dt, true); returnList.append(ExpandedIncidence(validity, *iit)); continue; }

Fix the non-valid dte to be dt+1 if (dte.isValid() && dte <= dt) { brokenEnd = true; }

Then insert the current; only if it (partially) fits within the [dtStart, dtEnd[ window. (note that dtEnd is not really included; similarly, the last second of events is not counted as valid. This is because (for example) all-day events in ical are typically stored as whole day+1 events (that is, the first second of next day is where it ends), and due to that otherwise date-specific queries won't work nicely.

Mandatory conditions: [1] dt < dtEnd <> start period early enough iff dtEnd specified [2] dte > dtStart <> end period late enough iff dte set

Note: This algorithm implies that events that are only partially within the desired [dtStart, dtEnd] range are also included.

    if ((!dtEnd.isValid() || dt < dtEnd)
            && (!dte.isValid()
                || (!brokenEnd && dte > dtStart)
                || (brokenEnd && dt > brokenDtStart))) {

/* DEBUG_EXPANSION

Variable Documentation

◆ appended

appended

◆ dtEnd

validity dtEnd = d->incidenceEndTime(*iit, dt, true)

◆ else

else
Initial value:
{
validity.dtStart = dt

◆ returnList

return returnList

Generated on Wed Jun 9 2021 14:20:48 for libextendedkcal by doxygen 1.9.1