summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index de11c13..39921a0 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -178,270 +178,273 @@ void KOEventViewer::setSource(const QString& n)
178 return; 178 return;
179 } 179 }
180 } else { 180 } else {
181 //QTextBrowser::setSource(n); 181 //QTextBrowser::setSource(n);
182 } 182 }
183#endif 183#endif
184} 184}
185void KOEventViewer::mailToAttendees( bool all ) 185void KOEventViewer::mailToAttendees( bool all )
186{ 186{
187 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 187 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
188 if (attendees.count() == 0) return; 188 if (attendees.count() == 0) return;
189 QStringList nameList; 189 QStringList nameList;
190 QStringList emailList; 190 QStringList emailList;
191 QStringList uidList; 191 QStringList uidList;
192 Attendee* a; 192 Attendee* a;
193 for(a=attendees.first();a;a=attendees.next()) { 193 for(a=attendees.first();a;a=attendees.next()) {
194 if ( !all && !a->RSVP() ) continue; 194 if ( !all && !a->RSVP() ) continue;
195 if (!a->email().isEmpty()) { 195 if (!a->email().isEmpty()) {
196 nameList.append (a->name() ); 196 nameList.append (a->name() );
197 emailList.append (a->email() ); 197 emailList.append (a->email() );
198 uidList.append (a->uid() ); 198 uidList.append (a->uid() );
199 } 199 }
200 } 200 }
201 QString uid = "ComposeMailUIpick2"+mMailSubject; 201 QString uid = "ComposeMailUIpick2"+mMailSubject;
202#ifndef DESKTOP_VERSION 202#ifndef DESKTOP_VERSION
203 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 203 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
204#endif 204#endif
205 205
206} 206}
207void KOEventViewer::addTag(const QString & tag,const QString & text) 207void KOEventViewer::addTag(const QString & tag,const QString & text)
208{ 208{
209 int number=text.contains("\n"); 209 int number=text.contains("\n");
210 QString str = "<" + tag + ">"; 210 QString str = "<" + tag + ">";
211 QString tmpText=text; 211 QString tmpText=text;
212 QString tmpStr=str; 212 QString tmpStr=str;
213 if(number !=-1) 213 if(number !=-1)
214 { 214 {
215 if (number > 0) { 215 if (number > 0) {
216 int pos=0; 216 int pos=0;
217 QString tmp; 217 QString tmp;
218 for(int i=0;i<=number;i++) { 218 for(int i=0;i<=number;i++) {
219 pos=tmpText.find("\n"); 219 pos=tmpText.find("\n");
220 tmp=tmpText.left(pos); 220 tmp=tmpText.left(pos);
221 tmpText=tmpText.right(tmpText.length()-pos-1); 221 tmpText=tmpText.right(tmpText.length()-pos-1);
222 tmpStr+=tmp+"<br>"; 222 tmpStr+=tmp+"<br>";
223 } 223 }
224 } 224 }
225 else tmpStr += tmpText; 225 else tmpStr += tmpText;
226 tmpStr+="</" + tag + ">"; 226 tmpStr+="</" + tag + ">";
227 mText.append(tmpStr); 227 mText.append(tmpStr);
228 } 228 }
229 else 229 else
230 { 230 {
231 str += text + "</" + tag + ">"; 231 str += text + "</" + tag + ">";
232 mText.append(str); 232 mText.append(str);
233 } 233 }
234} 234}
235 235
236void KOEventViewer::setColorMode( int m ) 236void KOEventViewer::setColorMode( int m )
237{ 237{
238 mColorMode = m; 238 mColorMode = m;
239} 239}
240void KOEventViewer::appendEvent(Event *event, int mode ) 240void KOEventViewer::appendEvent(Event *event, int mode )
241{ 241{
242 mMailSubject = ""; 242 mMailSubject = "";
243 mCurrentIncidence = event; 243 mCurrentIncidence = event;
244 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 244 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
245 topLevelWidget()->setCaption(i18n("Event Viewer")); 245 topLevelWidget()->setCaption(i18n("Event Viewer"));
246 if ( mode == 0 ) { 246 if ( mode == 0 ) {
247 addTag("h2",event->summary()); 247 addTag("h2",event->summary());
248 } 248 }
249 else { 249 else {
250 if ( mColorMode == 1 ) { 250 if ( mColorMode == 1 ) {
251 mText +="<font color=\"#00A000\">"; 251 mText +="<font color=\"#00A000\">";
252 } 252 }
253 if ( mColorMode == 2 ) { 253 if ( mColorMode == 2 ) {
254 mText +="<font color=\"#C00000\">"; 254 mText +="<font color=\"#C00000\">";
255 } 255 }
256 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 256 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
257 if ( mode == 1 ) { 257 if ( mode == 1 ) {
258 addTag("h2",i18n( "Local: " ) +event->summary()); 258 addTag("h2",i18n( "Local: " ) +event->summary());
259 } else { 259 } else {
260 addTag("h2",i18n( "Remote: " ) +event->summary()); 260 addTag("h2",i18n( "Remote: " ) +event->summary());
261 } 261 }
262 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 262 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
263 if ( mColorMode ) 263 if ( mColorMode )
264 mText += "</font>"; 264 mText += "</font>";
265 } 265 }
266 mMailSubject += i18n( "Meeting " )+ event->summary(); 266 mMailSubject += i18n( "Meeting " )+ event->summary();
267 if (event->cancelled ()) { 267 if (event->cancelled ()) {
268 mText +="<font color=\"#B00000\">"; 268 mText +="<font color=\"#B00000\">";
269 addTag("i",i18n("This event has been cancelled!")); 269 addTag("i",i18n("This event has been cancelled!"));
270 mText.append("<br>"); 270 mText.append("<br>");
271 mText += "</font>"; 271 mText += "</font>";
272 mMailSubject += i18n("(cancelled)"); 272 mMailSubject += i18n("(cancelled)");
273 } 273 }
274 if (!event->location().isEmpty()) { 274 if (!event->location().isEmpty()) {
275 addTag("b",i18n("Location: ")); 275 addTag("b",i18n("Location: "));
276 mText.append(event->location()+"<br>"); 276 mText.append(event->location()+"<br>");
277 mMailSubject += i18n(" at ") + event->location(); 277 mMailSubject += i18n(" at ") + event->location();
278 } 278 }
279 if (event->doesFloat()) { 279 if (event->doesFloat()) {
280 if (event->isMultiDay()) { 280 if (event->isMultiDay()) {
281 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 281 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
282 .arg(event->dtStartDateStr(shortDate)) 282 .arg(event->dtStartDateStr(shortDate))
283 .arg(event->dtEndDateStr(shortDate))); 283 .arg(event->dtEndDateStr(shortDate)));
284 } else { 284 } else {
285 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 285 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
286 } 286 }
287 } else { 287 } else {
288 if (event->isMultiDay()) { 288 if (event->isMultiDay()) {
289 mText.append(i18n("<p><b>From:</b> %1</p> ") 289 mText.append(i18n("<p><b>From:</b> %1</p> ")
290 .arg(event->dtStartStr( shortDate))); 290 .arg(event->dtStartStr( shortDate)));
291 mText.append(i18n("<p><b>To:</b> %1</p>") 291 mText.append(i18n("<p><b>To:</b> %1</p>")
292 .arg(event->dtEndStr(shortDate))); 292 .arg(event->dtEndStr(shortDate)));
293 } else { 293 } else {
294 mText.append(i18n("<p><b>On:</b> %1</p> ") 294 mText.append(i18n("<p><b>On:</b> %1</p> ")
295 .arg(event->dtStartDateStr( shortDate ))); 295 .arg(event->dtStartDateStr( shortDate )));
296 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 296 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
297 .arg(event->dtStartTimeStr()) 297 .arg(event->dtStartTimeStr())
298 .arg(event->dtEndTimeStr())); 298 .arg(event->dtEndTimeStr()));
299 } 299 }
300 } 300 }
301 301
302 if (event->recurrence()->doesRecur()) { 302 if (event->recurrence()->doesRecur()) {
303 303
304 QString recurText = event->recurrence()->recurrenceText(); 304 QString recurText = event->recurrence()->recurrenceText();
305 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 305 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
306 bool last; 306 bool ok;
307 QDate start = QDate::currentDate(); 307 QDate start = QDate::currentDate();
308 QDate next; 308 QDateTime next;
309 next = event->recurrence()->getPreviousDate( start , &last ); 309 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
310 if ( !last ) { 310 if ( ok ) {
311 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
312 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 311 addTag("p",i18n("<b>Next recurrence is on:</b>") );
313 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 312 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
314 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 313 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
315 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
316 314
317 } else { 315 } else {
318 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 316 bool last;
319 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 317 QDate nextd;
318 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
319 if ( last ) {
320 addTag("p",i18n("<b>Last recurrence was on:</b>") );
321 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
322 }
320 } 323 }
321 } else { 324 } else {
322 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 325 mMailSubject += i18n(" - " )+event->dtStartStr( true );
323 326
324 } 327 }
325 328
326 329
327 if (event->isAlarmEnabled()) { 330 if (event->isAlarmEnabled()) {
328 Alarm *alarm =event->alarms().first() ; 331 Alarm *alarm =event->alarms().first() ;
329 QDateTime t = alarm->time(); 332 QDateTime t = alarm->time();
330 int min = t.secsTo( event->dtStart() )/60; 333 int min = t.secsTo( event->dtStart() )/60;
331 QString s =i18n("( %1 min before )").arg( min ); 334 QString s =i18n("( %1 min before )").arg( min );
332 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 335 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
333 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 336 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
334 //addTag("p",s); 337 //addTag("p",s);
335 } 338 }
336 339
337 addTag("b",i18n("Access: ")); 340 addTag("b",i18n("Access: "));
338 mText.append(event->secrecyStr()+"<br>"); 341 mText.append(event->secrecyStr()+"<br>");
339 if (!event->description().isEmpty()) { 342 if (!event->description().isEmpty()) {
340 addTag("p",i18n("<b>Details: </b>")); 343 addTag("p",i18n("<b>Details: </b>"));
341 addTag("p",event->description()); 344 addTag("p",event->description());
342 } 345 }
343 346
344 formatCategories(event); 347 formatCategories(event);
345 348
346 formatReadOnly(event); 349 formatReadOnly(event);
347 formatAttendees(event); 350 formatAttendees(event);
348 351
349 setText(mText); 352 setText(mText);
350 //QWhatsThis::add(this,mText); 353 //QWhatsThis::add(this,mText);
351 354
352} 355}
353 356
354void KOEventViewer::appendTodo(Todo *event, int mode ) 357void KOEventViewer::appendTodo(Todo *event, int mode )
355{ 358{
356 mMailSubject = ""; 359 mMailSubject = "";
357 mCurrentIncidence = event; 360 mCurrentIncidence = event;
358 topLevelWidget()->setCaption(i18n("Todo Viewer")); 361 topLevelWidget()->setCaption(i18n("Todo Viewer"));
359 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 362 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
360 if (mode == 0 ) 363 if (mode == 0 )
361 addTag("h2",event->summary()); 364 addTag("h2",event->summary());
362 else { 365 else {
363 if ( mColorMode == 1 ) { 366 if ( mColorMode == 1 ) {
364 mText +="<font color=\"#00A000\">"; 367 mText +="<font color=\"#00A000\">";
365 } 368 }
366 if ( mColorMode == 2 ) { 369 if ( mColorMode == 2 ) {
367 mText +="<font color=\"#B00000\">"; 370 mText +="<font color=\"#B00000\">";
368 } 371 }
369 if ( mode == 1 ) { 372 if ( mode == 1 ) {
370 addTag("h2",i18n( "Local: " ) +event->summary()); 373 addTag("h2",i18n( "Local: " ) +event->summary());
371 } else { 374 } else {
372 addTag("h2",i18n( "Remote: " ) +event->summary()); 375 addTag("h2",i18n( "Remote: " ) +event->summary());
373 } 376 }
374 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 377 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
375 if ( mColorMode ) 378 if ( mColorMode )
376 mText += "</font>"; 379 mText += "</font>";
377 } 380 }
378 mMailSubject += i18n( "Todo " )+ event->summary(); 381 mMailSubject += i18n( "Todo " )+ event->summary();
379 382
380 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 383 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
381 mText +="<font color=\"#B00000\">"; 384 mText +="<font color=\"#B00000\">";
382 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); 385 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) );
383 mText += "</font>"; 386 mText += "</font>";
384 } else { 387 } else {
385 mText.append(i18n("<p><i>%1 % completed</i></p>") 388 mText.append(i18n("<p><i>%1 % completed</i></p>")
386 .arg(event->percentComplete())); 389 .arg(event->percentComplete()));
387 } 390 }
388 391
389 if (event->cancelled ()) { 392 if (event->cancelled ()) {
390 mText +="<font color=\"#B00000\">"; 393 mText +="<font color=\"#B00000\">";
391 addTag("i",i18n("This todo has been cancelled!")); 394 addTag("i",i18n("This todo has been cancelled!"));
392 mText.append("<br>"); 395 mText.append("<br>");
393 mText += "</font>"; 396 mText += "</font>";
394 mMailSubject += i18n("(cancelled)"); 397 mMailSubject += i18n("(cancelled)");
395 } 398 }
396 399
397 if (!event->location().isEmpty()) { 400 if (!event->location().isEmpty()) {
398 addTag("b",i18n("Location: ")); 401 addTag("b",i18n("Location: "));
399 mText.append(event->location()+"<br>"); 402 mText.append(event->location()+"<br>");
400 mMailSubject += i18n(" at ") + event->location(); 403 mMailSubject += i18n(" at ") + event->location();
401 } 404 }
402 if (event->hasStartDate()) { 405 if (event->hasStartDate()) {
403 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 406 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
404 } 407 }
405 if (event->hasDueDate()) { 408 if (event->hasDueDate()) {
406 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 409 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
407 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 410 mMailSubject += i18n(" - " )+event->dtDueStr( true );
408 } 411 }
409 addTag("b",i18n("Access: ")); 412 addTag("b",i18n("Access: "));
410 mText.append(event->secrecyStr()+"<br>"); 413 mText.append(event->secrecyStr()+"<br>");
411 if (!event->description().isEmpty()) { 414 if (!event->description().isEmpty()) {
412 addTag("p",i18n("<b>Details: </b>")); 415 addTag("p",i18n("<b>Details: </b>"));
413 addTag("p",event->description()); 416 addTag("p",event->description());
414 } 417 }
415 418
416 formatCategories(event); 419 formatCategories(event);
417 420
418 mText.append(i18n("<p><b>Priority:</b> %2</p>") 421 mText.append(i18n("<p><b>Priority:</b> %2</p>")
419 .arg(QString::number(event->priority()))); 422 .arg(QString::number(event->priority())));
420 423
421 formatReadOnly(event); 424 formatReadOnly(event);
422 formatAttendees(event); 425 formatAttendees(event);
423 if ( event->relatedTo() ) { 426 if ( event->relatedTo() ) {
424 addTag("b",i18n("Parent todo:<br>")); 427 addTag("b",i18n("Parent todo:<br>"));
425 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 428 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
426 } 429 }
427 QPtrList<Incidence> Relations = event->relations(); 430 QPtrList<Incidence> Relations = event->relations();
428 Incidence *to; 431 Incidence *to;
429 if ( Relations.first() ) 432 if ( Relations.first() )
430 addTag("b",i18n("Sub todos:<br>")); 433 addTag("b",i18n("Sub todos:<br>"));
431 for (to=Relations.first();to;to=Relations.next()) { 434 for (to=Relations.first();to;to=Relations.next()) {
432 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 435 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
433 436
434 } 437 }
435 setText(mText); 438 setText(mText);
436} 439}
437 440
438void KOEventViewer::formatCategories(Incidence *event) 441void KOEventViewer::formatCategories(Incidence *event)
439{ 442{
440 if (!event->categoriesStr().isEmpty()) { 443 if (!event->categoriesStr().isEmpty()) {
441 if (event->categories().count() == 1) { 444 if (event->categories().count() == 1) {
442 addTag("h3",i18n("Category")); 445 addTag("h3",i18n("Category"));
443 } else { 446 } else {
444 addTag("h3",i18n("Categories")); 447 addTag("h3",i18n("Categories"));
445 } 448 }
446 addTag("p",event->categoriesStr()); 449 addTag("p",event->categoriesStr());
447 } 450 }