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 
186  virtual Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
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:
234  void resourceChanged( ResourceCalendar * );
235 
240  void resourceLoaded( ResourceCalendar * );
245  void resourceSaved( ResourceCalendar * );
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;
289  virtual Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 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;
315  virtual Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 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
@ JournalSortUnsorted
Journals are to be unsorted.
Definition: calendar.h:113
Calendar format related error class.
Definition: exceptions.h:64
TodoSortField
Definition: calendar.h:90
virtual TQString subresourceIdentifier(Incidence *incidence)
Get the identifier of the subresource associated with a specified incidence.
virtual const TQString labelForSubresource(const TQString &resource) const
What is the label for this subresource?
This class provides an Event in the sense of RFC2445.
Definition: event.h:32
Definition: alarm.h:38
@ SortDirectionAscending
Sort in ascending order (first to last)
Definition: calendar.h:65
This class provides a Todo in the sense of RFC2445.
Definition: todo.h:31
EventSortField
Definition: calendar.h:74
JournalSortField
Definition: calendar.h:110
@ EventSortUnsorted
Events are to be unsorted.
Definition: calendar.h:77
This class provides the base class common to all calendar components.
Definition: incidence.h:47
virtual bool canHaveSubresources() const
Is this subresource capable of having subresources or not?
This class provides the interfaces for a calendar resource.
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.
@ TodoSortUnsorted
Todos are to be unsorted.
Definition: calendar.h:93
This class provides a Journal in the sense of RFC2445.
Definition: journal.h:33
virtual void addInfoText(TQString &) const
Add info text for concrete resources.
virtual bool subresourceActive(const TQString &) const
Is this subresource active or not?
SortDirection
Definition: calendar.h:62