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

List:       kde-commits
Subject:    kdepim/libkcal
From:       Reinhold Kainhofer <reinhold () kainhofer ! com>
Date:       2004-09-14 19:59:48
Message-ID: 20040914195948.ECB911C67 () office ! kde ! org
[Download RAW message or body]

CVS commit by kainhofe: 

Move the incidenceUpdated method to the Calendar class. Also save the calendar only \
if it was really changed, or saved to a different file name.


  M +12 -16    calendarlocal.cpp   1.64
  M +1 -3      calendarlocal.h   1.39


--- kdepim/libkcal/calendarlocal.h  #1.38:1.39
@@ -182,7 +182,4 @@ class CalendarLocal : public Calendar
   protected:
 
-    /** Notification function of IncidenceBase::Observer. */
-    void incidenceUpdated( IncidenceBase *i );
-
     /** inserts an event into its "proper place" in the calendar. */
     void insertEvent( Event *event );
@@ -206,4 +203,5 @@ class CalendarLocal : public Calendar
 
     Incidence::List mDeletedIncidences;
+                QString mFileName;
 
     class Private;

--- kdepim/libkcal/calendarlocal.cpp  #1.63:1.64
@@ -54,4 +54,5 @@ void CalendarLocal::init()
 {
   mDeletedIncidences.setAutoDelete( true );
+        mFileName = QString::null;
 }
 
@@ -64,4 +65,5 @@ CalendarLocal::~CalendarLocal()
 bool CalendarLocal::load( const QString &fileName )
 {
+        mFileName = fileName;
   FileStorage storage( this, fileName );
   return storage.load();
@@ -70,6 +72,13 @@ bool CalendarLocal::load( const QString 
 bool CalendarLocal::save( const QString &fileName, CalFormat *format )
 {
+        // 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 );
   return storage.save();
+        } else {
+                return true;
+        }
 }
 
@@ -77,4 +86,5 @@ void CalendarLocal::close()
 {
   setObserversEnabled( false );
+        mFileName = QString::null;
 
   deleteAllEvents();
@@ -329,18 +339,4 @@ void CalendarLocal::appendRecurringAlarm
 
 
-void CalendarLocal::incidenceUpdated( IncidenceBase *incidence )
-{
-  incidence->setSyncStatus( Event::SYNCMOD );
-  incidence->setLastModified( QDateTime::currentDateTime() );
-  // we should probably update the revision number here,
-  // or internally in the Event itself when certain things change.
-  // need to verify with ical documentation.
-
-  // The static_cast is ok as the CalendarLocal only observes Incidence objects
-  notifyIncidenceChanged( static_cast<Incidence *>( incidence ) );
-
-  setModified( true );
-}
-
 void CalendarLocal::insertEvent( Event *event )
 {


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

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