1 | /* |
2 | This file is part of the kcal library. |
3 | |
4 | Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 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 | */ |
22 | /** |
23 | @file |
24 | This file is part of the API for handling calendar data and |
25 | defines the FreeBusy class. |
26 | |
27 | @author Cornelius Schumacher \<schumacher@kde.org\> |
28 | @author Reinhold Kainhofer \<reinhold@kainhofer.com\> |
29 | */ |
30 | |
31 | #ifndef KCAL_FREEBUSY_H |
32 | #define KCAL_FREEBUSY_H |
33 | |
34 | #include "incidencebase.h" |
35 | #include "event.h" |
36 | #include "freebusyperiod.h" |
37 | |
38 | #include <QtCore/QByteArray> |
39 | |
40 | namespace KCal { |
41 | |
42 | class Calendar; |
43 | |
44 | /** |
45 | @brief |
46 | Provides information about the free/busy time of a calendar. |
47 | |
48 | A free/busy is a collection of Periods (@see Period). |
49 | */ |
50 | class KCAL_DEPRECATED_EXPORT FreeBusy : public IncidenceBase |
51 | { |
52 | public: |
53 | /** |
54 | Constructs an free/busy without any periods. |
55 | */ |
56 | FreeBusy(); |
57 | |
58 | /** |
59 | Copy constructor. |
60 | @param other is the free/busy to copy. |
61 | */ |
62 | FreeBusy( const FreeBusy &other ); |
63 | |
64 | /** |
65 | Constructs a free/busy from a list of periods. |
66 | |
67 | @param busyPeriods is a QList of periods. |
68 | */ |
69 | explicit FreeBusy( const Period::List &busyPeriods ); |
70 | |
71 | /** |
72 | Constructs a free/busy from a list of periods. |
73 | |
74 | @param busyPeriods is a QList of periods. |
75 | */ |
76 | explicit FreeBusy( const FreeBusyPeriod::List &busyPeriods ); |
77 | |
78 | /** |
79 | Constructs a free/busy from a single period. |
80 | |
81 | @param start is the start datetime of the period. |
82 | @param end is the end datetime of the period. |
83 | */ |
84 | FreeBusy( const KDateTime &start, const KDateTime &end ); |
85 | |
86 | /** |
87 | Constructs a freebusy for a specified calendar give a single period. |
88 | |
89 | @param calendar is a pointer to a valid Calendar object. |
90 | @param start is the start datetime of the period. |
91 | @param end is the end datetime of the period. |
92 | */ |
93 | FreeBusy( Calendar *calendar, const KDateTime &start, const KDateTime &end ); |
94 | |
95 | /** |
96 | Constructs a freebusy for a specified list of events given a single period. |
97 | |
98 | @param events list of events. |
99 | @param start is the start datetime of the period. |
100 | @param end is the end datetime of the period. |
101 | @since 4.4 |
102 | */ |
103 | FreeBusy( const Event::List &events, const KDateTime &start, const KDateTime &end ); |
104 | |
105 | /** |
106 | Destroys a free/busy. |
107 | */ |
108 | ~FreeBusy(); |
109 | |
110 | /** |
111 | @copydoc |
112 | IncidenceBase::type() |
113 | */ |
114 | QByteArray type() const; |
115 | |
116 | /** |
117 | @copydoc |
118 | IncidenceBase::typeStr() |
119 | */ |
120 | //KDE5: QString typeStr() const; |
121 | |
122 | /** |
123 | Sets the start datetime for the free/busy. Note that this datetime |
124 | may be later or earlier than all periods within the free/busy. |
125 | |
126 | @param start is a KDateTime specifying an start datetime. |
127 | @see IncidenceBase::dtStart(), setDtEnd(). |
128 | */ |
129 | virtual void setDtStart( const KDateTime &start ); |
130 | |
131 | /** |
132 | Sets the end datetime for the free/busy. Note that this datetime |
133 | may be later or earlier than all periods within the free/busy. |
134 | |
135 | @param end is a KDateTime specifying an end datetime. |
136 | @see dtEnd(), setDtStart(). |
137 | */ |
138 | void setDtEnd( const KDateTime &end ); |
139 | |
140 | /** |
141 | Returns the end datetime for the free/busy. |
142 | FIXME: calling addPeriod() does not change mDtEnd. Is that incorrect? |
143 | @see setDtEnd(). |
144 | */ |
145 | virtual KDateTime dtEnd() const; |
146 | |
147 | /** |
148 | @copydoc |
149 | IncidenceBase::shiftTimes() |
150 | */ |
151 | virtual void shiftTimes( const KDateTime::Spec &oldSpec, |
152 | const KDateTime::Spec &newSpec ); |
153 | |
154 | /** |
155 | Returns the list of all periods within the free/busy. |
156 | */ |
157 | Period::List busyPeriods() const; |
158 | |
159 | /** |
160 | Returns the list of all periods within the free/busy. |
161 | */ |
162 | FreeBusyPeriod::List fullBusyPeriods() const; |
163 | |
164 | /** |
165 | Adds a period to the freebusy list and sorts the list. |
166 | |
167 | @param start is the start datetime of the period. |
168 | @param end is the end datetime of the period. |
169 | */ |
170 | void addPeriod( const KDateTime &start, const KDateTime &end ); |
171 | |
172 | /** |
173 | Adds a period to the freebusy list and sorts the list. |
174 | |
175 | @param start is the start datetime of the period. |
176 | @param duration is the Duration of the period. |
177 | */ |
178 | void addPeriod( const KDateTime &start, const Duration &duration ); |
179 | |
180 | /** |
181 | Adds a list of periods to the freebusy object and then sorts that list. |
182 | Use this if you are adding many items, instead of the addPeriod method, |
183 | to avoid sorting repeatedly. |
184 | |
185 | @param list is a QList of Period objects. |
186 | */ |
187 | void addPeriods( const Period::List &list ); |
188 | |
189 | /** |
190 | Adds a list of periods to the freebusy object and then sorts that list. |
191 | Use this if you are adding many items, instead of the addPeriod method, |
192 | to avoid sorting repeatedly. |
193 | |
194 | @param list is a QList of FreeBusyPeriod objects. |
195 | */ |
196 | void addPeriods( const FreeBusyPeriod::List &list ); |
197 | |
198 | /** |
199 | Sorts the list of free/busy periods into ascending order. |
200 | */ |
201 | void sortList(); |
202 | |
203 | /** |
204 | Merges another free/busy into this free/busy. |
205 | |
206 | @param freebusy is a pointer to a valid FreeBusy object. |
207 | */ |
208 | void merge( FreeBusy *freebusy ); |
209 | |
210 | /** |
211 | Assignment operator. |
212 | */ |
213 | FreeBusy &operator=( const FreeBusy &other ); |
214 | |
215 | /** |
216 | Compare this with @p freebusy for equality. |
217 | |
218 | @param freebusy is the FreeBusy to compare. |
219 | */ |
220 | bool operator==( const FreeBusy &freebusy ) const; |
221 | |
222 | private: |
223 | /** |
224 | @copydoc |
225 | IncidenceBase::accept() |
226 | */ |
227 | bool accept( Visitor &v ) { return v.visit( this ); } |
228 | |
229 | //@cond PRIVATE |
230 | class Private; |
231 | Private *const d; |
232 | //@endcond |
233 | }; |
234 | |
235 | } |
236 | |
237 | #endif |
238 | |