summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
Unidiff
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 32aac7a..a3977d7 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -1,64 +1,65 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <stdlib.h> 22#include <stdlib.h>
23#include <time.h> 23#include <time.h>
24 24
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#include "exceptions.h" 29#include "exceptions.h"
30#include "calfilter.h" 30#include "calfilter.h"
31 31
32#include "calendar.h" 32#include "calendar.h"
33#include "syncdefines.h"
33 34
34using namespace KCal; 35using namespace KCal;
35 36
36Calendar::Calendar() 37Calendar::Calendar()
37{ 38{
38 39
39 init(); 40 init();
40 setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); 41 setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") );
41} 42}
42 43
43Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
44{ 45{
45 46
46 init(); 47 init();
47 setTimeZoneId(timeZoneId); 48 setTimeZoneId(timeZoneId);
48} 49}
49 50
50void Calendar::init() 51void Calendar::init()
51{ 52{
52 mObserver = 0; 53 mObserver = 0;
53 mNewObserver = false; 54 mNewObserver = false;
54 55
55 mModified = false; 56 mModified = false;
56 57
57 // Setup default filter, which does nothing 58 // Setup default filter, which does nothing
58 mDefaultFilter = new CalFilter; 59 mDefaultFilter = new CalFilter;
59 mFilter = mDefaultFilter; 60 mFilter = mDefaultFilter;
60 mFilter->setEnabled(false); 61 mFilter->setEnabled(false);
61 62
62 // initialize random numbers. This is a hack, and not 63 // initialize random numbers. This is a hack, and not
63 // even that good of one at that. 64 // even that good of one at that.
64// srandom(time(0)); 65// srandom(time(0));
@@ -218,65 +219,79 @@ void Calendar::setEmail(const QString &e)
218 mOwnerEmail = e; 219 mOwnerEmail = e;
219 220
220 setModified( true ); 221 setModified( true );
221} 222}
222 223
223void Calendar::setFilter(CalFilter *filter) 224void Calendar::setFilter(CalFilter *filter)
224{ 225{
225 mFilter = filter; 226 mFilter = filter;
226} 227}
227 228
228CalFilter *Calendar::filter() 229CalFilter *Calendar::filter()
229{ 230{
230 return mFilter; 231 return mFilter;
231} 232}
232 233
233QPtrList<Incidence> Calendar::incidences() 234QPtrList<Incidence> Calendar::incidences()
234{ 235{
235 QPtrList<Incidence> incidences; 236 QPtrList<Incidence> incidences;
236 237
237 Incidence *i; 238 Incidence *i;
238 239
239 QPtrList<Event> e = events(); 240 QPtrList<Event> e = events();
240 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 241 for( i = e.first(); i; i = e.next() ) incidences.append( i );
241 242
242 QPtrList<Todo> t = todos(); 243 QPtrList<Todo> t = todos();
243 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 244 for( i = t.first(); i; i = t.next() ) incidences.append( i );
244 245
245 QPtrList<Journal> j = journals(); 246 QPtrList<Journal> j = journals();
246 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 247 for( i = j.first(); i; i = j.next() ) incidences.append( i );
247 248
248 return incidences; 249 return incidences;
249} 250}
251void Calendar::resetTempSyncStat()
252{
253 QPtrList<Incidence> incidences;
254
255 Incidence *i;
256
257 QPtrList<Event> e = rawEvents();
258 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
250 259
260 QPtrList<Todo> t = rawTodos();
261 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
262
263 QPtrList<Journal> j = journals();
264 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
265}
251QPtrList<Incidence> Calendar::rawIncidences() 266QPtrList<Incidence> Calendar::rawIncidences()
252{ 267{
253 QPtrList<Incidence> incidences; 268 QPtrList<Incidence> incidences;
254 269
255 Incidence *i; 270 Incidence *i;
256 271
257 QPtrList<Event> e = rawEvents(); 272 QPtrList<Event> e = rawEvents();
258 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 273 for( i = e.first(); i; i = e.next() ) incidences.append( i );
259 274
260 QPtrList<Todo> t = rawTodos(); 275 QPtrList<Todo> t = rawTodos();
261 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 276 for( i = t.first(); i; i = t.next() ) incidences.append( i );
262 277
263 QPtrList<Journal> j = journals(); 278 QPtrList<Journal> j = journals();
264 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 279 for( i = j.first(); i; i = j.next() ) incidences.append( i );
265 280
266 return incidences; 281 return incidences;
267} 282}
268 283
269QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 284QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
270{ 285{
271 QPtrList<Event> el = rawEventsForDate(date,sorted); 286 QPtrList<Event> el = rawEventsForDate(date,sorted);
272 mFilter->apply(&el); 287 mFilter->apply(&el);
273 return el; 288 return el;
274} 289}
275 290
276QPtrList<Event> Calendar::events( const QDateTime &qdt ) 291QPtrList<Event> Calendar::events( const QDateTime &qdt )
277{ 292{
278 QPtrList<Event> el = rawEventsForDate(qdt); 293 QPtrList<Event> el = rawEventsForDate(qdt);
279 mFilter->apply(&el); 294 mFilter->apply(&el);
280 return el; 295 return el;
281} 296}
282 297