summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp31
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkcal/journal.cpp4
3 files changed, 24 insertions, 12 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 5baa7dc..e8c969f 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -259,25 +259,38 @@ void CalendarLocal::close()
mJournalList.setAutoDelete( true );
mEventList.clear();
mTodoList.clear();
mJournalList.clear();
mEventList.setAutoDelete( false );
mTodoList.setAutoDelete( false );
mJournalList.setAutoDelete( false );
setModified( false );
}
-
+ void CalendarLocal::clearUndo()
+{
+ if ( mUndoIncidence ) {
+ if ( mUndoIncidence->typeID() == eventID )
+ delete ((Event*) mUndoIncidence) ;
+ else if ( mUndoIncidence->typeID() == todoID )
+ delete ( (Todo*) mUndoIncidence );
+ else if ( mUndoIncidence->typeID() == journalID )
+ delete ( (Journal*) mUndoIncidence );
+ else
+ delete mUndoIncidence;
+ }
+ mUndoIncidence = 0;
+}
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! ");
@@ -318,26 +331,26 @@ bool CalendarLocal::addEvent( Event *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();
+ clearUndo();
+ mUndoIncidence = event;
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 ) {
@@ -373,27 +386,27 @@ bool CalendarLocal::addTodo( Todo *todo )
setupRelations( todo );
setModified( true );
if ( todo->calID() == 0 )
todo->setCalID( mDefaultCalendar );
todo->setCalEnabled( true );
return true;
}
void CalendarLocal::deleteTodo( Todo *todo )
{
// Handle orphaned children
- if ( mUndoIncidence ) delete mUndoIncidence;
+ clearUndo();
removeRelations( todo );
- mUndoIncidence = todo->clone();
+ mUndoIncidence = todo;
if ( mTodoList.removeRef( todo ) ) {
setModified( true );
}
}
QPtrList<Todo> CalendarLocal::rawTodos()
{
QPtrList<Todo> el;
for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
if ( it->calEnabled() ) el.append( it );
return el;
@@ -877,27 +890,26 @@ bool CalendarLocal::addJournal(Journal *journal)
journal->registerObserver( this );
setModified( true );
if ( journal->calID() == 0 )
journal->setCalID( mDefaultCalendar );
journal->setCalEnabled( true );
return true;
}
void CalendarLocal::deleteJournal( Journal *journal )
{
- if ( mUndoIncidence ) delete mUndoIncidence;
- mUndoIncidence = journal->clone();
- mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
+ clearUndo();
+ mUndoIncidence = journal;
if ( mJournalList.removeRef(journal) ) {
setModified( true );
}
}
QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
{
QPtrList<Journal> el;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calEnabled() && it->dtStart().date() == date) el.append( it );
return el;
}
@@ -958,26 +970,25 @@ void CalendarLocal::setCalendarRemove( int id )
}
}
{
QPtrList<Journal> JournalList = mJournalList;
Journal * ev = JournalList.first();
while ( ev ) {
if ( ev->calID() == id )
deleteJournal( ev );
ev = JournalList.next();
}
}
- if ( mUndoIncidence ) delete mUndoIncidence;
- mUndoIncidence = 0;
+ clearUndo();
}
void CalendarLocal::setCalendarEnabled( int id, bool enable )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calID() == id ) it->setCalEnabled( enable );
for ( Event *it = mEventList.first(); it; it = mEventList.next() )
if ( it->calID() == id ) it->setCalEnabled( enable );
for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index a7a85c8..ae7e30c 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -60,24 +60,25 @@ class CalendarLocal : public Calendar
/**
Writes out the calendar to disk in the specified \a format.
CalendarLocal takes ownership of the CalFormat object.
@return true, if successfull, false on error.
@param fileName the name of the file
*/
bool save( const QString &fileName, CalFormat *format = 0 );
/**
Clears out the current calendar, freeing all used memory etc. etc.
*/
void close();
+ void clearUndo();
void save() {}
/**
Add Event to calendar.
*/
void removeSyncInfo( QString syncProfile);
bool addAnniversaryNoDup( Event *event );
bool addEventNoDup( Event *event );
bool addEvent( Event *event );
/**
Deletes an event from this calendar.
diff --git a/libkcal/journal.cpp b/libkcal/journal.cpp
index c4e4474..328db46 100644
--- a/libkcal/journal.cpp
+++ b/libkcal/journal.cpp
@@ -15,30 +15,30 @@
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 );
}