summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
Unidiff
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 7e8e2c5..f4350d9 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -41,33 +41,33 @@ Calendar::Calendar()
41 setTimeZoneId( " 00:00 Europe/London(UTC)" ); 41 setTimeZoneId( " 00:00 Europe/London(UTC)" );
42} 42}
43 43
44Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
45{ 45{
46 46
47 init(); 47 init();
48 setTimeZoneId(timeZoneId); 48 setTimeZoneId(timeZoneId);
49} 49}
50 50
51void Calendar::init() 51void Calendar::init()
52{ 52{
53 mObserver = 0; 53 mObserver = 0;
54 mNewObserver = false; 54 mNewObserver = false;
55 mUndoIncidence = 0; 55 mUndoIncidence = 0;
56 mModified = false; 56 mModified = false;
57 57 mDefaultCalendar = 1;
58 // Setup default filter, which does nothing 58 // Setup default filter, which does nothing
59 mDefaultFilter = new CalFilter; 59 mDefaultFilter = new CalFilter;
60 mFilter = mDefaultFilter; 60 mFilter = mDefaultFilter;
61 mFilter->setEnabled(false); 61 mFilter->setEnabled(false);
62 62
63 // initialize random numbers. This is a hack, and not 63 // initialize random numbers. This is a hack, and not
64 // even that good of one at that. 64 // even that good of one at that.
65// srandom(time(0)); 65// srandom(time(0));
66 66
67 // user information... 67 // user information...
68 setOwner(i18n("Unknown Name")); 68 setOwner(i18n("Unknown Name"));
69 setEmail(i18n("unknown@nowhere")); 69 setEmail(i18n("unknown@nowhere"));
70 70
71#if 0 71#if 0
72 tmpStr = KOPrefs::instance()->mTimeZone; 72 tmpStr = KOPrefs::instance()->mTimeZone;
73// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; 73// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl;
@@ -99,33 +99,40 @@ void Calendar::init()
99 KOPrefs::instance()->mTimeZone = tzStr; 99 KOPrefs::instance()->mTimeZone = tzStr;
100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst; 100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
101 } 101 }
102 102
103 setTimeZone(tzStr); 103 setTimeZone(tzStr);
104#endif 104#endif
105 105
106// KOPrefs::instance()->writeConfig(); 106// KOPrefs::instance()->writeConfig();
107} 107}
108 108
109Calendar::~Calendar() 109Calendar::~Calendar()
110{ 110{
111 delete mDefaultFilter; 111 delete mDefaultFilter;
112 if ( mUndoIncidence ) 112 if ( mUndoIncidence )
113 delete mUndoIncidence; 113 delete mUndoIncidence;
114} 114}
115 115void Calendar::setDefaultCalendar( int d )
116{
117 mDefaultCalendar = d;
118}
119int Calendar::defaultCalendar()
120{
121 return mDefaultCalendar;
122}
116const QString &Calendar::getOwner() const 123const QString &Calendar::getOwner() const
117{ 124{
118 return mOwner; 125 return mOwner;
119} 126}
120 127
121bool Calendar::undoDeleteIncidence() 128bool Calendar::undoDeleteIncidence()
122{ 129{
123 if (!mUndoIncidence) 130 if (!mUndoIncidence)
124 return false; 131 return false;
125 addIncidence(mUndoIncidence); 132 addIncidence(mUndoIncidence);
126 mUndoIncidence = 0; 133 mUndoIncidence = 0;
127 return true; 134 return true;
128} 135}
129void Calendar::setOwner(const QString &os) 136void Calendar::setOwner(const QString &os)
130{ 137{
131 int i; 138 int i;
@@ -335,33 +342,34 @@ QPtrList<Event> Calendar::events()
335 mFilter->apply(&el); 342 mFilter->apply(&el);
336 return el; 343 return el;
337} 344}
338void Calendar::addIncidenceBranch(Incidence *i) 345void Calendar::addIncidenceBranch(Incidence *i)
339{ 346{
340 addIncidence( i ); 347 addIncidence( i );
341 Incidence * inc; 348 Incidence * inc;
342 QPtrList<Incidence> Relations = i->relations(); 349 QPtrList<Incidence> Relations = i->relations();
343 for (inc=Relations.first();inc;inc=Relations.next()) { 350 for (inc=Relations.first();inc;inc=Relations.next()) {
344 addIncidenceBranch( inc ); 351 addIncidenceBranch( inc );
345 } 352 }
346} 353}
347 354
348bool Calendar::addIncidence(Incidence *i) 355bool Calendar::addIncidence(Incidence *i)
349{ 356{
350 Incidence::AddVisitor<Calendar> v(this); 357 Incidence::AddVisitor<Calendar> v(this);
351 358 i->setCalID( mDefaultCalendar );
359 i->setCalEnabled( true );
352 return i->accept(v); 360 return i->accept(v);
353} 361}
354void Calendar::deleteIncidence(Incidence *in) 362void Calendar::deleteIncidence(Incidence *in)
355{ 363{
356 if ( in->typeID() == eventID ) 364 if ( in->typeID() == eventID )
357 deleteEvent( (Event*) in ); 365 deleteEvent( (Event*) in );
358 else if ( in->typeID() == todoID ) 366 else if ( in->typeID() == todoID )
359 deleteTodo( (Todo*) in); 367 deleteTodo( (Todo*) in);
360 else if ( in->typeID() == journalID ) 368 else if ( in->typeID() == journalID )
361 deleteJournal( (Journal*) in ); 369 deleteJournal( (Journal*) in );
362} 370}
363 371
364Incidence* Calendar::incidence( const QString& uid ) 372Incidence* Calendar::incidence( const QString& uid )
365{ 373{
366 Incidence* i; 374 Incidence* i;
367 375