libkcal

calendar.h
Go to the documentation of this file.
1 /*
2  This file is part of libkcal.
3 
4  Copyright (c) 1998 Preston Brown <pbrown@kde.org>
5  Copyright (c) 2001,2003,2004 Cornelius Schumacher <schumacher@kde.org>
6  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
31 #ifndef KCAL_CALENDAR_H
32 #define KCAL_CALENDAR_H
33 
34 #include "exceptions.h"
35 #include "customproperties.h"
36 #include "event.h"
37 #include "todo.h"
38 #include "journal.h"
39 #include "kcalversion.h"
40 #include "person.h"
41 
42 #include <tdemacros.h>
43 
44 #include <tqobject.h>
45 #include <tqstring.h>
46 #include <tqdatetime.h>
47 #include <tqptrlist.h>
48 #include <tqdict.h>
49 
54 namespace KCal {
55 
56 class CalFilter;
57 
63 {
68 };
69 
75 {
84 };
85 
91 {
104 };
105 
111 {
118 };
119 
169 class LIBKCAL_EXPORT Calendar : public TQObject, public CustomProperties,
170  public IncidenceBase::Observer
171 {
172  TQ_OBJECT
173 
174 
175  public:
176 
191  Calendar( const TQString &timeZoneId );
192 
196  virtual ~Calendar();
197 
203  void setProductId( const TQString &productId );
204 
210  TQString productId();
211 
215  void clearException();
216 
221  ErrorFormat *exception() const;
222 
228  void setOwner( const Person &owner );
229 
235  const Person &getOwner() const;
236 
251  void setTimeZoneId( const TQString &timeZoneId );
252 
259  virtual void setTimeZoneIdViewOnly( const TQString &timeZoneId ) = 0;
260 
266  TQString timeZoneId() const;
267 
271  void setLocalTime();
272 
279  bool isLocalTime() const;
280 
287  void setModified( bool modified );
288 
294  bool isModified() const { return mModified; }
295 
299  virtual void close() = 0;
300 
304  virtual void closeEvents() = 0;
305 
309  virtual void closeTodos() = 0;
310 
314  virtual void closeJournals() = 0;
315 
319  virtual void save() = 0;
320 
326  virtual bool reload( const TQString &tz ) = 0;
327 
333  virtual bool isSaving() { return false; }
334 
340  TQStringList categories();
341 
342 // Incidence Specific Methods //
343 
351  virtual bool addIncidence( Incidence *incidence );
352 
360  virtual bool deleteIncidence( Incidence *incidence );
361 
367  virtual Incidence::List incidences();
368 
376  virtual Incidence::List incidences( const TQDate &date );
377 
383  virtual Incidence::List rawIncidences();
384 
393  Incidence *incidence( const TQString &uid );
394 
403  Incidence *incidenceFromSchedulingID( const TQString &sid );
404 
409  Incidence::List incidencesFromSchedulingID( const TQString &UID );
410 
420  static Incidence::List mergeIncidenceList( const Event::List &events,
421  const Todo::List &todos,
422  const Journal::List &journals );
423 
429  virtual bool beginChange( Incidence *incidence );
430 
436  virtual bool endChange( Incidence *incidence );
437 
454  Incidence *dissociateOccurrence( Incidence *incidence, TQDate date,
455  bool single = true );
456 
457 // Event Specific Methods //
458 
466  virtual bool addEvent( Event *event ) = 0;
467 
475  virtual bool deleteEvent( Event *event ) = 0;
476 
486  static Event::List sortEvents( Event::List *eventList,
487  EventSortField sortField,
488  SortDirection sortDirection );
489 
500  static Event::List sortEventsForDate( Event::List *eventList,
501  const TQDate &date,
502  EventSortField sortField,
503  SortDirection sortDirection );
504 
513  virtual Event::List events(
514  EventSortField sortField = EventSortUnsorted,
515  SortDirection sortDirection = SortDirectionAscending );
516 
524  Event::List events( const TQDateTime &qdt );
525 
537  Event::List events( const TQDate &start, const TQDate &end,
538  bool inclusive = false);
539 
551  Event::List events(
552  const TQDate &date,
553  EventSortField sortField = EventSortUnsorted,
554  SortDirection sortDirection = SortDirectionAscending );
555 
565  EventSortField sortField = EventSortUnsorted,
566  SortDirection sortDirection = SortDirectionAscending ) = 0;
567 
577  virtual Event::List rawEventsForDate( const TQDateTime &qdt ) = 0;
578 
590  virtual Event::List rawEvents( const TQDate &start, const TQDate &end,
591  bool inclusive = false ) = 0;
592 
605  const TQDate &date,
606  EventSortField sortField = EventSortUnsorted,
607  SortDirection sortDirection = SortDirectionAscending ) = 0;
608 
617  virtual Event *event( const TQString &uid ) = 0;
618 
619 // Todo Specific Methods //
620 
628  virtual bool addTodo( Todo *todo ) = 0;
629 
637  virtual bool deleteTodo( Todo *todo ) = 0;
638 
648  static Todo::List sortTodos( Todo::List *todoList,
649  TodoSortField sortField,
650  SortDirection sortDirection );
651 
660  virtual Todo::List todos(
661  TodoSortField sortField = TodoSortUnsorted,
662  SortDirection sortDirection = SortDirectionAscending );
663 
671  virtual Todo::List todos( const TQDate &date );
672 
682  TodoSortField sortField = TodoSortUnsorted,
683  SortDirection sortDirection = SortDirectionAscending ) = 0;
684 
692  virtual Todo::List rawTodosForDate( const TQDate &date ) = 0;
693 
702  virtual Todo *todo( const TQString &uid ) = 0;
703 
704 // Journal Specific Methods //
705 
713  virtual bool addJournal( Journal *journal ) = 0;
714 
722  virtual bool deleteJournal( Journal *journal ) = 0;
723 
733  static Journal::List sortJournals( Journal::List *journalList,
734  JournalSortField sortField,
735  SortDirection sortDirection );
744  virtual Journal::List journals(
746  SortDirection sortDirection = SortDirectionAscending );
747 
755  virtual Journal::List journals( const TQDate &date );
756 
767  SortDirection sortDirection = SortDirectionAscending ) = 0;
768 
776  virtual Journal::List rawJournalsForDate( const TQDate &date ) = 0;
777 
786  virtual Journal *journal( const TQString &uid ) = 0;
787 
800  void beginBatchAdding();
801 
810  void endBatchAdding();
811 
812 // Relations Specific Methods //
813 
820  virtual void setupRelations( Incidence *incidence );
821 
828  virtual void removeRelations( Incidence *incidence );
829 
830 // Filter Specific Methods //
831 
838  void setFilter( CalFilter *filter );
839 
846  CalFilter *filter();
847 
848 // Alarm Specific Methods //
849 
858  virtual Alarm::List alarms( const TQDateTime &from,
859  const TQDateTime &to ) = 0;
860 
861 // Observer Specific Methods //
862 
868  class Observer
869  {
870  public:
871  virtual ~Observer() {}
879  virtual void calendarModified( bool /*modified*/,
880  Calendar * /*calendar*/ ) {};
881 
887  virtual void calendarIncidenceAdded( Incidence * /*incidence*/ ) {}
888 
894  virtual void calendarIncidenceChanged( Incidence * /*incidence*/ ) {}
895 
901  virtual void calendarIncidenceDeleted( Incidence * /*incidence*/ ) {}
902  };
903 
910  void registerObserver( Observer *observer );
911 
918  void unregisterObserver( Observer *observer );
919 
920  signals:
925 
930 
935 
941 
947 
948  protected:
953  void setException( ErrorFormat *e );
954 
960  void incidenceUpdated( IncidenceBase *incidenceBase );
961 
974  virtual void doSetTimeZoneId( const TQString &/*timeZoneId*/ ) {}
975 
981  void notifyIncidenceAdded( Incidence *incidence );
982 
988  void notifyIncidenceChanged( Incidence *incidence );
989 
995  void notifyIncidenceDeleted( Incidence *incidence );
996 
1001  virtual void customPropertyUpdated();
1002 
1009  void setObserversEnabled( bool enabled );
1010 
1011  //TODO: Move appendAlarms() and appendRecurringAlarms() from
1012  // calendarlocal here, as protected static methods
1013  // returning static Alarm::List
1014 
1015  private:
1016 
1020  void init();
1021 
1022  TQString mProductId;
1023  Person mOwner;
1024  TQString mTimeZoneId;
1025  bool mLocalTime;
1026 
1027  bool mModified;
1028 
1029  CalFilter *mFilter;
1030  CalFilter *mDefaultFilter;
1031 
1032  TQPtrList<Observer> mObservers;
1033  bool mNewObserver;
1034  bool mObserversEnabled;
1035 
1036  // This list is used to put together related Todos
1037  TQDict<Incidence> mOrphans;
1038  TQDict<Incidence> mOrphanUids;
1039 
1040  ErrorFormat *mException;
1041  class Private;
1042  Private *d;
1043  };
1044 
1045 }
1046 
1047 #endif
Filter for calendar objects.
Definition: calfilter.h:39
The Observer class.
Definition: calendar.h:869
virtual void calendarIncidenceAdded(Incidence *)
Notify the Observer that an Incidence has been inserted.
Definition: calendar.h:887
virtual void calendarIncidenceDeleted(Incidence *)
Notify the Observer that an Incidence has been removed.
Definition: calendar.h:901
virtual void calendarModified(bool, Calendar *)
Notify the Observer that a Calendar has been modified.
Definition: calendar.h:879
virtual void calendarIncidenceChanged(Incidence *)
Notify the Observer that an Incidence has been modified.
Definition: calendar.h:894
This is the main "calendar" object class.
Definition: calendar.h:171
void calendarLoaded()
Signal that the Calendar has been loaded into memory.
virtual void setTimeZoneIdViewOnly(const TQString &timeZoneId)=0
Set the timezone used for viewing the incidences in this calendar.
virtual void doSetTimeZoneId(const TQString &)
Let Calendar subclasses set the Time Zone ID.
Definition: calendar.h:974
virtual Journal::List rawJournals(JournalSortField sortField=JournalSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return a sorted, unfiltered list of all Journals for this Calendar.
virtual bool addJournal(Journal *journal)=0
Insert a Journal into the Calendar.
virtual Journal::List rawJournalsForDate(const TQDate &date)=0
Return an unfiltered list of all Journals for on the specifed date.
bool isModified() const
Determine the Calendar's modification status.
Definition: calendar.h:294
virtual Event::List rawEventsForDate(const TQDateTime &qdt)=0
Return an unfiltered list of all Events which occur on the given timestamp.
void calendarSaved()
Signal that the Calendar has been saved.
virtual Todo * todo(const TQString &uid)=0
Returns the Todo associated with the given unique identifier.
virtual Event * event(const TQString &uid)=0
Returns the Event associated with the given unique identifier.
virtual bool addEvent(Event *event)=0
Insert an Event into the Calendar.
virtual Journal * journal(const TQString &uid)=0
Returns the Journal associated with the given unique identifier.
virtual bool addTodo(Todo *todo)=0
Insert a Todo into the Calendar.
virtual void closeTodos()=0
Clears out the current Calendar, freeing all used memory etc.
virtual void closeJournals()=0
Clears out the current Calendar, freeing all used memory etc.
virtual void save()=0
Sync changes in memory to persistant storage.
virtual bool isSaving()
Determine if the Calendar is currently being saved.
Definition: calendar.h:333
virtual Alarm::List alarms(const TQDateTime &from, const TQDateTime &to)=0
Return a list of Alarms within a time range for this Calendar.
virtual bool deleteEvent(Event *event)=0
Remove an Event from the Calendar.
void calendarChanged()
Signal that the Calendar has been modified.
virtual Event::List rawEvents(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return a sorted, unfiltered list of all Events for this Calendar.
virtual bool deleteTodo(Todo *todo)=0
Remove a Todo from the Calendar.
virtual bool deleteJournal(Journal *journal)=0
Remove a Journal from the Calendar.
virtual Event::List rawEvents(const TQDate &start, const TQDate &end, bool inclusive=false)=0
Return an unfiltered list of all Events occurring within a date range.
virtual Todo::List rawTodos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return a sorted, unfiltered list of all Todos for this Calendar.
void batchAddingEnds()
virtual Todo::List rawTodosForDate(const TQDate &date)=0
Return an unfiltered list of all Todos which due on the specified date.
void batchAddingBegins()
virtual void close()=0
Clears out the current Calendar, freeing all used memory etc.
virtual bool reload(const TQString &tz)=0
Load the calendar contents from storage.
virtual void closeEvents()=0
Clears out the current Calendar, freeing all used memory etc.
virtual Event::List rawEventsForDate(const TQDate &date, EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return a sorted, unfiltered list of all Events which occur on the given date.
This class represents custom calendar properties.
Calendar format related error class.
Definition: exceptions.h:65
This class provides an Event in the sense of RFC2445.
Definition: event.h:33
This class provides the base class common to all calendar components.
Definition: incidencebase.h:46
This class provides the base class common to all calendar components.
Definition: incidence.h:48
This class provides a Journal in the sense of RFC2445.
Definition: journal.h:34
This class represents a person.
Definition: person.h:35
This class provides a Todo in the sense of RFC2445.
Definition: todo.h:32
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition: alarm.h:38
TodoSortField
How Todos are to be sorted.
Definition: calendar.h:91
@ TodoSortSummary
Sort Todos alphabetically, by summary.
Definition: calendar.h:103
@ TodoSortDueDate
Sort Todos chronologically, by due date.
Definition: calendar.h:97
@ TodoSortPriority
Sort Todos by priority.
Definition: calendar.h:99
@ TodoSortPercentComplete
Sort Todos by percentage completed.
Definition: calendar.h:101
@ TodoSortStartDate
Sort Todos chronologically, by start date.
Definition: calendar.h:95
@ TodoSortUnsorted
Todos are to be unsorted.
Definition: calendar.h:93
JournalSortField
How Journals are to be sorted.
Definition: calendar.h:111
@ JournalSortUnsorted
Journals are to be unsorted.
Definition: calendar.h:113
@ JournalSortDate
Sort Journals chronologically by date.
Definition: calendar.h:115
@ JournalSortSummary
Sort Journals alphabetically, by summary.
Definition: calendar.h:117
EventSortField
How Events are to be sorted.
Definition: calendar.h:75
@ EventSortUnsorted
Events are to be unsorted.
Definition: calendar.h:77
@ EventSortEndDate
Sort Events chronologically, by end date.
Definition: calendar.h:81
@ EventSortSummary
Sort Events alphabetically, by summary.
Definition: calendar.h:83
@ EventSortStartDate
Sort Events chronologically, by start date.
Definition: calendar.h:79
SortDirection
Sort direction.
Definition: calendar.h:63
@ SortDirectionAscending
Sort in ascending order (first to last)
Definition: calendar.h:65
@ SortDirectionDescending
Sort in descending order (last to first)
Definition: calendar.h:67