libkcal

resourcecalendar.h
1 /*
2  This file is part of libkcal.
3 
4  Copyright (c) 1998 Preston Brown <pbrown@kde.org>
5  Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6  Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
7  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Library General Public
11  License as published by the Free Software Foundation; either
12  version 2 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Library General Public License for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with this library; see the file COPYING.LIB. If not, write to
21  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  Boston, MA 02110-1301, USA.
23 */
24 
25 #ifndef KCAL_RESOURCECALENDAR_H
26 #define KCAL_RESOURCECALENDAR_H
27 
28 #include <tqstring.h>
29 #include <tqdatetime.h>
30 #include <tqptrlist.h>
31 
32 #include <tdeconfig.h>
33 
34 #include "alarm.h"
35 #include "todo.h"
36 #include "event.h"
37 #include "journal.h"
38 #include "calendar.h"
39 #include "exceptions.h"
40 
41 #include <tderesources/resource.h>
42 #include <tderesources/manager.h>
43 #include <tdeabc/lock.h>
44 #include <tdemacros.h>
45 
46 namespace KCal {
47 
48 class CalFormat;
49 
57 class LIBKCAL_EXPORT ResourceCalendar : public KRES::Resource
58 {
59  TQ_OBJECT
60 
61  public:
62  ResourceCalendar( const TDEConfig * );
63  virtual ~ResourceCalendar();
64 
68  void clearException();
69 
74  void setException( ErrorFormat *error );
75 
80  ErrorFormat *exception();
81 
82  void setResolveConflict( bool b);
83 
84  virtual void writeConfig( TDEConfig* config );
85 
90  virtual TQString infoText() const;
91 
111  bool load();
112 
130  bool save( Incidence *incidence = 0 );
131 
136  virtual bool isSaving() { return false; }
137 
141  virtual TDEABC::Lock *lock() = 0;
142 
147  virtual TDE_DEPRECATED bool addIncidence( Incidence * );
148 
152  virtual bool addIncidence( Incidence *, const TQString &subresource );
153 
157  virtual bool deleteIncidence( Incidence * );
158 
163  Incidence *incidence( const TQString &uid );
164 
169  virtual TDE_DEPRECATED bool addEvent( Event *event ) = 0;
170  virtual bool addEvent( Event *event, const TQString &subresource ) = 0;
171 
175  virtual bool deleteEvent( Event * ) = 0;
176 
180  virtual Event *event( const TQString &uid ) = 0;
181 
187 
192  virtual Event::List rawEventsForDate( const TQDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
193 
197  virtual Event::List rawEventsForDate( const TQDateTime &qdt ) = 0;
198 
203  virtual Event::List rawEvents( const TQDate &start, const TQDate &end,
204  bool inclusive = false ) = 0;
205 
225  virtual bool setValue( const TQString &key, const TQString &value );
226 
227  signals:
235 
246 
250  void resourceLoadError( ResourceCalendar *, const TQString &error );
254  void resourceSaveError( ResourceCalendar *, const TQString &error );
255 
259  void signalSubresourceAdded( ResourceCalendar *, const TQString& type,
260  const TQString& subresource, const TQString& label );
261 
265  void signalSubresourceRemoved( ResourceCalendar *, const TQString &,
266  const TQString & );
267 
268  public:
273  virtual TDE_DEPRECATED bool addTodo( Todo *todo ) = 0;
274  virtual bool addTodo( Todo *todo, const TQString &subresource ) = 0;
275 
279  virtual bool deleteTodo( Todo * ) = 0;
285  virtual Todo *todo( const TQString &uid ) = 0;
293  virtual Todo::List rawTodosForDate( const TQDate &date ) = 0;
294 
295 
300  virtual TDE_DEPRECATED bool addJournal( Journal * ) = 0;
301  virtual bool addJournal( Journal *journal, const TQString &subresource ) = 0;
302 
306  virtual bool deleteJournal( Journal * ) = 0;
307 
311  virtual Journal *journal( const TQString &uid ) = 0;
319  virtual Journal::List rawJournalsForDate( const TQDate &date ) = 0;
320 
324  virtual Alarm::List alarms( const TQDateTime &from,
325  const TQDateTime &to ) = 0;
326 
330  virtual Alarm::List alarmsTo( const TQDateTime &to ) = 0;
331 
332 
334  Incidence::List rawIncidences();
335 
339  virtual void setTimeZoneId( const TQString &timeZoneId ) = 0;
340 
346  virtual TQStringList subresources() const { return TQStringList(); }
347 
351  virtual bool canHaveSubresources() const { return false; }
352 
356  virtual bool subresourceActive( const TQString& ) const { return true; }
357 
361  virtual bool subresourceWritable( const TQString& ) const;
362 
366  virtual const TQString labelForSubresource( const TQString& resource ) const
367  {
368  // the resource identifier is a sane fallback
369  return resource;
370  };
371 
378  virtual TQString subresourceIdentifier( Incidence *incidence )
379  { Q_UNUSED( incidence ); return TQString(); }
380 
381 
382 
386  virtual bool removeSubresource( const TQString& resource );
387 
392  virtual bool addSubresource( const TQString& resource, const TQString& parent );
393 
398  virtual TQString subresourceType( const TQString &resource );
399 
404  virtual void beginAddingIncidences();
405 
410  virtual void endAddingIncidences();
411 
412  public slots:
416  virtual void setSubresourceActive( const TQString &, bool active );
417 
418  protected:
419 
420  bool mResolveConflict;
424  virtual bool doLoad() = 0;
428  virtual bool doSave() = 0;
429 
434  virtual bool doSave( Incidence * );
435 
439  virtual void addInfoText( TQString & ) const {};
440 
444  void loadError( const TQString &errorMessage = TQString() );
448  void saveError( const TQString &errorMessage = TQString() );
449 
450  private:
451  bool mReceivedLoadError;
452  bool mReceivedSaveError;
453 
454  ErrorFormat *mException;
455 
456  class Private;
457  Private *d;
458 };
459 
460 typedef KRES::Manager<ResourceCalendar> CalendarResourceManager;
461 
462 }
463 
464 #endif
Provides the main "calendar" object class.
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: incidence.h:48
This class provides a Journal in the sense of RFC2445.
Definition: journal.h:34
This class provides the interfaces for a calendar resource.
virtual Todo * todo(const TQString &uid)=0
Searches todolist for an event with this unique id.
virtual Alarm::List alarmsTo(const TQDateTime &to)=0
Return all alarms which occur before given date.
virtual Event * event(const TQString &uid)=0
Retrieves an event on the basis of the unique string ID.
virtual bool doLoad()=0
Do the actual loading of the resource data.
virtual bool doSave()=0
Do the actual saving of the resource data.
virtual TDEABC::Lock * lock()=0
Return object for locking the resource.
void signalSubresourceRemoved(ResourceCalendar *, const TQString &, const TQString &)
This signal is emitted when a subresource is removed.
virtual TQString subresourceIdentifier(Incidence *incidence)
Get the identifier of the subresource associated with a specified incidence.
virtual TQStringList subresources() const
If this resource has subresources, return a TQStringList of them.
virtual bool isSaving()
Return true if a save operation is still in progress, otherwise return false.
void signalSubresourceAdded(ResourceCalendar *, const TQString &type, const TQString &subresource, const TQString &label)
This signal is emitted when a subresource is added.
virtual Event::List rawEvents(const TQDate &start, const TQDate &end, bool inclusive=false)=0
Get unfiltered events in a range of dates.
void resourceLoaded(ResourceCalendar *)
This signal is emitted when loading data into the resource has been finished.
virtual bool deleteJournal(Journal *)=0
Remove a Journal entry from calendar.
virtual Event::List rawEvents(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return unfiltered list of all events in calendar.
virtual TDE_DEPRECATED bool addTodo(Todo *todo)=0
Add a todo to the todolist.
virtual bool deleteEvent(Event *)=0
Delete event from this resource.
virtual Journal * journal(const TQString &uid)=0
Return Journal with given unique id.
virtual Todo::List rawTodos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return list of all todos.
void resourceSaved(ResourceCalendar *)
This signal is emitted when saving the data of the resource has been finished.
virtual bool subresourceActive(const TQString &) const
Is this subresource active or not?
void resourceChanged(ResourceCalendar *)
This signal is emitted when the data in the resource has changed.
virtual Event::List rawEventsForDate(const TQDateTime &qdt)=0
Get unfiltered events for date qdt.
virtual Alarm::List alarms(const TQDateTime &from, const TQDateTime &to)=0
Return all alarms which occur in the given time interval.
virtual Event::List rawEventsForDate(const TQDate &date, EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Builds and then returns a list of all events that match the date specified.
virtual bool canHaveSubresources() const
Is this subresource capable of having subresources or not?
void resourceSaveError(ResourceCalendar *, const TQString &error)
This signal is emitted when an error occurs during saving.
virtual TDE_DEPRECATED bool addJournal(Journal *)=0
Add a Journal entry to the resource.
virtual Journal::List rawJournals(JournalSortField sortField=JournalSortUnsorted, SortDirection sortDirection=SortDirectionAscending)=0
Return list of all journals.
virtual Todo::List rawTodosForDate(const TQDate &date)=0
Returns list of todos due on the specified date.
virtual Journal::List rawJournalsForDate(const TQDate &date)=0
Returns list of journals for the given date.
virtual const TQString labelForSubresource(const TQString &resource) const
What is the label for this subresource?
virtual TDE_DEPRECATED bool addEvent(Event *event)=0
Add event to resource.
void resourceLoadError(ResourceCalendar *, const TQString &error)
This signal is emitted when an error occurs during loading.
virtual void addInfoText(TQString &) const
Add info text for concrete resources.
virtual void setTimeZoneId(const TQString &timeZoneId)=0
Set time zone id used by this resource, e.g.
virtual bool deleteTodo(Todo *)=0
Remove a todo from the todolist.
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
@ 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
EventSortField
How Events are to be sorted.
Definition: calendar.h:75
@ EventSortUnsorted
Events are to be unsorted.
Definition: calendar.h:77
SortDirection
Sort direction.
Definition: calendar.h:63
@ SortDirectionAscending
Sort in ascending order (first to last)
Definition: calendar.h:65