author | zautrix <zautrix> | 2005-06-10 20:13:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-10 20:13:31 (UTC) |
commit | cdc55afb3d2c3ebd970843b7dce02acb1e6a189b (patch) (unidiff) | |
tree | 45f3bfa69a72de4e8b53bbcb2414478ec65cd183 /libkcal/event.cpp | |
parent | 31fed261955dcb25d06052a8154ac4cc630b0f7d (diff) | |
download | kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.zip kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.gz kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.bz2 |
many preparations for multiple calendars
-rw-r--r-- | libkcal/event.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 9b99855..7cd81fa 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -112,110 +112,112 @@ void Event::setDtEnd(const QDateTime &dtEnd) | |||
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 | return dtStart(); | 123 | return dtStart(); |
124 | } | 124 | } |
125 | 125 | ||
126 | QString Event::dtEndTimeStr() const | 126 | QString Event::dtEndTimeStr() const |
127 | { | 127 | { |
128 | return KGlobal::locale()->formatTime(mDtEnd.time()); | 128 | return KGlobal::locale()->formatTime(mDtEnd.time()); |
129 | } | 129 | } |
130 | 130 | ||
131 | QString Event::dtEndDateStr(bool shortfmt) const | 131 | QString Event::dtEndDateStr(bool shortfmt) const |
132 | { | 132 | { |
133 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); | 133 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); |
134 | } | 134 | } |
135 | 135 | ||
136 | QString Event::dtEndStr(bool shortfmt) const | 136 | QString Event::dtEndStr(bool shortfmt) const |
137 | { | 137 | { |
138 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); | 138 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); |
139 | } | 139 | } |
140 | 140 | ||
141 | void Event::setHasEndDate(bool b) | 141 | void Event::setHasEndDate(bool b) |
142 | { | 142 | { |
143 | mHasEndDate = b; | 143 | mHasEndDate = b; |
144 | } | 144 | } |
145 | 145 | ||
146 | bool Event::hasEndDate() const | 146 | bool Event::hasEndDate() const |
147 | { | 147 | { |
148 | return mHasEndDate; | 148 | return mHasEndDate; |
149 | } | 149 | } |
150 | 150 | ||
151 | bool Event::isMultiDay() const | 151 | bool Event::isMultiDay() const |
152 | { | 152 | { |
153 | bool multi = !(dtStart().date() == dtEnd().date()); | 153 | bool multi = !(dtStart().date() == dtEnd().date()); |
154 | return multi; | 154 | return multi; |
155 | } | 155 | } |
156 | 156 | ||
157 | void Event::setTransparency(Event::Transparency transparency) | 157 | void Event::setTransparency(Event::Transparency transparency) |
158 | { | 158 | { |
159 | if (mReadOnly) return; | 159 | if (mReadOnly) return; |
160 | mTransparency = transparency; | 160 | mTransparency = transparency; |
161 | updated(); | 161 | updated(); |
162 | } | 162 | } |
163 | 163 | ||
164 | Event::Transparency Event::transparency() const | 164 | Event::Transparency Event::transparency() const |
165 | { | 165 | { |
166 | return mTransparency; | 166 | return mTransparency; |
167 | } | 167 | } |
168 | 168 | ||
169 | void Event::setDuration(int seconds) | 169 | void Event::setDuration(int seconds) |
170 | { | 170 | { |
171 | setHasEndDate(false); | 171 | setHasEndDate(false); |
172 | Incidence::setDuration(seconds); | 172 | Incidence::setDuration(seconds); |
173 | } | 173 | } |
174 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 174 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
175 | { | 175 | { |
176 | 176 | *ok = false; | |
177 | if ( !alarmEnabled() ) | ||
178 | return QDateTime (); | ||
177 | bool yes; | 179 | bool yes; |
178 | QDateTime incidenceStart = getNextOccurence( start_dt, &yes ); | 180 | QDateTime incidenceStart = getNextOccurence( start_dt, &yes ); |
179 | if ( ! yes || cancelled() ) { | 181 | if ( ! yes || cancelled() ) { |
180 | *ok = false; | 182 | *ok = false; |
181 | return QDateTime (); | 183 | return QDateTime (); |
182 | } | 184 | } |
183 | 185 | ||
184 | bool enabled = false; | 186 | bool enabled = false; |
185 | Alarm* alarm; | 187 | Alarm* alarm; |
186 | int off = 0; | 188 | int off = 0; |
187 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 189 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
188 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 190 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
189 | // *ok = false; | 191 | // *ok = false; |
190 | // return incidenceStart; | 192 | // return incidenceStart; |
191 | // } | 193 | // } |
192 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 194 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
193 | if (alarm->enabled()) { | 195 | if (alarm->enabled()) { |
194 | if ( alarm->hasTime () ) { | 196 | if ( alarm->hasTime () ) { |
195 | if ( alarm->time() < alarmStart ) { | 197 | if ( alarm->time() < alarmStart ) { |
196 | alarmStart = alarm->time(); | 198 | alarmStart = alarm->time(); |
197 | enabled = true; | 199 | enabled = true; |
198 | off = alarmStart.secsTo( incidenceStart ); | 200 | off = alarmStart.secsTo( incidenceStart ); |
199 | } | 201 | } |
200 | 202 | ||
201 | } else { | 203 | } else { |
202 | int secs = alarm->startOffset().asSeconds(); | 204 | int secs = alarm->startOffset().asSeconds(); |
203 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 205 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
204 | alarmStart = incidenceStart.addSecs( secs ); | 206 | alarmStart = incidenceStart.addSecs( secs ); |
205 | enabled = true; | 207 | enabled = true; |
206 | off = -secs; | 208 | off = -secs; |
207 | } | 209 | } |
208 | } | 210 | } |
209 | } | 211 | } |
210 | } | 212 | } |
211 | if ( enabled ) { | 213 | if ( enabled ) { |
212 | if ( alarmStart > start_dt ) { | 214 | if ( alarmStart > start_dt ) { |
213 | *ok = true; | 215 | *ok = true; |
214 | * offset = off; | 216 | * offset = off; |
215 | return alarmStart; | 217 | return alarmStart; |
216 | } | 218 | } |
217 | } | 219 | } |
218 | *ok = false; | 220 | *ok = false; |
219 | return QDateTime (); | 221 | return QDateTime (); |
220 | 222 | ||
221 | } | 223 | } |