summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-02-07 20:05:18 (UTC)
committer zautrix <zautrix>2005-02-07 20:05:18 (UTC)
commitda5e47069d88fa9aa656423ce4c60bf505728e1c (patch) (unidiff)
treefdbaf29835a028f1204a19fc10dea97d469c0b29 /libkcal
parent456b0246521847635fe98471691ceecae211e0c3 (diff)
downloadkdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.zip
kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.gz
kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.bz2
fixes
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp1
-rw-r--r--libkcal/event.cpp6
-rw-r--r--libkcal/todo.cpp4
3 files changed, 5 insertions, 6 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 88351eb..dcfee5d 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -103,48 +103,49 @@ void Calendar::init()
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 115
116const QString &Calendar::getOwner() const 116const QString &Calendar::getOwner() const
117{ 117{
118 return mOwner; 118 return mOwner;
119} 119}
120 120
121bool Calendar::undoDeleteIncidence() 121bool Calendar::undoDeleteIncidence()
122{ 122{
123 if (!mUndoIncidence) 123 if (!mUndoIncidence)
124 return false; 124 return false;
125 addIncidence(mUndoIncidence); 125 addIncidence(mUndoIncidence);
126 mUndoIncidence = 0; 126 mUndoIncidence = 0;
127 return true;
127} 128}
128void Calendar::setOwner(const QString &os) 129void Calendar::setOwner(const QString &os)
129{ 130{
130 int i; 131 int i;
131 mOwner = os; 132 mOwner = os;
132 i = mOwner.find(','); 133 i = mOwner.find(',');
133 if (i != -1) 134 if (i != -1)
134 mOwner = mOwner.left(i); 135 mOwner = mOwner.left(i);
135 136
136 setModified( true ); 137 setModified( true );
137} 138}
138 139
139void Calendar::setTimeZone(const QString & tz) 140void Calendar::setTimeZone(const QString & tz)
140{ 141{
141 bool neg = FALSE; 142 bool neg = FALSE;
142 int hours, minutes; 143 int hours, minutes;
143 QString tmpStr(tz); 144 QString tmpStr(tz);
144 145
145 if (tmpStr.left(1) == "-") 146 if (tmpStr.left(1) == "-")
146 neg = TRUE; 147 neg = TRUE;
147 if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") 148 if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+")
148 tmpStr.remove(0, 1); 149 tmpStr.remove(0, 1);
149 hours = tmpStr.left(2).toInt(); 150 hours = tmpStr.left(2).toInt();
150 if (tmpStr.length() > 2) 151 if (tmpStr.length() > 2)
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 7256f05..de8dceb 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -68,81 +68,79 @@ bool Event::contains ( Event* from )
68 if ( from->dtEnd().isValid() ) 68 if ( from->dtEnd().isValid() )
69 if ( dtEnd() != from->dtEnd() ) 69 if ( dtEnd() != from->dtEnd() )
70 return false; 70 return false;
71 if ( !from->location().isEmpty() ) 71 if ( !from->location().isEmpty() )
72 if ( !location().startsWith( from->location() ) ) 72 if ( !location().startsWith( from->location() ) )
73 return false; 73 return false;
74 if ( !from->description().isEmpty() ) 74 if ( !from->description().isEmpty() )
75 if ( !description().startsWith( from->description() )) 75 if ( !description().startsWith( from->description() ))
76 return false; 76 return false;
77 if ( from->alarms().count() ) { 77 if ( from->alarms().count() ) {
78 Alarm *a = from->alarms().first(); 78 Alarm *a = from->alarms().first();
79 if ( a->enabled() ){ 79 if ( a->enabled() ){
80 if ( !alarms().count() ) 80 if ( !alarms().count() )
81 return false; 81 return false;
82 Alarm *b = alarms().first(); 82 Alarm *b = alarms().first();
83 if( ! b->enabled() ) 83 if( ! b->enabled() )
84 return false; 84 return false;
85 if ( ! (a->offset() == b->offset() )) 85 if ( ! (a->offset() == b->offset() ))
86 return false; 86 return false;
87 } 87 }
88 } 88 }
89 QStringList cat = categories(); 89 QStringList cat = categories();
90 QStringList catFrom = from->categories(); 90 QStringList catFrom = from->categories();
91 QString nCat; 91 QString nCat;
92 int iii; 92 unsigned int iii;
93 for ( iii = 0; iii < catFrom.count();++iii ) { 93 for ( iii = 0; iii < catFrom.count();++iii ) {
94 nCat = catFrom[iii]; 94 nCat = catFrom[iii];
95 if ( !nCat.isEmpty() ) 95 if ( !nCat.isEmpty() )
96 if ( !cat.contains( nCat )) { 96 if ( !cat.contains( nCat )) {
97 return false; 97 return false;
98 } 98 }
99 } 99 }
100 if ( from->doesRecur() ) 100 if ( from->doesRecur() )
101 if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) 101 if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) )
102 return false; 102 return false;
103 return true; 103 return true;
104} 104}
105 105
106void Event::setDtEnd(const QDateTime &dtEnd) 106void Event::setDtEnd(const QDateTime &dtEnd)
107{ 107{
108 if (mReadOnly) return; 108 if (mReadOnly) return;
109 109
110 mDtEnd = getEvenTime( dtEnd ); 110 mDtEnd = getEvenTime( dtEnd );
111 111
112 setHasEndDate(true); 112 setHasEndDate(true);
113 setHasDuration(false); 113 setHasDuration(false);
114 114
115 updated(); 115 updated();
116} 116}
117 117
118QDateTime Event::dtEnd() const 118QDateTime Event::dtEnd() const
119{ 119{
120 if (hasEndDate()) return mDtEnd; 120 if (hasEndDate()) return mDtEnd;
121 if (hasDuration()) return dtStart().addSecs(duration()); 121 if (hasDuration()) return dtStart().addSecs(duration());
122 122
123 kdDebug(5800) << "Warning! Event '" << summary()
124 << "' does have neither end date nor duration." << endl;
125 return dtStart(); 123 return dtStart();
126} 124}
127 125
128QString Event::dtEndTimeStr() const 126QString Event::dtEndTimeStr() const
129{ 127{
130 return KGlobal::locale()->formatTime(mDtEnd.time()); 128 return KGlobal::locale()->formatTime(mDtEnd.time());
131} 129}
132 130
133QString Event::dtEndDateStr(bool shortfmt) const 131QString Event::dtEndDateStr(bool shortfmt) const
134{ 132{
135 return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); 133 return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt);
136} 134}
137 135
138QString Event::dtEndStr(bool shortfmt) const 136QString Event::dtEndStr(bool shortfmt) const
139{ 137{
140 return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); 138 return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt);
141} 139}
142 140
143void Event::setHasEndDate(bool b) 141void Event::setHasEndDate(bool b)
144{ 142{
145 mHasEndDate = b; 143 mHasEndDate = b;
146} 144}
147 145
148bool Event::hasEndDate() const 146bool Event::hasEndDate() const
@@ -164,49 +162,49 @@ void Event::setTransparency(Event::Transparency transparency)
164} 162}
165 163
166Event::Transparency Event::transparency() const 164Event::Transparency Event::transparency() const
167{ 165{
168 return mTransparency; 166 return mTransparency;
169} 167}
170 168
171void Event::setDuration(int seconds) 169void Event::setDuration(int seconds)
172{ 170{
173 setHasEndDate(false); 171 setHasEndDate(false);
174 Incidence::setDuration(seconds); 172 Incidence::setDuration(seconds);
175} 173}
176QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const 174QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const
177{ 175{
178 176
179 bool yes; 177 bool yes;
180 QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes ); 178 QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes );
181 if ( ! yes || cancelled() ) { 179 if ( ! yes || cancelled() ) {
182 *ok = false; 180 *ok = false;
183 return QDateTime (); 181 return QDateTime ();
184 } 182 }
185 183
186 bool enabled = false; 184 bool enabled = false;
187 Alarm* alarm; 185 Alarm* alarm;
188 int off; 186 int off = 0;
189 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 187 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
190 // if ( QDateTime::currentDateTime() > incidenceStart ){ 188 // if ( QDateTime::currentDateTime() > incidenceStart ){
191// *ok = false; 189// *ok = false;
192// return incidenceStart; 190// return incidenceStart;
193// } 191// }
194 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 192 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
195 if (alarm->enabled()) { 193 if (alarm->enabled()) {
196 if ( alarm->hasTime () ) { 194 if ( alarm->hasTime () ) {
197 if ( alarm->time() < alarmStart ) { 195 if ( alarm->time() < alarmStart ) {
198 alarmStart = alarm->time(); 196 alarmStart = alarm->time();
199 enabled = true; 197 enabled = true;
200 off = alarmStart.secsTo( incidenceStart ); 198 off = alarmStart.secsTo( incidenceStart );
201 } 199 }
202 200
203 } else { 201 } else {
204 int secs = alarm->startOffset().asSeconds(); 202 int secs = alarm->startOffset().asSeconds();
205 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 203 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
206 alarmStart = incidenceStart.addSecs( secs ); 204 alarmStart = incidenceStart.addSecs( secs );
207 enabled = true; 205 enabled = true;
208 off = -secs; 206 off = -secs;
209 } 207 }
210 } 208 }
211 } 209 }
212 } 210 }
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index d81a68f..9c04a7e 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -75,49 +75,49 @@ bool Todo::contains ( Todo* from )
75 return false; 75 return false;
76 } 76 }
77 if ( !from->location().isEmpty() ) 77 if ( !from->location().isEmpty() )
78 if ( !location().startsWith( from->location() ) ) 78 if ( !location().startsWith( from->location() ) )
79 return false; 79 return false;
80 if ( !from->description().isEmpty() ) 80 if ( !from->description().isEmpty() )
81 if ( !description().startsWith( from->description() )) 81 if ( !description().startsWith( from->description() ))
82 return false; 82 return false;
83 if ( from->alarms().count() ) { 83 if ( from->alarms().count() ) {
84 Alarm *a = from->alarms().first(); 84 Alarm *a = from->alarms().first();
85 if ( a->enabled() ){ 85 if ( a->enabled() ){
86 if ( !alarms().count() ) 86 if ( !alarms().count() )
87 return false; 87 return false;
88 Alarm *b = alarms().first(); 88 Alarm *b = alarms().first();
89 if( ! b->enabled() ) 89 if( ! b->enabled() )
90 return false; 90 return false;
91 if ( ! (a->offset() == b->offset() )) 91 if ( ! (a->offset() == b->offset() ))
92 return false; 92 return false;
93 } 93 }
94 } 94 }
95 95
96 QStringList cat = categories(); 96 QStringList cat = categories();
97 QStringList catFrom = from->categories(); 97 QStringList catFrom = from->categories();
98 QString nCat; 98 QString nCat;
99 int iii; 99 unsigned int iii;
100 for ( iii = 0; iii < catFrom.count();++iii ) { 100 for ( iii = 0; iii < catFrom.count();++iii ) {
101 nCat = catFrom[iii]; 101 nCat = catFrom[iii];
102 if ( !nCat.isEmpty() ) 102 if ( !nCat.isEmpty() )
103 if ( !cat.contains( nCat )) { 103 if ( !cat.contains( nCat )) {
104 return false; 104 return false;
105 } 105 }
106 } 106 }
107 if ( from->isCompleted() ) { 107 if ( from->isCompleted() ) {
108 if ( !isCompleted() ) 108 if ( !isCompleted() )
109 return false; 109 return false;
110 } 110 }
111 if( priority() != from->priority() ) 111 if( priority() != from->priority() )
112 return false; 112 return false;
113 113
114 114
115 return true; 115 return true;
116 116
117} 117}
118bool KCal::operator==( const Todo& t1, const Todo& t2 ) 118bool KCal::operator==( const Todo& t1, const Todo& t2 )
119{ 119{
120 120
121 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 121 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
122 if ( ! ret ) 122 if ( ! ret )
123 return false; 123 return false;
@@ -354,49 +354,49 @@ bool Todo::hasCompletedDate() const
354} 354}
355 355
356int Todo::percentComplete() const 356int Todo::percentComplete() const
357{ 357{
358 return mPercentComplete; 358 return mPercentComplete;
359} 359}
360 360
361void Todo::setPercentComplete(int v) 361void Todo::setPercentComplete(int v)
362{ 362{
363 mPercentComplete = v; 363 mPercentComplete = v;
364 if ( v != 100 ) 364 if ( v != 100 )
365 mHasCompletedDate = false; 365 mHasCompletedDate = false;
366 updated(); 366 updated();
367} 367}
368QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 368QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
369{ 369{
370 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 370 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
371 *ok = false; 371 *ok = false;
372 return QDateTime (); 372 return QDateTime ();
373 } 373 }
374 QDateTime incidenceStart; 374 QDateTime incidenceStart;
375 incidenceStart = dtDue(); 375 incidenceStart = dtDue();
376 bool enabled = false; 376 bool enabled = false;
377 Alarm* alarm; 377 Alarm* alarm;
378 int off; 378 int off = 0;
379 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 379 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
380 // if ( QDateTime::currentDateTime() > incidenceStart ){ 380 // if ( QDateTime::currentDateTime() > incidenceStart ){
381// *ok = false; 381// *ok = false;
382// return incidenceStart; 382// return incidenceStart;
383// } 383// }
384 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 384 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
385 if (alarm->enabled()) { 385 if (alarm->enabled()) {
386 if ( alarm->hasTime () ) { 386 if ( alarm->hasTime () ) {
387 if ( alarm->time() < alarmStart ) { 387 if ( alarm->time() < alarmStart ) {
388 alarmStart = alarm->time(); 388 alarmStart = alarm->time();
389 enabled = true; 389 enabled = true;
390 off = alarmStart.secsTo( incidenceStart ); 390 off = alarmStart.secsTo( incidenceStart );
391 } 391 }
392 392
393 } else { 393 } else {
394 int secs = alarm->startOffset().asSeconds(); 394 int secs = alarm->startOffset().asSeconds();
395 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 395 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
396 alarmStart = incidenceStart.addSecs( secs ); 396 alarmStart = incidenceStart.addSecs( secs );
397 enabled = true; 397 enabled = true;
398 off = -secs; 398 off = -secs;
399 } 399 }
400 } 400 }
401 } 401 }
402 } 402 }