[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    [Kde-pim] [PATCH] Server-based resources and editing events
From:       "Best, Jan-Pascal van" <j.p.vanbest () tbm ! tudelft ! nl>
Date:       2003-12-11 16:55:04
[Download RAW message or body]

Hi again,

> > It would mean changing the signature of 
> > ResourceCalendar::save() to add an
> > (optional) QPtrList<KCal::Incidence> parameter. Resource 
> > implementations based
> > on files (local or remote) can ignore this parameter and just 
> > save the whole lot,
> > but ldap/database/exchange resources can just save the 
> > modified incidences.

I realised that would be a bit awkward: For new events, the event is 
added to the calendar by the koEventEditor by a mCalendar->addEvent()
call. I'd think changed events should be notified to the
calendar in same way. Attached patch adds a method eventChanged() 
to KCal::Calendar, which is implemented in CalendarResources by
notifying the appropriate resource. ResourceCalendar also gets an
eventChanged() method. The Exchange resource implements this by writing
the modified event back to the server, which works wonderfully.

What do you think of this?

Jan-Pascal

["eventChanged.patch" (application/octet-stream)]

Index: korganizer/koeventeditor.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koeventeditor.cpp,v
retrieving revision 1.63
diff -u -3 -p -r1.63 koeventeditor.cpp
--- korganizer/koeventeditor.cpp	27 Oct 2003 13:45:17 -0000	1.63
+++ korganizer/koeventeditor.cpp	11 Dec 2003 16:50:38 -0000
@@ -237,10 +237,11 @@ bool KOEventEditor::processInput()
     Event *oldEvent = mEvent->clone();
     writeEvent( event );
 
-    if( *mEvent == *event )
+    if( *mEvent == *event ) {
       // Don't do anything
       kdDebug(5850) << "Event not changed\n";
-    else {
+      emit editCanceled( mEvent );
+    } else {
       kdDebug(5850) << "Event changed\n";
       int revision = event->revision();
       event->setRevision( revision + 1 );
@@ -250,6 +251,7 @@ bool KOEventEditor::processInput()
 	// Accept the event changes
 	writeEvent( mEvent );
 	mEvent->setRevision( revision + 1 );
+        mCalendar->eventChanged( mEvent );
 	emit eventChanged( oldEvent, mEvent );
       } else {
 	// Revert the changes
Index: libkcal/calendar.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/calendar.cpp,v
retrieving revision 1.45
diff -u -3 -p -r1.45 calendar.cpp
--- libkcal/calendar.cpp	20 Nov 2003 07:14:15 -0000	1.45
+++ libkcal/calendar.cpp	11 Dec 2003 16:50:38 -0000
@@ -187,6 +187,12 @@ Incidence::List Calendar::rawIncidences(
   return mergeIncidenceList( rawEvents(), rawTodos(), journals() );
 }
 
+void Calendar::eventChanged( Event *event )
+{
+  setModified( true );
+}
+
+
 Event::List Calendar::events( const QDate &date, bool sorted )
 {
   Event::List el = rawEventsForDate( date, sorted );
Index: libkcal/calendar.h
===================================================================
RCS file: /home/kde/kdepim/libkcal/calendar.h,v
retrieving revision 1.46
diff -u -3 -p -r1.46 calendar.h
--- libkcal/calendar.h	24 Oct 2003 23:48:41 -0000	1.46
+++ libkcal/calendar.h	11 Dec 2003 16:50:39 -0000
@@ -146,6 +146,10 @@ class Calendar : public QObject, public 
       Delete event from calendar.
     */
     virtual void deleteEvent( Event * ) = 0;
+    /** 
+      Notify the calendar that an event has been changed 
+    */
+    virtual void eventChanged(Event *);
     /**
       Retrieves an event on the basis of the unique string ID.
     */
Index: libkcal/calendarresources.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/calendarresources.cpp,v
retrieving revision 1.35
diff -u -3 -p -r1.35 calendarresources.cpp
--- libkcal/calendarresources.cpp	9 Nov 2003 23:23:26 -0000	1.35
+++ libkcal/calendarresources.cpp	11 Dec 2003 16:50:39 -0000
@@ -234,6 +234,18 @@ void CalendarResources::deleteEvent(Even
   setModified( true );
 }
 
+void CalendarResources::eventChanged(Event * event)
+{
+  kdDebug(5800) << "CalendarResources::eventChanged" << endl;
+
+  if ( mResourceMap.find(event)!=mResourceMap.end() ) {
+    mResourceMap[event]->eventChanged( event );
+  } else {
+    kdDebug(5800) << "CalendarResources::eventChanged: Error: No resource found for event" << endl;
+  }
+
+  setModified( true );
+}
 
 Event *CalendarResources::event( const QString &uid )
 {
Index: libkcal/calendarresources.h
===================================================================
RCS file: /home/kde/kdepim/libkcal/calendarresources.h,v
retrieving revision 1.26
diff -u -3 -p -r1.26 calendarresources.h
--- libkcal/calendarresources.h	9 Nov 2003 23:23:26 -0000	1.26
+++ libkcal/calendarresources.h	11 Dec 2003 16:50:39 -0000
@@ -145,6 +145,8 @@ class CalendarResources : public Calenda
     bool addEvent(Event *anEvent, ResourceCalendar *resource);
     /** deletes an event from this calendar. */
     void deleteEvent(Event *);
+    /** Notify the calendar that an event has been changed */
+    void eventChanged(Event *);
 
     /**
       Retrieves an event on the basis of the unique string ID.
Index: libkcal/resourcecalendar.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/resourcecalendar.cpp,v
retrieving revision 1.9
diff -u -3 -p -r1.9 resourcecalendar.cpp
--- libkcal/resourcecalendar.cpp	22 Jul 2003 18:56:46 -0000	1.9
+++ libkcal/resourcecalendar.cpp	11 Dec 2003 16:50:39 -0000
@@ -45,6 +45,11 @@ void ResourceCalendar::writeConfig( KCon
   KRES::Resource::writeConfig( config );
 }
 
+void ResourceCalendar::eventChanged( Event * ) 
+{
+   return;
+}
+
 bool ResourceCalendar::addIncidence( Incidence *incidence )
 {
   Incidence::AddVisitor<ResourceCalendar> v( this );
Index: libkcal/resourcecalendar.h
===================================================================
RCS file: /home/kde/kdepim/libkcal/resourcecalendar.h,v
retrieving revision 1.18
diff -u -3 -p -r1.18 resourcecalendar.h
--- libkcal/resourcecalendar.h	30 Oct 2003 09:44:04 -0000	1.18
+++ libkcal/resourcecalendar.h	11 Dec 2003 16:50:39 -0000
@@ -73,7 +73,7 @@ class ResourceCalendar : public KRES::Re
     virtual bool load() = 0;
 
     /**
-      Save resource data. After calling this function it is save to close the
+      Save resource data. After calling this function it is safe to close the
       resource without losing data.
       
       If data is actually saved within this function or saving is delayed
@@ -97,6 +97,9 @@ class ResourceCalendar : public KRES::Re
     /** deletes an event from this calendar. */
     virtual void deleteEvent(Event *) = 0;
 
+    /** notify resource that an event has been modified. */
+    virtual void eventChanged(Event *);
+
     /** deletes a journal from this calendar. */
     virtual void deleteJournal(Journal *) = 0;
 


_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic