void CalPrintJournal::print( QPainter &p, int width, int height )
{
  int x=0, y=0;
  Journal::List journals( mCalendar->journals() );
  if ( mUseDateRange ) {
    Journal::List allJournals = journals;
    journals.clear();
    Journal::List::Iterator it = allJournals.begin();
    for ( ; it != allJournals.end(); ++it ) {
      QDate dt = (*it)->dtStart().date();
      if ( mFromDate <= dt && dt <= mToDate ) {
        journals.append( *it );
      }
    }
  }

  drawHeader( p, i18n( "Journal entries" ), QDate(), QDate(),
              QRect( 0, 0, width, headerHeight() ) );
  y = headerHeight() + 15;

  Journal::List::Iterator it = journals.begin();
  for ( ; it != journals.end(); ++it ) {
    drawJournal( *it, p, x, y, width, height );
  }
}
Beispiel #2
0
QString ICalFormat::toString(Calendar *cal)
{
    setTimeZone(cal->timeZoneId(), !cal->isLocalTime());

    icalcomponent *calendar = mImpl->createCalendarComponent(cal);

    icalcomponent *component;

    // todos
    Todo::List todoList = cal->rawTodos();
    Todo::List::ConstIterator it;
    for(it = todoList.begin(); it != todoList.end(); ++it)
    {
        //    kdDebug(5800) << "ICalFormat::toString() write todo "
        //                  << (*it)->uid() << endl;
        component = mImpl->writeTodo(*it);
        icalcomponent_add_component(calendar, component);
    }

    // events
    Event::List events = cal->rawEvents();
    Event::List::ConstIterator it2;
    for(it2 = events.begin(); it2 != events.end(); ++it2)
    {
        //    kdDebug(5800) << "ICalFormat::toString() write event "
        //                  << (*it2)->uid() << endl;
        component = mImpl->writeEvent(*it2);
        icalcomponent_add_component(calendar, component);
    }

    // journals
    Journal::List journals = cal->journals();
    Journal::List::ConstIterator it3;
    for(it3 = journals.begin(); it3 != journals.end(); ++it3)
    {
        kdDebug(5800) << "ICalFormat::toString() write journal "
                      << (*it3)->uid() << endl;
        component = mImpl->writeJournal(*it3);
        icalcomponent_add_component(calendar, component);
    }

    QString text = QString::fromUtf8(icalcomponent_as_ical_string(calendar));

    icalcomponent_free(calendar);
    icalmemory_free_ring();

    if(!text)
    {
        setException(new ErrorFormat(ErrorFormat::SaveError,
                                     i18n("libical error")));
        return QString::null;
    }

    return text;
}
Beispiel #3
0
Incidence::List Calendar::mergeIncidenceList(const Event::List &events,
        const Todo::List &todos,
        const Journal::List &journals)
{
    Incidence::List incidences;

    Event::List::ConstIterator it1;
    for(it1 = events.begin(); it1 != events.end(); ++it1)
        incidences.append(*it1);

    Todo::List::ConstIterator it2;
    for(it2 = todos.begin(); it2 != todos.end(); ++it2)
        incidences.append(*it2);

    Journal::List::ConstIterator it3;
    for(it3 = journals.begin(); it3 != journals.end(); ++it3)
        incidences.append(*it3);

    return incidences;
}
Beispiel #4
0
Journal::List Calendar::sortJournals(Journal::List *journalList,
                                     JournalSortField sortField,
                                     SortDirection sortDirection)
{
    Journal::List journalListSorted;
    Journal::List::Iterator sortIt;
    Journal::List::Iterator eit;

    switch(sortField)
    {
        case JournalSortUnsorted:
            journalListSorted = *journalList;
            break;

        case JournalSortDate:
            for(eit = journalList->begin(); eit != journalList->end(); ++eit)
            {
                sortIt = journalListSorted.begin();
                if(sortDirection == SortDirectionAscending)
                {
                    while(sortIt != journalListSorted.end() &&
                            (*eit)->dtStart() >= (*sortIt)->dtStart())
                    {
                        ++sortIt;
                    }
                }
                else
                {
                    while(sortIt != journalListSorted.end() &&
                            (*eit)->dtStart() < (*sortIt)->dtStart())
                    {
                        ++sortIt;
                    }
                }
                journalListSorted.insert(sortIt, *eit);
            }
            break;

        case JournalSortSummary:
            for(eit = journalList->begin(); eit != journalList->end(); ++eit)
            {
                sortIt = journalListSorted.begin();
                if(sortDirection == SortDirectionAscending)
                {
                    while(sortIt != journalListSorted.end() &&
                            (*eit)->summary() >= (*sortIt)->summary())
                    {
                        ++sortIt;
                    }
                }
                else
                {
                    while(sortIt != journalListSorted.end() &&
                            (*eit)->summary() < (*sortIt)->summary())
                    {
                        ++sortIt;
                    }
                }
                journalListSorted.insert(sortIt, *eit);
            }
            break;
    }

    return journalListSorted;
}