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

List:       kde-pim
Subject:    [Kde-pim] [PATCH] KCal::CalendarResources refactoring
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2003-11-27 14:44:17
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

the attached patch factors out the readConfig() and load() method from
KCal::CalendarResources, so the following code

 CalendarResources *calendar = new CalendarResources();

has to be written as

 CalendarResources *calendar = new CalendarResources();
 calendar->readConfig();
 calendar->load();

now to get the same results.
This refactoring is neccassary to get code like the following working:

 CalendarResources *calendar = new CalendarResources();
 ResourcesLocal *res = new ResourceLocal( "/home/user/events.ics" );
 calendar->resourceManager()->add( res );

 calendar->load();

With the old implementation the 'standard' calendars would also be
loaded and the new resource was written back to the config file (see
other kresources patch), now only the dates from events.ics are loaded
and stored. This behaviour is needed to get KNotes(Part/Summary) working
with locking and change notifications.

The patch also includes the neccessary changes in the whole kdepim
sources.

Ok for commit?

Ciao,
Tobias
-- 
Can a government that shoots at reporters be democratic?
Separate politics from religion and economy!

["calendarresources_with_kdepim_fixes.patch" (text/plain)]

Index: konsolekalendar/main.cpp
===================================================================
RCS file: /home/kde/kdepim/konsolekalendar/main.cpp,v
retrieving revision 1.48
diff -p -u -b -r1.48 main.cpp
--- konsolekalendar/main.cpp	26 Nov 2003 09:21:50 -0000	1.48
+++ konsolekalendar/main.cpp	27 Nov 2003 14:33:07 -0000
@@ -494,6 +494,8 @@ int main(int argc, char *argv[])
   variables.setCalendar( localCalendar  );   
  } else {
   calendarResource = new CalendarResources();	 
+  calendarResource->readConfig();
+  calendarResource->load();
   variables.setCalendarResources( calendarResource );	 
  }
 
Index: korganizer/kocore.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/kocore.cpp,v
retrieving revision 1.29
diff -p -u -b -r1.29 kocore.cpp
--- korganizer/kocore.cpp	25 Nov 2003 21:35:39 -0000	1.29
+++ korganizer/kocore.cpp	27 Nov 2003 14:33:08 -0000
@@ -311,6 +311,8 @@ KCal::CalendarResources *KOCore::calenda
 {
   if ( !mCalendarResources ) {
     mCalendarResources = new KCal::CalendarResources( KOPrefs::instance()->mTimeZoneId );
+    mCalendarResources->readConfig();
+    mCalendarResources->load();
 
     KCal::CalendarResourceManager *manager = mCalendarResources->resourceManager();
 
Index: korganizer/korgac/koalarmclient.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/korgac/koalarmclient.cpp,v
retrieving revision 1.15
diff -p -u -b -r1.15 koalarmclient.cpp
--- korganizer/korgac/koalarmclient.cpp	16 Nov 2003 19:28:40 -0000	1.15
+++ korganizer/korgac/koalarmclient.cpp	27 Nov 2003 14:33:08 -0000
@@ -53,6 +53,8 @@ KOAlarmClient::KOAlarmClient( QObject *p
            SLOT( suspend( int ) ) );
 
   mCalendar = new CalendarResources();
+  mCalendar->readConfig();
+  mCalendar->load();
 
   KConfig c( locate( "config", "korganizerrc" ) );
   c.setGroup( "Time & Date" );
Index: kpilot/conduits/vcalconduit/vcal-conduitbase.cc
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/vcal-conduitbase.cc,v
retrieving revision 1.48
diff -p -u -b -r1.48 vcal-conduitbase.cc
--- kpilot/conduits/vcalconduit/vcal-conduitbase.cc	19 Oct 2003 20:38:58 -0000	1.48
+++ kpilot/conduits/vcalconduit/vcal-conduitbase.cc	27 Nov 2003 14:33:10 -0000
@@ -318,6 +318,8 @@ error:
 					"object for ResourceCalendar"<<endl;
 				return false;
 			}
+      fCalendar->readConfig();
+      fCalendar->load();
 			break;
 		default:
 			break;
Index: libkcal/calendarresources.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/calendarresources.cpp,v
retrieving revision 1.35
diff -p -u -b -r1.35 calendarresources.cpp
--- libkcal/calendarresources.cpp	9 Nov 2003 23:23:26 -0000	1.35
+++ libkcal/calendarresources.cpp	27 Nov 2003 14:33:11 -0000
@@ -85,9 +85,29 @@ void CalendarResources::init()
   kdDebug(5800) << "CalendarResources::init" << endl;
 
   mManager = new CalendarResourceManager( "calendar" );
-  mManager->readConfig( 0 );
   mManager->addObserver( this );
 
+  mStandardPolicy = new StandardDestinationPolicy( mManager );
+  mAskPolicy = new AskDestinationPolicy( mManager );
+  mDestinationPolicy = mStandardPolicy;
+}
+
+CalendarResources::~CalendarResources()
+{
+  kdDebug(5800) << "CalendarResources::destructor" << endl;
+
+  close();
+
+  delete mManager;
+}
+
+void CalendarResources::readConfig( KConfig *config )
+{
+  mManager->readConfig( config );
+}
+
+void CalendarResources::load()
+{
   if ( !mManager->standardResource() ) {
     kdDebug(5800) << "Warning! No standard resource yet." << endl;
   }
@@ -108,23 +128,9 @@ void CalendarResources::init()
     connectResource( *it );
   }
 
-  mStandardPolicy = new StandardDestinationPolicy( mManager );
-  mAskPolicy = new AskDestinationPolicy( mManager );
-  mDestinationPolicy = mStandardPolicy;
-
   mOpen = true;
 }
 
-
-CalendarResources::~CalendarResources()
-{
-  kdDebug(5800) << "CalendarResources::destructor" << endl;
-
-  close();
-
-  delete mManager;
-}
-
 void CalendarResources::setStandardDestinationPolicy()
 {
   mDestinationPolicy = mStandardPolicy;
Index: libkcal/calendarresources.h
===================================================================
RCS file: /home/kde/kdepim/libkcal/calendarresources.h,v
retrieving revision 1.26
diff -p -u -b -r1.26 calendarresources.h
--- libkcal/calendarresources.h	9 Nov 2003 23:23:26 -0000	1.26
+++ libkcal/calendarresources.h	27 Nov 2003 14:33:11 -0000
@@ -99,6 +99,22 @@ class CalendarResources : public Calenda
     ~CalendarResources();
 
     /**
+      Read the resources settings from a config file. You have to call this
+      method before load().
+
+      @param config The KConfig object which points to the config file.
+                    If no object is given (null pointer) the standard config
+                    file is used.
+     */
+    void readConfig( KConfig *config = 0 );
+
+    /**
+      Loads all events from the resources. You have to add the resources first
+      or call readConfig() to load the system resources.
+     */
+    void load();
+
+    /**
       Return ResourceManager used by this calendar.
     */
     CalendarResourceManager *resourceManager() const

["signature.asc" (application/pgp-signature)]

_______________________________________________
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