-rw-r--r-- | libkcal/calendar.cpp | 1 | ||||
-rw-r--r-- | libkcal/event.cpp | 6 | ||||
-rw-r--r-- | libkcal/todo.cpp | 4 |
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 | |||
@@ -79,96 +79,97 @@ void Calendar::init() | |||
79 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
82 | hourOff += 1; | 82 | hourOff += 1; |
83 | QString tzStr; | 83 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 85 | hourOff, |
86 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
87 | 87 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 91 | } else { |
92 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
93 | } | 93 | } |
94 | 94 | ||
95 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
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 | ||
109 | Calendar::~Calendar() | 109 | Calendar::~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 | ||
116 | const QString &Calendar::getOwner() const | 116 | const QString &Calendar::getOwner() const |
117 | { | 117 | { |
118 | return mOwner; | 118 | return mOwner; |
119 | } | 119 | } |
120 | 120 | ||
121 | bool Calendar::undoDeleteIncidence() | 121 | bool 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 | } |
128 | void Calendar::setOwner(const QString &os) | 129 | void 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 | ||
139 | void Calendar::setTimeZone(const QString & tz) | 140 | void 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) |
151 | minutes = tmpStr.right(2).toInt(); | 152 | minutes = tmpStr.right(2).toInt(); |
152 | else | 153 | else |
153 | minutes = 0; | 154 | minutes = 0; |
154 | mTimeZone = (60*hours+minutes); | 155 | mTimeZone = (60*hours+minutes); |
155 | if (neg) | 156 | if (neg) |
156 | mTimeZone = -mTimeZone; | 157 | mTimeZone = -mTimeZone; |
157 | mLocalTime = false; | 158 | mLocalTime = false; |
158 | 159 | ||
159 | setModified( true ); | 160 | setModified( true ); |
160 | } | 161 | } |
161 | 162 | ||
162 | QString Calendar::getTimeZoneStr() const | 163 | QString Calendar::getTimeZoneStr() const |
163 | { | 164 | { |
164 | if (mLocalTime) | 165 | if (mLocalTime) |
165 | return ""; | 166 | return ""; |
166 | QString tmpStr; | 167 | QString tmpStr; |
167 | int hours = abs(mTimeZone / 60); | 168 | int hours = abs(mTimeZone / 60); |
168 | int minutes = abs(mTimeZone % 60); | 169 | int minutes = abs(mTimeZone % 60); |
169 | bool neg = mTimeZone < 0; | 170 | bool neg = mTimeZone < 0; |
170 | 171 | ||
171 | tmpStr.sprintf("%c%.2d%.2d", | 172 | tmpStr.sprintf("%c%.2d%.2d", |
172 | (neg ? '-' : '+'), | 173 | (neg ? '-' : '+'), |
173 | hours, minutes); | 174 | hours, minutes); |
174 | return tmpStr; | 175 | return tmpStr; |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 7256f05..de8dceb 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -44,180 +44,178 @@ Event::~Event() | |||
44 | 44 | ||
45 | Incidence *Event::clone() | 45 | Incidence *Event::clone() |
46 | { | 46 | { |
47 | return new Event(*this); | 47 | return new Event(*this); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool KCal::operator==( const Event& e1, const Event& e2 ) | 50 | bool KCal::operator==( const Event& e1, const Event& e2 ) |
51 | { | 51 | { |
52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && | 52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && |
53 | e1.dtEnd() == e2.dtEnd() && | 53 | e1.dtEnd() == e2.dtEnd() && |
54 | e1.hasEndDate() == e2.hasEndDate() && | 54 | e1.hasEndDate() == e2.hasEndDate() && |
55 | e1.transparency() == e2.transparency(); | 55 | e1.transparency() == e2.transparency(); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | bool Event::contains ( Event* from ) | 59 | bool Event::contains ( Event* from ) |
60 | { | 60 | { |
61 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | 62 | if ( !from->summary().isEmpty() ) |
63 | if ( !summary().startsWith( from->summary() )) | 63 | if ( !summary().startsWith( from->summary() )) |
64 | return false; | 64 | return false; |
65 | if ( from->dtStart().isValid() ) | 65 | if ( from->dtStart().isValid() ) |
66 | if (dtStart() != from->dtStart() ) | 66 | if (dtStart() != from->dtStart() ) |
67 | return false; | 67 | return false; |
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 | ||
106 | void Event::setDtEnd(const QDateTime &dtEnd) | 106 | void 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 | ||
118 | QDateTime Event::dtEnd() const | 118 | QDateTime 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 | ||
128 | QString Event::dtEndTimeStr() const | 126 | QString Event::dtEndTimeStr() const |
129 | { | 127 | { |
130 | return KGlobal::locale()->formatTime(mDtEnd.time()); | 128 | return KGlobal::locale()->formatTime(mDtEnd.time()); |
131 | } | 129 | } |
132 | 130 | ||
133 | QString Event::dtEndDateStr(bool shortfmt) const | 131 | QString 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 | ||
138 | QString Event::dtEndStr(bool shortfmt) const | 136 | QString 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 | ||
143 | void Event::setHasEndDate(bool b) | 141 | void Event::setHasEndDate(bool b) |
144 | { | 142 | { |
145 | mHasEndDate = b; | 143 | mHasEndDate = b; |
146 | } | 144 | } |
147 | 145 | ||
148 | bool Event::hasEndDate() const | 146 | bool Event::hasEndDate() const |
149 | { | 147 | { |
150 | return mHasEndDate; | 148 | return mHasEndDate; |
151 | } | 149 | } |
152 | 150 | ||
153 | bool Event::isMultiDay() const | 151 | bool Event::isMultiDay() const |
154 | { | 152 | { |
155 | bool multi = !(dtStart().date() == dtEnd().date()); | 153 | bool multi = !(dtStart().date() == dtEnd().date()); |
156 | return multi; | 154 | return multi; |
157 | } | 155 | } |
158 | 156 | ||
159 | void Event::setTransparency(Event::Transparency transparency) | 157 | void Event::setTransparency(Event::Transparency transparency) |
160 | { | 158 | { |
161 | if (mReadOnly) return; | 159 | if (mReadOnly) return; |
162 | mTransparency = transparency; | 160 | mTransparency = transparency; |
163 | updated(); | 161 | updated(); |
164 | } | 162 | } |
165 | 163 | ||
166 | Event::Transparency Event::transparency() const | 164 | Event::Transparency Event::transparency() const |
167 | { | 165 | { |
168 | return mTransparency; | 166 | return mTransparency; |
169 | } | 167 | } |
170 | 168 | ||
171 | void Event::setDuration(int seconds) | 169 | void Event::setDuration(int seconds) |
172 | { | 170 | { |
173 | setHasEndDate(false); | 171 | setHasEndDate(false); |
174 | Incidence::setDuration(seconds); | 172 | Incidence::setDuration(seconds); |
175 | } | 173 | } |
176 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const | 174 | QDateTime 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 | } |
213 | if ( enabled ) { | 211 | if ( enabled ) { |
214 | if ( alarmStart > QDateTime::currentDateTime() ) { | 212 | if ( alarmStart > QDateTime::currentDateTime() ) { |
215 | *ok = true; | 213 | *ok = true; |
216 | * offset = off; | 214 | * offset = off; |
217 | return alarmStart; | 215 | return alarmStart; |
218 | } | 216 | } |
219 | } | 217 | } |
220 | *ok = false; | 218 | *ok = false; |
221 | return QDateTime (); | 219 | return QDateTime (); |
222 | 220 | ||
223 | } | 221 | } |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index d81a68f..9c04a7e 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -51,97 +51,97 @@ Todo::~Todo() | |||
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | Incidence *Todo::clone() | 54 | Incidence *Todo::clone() |
55 | { | 55 | { |
56 | return new Todo(*this); | 56 | return new Todo(*this); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool Todo::contains ( Todo* from ) | 59 | bool Todo::contains ( Todo* from ) |
60 | { | 60 | { |
61 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | 62 | if ( !from->summary().isEmpty() ) |
63 | if ( !summary().startsWith( from->summary() )) | 63 | if ( !summary().startsWith( from->summary() )) |
64 | return false; | 64 | return false; |
65 | if ( from->hasStartDate() ) { | 65 | if ( from->hasStartDate() ) { |
66 | if ( !hasStartDate() ) | 66 | if ( !hasStartDate() ) |
67 | return false; | 67 | return false; |
68 | if ( from->dtStart() != dtStart()) | 68 | if ( from->dtStart() != dtStart()) |
69 | return false; | 69 | return false; |
70 | } | 70 | } |
71 | if ( from->hasDueDate() ){ | 71 | if ( from->hasDueDate() ){ |
72 | if ( !hasDueDate() ) | 72 | if ( !hasDueDate() ) |
73 | return false; | 73 | return false; |
74 | if ( from->dtDue() != dtDue()) | 74 | if ( from->dtDue() != dtDue()) |
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 | } |
118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 118 | bool 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; |
124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
125 | if ( t1.hasDueDate() ) { | 125 | if ( t1.hasDueDate() ) { |
126 | if ( t1.doesFloat() == t2.doesFloat() ) { | 126 | if ( t1.doesFloat() == t2.doesFloat() ) { |
127 | if ( t1.doesFloat() ) { | 127 | if ( t1.doesFloat() ) { |
128 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 128 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
129 | return false; | 129 | return false; |
130 | } else | 130 | } else |
131 | if ( t1.dtDue() != t2.dtDue() ) | 131 | if ( t1.dtDue() != t2.dtDue() ) |
132 | return false; | 132 | return false; |
133 | } else | 133 | } else |
134 | return false;// float != | 134 | return false;// float != |
135 | } | 135 | } |
136 | 136 | ||
137 | } else | 137 | } else |
138 | return false; | 138 | return false; |
139 | if ( t1.percentComplete() != t2.percentComplete() ) | 139 | if ( t1.percentComplete() != t2.percentComplete() ) |
140 | return false; | 140 | return false; |
141 | if ( t1.isCompleted() ) { | 141 | if ( t1.isCompleted() ) { |
142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
143 | if ( t1.hasCompletedDate() ) { | 143 | if ( t1.hasCompletedDate() ) { |
144 | if ( t1.completed() != t2.completed() ) | 144 | if ( t1.completed() != t2.completed() ) |
145 | return false; | 145 | return false; |
146 | } | 146 | } |
147 | 147 | ||
@@ -330,85 +330,85 @@ QDateTime Todo::completed() const | |||
330 | return mCompleted; | 330 | return mCompleted; |
331 | } | 331 | } |
332 | 332 | ||
333 | QString Todo::completedStr( bool shortF ) const | 333 | QString Todo::completedStr( bool shortF ) const |
334 | { | 334 | { |
335 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 335 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
336 | } | 336 | } |
337 | 337 | ||
338 | void Todo::setCompleted(const QDateTime &completed) | 338 | void Todo::setCompleted(const QDateTime &completed) |
339 | { | 339 | { |
340 | //qDebug("Todo::setCompleted "); | 340 | //qDebug("Todo::setCompleted "); |
341 | if ( mHasCompletedDate ) { | 341 | if ( mHasCompletedDate ) { |
342 | // qDebug("has completed data - return "); | 342 | // qDebug("has completed data - return "); |
343 | return; | 343 | return; |
344 | } | 344 | } |
345 | mHasCompletedDate = true; | 345 | mHasCompletedDate = true; |
346 | mPercentComplete = 100; | 346 | mPercentComplete = 100; |
347 | mCompleted = getEvenTime(completed); | 347 | mCompleted = getEvenTime(completed); |
348 | updated(); | 348 | updated(); |
349 | } | 349 | } |
350 | 350 | ||
351 | bool Todo::hasCompletedDate() const | 351 | bool Todo::hasCompletedDate() const |
352 | { | 352 | { |
353 | return mHasCompletedDate; | 353 | return mHasCompletedDate; |
354 | } | 354 | } |
355 | 355 | ||
356 | int Todo::percentComplete() const | 356 | int Todo::percentComplete() const |
357 | { | 357 | { |
358 | return mPercentComplete; | 358 | return mPercentComplete; |
359 | } | 359 | } |
360 | 360 | ||
361 | void Todo::setPercentComplete(int v) | 361 | void 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 | } |
368 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 368 | QDateTime 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 | } |
403 | if ( enabled ) { | 403 | if ( enabled ) { |
404 | if ( alarmStart > QDateTime::currentDateTime() ) { | 404 | if ( alarmStart > QDateTime::currentDateTime() ) { |
405 | *ok = true; | 405 | *ok = true; |
406 | * offset = off; | 406 | * offset = off; |
407 | return alarmStart; | 407 | return alarmStart; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | *ok = false; | 410 | *ok = false; |
411 | return QDateTime (); | 411 | return QDateTime (); |
412 | 412 | ||
413 | } | 413 | } |
414 | 414 | ||