summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendar.cpp6
-rw-r--r--libkcal/calendarlocal.cpp4
-rw-r--r--libkcal/calfilter.cpp6
-rw-r--r--libkcal/event.h1
-rw-r--r--libkcal/freebusy.h1
-rw-r--r--libkcal/icalformat.cpp4
-rw-r--r--libkcal/icalformatimpl.cpp6
-rw-r--r--libkcal/incidence.cpp6
-rw-r--r--libkcal/incidencebase.h2
-rw-r--r--libkcal/journal.h1
-rw-r--r--libkcal/kincidenceformatter.cpp4
-rw-r--r--libkcal/todo.cpp5
-rw-r--r--libkcal/todo.h1
13 files changed, 25 insertions, 22 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index ed39ddb..7e8e2c5 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -350,17 +350,17 @@ bool Calendar::addIncidence(Incidence *i)
Incidence::AddVisitor<Calendar> v(this);
return i->accept(v);
}
void Calendar::deleteIncidence(Incidence *in)
{
- if ( in->type() == "Event" )
+ if ( in->typeID() == eventID )
deleteEvent( (Event*) in );
- else if ( in->type() =="Todo" )
+ else if ( in->typeID() == todoID )
deleteTodo( (Todo*) in);
- else if ( in->type() =="Journal" )
+ else if ( in->typeID() == journalID )
deleteJournal( (Journal*) in );
}
Incidence* Calendar::incidence( const QString& uid )
{
Incidence* i;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index bc76c0b..fe74052 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -455,14 +455,12 @@ Alarm::List CalendarLocal::alarmsTo( const QDateTime &to )
{
return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to );
}
Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
{
- kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - "
- << to.toString() << ")\n";
Alarm::List alarms;
Event *e;
for( e = mEventList.first(); e; e = mEventList.next() ) {
@@ -485,14 +483,12 @@ void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
Alarm *alarm;
for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text()
// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl;
if ( alarm->enabled() ) {
if ( alarm->time() >= from && alarm->time() <= to ) {
- kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary()
- << "': " << alarm->time().toString() << endl;
alarms.append( alarm );
}
}
}
}
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index c425dfc..20078a7 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -75,17 +75,17 @@ void CalFilter::apply(QPtrList<Todo> *eventlist)
}
// kdDebug(5800) << "CalFilter::apply() done" << endl;
}
bool CalFilter::filterCalendarItem(Incidence *in)
{
- if ( in->type() == "Event" )
+ if ( in->typeID() == eventID )
return filterEvent( (Event*) in );
- else if ( in->type() =="Todo" )
+ else if ( in->typeID() == todoID )
return filterTodo( (Todo*) in);
- else if ( in->type() =="Journal" )
+ else if ( in->typeID () == journalID )
return filterJournal( (Journal*) in );
return false;
}
bool CalFilter::filterEvent(Event *event)
{
if (mCriteria & HideEvents)
diff --git a/libkcal/event.h b/libkcal/event.h
index 8729956..287d403 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -37,12 +37,13 @@ class Event : public Incidence
typedef ListBase<Event> List;
Event();
Event(const Event &);
~Event();
QCString type() const { return "Event"; }
+ IncTypeID typeID() const { return eventID; }
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
/** for setting an event's ending date/time with a QDateTime. */
void setDtEnd(const QDateTime &dtEnd);
diff --git a/libkcal/freebusy.h b/libkcal/freebusy.h
index 054feda..d741c72 100644
--- a/libkcal/freebusy.h
+++ b/libkcal/freebusy.h
@@ -45,12 +45,13 @@ class FreeBusy : public IncidenceBase
FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end);
FreeBusy(QValueList<Period> busyPeriods);
~FreeBusy();
QCString type() const { return "FreeBusy"; }
+ IncTypeID typeID() const { return freebusyID; }
virtual QDateTime dtEnd() const;
bool setDtEnd( const QDateTime &end );
QValueList<Period> busyPeriods() const;
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index 3a2aac6..d9fe40b 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -381,18 +381,18 @@ ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal,
icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal);
Incidence *existingIncidence = cal->event(incidence->uid());
if (existingIncidence) {
// TODO: check, if cast is required, or if it can be done by virtual funcs.
- if (existingIncidence->type() == "Todo") {
+ if (existingIncidence->typeID() == todoID ) {
Todo *todo = static_cast<Todo *>(existingIncidence);
icalcomponent_add_component(calendarComponent,
mImpl->writeTodo(todo));
}
- if (existingIncidence->type() == "Event") {
+ if (existingIncidence->typeID() == eventID ) {
Event *event = static_cast<Event *>(existingIncidence);
icalcomponent_add_component(calendarComponent,
mImpl->writeEvent(event));
}
} else {
calendarComponent = 0;
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 2405682..3e28714 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -2152,21 +2152,21 @@ icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence,
return message;
}
icalcomponent_add_property(message,icalproperty_new_method(icalmethod));
// TODO: check, if dynamic cast is required
- if(incidence->type() == "Todo") {
+ if(incidence->typeID() == todoID ) {
Todo *todo = static_cast<Todo *>(incidence);
icalcomponent_add_component(message,writeTodo(todo));
}
- if(incidence->type() == "Event") {
+ if(incidence->typeID() == eventID ) {
Event *event = static_cast<Event *>(incidence);
icalcomponent_add_component(message,writeEvent(event));
}
- if(incidence->type() == "FreeBusy") {
+ if(incidence->typeID() == freebusyID) {
FreeBusy *freebusy = static_cast<FreeBusy *>(incidence);
icalcomponent_add_component(message,writeFreeBusy(freebusy, method));
}
return message;
}
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 762103f..f446197 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -233,13 +233,13 @@ Incidence* Incidence::recreateCloneException( QDate d )
{
Incidence* newInc = clone();
newInc->recreate();
if ( doesRecur() ) {
addExDate( d );
newInc->recurrence()->unsetRecurs();
- if ( type() == "Event") {
+ if ( typeID() == eventID ) {
int len = dtStart().secsTo( ((Event*)this)->dtEnd());
QTime tim = dtStart().time();
newInc->setDtStart( QDateTime(d, tim) );
((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
} else {
int len = dtStart().secsTo( ((Todo*)this)->dtDue());
@@ -721,24 +721,24 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
return QDateTime ();
}
} else {
if ( hasStartDate () ) {
incidenceStart = dtStart();
}
- if ( type() =="Todo" ) {
+ if ( typeID() == todoID ) {
if ( ((Todo*)this)->hasDueDate() )
incidenceStart = ((Todo*)this)->dtDue();
}
}
if ( incidenceStart > dt )
*ok = true;
return incidenceStart;
}
QDateTime Incidence::dtStart() const
{
if ( doesRecur() ) {
- if ( type() == "Todo" ) {
+ if ( typeID() == todoID ) {
((Todo*)this)->checkSetCompletedFalse();
}
}
return mDtStart;
}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 8624786..05209e0 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -31,12 +31,13 @@
#include "customproperties.h"
#include "attendee.h"
namespace KCal {
typedef QValueList<QDate> DateList;
+ enum IncTypeID { eventID,todoID,journalID,freebusyID };
/**
This class provides the base class common to all calendar components.
*/
class IncidenceBase : public CustomProperties
{
@@ -48,12 +49,13 @@ class IncidenceBase : public CustomProperties
IncidenceBase();
IncidenceBase(const IncidenceBase &);
virtual ~IncidenceBase();
virtual QCString type() const = 0;
+ virtual IncTypeID typeID() const = 0;
/** Set the unique id for the event */
void setUid(const QString &);
/** Return the unique id for the event */
QString uid() const;
diff --git a/libkcal/journal.h b/libkcal/journal.h
index 2c1d7ea..1cd0a22 100644
--- a/libkcal/journal.h
+++ b/libkcal/journal.h
@@ -34,12 +34,13 @@ class Journal : public Incidence
{
public:
Journal();
~Journal();
QCString type() const { return "Journal"; }
+ IncTypeID typeID() const { return journalID; }
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
private:
bool accept(Visitor &v) { return v.visit(this); }
};
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 7d61b7f..d1ace4f 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -18,15 +18,15 @@ QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bo
// return QString::null;
// #endif
mDetails = details;
mCreated = created ;
mModified = modified;
mText = "";
- if ( inc->type() == "Event" )
+ if ( inc->typeID() == eventID )
setEvent((Event *) inc );
- else if ( inc->type() == "Todo" )
+ else if ( inc->typeID() == todoID )
setTodo((Todo *) inc );
return mText;
}
KIncidenceFormatter* KIncidenceFormatter::instance()
{
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 38ba2c7..c97a61e 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -127,13 +127,13 @@ void Todo::saveRunningInfoToFile( QString comment )
}
void Todo::saveParents()
{
if (!relatedTo() )
return;
Incidence * inc = relatedTo();
- if ( inc->type() != "Todo" )
+ if ( inc->typeID() != todoID )
return;
Todo* to = (Todo*)inc;
bool saveTodo = false;
QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
QFileInfo fi ( file );
if ( fi.exists() ) {
@@ -561,14 +561,15 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_d
return QDateTime ();
}
void Todo::checkSetCompletedFalse()
{
- if ( !hasRecurrenceID() ) {
+ if ( !mHasRecurrenceID ) {
qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
+ return;
}
// qDebug("Todo::checkSetCompletedFalse()");
//qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
if ( mPercentComplete == 100 ) {
QDateTime dt = QDateTime::currentDateTime();
if ( dt > mDtStart && dt > mRecurrenceID ) {
diff --git a/libkcal/todo.h b/libkcal/todo.h
index ab8fdf1..501c2ba 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -38,12 +38,13 @@ namespace KCal {
public:
Todo();
Todo(const Todo &);
~Todo();
typedef ListBase<Todo> List;
QCString type() const { return "Todo"; }
+ IncTypeID typeID() const { return todoID; }
/** Return an exact copy of this todo. */
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
/** for setting the todo's due date/time with a QDateTime. */