libkcal

calendarresources.h
Go to the documentation of this file.
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
29#ifndef KCAL_CALENDARRESOURCES_H
30#define KCAL_CALENDARRESOURCES_H
31
32#include <tqintdict.h>
33#include <tqmap.h>
34
35#include "calendar.h"
36#include "resourcecalendar.h"
37
38#include "libkcal_export.h"
39
40#include <tderesources/manager.h>
41
42class TQWidget;
43
48namespace KCal {
49
50class CalFormat;
51
64class LIBKCAL_EXPORT CalendarResources :
65 public Calendar,
66 public KRES::ManagerObserver<ResourceCalendar>
67{
68 TQ_OBJECT
69
70 public:
74 class DestinationPolicy
75 {
76 public:
77 DestinationPolicy( CalendarResourceManager *manager,
78 TQWidget *parent = 0 ) :
79 mManager( manager ), mParent( parent ) {}
80 virtual ~DestinationPolicy() {}
81
82 virtual ResourceCalendar *destination( Incidence *incidence ) = 0;
83 virtual TQWidget *parent() { return mParent; }
84 virtual void setParent( TQWidget *newparent ) { mParent = newparent; }
85 bool hasCalendarResources();
86 protected:
87 CalendarResourceManager *resourceManager()
88 { return mManager; }
89
90 private:
91 CalendarResourceManager *mManager;
92 TQWidget *mParent;
93 };
94
98 class StandardDestinationPolicy : public DestinationPolicy
99 {
100 public:
101 StandardDestinationPolicy( CalendarResourceManager *manager,
102 TQWidget *parent = 0 ) :
103 DestinationPolicy( manager, parent ) {}
104 virtual ~StandardDestinationPolicy() {}
105
106 ResourceCalendar *destination( Incidence *incidence );
107
108 private:
109 class Private;
110 Private *d;
111 };
112
116 class AskDestinationPolicy : public DestinationPolicy
117 {
118 public:
119 AskDestinationPolicy( CalendarResourceManager *manager,
120 TQWidget *parent = 0 ) :
121 DestinationPolicy( manager, parent ) {}
122 virtual ~AskDestinationPolicy() {}
123
124 ResourceCalendar *destination( Incidence *incidence );
125
126 private:
127 class Private;
128 Private *d;
129 };
130
134 class Ticket
135 {
136 friend class CalendarResources;
137 public:
138 ResourceCalendar *resource() const
139 { return mResource; }
140
141 private:
142 Ticket( ResourceCalendar *r ) : mResource( r ) {}
143
144 ResourceCalendar *mResource;
145
146 class Private;
147 Private *d;
148 };
149
167 const TQString &timeZoneId,
168 const TQString &family = TQString::fromLatin1( "calendar" ) );
169
174
180 void load();
181
187 bool reload( const TQString &tz );
188
192 void close();
193
197 void closeEvents();
198
202 void closeTodos();
203
207 void closeJournals();
208
222 virtual bool save( Ticket *ticket, Incidence *incidence = 0 );
223
227 void save();
228
234 bool isSaving();
235
241 CalendarResourceManager *resourceManager() const
242 { return mManager; }
243
252 ResourceCalendar *resource( Incidence *incidence );
253
262 void readConfig( TDEConfig *config = 0 );
263
268 void setStandardDestinationPolicy();
269
274 void setAskDestinationPolicy();
275
284 TQWidget *dialogParentWidget();
291 void setDialogParentWidget( TQWidget *parent );
292
303 Ticket *requestSaveTicket( ResourceCalendar *resource );
304
310 virtual void releaseSaveTicket( Ticket *ticket );
311
320 void resourceAdded( ResourceCalendar *resource );
321
322// Incidence Specific Methods //
323
331 bool addIncidence( Incidence *incidence );
332
343 TDE_DEPRECATED bool addIncidence( Incidence *incidence, ResourceCalendar *resource );
344
355 bool addIncidence( Incidence *incidence,
356 ResourceCalendar *resource, const TQString &subresource );
357
365 TDE_DEPRECATED bool beginChange( Incidence *incidence );
366
379 bool beginChange( Incidence *incidence, ResourceCalendar *resource, const TQString &subresource );
380
388 TDE_DEPRECATED bool endChange( Incidence *incidence );
389
402 bool endChange( Incidence *incidence,
403 ResourceCalendar *resource, const TQString &subresource );
404
405// Event Specific Methods //
406
417 bool addEvent( Event *event );
418
430 TDE_DEPRECATED bool addEvent( Event *event, ResourceCalendar *resource );
431
445 bool addEvent( Event *event, ResourceCalendar *resource, const TQString &subresource );
446
457 bool deleteEvent( Event *event );
458
467 Event::List rawEvents(
469 SortDirection sortDirection = SortDirectionAscending );
470
480 Event::List rawEventsForDate( const TQDateTime &qdt );
481
493 Event::List rawEvents( const TQDate &start, const TQDate &end,
494 bool inclusive = false );
495
507 Event::List rawEventsForDate(
508 const TQDate &date,
510 SortDirection sortDirection = SortDirectionAscending );
511
520 Event *event( const TQString &uid );
521
522// Todo Specific Methods //
523
534 bool addTodo( Todo *todo );
535
547 TDE_DEPRECATED bool addTodo( Todo *todo, ResourceCalendar *resource );
548
562 bool addTodo( Todo *todo, ResourceCalendar *resource, const TQString &subresource );
563
574 bool deleteTodo( Todo *todo );
575
584 Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted,
585 SortDirection sortDirection = SortDirectionAscending );
586
595 Todo::List rawTodosForDate( const TQDate &date );
596
605 Todo *todo( const TQString &uid );
606
607// Journal Specific Methods //
608
619 bool addJournal( Journal *journal );
620
632 TDE_DEPRECATED bool addJournal( Journal *journal, ResourceCalendar *resource );
633
647 bool addJournal( Journal *journal, ResourceCalendar *resource, const TQString &subresource );
648
659 bool deleteJournal( Journal *journal );
660
669 Journal::List rawJournals(
671 SortDirection sortDirection = SortDirectionAscending );
672
680 Journal::List rawJournalsForDate( const TQDate &date );
681
690 Journal *journal( const TQString &uid );
691
692// Alarm Specific Methods //
693
702 Alarm::List alarms( const TQDateTime &from, const TQDateTime &to );
703
711 Alarm::List alarmsTo( const TQDateTime &to );
712
720 void setTimeZoneIdViewOnly( const TQString& tz );
721
722 //issue 2508
723 bool hasCalendarResources();
724 signals:
729
734
739
743 void signalErrorMessage( const TQString &err );
744
745 protected:
746 void connectResource( ResourceCalendar *resource );
747 void resourceModified( ResourceCalendar *resource );
748 void resourceDeleted( ResourceCalendar *resource );
749
762 virtual void doSetTimeZoneId( const TQString &timeZoneId );
763
771 int incrementChangeCount( ResourceCalendar *resource );
772
780 int decrementChangeCount( ResourceCalendar *resource );
781
782 protected slots:
783 void slotLoadError( ResourceCalendar *resource, const TQString &err );
784 void slotSaveError( ResourceCalendar *resource, const TQString &err );
785
792 void beginAddingIncidences();
793
798 void endAddingIncidences();
799
800 private:
801
805 void init( const TQString &family );
806
807 bool mOpen;
808
809 KRES::Manager<ResourceCalendar>* mManager;
810 TQMap <Incidence*, ResourceCalendar*> mResourceMap;
811
812 DestinationPolicy *mDestinationPolicy;
813 StandardDestinationPolicy *mStandardPolicy;
814 AskDestinationPolicy *mAskPolicy;
815 bool mPendingDeleteFromResourceMap;
816
817 TQMap<ResourceCalendar *, Ticket *> mTickets;
818 TQMap<ResourceCalendar *, int> mChangeCounts;
819
820 class Private;
821 Private *d;
822};
823
824}
825
826#endif
Provides the main "calendar" object class.
This class provides a Calendar which is composed of other Calendars known as "Resources".
void signalResourceModified(ResourceCalendar *resource)
Signal that the Resource has been modified.
void signalErrorMessage(const TQString &err)
Signal an error message.
void signalResourceDeleted(ResourceCalendar *resource)
Signal that an Incidence has been removed from the Resource.
CalendarResourceManager * resourceManager() const
Get the CalendarResourceManager used by this calendar.
void signalResourceAdded(ResourceCalendar *resource)
Signal that an Incidence has been inserted to the Resource.
This is the main "calendar" object class.
Definition: calendar.h:171
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.
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