| Summary: | Data is saved after korganizer exit even without any changes | ||
|---|---|---|---|
| Product: | [Applications] korganizer | Reporter: | temp1.neufrank |
| Component: | general | Assignee: | Cornelius Schumacher <schumacher> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 3.2.1 | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
temp1.neufrank
2004-08-02 00:30:26 UTC
CVS commit by kainhofe: Properly add Observers to CalendarResources. This also makes it possible to watch changes of all incidences, and so only save the calendar if it was changed at all. CCMAIL: 86401-done@bugs.kde.org M +9 -10 calendarlocal.cpp 1.65 M +19 -7 calendarresources.cpp 1.51 M +0 -6 calendarresources.h 1.39 M +0 -2 resourcelocal.cpp 1.30 --- kdepim/libkcal/calendarlocal.cpp #1.64:1.65 @@ -74,5 +74,4 @@ bool CalendarLocal::save( const QString // Save only if the calendar is either modified, or saved to a // different file than it was loaded from -kdDebug()<<"CalendarLocal::save(), fileName="<<fileName<<", mFileName="<<mFileName<<", isModified="<<isModified()<<endl; if ( mFileName != fileName || isModified() ) { FileStorage storage( this, fileName, format ); --- kdepim/libkcal/calendarresources.cpp #1.50:1.51 @@ -131,4 +131,10 @@ void CalendarResources::load() for ( it = mManager->activeBegin(); it != mManager->activeEnd(); ++it ) { (*it)->load(); + Incidence::List incidences = (*it)->rawIncidences(); + Incidence::List::Iterator incit; + for ( incit = incidences.begin(); incit != incidences.end(); ++incit ) { + (*incit)->registerObserver( this ); + notifyIncidenceAdded( *incit ); + } } @@ -165,5 +171,5 @@ void CalendarResources::save() kdDebug(5800) << "CalendarResources::save()" << endl; - if ( mOpen ) { + if ( mOpen && isModified() ) { CalendarResourceManager::ActiveIterator it; for ( it = mManager->activeBegin(); it != mManager->activeEnd(); ++it ) { @@ -189,5 +195,5 @@ bool CalendarResources::isSaving() bool CalendarResources::addIncidence( Incidence *incidence ) { - kdDebug(5800) << "CalendarResources::addIncidence" << endl; + kdDebug(5800) << "CalendarResources::addIncidence" << this << endl; ResourceCalendar *resource = mDestinationPolicy->destination( incidence ); @@ -195,4 +201,8 @@ bool CalendarResources::addIncidence( In if ( resource ) { if ( resource->addIncidence( incidence ) ) { + incidence->registerObserver( this ); + notifyIncidenceAdded( incidence ); + + mResourceMap[ incidence ] = resource; setModified( true ); @@ -219,4 +229,6 @@ bool CalendarResources::addEvent( Event if ( validRes && resource->addEvent( anEvent ) ) { mResourceMap[anEvent] = resource; + anEvent->registerObserver( this ); + notifyIncidenceAdded( anEvent ); setModified( true ); return true; @@ -278,4 +290,6 @@ bool CalendarResources::addTodo(Todo *to if ( validRes && resource->addTodo( todo ) ) { mResourceMap[todo] = resource; + todo->registerObserver( this ); + notifyIncidenceAdded( todo ); setModified( true ); return true; @@ -518,4 +532,6 @@ bool CalendarResources::addJournal(Journ if ( validRes && resource->addJournal( journal ) ) { mResourceMap[journal] = resource; + journal->registerObserver( this ); + notifyIncidenceAdded( journal ); setModified( true ); return true; @@ -588,9 +604,4 @@ Journal::List CalendarResources::journal -void CalendarResources::incidenceUpdated( IncidenceBase * ) -{ - kdDebug(5800) << "CalendarResources::incidenceUpdated( IncidenceBase * ): Not yet implemented\n"; -} - void CalendarResources::connectResource( ResourceCalendar *resource ) { @@ -673,4 +684,5 @@ bool CalendarResources::save( Ticket *ti kdDebug(5800) << "tick " << ticket->resource()->resourceName() << endl; + // @TODO: Check if the resource was changed at all. If not, don't save. if ( ticket->resource()->save() ) { releaseSaveTicket( ticket ); --- kdepim/libkcal/calendarresources.h #1.38:1.39 @@ -250,10 +250,4 @@ class CalendarResources : public Calenda void signalErrorMessage( const QString & ); - protected: - /** - The observer interface. So far not implemented. - */ - void incidenceUpdated( IncidenceBase * ); - public: /** --- kdepim/libkcal/resourcelocal.cpp #1.29:1.30 @@ -159,7 +159,5 @@ bool ResourceLocal::doLoad() bool ResourceLocal::doSave() { -kdDebug()<<"ResourceLoadl::doSave"<<endl; bool success = mCalendar.save( mURL.path() ); -kdDebug()<<"ResourceLocal::doSave, success="<<success<<endl; d->mLastModified = readLastModified(); |