-rw-r--r-- | libkcal/calendar.h | 2 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 11 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 66836a1..f301768 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -48,65 +48,65 @@ namespace KCal { This is an abstract base class defining the interface to a calendar. It is implemented by subclasses like @see CalendarLocal, which use different methods to store and access the data. Ownership of events etc. is handled by the following policy: As soon as an event (or any other subclass of IncidenceBase) object is added to the Calendar by addEvent() it is owned by the Calendar object. The Calendar takes care of deleting it. All Events returned by the query functions are returned as pointers, that means all changes to the returned events are immediately visible in the Calendar. You shouldn't delete any Event object you get from Calendar. */ class Calendar : public QObject, public CustomProperties, public IncidenceBase::Observer { Q_OBJECT public: Calendar(); Calendar(const QString &timeZoneId); virtual ~Calendar(); Incidence * undoIncidence() { return mUndoIncidence; }; bool undoDeleteIncidence(); void deleteIncidence(Incidence *in); void resetTempSyncStat(); void resetPilotStat(int id); /** Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; virtual void addCalendar( Calendar* ) = 0; virtual bool addCalendarFile( QString name, int id ) = 0; virtual bool mergeCalendarFile( QString name ) = 0; - virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; + virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ) = 0; virtual void setSyncEventsReadOnly() = 0; virtual void setSyncEventsEnabled() = 0; virtual void stopAllTodos() = 0; virtual void clearUndo( Incidence * newUndo ); /** Sync changes in memory to persistant storage. */ virtual void save() = 0; virtual QPtrList<Event> getExternLastSyncEvents() = 0; virtual void removeSyncInfo( QString syncProfile) = 0; virtual bool isSaving() { return false; } /** Return the owner of the calendar's full name. */ const QString &getOwner() const; /** Set the owner of the calendar. Should be owner's full name. */ void setOwner( const QString &os ); /** Return the email address of the calendar owner. */ const QString &getEmail(); /** Set the email address of the calendar owner. */ void setEmail( const QString & ); /** Set time zone from a timezone string (e.g. -2:00) diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index b02f706..ad8ace3 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -51,97 +51,106 @@ CalendarLocal::CalendarLocal() init(); } CalendarLocal::CalendarLocal(const QString &timeZoneId) : Calendar(timeZoneId) { init(); } void CalendarLocal::init() { mNextAlarmIncidence = 0; } CalendarLocal::~CalendarLocal() { registerObserver( 0 ); if ( mDeleteIncidencesOnClose ) close(); } bool CalendarLocal::mergeCalendarFile( QString name ) { CalendarLocal calendar( timeZoneId() ); calendar.setDefaultCalendar( 1 ); if ( calendar.load( name ) ) { mergeCalendar( &calendar ); return true; } return false; } -Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) +Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly ) { Todo *todo;; Incidence *retVal = 0; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->uid() == uid ) { + if ( enabledOnly ) + if ( !todo->calEnabled() ) + continue; if ( doNotCheckDuplicates ) return todo; if ( retVal ) { if ( retVal->calID() > todo->calID() ) { retVal = todo; } } else { retVal = todo; } } } if ( retVal ) return retVal; Event *event; for ( event = mEventList.first(); event; event = mEventList.next() ) { if ( event->uid() == uid ) { + if ( enabledOnly ) + if ( !event->calEnabled() ) + continue; if ( doNotCheckDuplicates ) return event; if ( retVal ) { if ( retVal->calID() > event->calID() ) { retVal = event; } } else { retVal = event; } } } if ( retVal ) return retVal; for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->uid() == uid ) { + if ( enabledOnly ) + if ( !it->calEnabled() ) + continue; if ( doNotCheckDuplicates ) return it; if ( retVal ) { if ( retVal->calID() > it->calID() ) { retVal = it; } } else { retVal = it; } } return retVal; } bool CalendarLocal::mergeCalendar( Calendar* remote ) { // 1 look for raw inc in local // if inc not in remote, delete in local // 2 look for raw inc in remote // if inc in local, replace it // if not in local, add it to default calendar QPtrList<Incidence> localInc = rawIncidences(); Incidence* inL = localInc.first(); while ( inL ) { if ( ! inL->isReadOnly () ) if ( !remote->incidenceForUid( inL->uid(), true )) deleteIncidence( inL ); inL = localInc.next(); } QPtrList<Incidence> er = remote->rawIncidences(); Incidence* inR = er.first(); while ( inR ) { inL = incidenceForUid( inR->uid(),false ); if ( inL ) { diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index b70f0c9..b611704 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -18,65 +18,65 @@ 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. */ #ifndef KCAL_CALENDARLOCAL_H #define KCAL_CALENDARLOCAL_H #include "calendar.h" namespace KCal { class CalFormat; /** This class provides a calendar stored as a local file. */ class CalendarLocal : public Calendar { public: /** Constructs a new calendar, with variables initialized to sane values. */ CalendarLocal(); /** Constructs a new calendar, with variables initialized to sane values. */ CalendarLocal( const QString &timeZoneId ); ~CalendarLocal(); void addCalendar( Calendar* ); bool addCalendarFile( QString name, int id ); bool mergeCalendarFile( QString name ); bool mergeCalendar( Calendar* cal ); - Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); + Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false ); void setSyncEventsReadOnly(); void setSyncEventsEnabled(); void stopAllTodos(); /** Loads a calendar on disk in vCalendar or iCalendar format into the current calendar. Any information already present is lost. @return true, if successfull, false on error. @param fileName the name of the calendar on disk. */ bool load( const QString &fileName ); /** 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 save() {} /** Add Event to calendar. */ void removeSyncInfo( QString syncProfile); bool addAnniversaryNoDup( Event *event ); bool addEventNoDup( Event *event ); bool addEvent( Event *event ); |