summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/incidence.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 762103f..f446197 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -191,97 +191,97 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
if ( i1.hasRecurrenceID() ) {
if ( i1.recurrenceID() != i2.recurrenceID() )
return false;
}
} else {
return false;
}
if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
return false;
if ( i1.hasStartDate() == i2.hasStartDate() ) {
if ( i1.hasStartDate() ) {
if ( i1.dtStart() != i2.dtStart() )
return false;
}
} else {
return false;
}
if (!( *i1.recurrence() == *i2.recurrence()) ) {
qDebug("recurrence is NOT equal ");
return false;
}
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( ":" );
setLastModified(QDateTime::currentDateTime());
}
void Incidence::cloneRelations( Incidence * newInc )
{
// newInc is already a clone of this incidence
Incidence * inc;
Incidence * cloneInc;
QPtrList<Incidence> Relations = relations();
for (inc=Relations.first();inc;inc=Relations.next()) {
cloneInc = inc->clone();
cloneInc->recreate();
cloneInc->setRelatedTo( newInc );
inc->cloneRelations( cloneInc );
}
}
void Incidence::setReadOnly( bool readOnly )
{
IncidenceBase::setReadOnly( readOnly );
recurrence()->setRecurReadOnly( readOnly);
}
void Incidence::setCreated(QDateTime created)
{
if (mReadOnly) return;
@@ -679,66 +679,66 @@ void Incidence::setLocation(const QString &location)
mLocation = location;
updated();
}
QString Incidence::location() const
{
return mLocation;
}
ushort Incidence::doesRecur() const
{
if ( mRecurrence ) return mRecurrence->doesRecur();
else return Recurrence::rNone;
}
QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
{
QDateTime incidenceStart = dt;
*ok = false;
if ( doesRecur() ) {
bool last;
recurrence()->getPreviousDateTime( incidenceStart , &last );
int count = 0;
if ( !last ) {
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;
}