summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-06-08 10:34:22 (UTC)
committer zautrix <zautrix>2005-06-08 10:34:22 (UTC)
commit793d117812b4da36c9c11d90cccba347cbc6e208 (patch) (side-by-side diff)
tree5bc77e2b7a32a541c2a3b3c3d6d50f873216deef /libkcal
parent39d84e2fc3099bd5d7596e8be5dc6783826cec01 (diff)
downloadkdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.zip
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.gz
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.bz2
changed incidence type to a faster access method
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp6
-rw-r--r--libkcal/calendarlocal.cpp6
-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, 26 insertions, 23 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index ed39ddb..7e8e2c5 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -332,53 +332,53 @@ QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
QPtrList<Event> Calendar::events()
{
QPtrList<Event> el = rawEvents();
mFilter->apply(&el);
return el;
}
void Calendar::addIncidenceBranch(Incidence *i)
{
addIncidence( i );
Incidence * inc;
QPtrList<Incidence> Relations = i->relations();
for (inc=Relations.first();inc;inc=Relations.next()) {
addIncidenceBranch( inc );
}
}
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;
if( (i = todo( uid )) != 0 )
return i;
if( (i = event( uid )) != 0 )
return i;
if( (i = journal( uid )) != 0 )
return i;
return 0;
}
QPtrList<Todo> Calendar::todos()
{
QPtrList<Todo> tl = rawTodos();
mFilter->apply( &tl );
return tl;
}
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index bc76c0b..fe74052 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -437,80 +437,76 @@ QDateTime CalendarLocal::nextAlarm( int daysTo )
next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
if ( ok ) {
if ( next < nextA ) {
nextA = next;
found = true;
mNextSummary = t->summary();
mNextAlarmEventDateTime = next.addSecs(offset );
mNextAlarmIncidence = (Incidence *) t;
}
}
}
if ( mNextAlarmIncidence ) {
mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
mNextAlarmDateTime = nextA;
}
return nextA;
}
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() ) {
if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
else appendAlarms( alarms, e, from, to );
}
Todo *t;
for( t = mTodoList.first(); t; t = mTodoList.next() ) {
appendAlarms( alarms, t, from, to );
}
return alarms;
}
void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
const QDateTime &from, const QDateTime &to )
{
QPtrList<Alarm> alarmList = incidence->alarms();
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 );
}
}
}
}
void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms,
Incidence *incidence,
const QDateTime &from,
const QDateTime &to )
{
QPtrList<Alarm> alarmList = incidence->alarms();
Alarm *alarm;
QDateTime qdt;
for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
if (incidence->recursOn(from.date())) {
qdt.setTime(alarm->time().time());
qdt.setDate(from.date());
}
else qdt = alarm->time();
// qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1());
if ( alarm->enabled() ) {
if ( qdt >= from && qdt <= to ) {
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index c425dfc..20078a7 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -57,53 +57,53 @@ void CalFilter::apply(QPtrList<Event> *eventlist)
}
}
// kdDebug(5800) << "CalFilter::apply() done" << endl;
}
// TODO: avoid duplicating apply() code
void CalFilter::apply(QPtrList<Todo> *eventlist)
{
if (!mEnabled) return;
Todo *event = eventlist->first();
while(event) {
if (!filterTodo(event)) {
eventlist->remove();
event = eventlist->current();
} else {
event = eventlist->next();
}
}
// 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)
return false;
if (mCriteria & HideRecurring) {
if (event->recurrence()->doesRecur()) return false;
}
return filterIncidence(event);
}
bool CalFilter::filterJournal(Journal *j)
{
if (mCriteria & HideJournals)
return false;
return true;
}
bool CalFilter::filterTodo(Todo *todo)
{
if (mCriteria & HideTodos)
return false;
if (mCriteria & HideCompleted) {
diff --git a/libkcal/event.h b/libkcal/event.h
index 8729956..287d403 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -19,48 +19,49 @@
*/
#ifndef EVENT_H
#define EVENT_H
//
// Event component, representing a VEVENT object
//
#include "incidence.h"
namespace KCal {
/**
This class provides an Event in the sense of RFC2445.
*/
class Event : public Incidence
{
public:
enum Transparency { Opaque, Transparent };
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);
/** Return the event's ending date/time as a QDateTime. */
virtual QDateTime dtEnd() const;
/** returns an event's end time as a string formatted according to the
users locale settings */
QString dtEndTimeStr() const;
/** returns an event's end date as a string formatted according to the
users locale settings */
QString dtEndDateStr(bool shortfmt=true) const;
/** returns an event's end date and time as a string formatted according
to the users locale settings */
QString dtEndStr(bool shortfmt=true) const;
void setHasEndDate(bool);
/** Return whether the event has an end date/time. */
bool hasEndDate() const;
/** Return true if the event spans multiple days, otherwise return false. */
bool isMultiDay() const;
diff --git a/libkcal/freebusy.h b/libkcal/freebusy.h
index 054feda..d741c72 100644
--- a/libkcal/freebusy.h
+++ b/libkcal/freebusy.h
@@ -27,46 +27,47 @@
#include <qvaluelist.h>
#include <qptrlist.h>
#include "period.h"
#include "calendar.h"
#include "incidencebase.h"
namespace KCal {
/**
This class provides information about free/busy time of a calendar user.
*/
class FreeBusy : public IncidenceBase
{
public:
FreeBusy();
FreeBusy(const QDateTime &start, const QDateTime &end);
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;
void addPeriod(const QDateTime &start, const QDateTime &end);
void sortList();
private:
//This is used for creating a freebusy object for the current user
bool addLocalPeriod(const QDateTime &start, const QDateTime &end);
QDateTime mDtEnd;
QValueList<Period> mBusyPeriods;
Calendar *mCalendar;
};
}
#endif
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index 3a2aac6..d9fe40b 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -363,54 +363,54 @@ ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal,
method = Scheduler::Counter;
break;
case ICAL_METHOD_DECLINECOUNTER:
method = Scheduler::Declinecounter;
break;
default:
method = Scheduler::NoMethod;
kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl;
break;
}
if (!icalrestriction_check(message)) {
setException(new ErrorFormat(ErrorFormat::Restriction,
Scheduler::translatedMethodName(method) + ": " +
mImpl->extractErrorProperty(c)));
return 0;
}
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;
}
qDebug("icalclassify commented out ");
ScheduleMessage::Status status;
#if 0
icalclass result = icalclassify(message,calendarComponent,(char *)"");
switch (result) {
case ICAL_PUBLISH_NEW_CLASS:
status = ScheduleMessage::PublishNew;
break;
case ICAL_OBSOLETE_CLASS:
status = ScheduleMessage::Obsolete;
break;
case ICAL_REQUEST_NEW_CLASS:
status = ScheduleMessage::RequestNew;
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 2405682..3e28714 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -2134,39 +2134,39 @@ icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence,
break;
case Scheduler::Cancel:
icalmethod = ICAL_METHOD_CANCEL;
break;
case Scheduler::Add:
icalmethod = ICAL_METHOD_ADD;
break;
case Scheduler::Reply:
icalmethod = ICAL_METHOD_REPLY;
break;
case Scheduler::Counter:
icalmethod = ICAL_METHOD_COUNTER;
break;
case Scheduler::Declinecounter:
icalmethod = ICAL_METHOD_DECLINECOUNTER;
break;
default:
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
@@ -215,49 +215,49 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
return
// i1.created() == i2.created() &&
stringCompare( i1.description(), i2.description() ) &&
stringCompare( i1.summary(), i2.summary() ) &&
i1.categories() == i2.categories() &&
// no need to compare mRelatedTo
stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
// i1.relations() == i2.relations() &&
i1.exDates() == i2.exDates() &&
i1.attachments() == i2.attachments() &&
i1.resources() == i2.resources() &&
i1.secrecy() == i2.secrecy() &&
i1.priority() == i2.priority() &&
i1.cancelled() == i2.cancelled() &&
stringCompare( i1.location(), i2.location() );
}
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());
QTime tim = ((Todo*)this)->dtDue().time();
((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
((Todo*)this)->setRecurDates();
}
newInc->setExDates( DateList () );
}
return newInc;
}
void Incidence::recreate()
{
setCreated(QDateTime::currentDateTime());
setUid(CalFormat::createUniqueId());
setRevision(0);
setIDStr( ":" );
@@ -703,42 +703,42 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
while ( !last ) {
++count;
incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
if ( recursOn( incidenceStart.date() ) ) {
last = true; // exit while llop
} else {
if ( last ) { // no alarm on last recurrence
return QDateTime ();
}
int year = incidenceStart.date().year();
// workaround for bug in recurrence
if ( count == 100 || year < 1000 || year > 5000 ) {
return QDateTime ();
}
incidenceStart = incidenceStart.addSecs( 1 );
}
}
} else {
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
@@ -13,65 +13,67 @@
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.
*/
#ifndef KCAL_INCIDENCEBASE_H
#define KCAL_INCIDENCEBASE_H
//
// Incidence - base class of calendaring components
//
#include <qdatetime.h>
#include <qstringlist.h>
#include <qvaluelist.h>
#include <qptrlist.h>
#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
{
public:
class Observer {
public:
virtual void incidenceUpdated( IncidenceBase * ) = 0;
};
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;
/** Sets the time the incidence was last modified. */
void setLastModified(const QDateTime &lm);
/** Return the time the incidence was last modified. */
QDateTime lastModified() const;
/** sets the organizer for the event */
void setOrganizer(const QString &o);
QString organizer() const;
/** Set readonly status. */
virtual void setReadOnly( bool );
/** Return if the object is read-only. */
bool isReadOnly() const { return mReadOnly; }
/** for setting the event's starting date/time with a QDateTime. */
virtual void setDtStart(const QDateTime &dtStart);
/** returns an event's starting date/time as a QDateTime. */
virtual QDateTime dtStart() const;
diff --git a/libkcal/journal.h b/libkcal/journal.h
index 2c1d7ea..1cd0a22 100644
--- a/libkcal/journal.h
+++ b/libkcal/journal.h
@@ -16,35 +16,36 @@
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.
*/
#ifndef JOURNAL_H
#define JOURNAL_H
//
// Journal component, representing a VJOURNAL object
//
#include "incidence.h"
namespace KCal {
/**
This class provides a Journal in the sense of RFC2445.
*/
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); }
};
bool operator==( const Journal&, const Journal& );
}
#endif
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 7d61b7f..d1ace4f 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,50 +1,50 @@
#include "kincidenceformatter.h"
#include <kstaticdeleter.h>
#include <kglobal.h>
#include <klocale.h>
#ifdef DEKTOP_VERSION
#include <kabc/stdaddressbook.h>
#define size count
#endif
KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
static KStaticDeleter<KIncidenceFormatter> insd;
QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified )
{
// #ifndef QT_NO_INPUTDIALOG
// return QInputDialog::getItem( caption, label, items, current, editable );
// #else
// 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()
{
if (!mInstance) {
mInstance = insd.setObject(new KIncidenceFormatter());
}
return mInstance;
}
KIncidenceFormatter::~KIncidenceFormatter()
{
if (mInstance == this)
mInstance = insd.setObject(0);
//qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
}
KIncidenceFormatter::KIncidenceFormatter()
{
mColorMode = 0;
}
void KIncidenceFormatter::setEvent(Event *event)
{
int mode = 0;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 38ba2c7..c97a61e 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -109,49 +109,49 @@ void Todo::saveRunningInfoToFile( QString comment )
to->setDtStart( mRunStart );
to->setHasStartDate( true );
to->setDtDue( QDateTime::currentDateTime() );
to->setHasDueDate( true );
to->setUid( file );
if ( !comment.isEmpty() ) {
QString des = to->description();
if ( des.isEmpty () )
to->setDescription( "TT-Note: " + comment );
else
to->setDescription( "TT-Note: " + comment +"\n" + des );
}
cal.addIncidence( to );
ICalFormat format;
file = dir +"/" +file +".ics";
format.save( &cal, file );
saveParents();
}
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() ) {
if ( fi.lastModified () < to->lastModified ())
saveTodo = true;
} else {
saveTodo = true;
}
if ( saveTodo ) {
CalendarLocal cal;
cal.setLocalTime();
Todo * par = (Todo *) to->clone();
cal.addIncidence( par );
ICalFormat format;
format.save( &cal, file );
}
to->saveParents();
}
int Todo::runTime()
{
@@ -543,38 +543,39 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_d
} else {
int secs = alarm->startOffset().asSeconds();
if ( incidenceStart.addSecs( secs ) < alarmStart ) {
alarmStart = incidenceStart.addSecs( secs );
enabled = true;
off = -secs;
}
}
}
}
if ( enabled ) {
if ( alarmStart > start_dt ) {
*ok = true;
* offset = off;
return alarmStart;
}
}
*ok = false;
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 ) {
qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
setCompleted( false );
qDebug("Todo::checkSetCompletedFalse ");
}
}
}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index ab8fdf1..501c2ba 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -20,48 +20,49 @@
#ifndef TODO_H
#define TODO_H
//
// Todo component, representing a VTODO object
//
#include "incidence.h"
#include <qtimer.h>
namespace KCal {
/**
This class provides a Todo in the sense of RFC2445.
*/
class Todo : public QObject,public Incidence
{
Q_OBJECT
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. */
void setDtDue(const QDateTime &dtDue);
/** returns an event's Due date/time as a QDateTime. */
QDateTime dtDue() const;
/** returns an event's due time as a string formatted according to the
users locale settings */
QString dtDueTimeStr() const;
/** returns an event's due date as a string formatted according to the
users locale settings */
QString dtDueDateStr(bool shortfmt=true) const;
/** returns an event's due date and time as a string formatted according
to the users locale settings */
QString dtDueStr(bool shortfmt=true) const;
/** returns TRUE or FALSE depending on whether the todo has a due date */
bool hasDueDate() const;
/** sets the event's hasDueDate value. */
void setHasDueDate(bool f);