-rw-r--r-- | libopie/pim/oevent.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp index 3ba8a52..28cf873 100644 --- a/libopie/pim/oevent.cpp +++ b/libopie/pim/oevent.cpp | |||
@@ -1,28 +1,29 @@ | |||
1 | #include <qshared.h> | 1 | #include <qshared.h> |
2 | 2 | ||
3 | #include <qpe/palmtopuidgen.h> | 3 | #include <qpe/palmtopuidgen.h> |
4 | #include <qpe/categories.h> | 4 | #include <qpe/categories.h> |
5 | #include <qpe/stringutil.h> | ||
5 | 6 | ||
6 | #include "orecur.h" | 7 | #include "orecur.h" |
7 | #include "opimresolver.h" | 8 | #include "opimresolver.h" |
8 | #include "opimnotifymanager.h" | 9 | #include "opimnotifymanager.h" |
9 | 10 | ||
10 | #include "oevent.h" | 11 | #include "oevent.h" |
11 | 12 | ||
12 | int OCalendarHelper::week( const QDate& date) { | 13 | int OCalendarHelper::week( const QDate& date) { |
13 | // Calculates the week this date is in within that | 14 | // Calculates the week this date is in within that |
14 | // month. Equals the "row" is is in in the month view | 15 | // month. Equals the "row" is is in in the month view |
15 | int week = 1; | 16 | int week = 1; |
16 | QDate tmp( date.year(), date.month(), 1 ); | 17 | QDate tmp( date.year(), date.month(), 1 ); |
17 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) | 18 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) |
18 | ++week; | 19 | ++week; |
19 | 20 | ||
20 | week += ( date.day() - 1 ) / 7; | 21 | week += ( date.day() - 1 ) / 7; |
21 | 22 | ||
22 | return week; | 23 | return week; |
23 | } | 24 | } |
24 | int OCalendarHelper::ocurrence( const QDate& date) { | 25 | int OCalendarHelper::ocurrence( const QDate& date) { |
25 | // calculates the number of occurrances of this day of the | 26 | // calculates the number of occurrances of this day of the |
26 | // week till the given date (e.g 3rd Wednesday of the month) | 27 | // week till the given date (e.g 3rd Wednesday of the month) |
27 | return ( date.day() - 1 ) / 7 + 1; | 28 | return ( date.day() - 1 ) / 7 + 1; |
28 | } | 29 | } |
@@ -189,58 +190,88 @@ QDateTime OEvent::endDateTimeInZone()const { | |||
189 | } | 190 | } |
190 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 191 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
191 | changeOrModify(); | 192 | changeOrModify(); |
192 | data->end = dt; | 193 | data->end = dt; |
193 | } | 194 | } |
194 | bool OEvent::isMultipleDay()const { | 195 | bool OEvent::isMultipleDay()const { |
195 | return data->end.date().day() - data->start.date().day(); | 196 | return data->end.date().day() - data->start.date().day(); |
196 | } | 197 | } |
197 | bool OEvent::isAllDay()const { | 198 | bool OEvent::isAllDay()const { |
198 | return data->isAllDay; | 199 | return data->isAllDay; |
199 | } | 200 | } |
200 | void OEvent::setAllDay( bool allDay ) { | 201 | void OEvent::setAllDay( bool allDay ) { |
201 | changeOrModify(); | 202 | changeOrModify(); |
202 | data->isAllDay = allDay; | 203 | data->isAllDay = allDay; |
203 | if (allDay ) data->timezone = "UTC"; | 204 | if (allDay ) data->timezone = "UTC"; |
204 | } | 205 | } |
205 | void OEvent::setTimeZone( const QString& tz ) { | 206 | void OEvent::setTimeZone( const QString& tz ) { |
206 | changeOrModify(); | 207 | changeOrModify(); |
207 | data->timezone = tz; | 208 | data->timezone = tz; |
208 | } | 209 | } |
209 | QString OEvent::timeZone()const { | 210 | QString OEvent::timeZone()const { |
210 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
211 | return data->timezone; | 212 | return data->timezone; |
212 | } | 213 | } |
213 | bool OEvent::match( const QRegExp& )const { | 214 | bool OEvent::match( const QRegExp& re )const { |
214 | // FIXME | 215 | if (data->description.contains( re ) ) |
216 | return true; | ||
217 | if ( data->note.contains( re ) ) | ||
218 | return true; | ||
219 | if ( data->location.contains( re ) ) | ||
220 | return true; | ||
221 | if ( data->start.toString().contains( re ) ) | ||
222 | return true; | ||
223 | if ( data->end.toString().contains( re ) ) | ||
224 | return true; | ||
215 | return false; | 225 | return false; |
216 | } | 226 | } |
217 | QString OEvent::toRichText()const { | 227 | QString OEvent::toRichText()const { |
218 | // FIXME | 228 | QString text; |
219 | return "OEvent test"; | 229 | if ( !description().isEmpty() ) { |
230 | text += "<b>" + QObject::tr( "Description:") + "</b><br>"; | ||
231 | text += Qtopia::escapeString(description() ). | ||
232 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
233 | } | ||
234 | if ( startDateTime().isValid() ) { | ||
235 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | ||
236 | text += Qtopia::escapeString(startDateTime().toString() ). | ||
237 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
238 | } | ||
239 | if ( endDateTime().isValid() ) { | ||
240 | text += "<b>" + QObject::tr( "End:") + "</b> "; | ||
241 | text += Qtopia::escapeString(endDateTime().toString() ). | ||
242 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
243 | } | ||
244 | if ( !note().isEmpty() ) { | ||
245 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | ||
246 | text += note(); | ||
247 | // text += Qtopia::escapeString(note() ). | ||
248 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
249 | } | ||
250 | return text; | ||
220 | } | 251 | } |
221 | QString OEvent::toShortText()const { | 252 | QString OEvent::toShortText()const { |
222 | return "OEvent shotText"; | 253 | return description(); |
223 | } | 254 | } |
224 | QString OEvent::type()const { | 255 | QString OEvent::type()const { |
225 | return QString::fromLatin1("OEvent"); | 256 | return QString::fromLatin1("OEvent"); |
226 | } | 257 | } |
227 | QString OEvent::recordField( int /*id */ )const { | 258 | QString OEvent::recordField( int /*id */ )const { |
228 | return QString::null; | 259 | return QString::null; |
229 | } | 260 | } |
230 | int OEvent::rtti() { | 261 | int OEvent::rtti() { |
231 | return OPimResolver::DateBook; | 262 | return OPimResolver::DateBook; |
232 | } | 263 | } |
233 | bool OEvent::loadFromStream( QDataStream& ) { | 264 | bool OEvent::loadFromStream( QDataStream& ) { |
234 | return true; | 265 | return true; |
235 | } | 266 | } |
236 | bool OEvent::saveToStream( QDataStream& )const { | 267 | bool OEvent::saveToStream( QDataStream& )const { |
237 | return true; | 268 | return true; |
238 | } | 269 | } |
239 | void OEvent::changeOrModify() { | 270 | void OEvent::changeOrModify() { |
240 | if ( data->count != 1 ) { | 271 | if ( data->count != 1 ) { |
241 | data->deref(); | 272 | data->deref(); |
242 | Data* d2 = new Data; | 273 | Data* d2 = new Data; |
243 | d2->description = data->description; | 274 | d2->description = data->description; |
244 | d2->location = data->location; | 275 | d2->location = data->location; |
245 | 276 | ||
246 | if (data->manager ) | 277 | if (data->manager ) |