summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorrecurrence.cpp12
-rw-r--r--korganizer/koeditorrecurrence.h3
-rw-r--r--libkcal/calendarlocal.cpp2
-rw-r--r--libkcal/icalformatimpl.cpp11
-rw-r--r--libkcal/journal.cpp2
5 files changed, 21 insertions, 9 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index 89504db..0e74a99 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -425,231 +425,235 @@ ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) :
void ExceptionsWidget::setDefaults( const QDateTime &from )
{
mExceptionDateEdit->setDate( from.date() );
}
void ExceptionsWidget::addException()
{
QDate date = mExceptionDateEdit->date();
QString dateStr = KGlobal::locale()->formatDate( date );
if( !mExceptionList->findItem( dateStr ) ) {
mExceptionDates.append( date );
mExceptionList->insertItem( dateStr );
}
}
void ExceptionsWidget::changeException()
{
int pos = mExceptionList->currentItem();
if ( pos < 0 ) return;
QDate date = mExceptionDateEdit->date();
mExceptionDates[ pos ] = date;
mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos );
}
void ExceptionsWidget::deleteException()
{
int pos = mExceptionList->currentItem();
if ( pos < 0 ) return;
mExceptionDates.remove( mExceptionDates.at( pos ) );
mExceptionList->removeItem( pos );
}
void ExceptionsWidget::setDates( const DateList &dates )
{
mExceptionList->clear();
mExceptionDates.clear();
DateList::ConstIterator dit;
for ( dit = dates.begin(); dit != dates.end(); ++dit ) {
mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) );
mExceptionDates.append( *dit );
}
}
DateList ExceptionsWidget::dates()
{
return mExceptionDates;
}
///////////////////////// ExceptionsDialog ///////////////////////////
ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) :
KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel )
{
mExceptions = new ExceptionsWidget( this );
setMainWidget( mExceptions );
resize(220,10);
}
void ExceptionsDialog::setDefaults( const QDateTime &from )
{
mExceptions->setDefaults( from );
}
void ExceptionsDialog::setDates( const DateList &dates )
{
mExceptions->setDates( dates );
}
DateList ExceptionsDialog::dates()
{
return mExceptions->dates();
}
///////////////////////// RecurrenceRangeWidget ///////////////////////////
RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent,
const char *name )
: QWidget( parent, name )
{
QBoxLayout *topLayout = new QVBoxLayout( this );
mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"),
this );
topLayout->addWidget( mRangeGroupBox );
QWidget *rangeBox = new QWidget( mRangeGroupBox );
QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox );
rangeLayout->setSpacing( KDialog::spacingHint() );
rangeLayout->setMargin( KDialog::marginHintSmall() );
mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox );
rangeLayout->addWidget( mStartDateLabel );
- QButtonGroup *rangeButtonGroup = new QButtonGroup;
+ mRangeButtonGroup = new QButtonGroup;
mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox );
- rangeButtonGroup->insert( mNoEndDateButton );
+ mRangeButtonGroup->insert( mNoEndDateButton );
rangeLayout->addWidget( mNoEndDateButton );
QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout );
durationLayout->setSpacing( KDialog::spacingHint() );
mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox );
- rangeButtonGroup->insert( mEndDurationButton );
+ mRangeButtonGroup->insert( mEndDurationButton );
durationLayout->addWidget( mEndDurationButton );
mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox );
durationLayout->addWidget( mEndDurationEdit );
QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox );
durationLayout ->addWidget( endDurationLabel );
QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout );
endDateLayout->setSpacing( KDialog::spacingHint() );
mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox );
- rangeButtonGroup->insert( mEndDateButton );
+ mRangeButtonGroup->insert( mEndDateButton );
endDateLayout->addWidget( mEndDateButton );
mEndDateEdit = new KDateEdit( rangeBox );
endDateLayout->addWidget( mEndDateEdit );
//endDateLayout->addStretch( 1 );
connect( mNoEndDateButton, SIGNAL( toggled( bool ) ),
SLOT( showCurrentRange() ) );
connect( mEndDurationButton, SIGNAL( toggled( bool ) ),
SLOT( showCurrentRange() ) );
connect( mEndDateButton, SIGNAL( toggled( bool ) ),
SLOT( showCurrentRange() ) );
}
+RecurrenceRangeWidget::~RecurrenceRangeWidget()
+{
+ delete mRangeButtonGroup;
+}
void RecurrenceRangeWidget::setDefaults( const QDateTime &from )
{
mNoEndDateButton->setChecked( true );
setDateTimes( from );
mEndDateEdit->setDate( from.date() );
}
void RecurrenceRangeWidget::setDuration( int duration )
{
if ( duration == -1 ) {
mNoEndDateButton->setChecked( true );
} else if ( duration == 0 ) {
mEndDateButton->setChecked( true );
} else {
mEndDurationButton->setChecked( true );
mEndDurationEdit->setValue( duration );
}
}
int RecurrenceRangeWidget::duration()
{
if ( mNoEndDateButton->isChecked() ) {
return -1;
} else if ( mEndDurationButton->isChecked() ) {
return mEndDurationEdit->value();
} else {
return 0;
}
}
void RecurrenceRangeWidget::setEndDate( const QDate &date )
{
mEndDateEdit->setDate( date );
}
QDate RecurrenceRangeWidget::endDate()
{
return mEndDateEdit->date();
}
void RecurrenceRangeWidget::showCurrentRange()
{
mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
}
void RecurrenceRangeWidget::setDateTimes( const QDateTime &start,
const QDateTime & )
{
mStartDateLabel->setText( i18n("Start date: %1")
.arg( KGlobal::locale()->formatDate( start.date() ) ) );
if(!mEndDateButton->isChecked())
mEndDateEdit->setDate( start.date() );
}
///////////////////////// RecurrenceRangeDialog ///////////////////////////
RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent,
const char *name ) :
KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel )
{
mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
setMainWidget( mRecurrenceRangeWidget );
}
void RecurrenceRangeDialog::setDefaults( const QDateTime &from )
{
mRecurrenceRangeWidget->setDefaults( from );
}
void RecurrenceRangeDialog::setDuration( int duration )
{
mRecurrenceRangeWidget->setDuration( duration );
}
int RecurrenceRangeDialog::duration()
{
return mRecurrenceRangeWidget->duration();
}
void RecurrenceRangeDialog::setEndDate( const QDate &date )
{
mRecurrenceRangeWidget->setEndDate( date );
}
QDate RecurrenceRangeDialog::endDate()
{
return mRecurrenceRangeWidget->endDate();
}
void RecurrenceRangeDialog::setDateTimes( const QDateTime &start,
const QDateTime &end )
{
mRecurrenceRangeWidget->setDateTimes( start, end );
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h
index f398f62..75e0c73 100644
--- a/korganizer/koeditorrecurrence.h
+++ b/korganizer/koeditorrecurrence.h
@@ -1,324 +1,327 @@
/*
This file is part of KOrganizer.
Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef _KOEDITORRECURRENCE_H
#define _KOEDITORRECURRENCE_H
#include <qframe.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qmultilineedit.h>
#include <qlistview.h>
#include <qradiobutton.h>
+#include <qbuttongroup.h>
#include <kdialogbase.h>
#include <libkcal/event.h>
#include "ktimeedit.h"
class QWidgetStack;
class QSpinBox;
class KDateEdit;
using namespace KCal;
class RecurBase : public QWidget
{
public:
RecurBase( QWidget *parent = 0, const char *name = 0 );
void setFrequency( int );
int frequency();
QWidget *frequencyEdit();
private:
QSpinBox *mFrequencyEdit;
};
class RecurDaily : public RecurBase
{
public:
RecurDaily( QWidget *parent = 0, const char *name = 0 );
};
class RecurWeekly : public RecurBase
{
public:
RecurWeekly( QWidget *parent = 0, const char *name = 0 );
void setDays( const QBitArray & );
QBitArray days();
private:
QCheckBox *mDayBoxes[7];
};
class RecurMonthly : public RecurBase
{
public:
RecurMonthly( QWidget *parent = 0, const char *name = 0 );
void setByDay( int day );
void setByPos( int count, int weekday );
bool byDay();
bool byPos();
int day();
int count();
int weekday();
private:
QRadioButton *mByDayRadio;
QComboBox *mByDayCombo;
QRadioButton *mByPosRadio;
QComboBox *mByPosCountCombo;
QComboBox *mByPosWeekdayCombo;
};
class RecurYearly : public RecurBase
{
public:
RecurYearly( QWidget *parent = 0, const char *name = 0 );
void setByDay( int doy );
void setByMonth( int month, int day );
bool byMonth();
bool byDay();
int month();
int day();
private:
int mDay;
QRadioButton *mByMonthRadio;
QComboBox *mByMonthCombo;
QLabel* mByDayLabel;
QLabel* mDayOfLabel;
QRadioButton *mByDayRadio;
};
class RecurrenceChooser : public QWidget
{
Q_OBJECT
public:
RecurrenceChooser( QWidget *parent = 0, const char *name = 0 );
enum { Daily, Weekly, Monthly, Yearly };
void setType( int );
int type();
signals:
void chosen( int );
protected slots:
void emitChoice();
private:
QComboBox *mTypeCombo;
QRadioButton *mDailyButton;
QRadioButton *mWeeklyButton;
QRadioButton *mMonthlyButton;
QRadioButton *mYearlyButton;
};
class ExceptionsBase
{
public:
virtual void setDefaults( const QDateTime &from ) = 0;
virtual void setDates( const DateList & ) = 0;
virtual DateList dates() = 0;
};
class ExceptionsWidget : public QWidget, public ExceptionsBase
{
Q_OBJECT
public:
ExceptionsWidget( QWidget *parent = 0, const char *name = 0 );
void setDefaults( const QDateTime &from );
void setDates( const DateList & );
DateList dates();
protected slots:
void addException();
void changeException();
void deleteException();
private:
KDateEdit *mExceptionDateEdit;
QListBox *mExceptionList;
DateList mExceptionDates;
};
class ExceptionsDialog : public KDialogBase, public ExceptionsBase
{
public:
ExceptionsDialog( QWidget *parent, const char *name = 0 );
void setDefaults( const QDateTime &from );
void setDates( const DateList & );
DateList dates();
private:
ExceptionsWidget *mExceptions;
};
class RecurrenceRangeBase
{
public:
virtual void setDefaults( const QDateTime &from ) = 0;
virtual void setDuration( int ) = 0;
virtual int duration() = 0;
virtual void setEndDate( const QDate & ) = 0;
virtual QDate endDate() = 0;
virtual void setDateTimes( const QDateTime &start,
const QDateTime &end = QDateTime() ) = 0;
};
class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase
{
Q_OBJECT
public:
RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 );
+ ~RecurrenceRangeWidget();
void setDefaults( const QDateTime &from );
void setDuration( int );
int duration();
void setEndDate( const QDate & );
QDate endDate();
void setDateTimes( const QDateTime &start,
const QDateTime &end = QDateTime() );
protected slots:
void showCurrentRange();
private:
+ QButtonGroup *mRangeButtonGroup;
QGroupBox *mRangeGroupBox;
QLabel *mStartDateLabel;
QRadioButton *mNoEndDateButton;
QRadioButton *mEndDurationButton;
QSpinBox *mEndDurationEdit;
QRadioButton *mEndDateButton;
KDateEdit *mEndDateEdit;
};
class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase
{
public:
RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 );
void setDefaults( const QDateTime &from );
void setDuration( int );
int duration();
void setEndDate( const QDate & );
QDate endDate();
void setDateTimes( const QDateTime &start,
const QDateTime &end = QDateTime() );
private:
RecurrenceRangeWidget *mRecurrenceRangeWidget;
};
class KOEditorRecurrence : public QWidget
{
Q_OBJECT
public:
KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 );
virtual ~KOEditorRecurrence();
enum { Daily, Weekly, Monthly, Yearly };
/** Read event object and setup widgets accordingly */
void readEvent( Incidence * );
/** Write event settings to event object */
void writeEvent( Incidence * );
/** Check if the input is valid. */
bool validateInput();
public slots:
void setDefaultsDates( QDateTime from, QDateTime to );
void setDefaults( QDateTime from, QDateTime to );
void setEnabled( bool );
void setDateTimes( QDateTime start, QDateTime end );
void setDateTimeStr( const QString & );
signals:
void dateTimesChanged( QDateTime start, QDateTime end );
protected slots:
void showCurrentRule( int );
void showExceptionsDialog();
void showRecurrenceRangeDialog();
private:
QCheckBox *mEnabledCheck;
QGroupBox *mTimeGroupBox;
QLabel *mDateTimeLabel;
QGroupBox *mRuleBox;
QWidgetStack *mRuleStack;
RecurrenceChooser *mRecurrenceChooser;
RecurDaily *mDaily;
RecurWeekly *mWeekly;
RecurMonthly *mMonthly;
RecurYearly *mYearly;
RecurrenceRangeBase *mRecurrenceRange;
RecurrenceRangeWidget *mRecurrenceRangeWidget;
RecurrenceRangeDialog *mRecurrenceRangeDialog;
QPushButton *mRecurrenceRangeButton;
ExceptionsBase *mExceptions;
ExceptionsDialog *mExceptionsDialog;
ExceptionsWidget *mExceptionsWidget;
QPushButton *mExceptionsButton;
};
#endif
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index eef8327..5baa7dc 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -163,193 +163,193 @@ bool CalendarLocal::mergeCalendar( Calendar* remote )
}
bool CalendarLocal::addCalendarFile( QString name, int id )
{
CalendarLocal calendar( timeZoneId() );
calendar.setDefaultCalendar( id );
if ( calendar.load( name ) ) {
addCalendar( &calendar );
return true;
}
return false;
}
void CalendarLocal::setSyncEventsReadOnly()
{
Event * ev;
ev = mEventList.first();
while ( ev ) {
if ( ev->uid().left(15) == QString("last-syncEvent-") )
ev->setReadOnly( true );
ev = mEventList.next();
}
}
void CalendarLocal::addCalendar( Calendar* cal )
{
cal->setDontDeleteIncidencesOnClose();
{
QPtrList<Event> EventList = cal->rawEvents();
Event * ev = EventList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mEventList.append( ev );
ev = EventList.next();
}
}
{
QPtrList<Todo> TodoList = cal->rawTodos();
Todo * ev = TodoList.first();
while ( ev ) {
QString rel = ev->relatedToUid();
if ( !rel.isEmpty() ){
ev->setRelatedTo ( 0 );
ev->setRelatedToUid( rel );
}
ev = TodoList.next();
}
//TodoList = cal->rawTodos();
ev = TodoList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mTodoList.append( ev );
setupRelations( ev );
ev = TodoList.next();
}
}
{
QPtrList<Journal> JournalList = cal->journals();
Journal * ev = JournalList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mJournalList.append( ev );
ev = JournalList.next();
}
}
setModified( true );
}
bool CalendarLocal::load( const QString &fileName )
{
FileStorage storage( this, fileName );
return storage.load();
}
bool CalendarLocal::save( const QString &fileName, CalFormat *format )
{
FileStorage storage( this, fileName, format );
return storage.save();
}
void CalendarLocal::stopAllTodos()
{
for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
it->setRunning( false );
}
void CalendarLocal::close()
{
Todo * i;
for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
mEventList.setAutoDelete( true );
mTodoList.setAutoDelete( true );
- mJournalList.setAutoDelete( false );
+ mJournalList.setAutoDelete( true );
mEventList.clear();
mTodoList.clear();
mJournalList.clear();
mEventList.setAutoDelete( false );
mTodoList.setAutoDelete( false );
mJournalList.setAutoDelete( false );
setModified( false );
}
bool CalendarLocal::addAnniversaryNoDup( Event *event )
{
QString cat;
bool isBirthday = true;
if( event->categoriesStr() == i18n( "Anniversary" ) ) {
isBirthday = false;
cat = i18n( "Anniversary" );
} else if( event->categoriesStr() == i18n( "Birthday" ) ) {
isBirthday = true;
cat = i18n( "Birthday" );
} else {
qDebug("addAnniversaryNoDup called without fitting category! ");
return false;
}
Event * eve;
for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
if ( !(eve->categories().contains( cat ) ))
continue;
// now we have an event with fitting category
if ( eve->dtStart().date() != event->dtStart().date() )
continue;
// now we have an event with fitting category+date
if ( eve->summary() != event->summary() )
continue;
// now we have an event with fitting category+date+summary
return false;
}
return addEvent( event );
}
bool CalendarLocal::addEventNoDup( Event *event )
{
Event * eve;
for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
if ( *eve == *event ) {
//qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
return false;
}
}
return addEvent( event );
}
bool CalendarLocal::addEvent( Event *event )
{
insertEvent( event );
event->registerObserver( this );
setModified( true );
if ( event->calID() == 0 )
event->setCalID( mDefaultCalendar );
event->setCalEnabled( true );
return true;
}
void CalendarLocal::deleteEvent( Event *event )
{
if ( mUndoIncidence ) delete mUndoIncidence;
mUndoIncidence = event->clone();
if ( mEventList.removeRef( event ) ) {
setModified( true );
}
}
Event *CalendarLocal::event( const QString &uid )
{
Event *event;
Event *retVal = 0;
for ( event = mEventList.first(); event; event = mEventList.next() ) {
if ( event->calEnabled() && event->uid() == uid ) {
if ( retVal ) {
if ( retVal->calID() > event->calID() ) {
retVal = event;
}
} else {
retVal = event;
}
}
}
return retVal;
}
bool CalendarLocal::addTodoNoDup( Todo *todo )
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index f349681..53aa039 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -909,193 +909,193 @@ Event *ICalFormatImpl::readEvent(icalcomponent *vevent)
}
anEvent->setAttachments(tmpStrList);
// resources
if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) {
QString resources = (s = fakeCString(vObjectUStringZValue(vo)));
deleteStr(s);
tmpStrList.clear();
index1 = 0;
index2 = 0;
QString resource;
while ((index2 = resources.find(';', index1)) != -1) {
resource = resources.mid(index1, (index2 - index1));
tmpStrList.append(resource);
index1 = index2;
}
anEvent->setResources(tmpStrList);
}
#endif
case ICAL_RELATEDTO_PROPERTY: // releated event (parent)
event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p)));
mEventsRelate.append(event);
break;
case ICAL_TRANSP_PROPERTY: // Transparency
if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT )
event->setTransparency( Event::Transparent );
else
event->setTransparency( Event::Opaque );
break;
default:
// kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind
// << endl;
break;
}
p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY);
}
QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT");
if (!msade.isNull()) {
bool floats = (msade == QString::fromLatin1("TRUE"));
kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl;
event->setFloats(floats);
if (floats) {
QDateTime endDate = event->dtEnd();
event->setDtEnd(endDate.addDays(-1));
}
}
// some stupid vCal exporters ignore the standard and use Description
// instead of Summary for the default field. Correct for this.
if (event->summary().isEmpty() &&
!(event->description().isEmpty())) {
QString tmpStr = event->description().simplifyWhiteSpace();
event->setDescription("");
event->setSummary(tmpStr);
}
return event;
}
FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy)
{
FreeBusy *freebusy = new FreeBusy;
readIncidenceBase(vfreebusy,freebusy);
icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY);
icaltimetype icaltime;
icalperiodtype icalperiod;
QDateTime period_start, period_end;
while (p) {
icalproperty_kind kind = icalproperty_isa(p);
switch (kind) {
case ICAL_DTSTART_PROPERTY: // start date and time
icaltime = icalproperty_get_dtstart(p);
freebusy->setDtStart(readICalDateTime(icaltime));
break;
case ICAL_DTEND_PROPERTY: // start End Date and Time
icaltime = icalproperty_get_dtend(p);
freebusy->setDtEnd(readICalDateTime(icaltime));
break;
case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times
icalperiod = icalproperty_get_freebusy(p);
period_start = readICalDateTime(icalperiod.start);
period_end = readICalDateTime(icalperiod.end);
freebusy->addPeriod(period_start, period_end);
break;
-
+
default:
kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind
<< endl;
break;
}
p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY);
}
return freebusy;
}
Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal)
{
Journal *journal = new Journal;
readIncidence(vjournal,journal);
if ( !journal->dtStart().isValid() && journal->created().isValid() ) {
journal->setDtStart( journal->created() );
}
return journal;
}
Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee)
{
icalparameter *p = 0;
QString email = QString::fromUtf8(icalproperty_get_attendee(attendee));
QString name;
QString uid = QString::null;
p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER);
if (p) {
name = QString::fromUtf8(icalparameter_get_cn(p));
} else {
}
bool rsvp=false;
p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER);
if (p) {
icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p);
if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true;
}
Attendee::PartStat status = Attendee::NeedsAction;
p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER);
if (p) {
icalparameter_partstat partStatParameter = icalparameter_get_partstat(p);
switch(partStatParameter) {
default:
case ICAL_PARTSTAT_NEEDSACTION:
status = Attendee::NeedsAction;
break;
case ICAL_PARTSTAT_ACCEPTED:
status = Attendee::Accepted;
break;
case ICAL_PARTSTAT_DECLINED:
status = Attendee::Declined;
break;
case ICAL_PARTSTAT_TENTATIVE:
status = Attendee::Tentative;
break;
case ICAL_PARTSTAT_DELEGATED:
status = Attendee::Delegated;
break;
case ICAL_PARTSTAT_COMPLETED:
status = Attendee::Completed;
break;
case ICAL_PARTSTAT_INPROCESS:
status = Attendee::InProcess;
break;
}
}
Attendee::Role role = Attendee::ReqParticipant;
p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER);
if (p) {
icalparameter_role roleParameter = icalparameter_get_role(p);
switch(roleParameter) {
case ICAL_ROLE_CHAIR:
role = Attendee::Chair;
break;
default:
case ICAL_ROLE_REQPARTICIPANT:
role = Attendee::ReqParticipant;
break;
case ICAL_ROLE_OPTPARTICIPANT:
role = Attendee::OptParticipant;
break;
case ICAL_ROLE_NONPARTICIPANT:
role = Attendee::NonParticipant;
break;
}
}
p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER);
@@ -1851,211 +1851,214 @@ bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar)
i18n("This calendar is an iTIP transaction of type \"%1\".")
.arg(methodType),
i18n("%1: iTIP Transaction").arg(CalFormat::application()));
delete methodType;
}
#endif
icalproperty *p;
p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY);
if (!p) {
// TODO: does no PRODID really matter?
// mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
// return false;
mLoadedProductId = "";
mCalendarVersion = 0;
} else {
mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p));
mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId);
delete mCompat;
mCompat = CompatFactory::createCompat( mLoadedProductId );
}
// TODO: check for unknown PRODID
#if 0
if (!mCalendarVersion
&& CalFormat::productId() != mLoadedProductId) {
// warn the user that we might have trouble reading non-known calendar.
if (mEnableDialogs)
KMessageBox::information(mTopWidget,
i18n("This vCalendar file was not created by KOrganizer "
"or any other product we support. Loading anyway..."),
i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application()));
}
#endif
p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY);
if (!p) {
mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
return false;
} else {
const char *version = icalproperty_get_version(p);
if (strcmp(version,"1.0") == 0) {
mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1,
i18n("Expected iCalendar format")));
return false;
} else if (strcmp(version,"2.0") != 0) {
mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
return false;
}
}
// TODO: check for calendar format version
#if 0
// warn the user we might have trouble reading this unknown version.
if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) {
char *s = fakeCString(vObjectUStringZValue(curVO));
if (strcmp(_VCAL_VERSION, s) != 0)
if (mEnableDialogs)
KMessageBox::sorry(mTopWidget,
i18n("This vCalendar file has version %1.\n"
"We only support %2.")
.arg(s).arg(_VCAL_VERSION),
i18n("%1: Unknown vCalendar Version").arg(CalFormat::application()));
deleteStr(s);
}
#endif
// custom properties
readCustomProperties(calendar, cal);
// TODO: set time zone
#if 0
// set the time zone
if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) {
char *s = fakeCString(vObjectUStringZValue(curVO));
cal->setTimeZone(s);
deleteStr(s);
}
#endif
// Store all events with a relatedTo property in a list for post-processing
mEventsRelate.clear();
mTodosRelate.clear();
// TODO: make sure that only actually added ecvens go to this lists.
icalcomponent *c;
// Iterate through all todos
c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT);
while (c) {
// kdDebug(5800) << "----Todo found" << endl;
Todo *todo = readTodo(c);
- if (!cal->todo(todo->uid())) cal->addTodo(todo);
+ if (!cal->todo(todo->uid()))
+ cal->addTodo(todo);
c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT);
}
// Iterate through all events
c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT);
while (c) {
// kdDebug(5800) << "----Event found" << endl;
Event *event = readEvent(c);
- if (!cal->event(event->uid())) cal->addEvent(event);
+ if (!cal->event(event->uid()))
+ cal->addEvent(event);
c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT);
}
// Iterate through all journals
c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT);
while (c) {
// kdDebug(5800) << "----Journal found" << endl;
Journal *journal = readJournal(c);
- if (!cal->journal(journal->uid())) cal->addJournal(journal);
+ if (!cal->journal(journal->uid()))
+ cal->addJournal(journal);
c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT);
}
#if 0
initPropIterator(&i, vcal);
// go through all the vobjects in the vcal
while (moreIteration(&i)) {
curVO = nextVObject(&i);
/************************************************************************/
// now, check to see that the object is an event or todo.
if (strcmp(vObjectName(curVO), VCEventProp) == 0) {
if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) {
char *s;
s = fakeCString(vObjectUStringZValue(curVOProp));
// check to see if event was deleted by the kpilot conduit
if (atoi(s) == Event::SYNCDEL) {
deleteStr(s);
goto SKIP;
}
deleteStr(s);
}
// this code checks to see if we are trying to read in an event
// that we already find to be in the calendar. If we find this
// to be the case, we skip the event.
if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) {
char *s = fakeCString(vObjectUStringZValue(curVOProp));
QString tmpStr(s);
deleteStr(s);
if (cal->event(tmpStr)) {
goto SKIP;
}
if (cal->todo(tmpStr)) {
goto SKIP;
}
}
if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) &&
(!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) {
kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl;
goto SKIP;
}
anEvent = VEventToEvent(curVO);
// we now use addEvent instead of insertEvent so that the
// signal/slot get connected.
if (anEvent)
cal->addEvent(anEvent);
else {
// some sort of error must have occurred while in translation.
goto SKIP;
}
} else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {
anEvent = VTodoToEvent(curVO);
cal->addTodo(anEvent);
} else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) ||
(strcmp(vObjectName(curVO), VCProdIdProp) == 0) ||
(strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) {
// do nothing, we know these properties and we want to skip them.
// we have either already processed them or are ignoring them.
;
} else {
;
}
SKIP:
;
} // while
#endif
// Post-Process list of events with relations, put Event objects in relation
Event *ev;
for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) {
Incidence * inc = cal->event(ev->relatedToUid());
if ( inc )
ev->setRelatedTo( inc );
}
Todo *todo;
for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) {
Incidence * inc = cal->todo(todo->relatedToUid());
if ( inc )
todo->setRelatedTo( inc );
}
return true;
}
QString ICalFormatImpl::extractErrorProperty(icalcomponent *c)
{
// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: "
// << icalcomponent_as_ical_string(c) << endl;
diff --git a/libkcal/journal.cpp b/libkcal/journal.cpp
index 859161f..c4e4474 100644
--- a/libkcal/journal.cpp
+++ b/libkcal/journal.cpp
@@ -1,49 +1,51 @@
/*
This file is part of libkcal.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "journal.h"
using namespace KCal;
Journal::Journal()
{
+ qDebug("New JJJ ");
}
Journal::~Journal()
{
+ qDebug("delete JJJ ");
}
Incidence *Journal::clone()
{
return new Journal(*this);
}
bool KCal::operator==( const Journal& j1, const Journal& j2 )
{
return operator==( (const Incidence&)j1, (const Incidence&)j2 );
}
QDateTime Journal::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
{
*ok = false;
return QDateTime ();
}