summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 3f46d53..12294c0 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -107,145 +107,147 @@ bool CalendarLocal::addAnniversaryNoDup( Event *event )
} 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 );
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;
for ( event = mEventList.first(); event; event = mEventList.next() ) {
if ( event->uid() == uid ) {
return event;
}
}
return 0;
}
bool CalendarLocal::addTodoNoDup( Todo *todo )
{
Todo * eve;
for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
if ( *eve == *todo ) {
//qDebug("duplicate todo found! not inserted! ");
return false;
}
}
return addTodo( todo );
}
bool CalendarLocal::addTodo( Todo *todo )
{
mTodoList.append( todo );
todo->registerObserver( this );
// Set up subtask relations
setupRelations( todo );
setModified( true );
return true;
}
void CalendarLocal::deleteTodo( Todo *todo )
{
// Handle orphaned children
+ if ( mUndoIncidence ) delete mUndoIncidence;
+ mUndoIncidence = todo->clone();
removeRelations( todo );
if ( mTodoList.removeRef( todo ) ) {
setModified( true );
}
}
QPtrList<Todo> CalendarLocal::rawTodos()
{
return mTodoList;
}
Todo *CalendarLocal::todo( QString syncProf, QString id )
{
Todo *todo;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
if ( todo->getID( syncProf ) == id ) return todo;
}
return 0;
}
void CalendarLocal::removeSyncInfo( QString syncProfile)
{
QPtrList<Incidence> all = rawIncidences() ;
Incidence *inc;
for ( inc = all.first(); inc; inc = all.next() ) {
inc->removeID( syncProfile );
}
if ( syncProfile.isEmpty() ) {
QPtrList<Event> el;
Event *todo;
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
el.append( todo );
}
for ( todo = el.first(); todo; todo = el.next() ) {
deleteIncidence ( todo );
}
} else {
Event *lse = event( "last-syncEvent-"+ syncProfile);
deleteIncidence ( lse );
}
}
QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
{
QPtrList<Event> el;
Event *todo;
for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
@@ -642,78 +644,81 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
if ( found ) eventList.append( event );
} else {
QDate s = event->dtStart().date();
QDate e = event->dtEnd().date();
if ( inclusive ) {
if ( s >= start && e <= end ) {
eventList.append( event );
}
} else {
if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) {
eventList.append( event );
}
}
}
}
return eventList;
}
QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
{
return rawEventsForDate( qdt.date() );
}
QPtrList<Event> CalendarLocal::rawEvents()
{
return mEventList;
}
bool CalendarLocal::addJournal(Journal *journal)
{
if ( journal->dtStart().isValid())
kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
else
kdDebug(5800) << "Adding Journal without a DTSTART" << endl;
mJournalList.append(journal);
journal->registerObserver( this );
setModified( true );
return true;
}
void CalendarLocal::deleteJournal( Journal *journal )
{
+ if ( mUndoIncidence ) delete mUndoIncidence;
+ mUndoIncidence = journal->clone();
+ mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
if ( mJournalList.removeRef(journal) ) {
setModified( true );
}
}
Journal *CalendarLocal::journal( const QDate &date )
{
// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->dtStart().date() == date )
return it;
return 0;
}
Journal *CalendarLocal::journal( const QString &uid )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->uid() == uid )
return it;
return 0;
}
QPtrList<Journal> CalendarLocal::journals()
{
return mJournalList;
}