-rw-r--r-- | korganizer/komonthview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 1 |
3 files changed, 2 insertions, 4 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6646b98..4cff23a 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -227,1043 +227,1043 @@ void MonthViewItem::paint(QPainter *p) | |||
227 | int yPos; | 227 | int yPos; |
228 | int pmheight = size; | 228 | int pmheight = size; |
229 | if( pmheight < fm.height() ) | 229 | if( pmheight < fm.height() ) |
230 | yPos = fm.ascent() + fm.leading()/2; | 230 | yPos = fm.ascent() + fm.leading()/2; |
231 | else | 231 | else |
232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
233 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 233 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
235 | p->drawText( x, yPos, text() ); | 235 | p->drawText( x, yPos, text() ); |
236 | if ( mIncidence->cancelled() ) { | 236 | if ( mIncidence->cancelled() ) { |
237 | int wid = fm.width( text() ); | 237 | int wid = fm.width( text() ); |
238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
239 | } | 239 | } |
240 | 240 | ||
241 | } | 241 | } |
242 | 242 | ||
243 | int MonthViewItem::height(const QListBox *lb) const | 243 | int MonthViewItem::height(const QListBox *lb) const |
244 | { | 244 | { |
245 | return lb->fontMetrics().lineSpacing()+1; | 245 | return lb->fontMetrics().lineSpacing()+1; |
246 | } | 246 | } |
247 | 247 | ||
248 | int MonthViewItem::width(const QListBox *lb) const | 248 | int MonthViewItem::width(const QListBox *lb) const |
249 | { | 249 | { |
250 | int size = PIXMAP_SIZE; | 250 | int size = PIXMAP_SIZE; |
251 | if ( QApplication::desktop()->width() < 300 ) | 251 | if ( QApplication::desktop()->width() < 300 ) |
252 | size = 3; | 252 | size = 3; |
253 | int x = 1; | 253 | int x = 1; |
254 | if ( mInfo ) { | 254 | if ( mInfo ) { |
255 | x += size + 1; | 255 | x += size + 1; |
256 | } | 256 | } |
257 | if( mRecur ) { | 257 | if( mRecur ) { |
258 | x += size+1; | 258 | x += size+1; |
259 | } | 259 | } |
260 | if( mAlarm ) { | 260 | if( mAlarm ) { |
261 | x += size+1; | 261 | x += size+1; |
262 | } | 262 | } |
263 | if( mReply ) { | 263 | if( mReply ) { |
264 | x += size+1; | 264 | x += size+1; |
265 | } | 265 | } |
266 | 266 | ||
267 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 267 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 271 | MonthViewCell::MonthViewCell( KOMonthView *parent) |
272 | : QWidget( parent ), | 272 | : QWidget( parent ), |
273 | mMonthView( parent ) | 273 | mMonthView( parent ) |
274 | { | 274 | { |
275 | 275 | ||
276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
277 | 277 | ||
278 | // mLabel = new QLabel( this );QPushButton | 278 | // mLabel = new QLabel( this );QPushButton |
279 | mLabel = new QPushButton( this ); | 279 | mLabel = new QPushButton( this ); |
280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
281 | //mLabel->setLineWidth( 1 ); | 281 | //mLabel->setLineWidth( 1 ); |
282 | //mLabel->setAlignment( AlignCenter ); | 282 | //mLabel->setAlignment( AlignCenter ); |
283 | mLabel->setFlat( true ); | 283 | mLabel->setFlat( true ); |
284 | mItemList = new KNoScrollListBox( this ); | 284 | mItemList = new KNoScrollListBox( this ); |
285 | mItemList->setMinimumSize( 10, 10 ); | 285 | mItemList->setMinimumSize( 10, 10 ); |
286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
287 | mItemList->setLineWidth( 1 ); | 287 | mItemList->setLineWidth( 1 ); |
288 | topLayout->addWidget( mItemList ); | 288 | topLayout->addWidget( mItemList ); |
289 | mLabel->raise(); | 289 | mLabel->raise(); |
290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
291 | mStandardPalette = palette(); | 291 | mStandardPalette = palette(); |
292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
293 | 293 | ||
294 | enableScrollBars( false ); | 294 | enableScrollBars( false ); |
295 | updateConfig(); | 295 | updateConfig(); |
296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
299 | SLOT( defaultAction( QListBoxItem * ) ) ); | 299 | SLOT( defaultAction( QListBoxItem * ) ) ); |
300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
301 | const QPoint &) ), | 301 | const QPoint &) ), |
302 | SLOT( contextMenu( QListBoxItem * ) ) ); | 302 | SLOT( contextMenu( QListBoxItem * ) ) ); |
303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
304 | SLOT( selection( QListBoxItem * ) ) ); | 304 | SLOT( selection( QListBoxItem * ) ) ); |
305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
306 | SLOT( cellClicked( QListBoxItem * ) ) ); | 306 | SLOT( cellClicked( QListBoxItem * ) ) ); |
307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
308 | SLOT( selection( QListBoxItem * ) ) ); | 308 | SLOT( selection( QListBoxItem * ) ) ); |
309 | } | 309 | } |
310 | #ifdef DESKTOP_VERSION | 310 | #ifdef DESKTOP_VERSION |
311 | QToolTipGroup *MonthViewCell::toolTipGroup() | 311 | QToolTipGroup *MonthViewCell::toolTipGroup() |
312 | { | 312 | { |
313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
314 | return mToolTipGroup; | 314 | return mToolTipGroup; |
315 | } | 315 | } |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | void MonthViewCell::setDate( const QDate &date ) | 318 | void MonthViewCell::setDate( const QDate &date ) |
319 | { | 319 | { |
320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
321 | mDate = date; | 321 | mDate = date; |
322 | 322 | ||
323 | 323 | ||
324 | 324 | ||
325 | //resizeEvent( 0 ); | 325 | //resizeEvent( 0 ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QDate MonthViewCell::date() const | 328 | QDate MonthViewCell::date() const |
329 | { | 329 | { |
330 | return mDate; | 330 | return mDate; |
331 | } | 331 | } |
332 | 332 | ||
333 | void MonthViewCell::setPrimary( bool primary ) | 333 | void MonthViewCell::setPrimary( bool primary ) |
334 | { | 334 | { |
335 | mPrimary = primary; | 335 | mPrimary = primary; |
336 | //setMyPalette(); | 336 | //setMyPalette(); |
337 | } | 337 | } |
338 | void MonthViewCell::setMyPalette() | 338 | void MonthViewCell::setMyPalette() |
339 | { | 339 | { |
340 | 340 | ||
341 | if ( mHoliday) { | 341 | if ( mHoliday) { |
342 | setPalette( mHolidayPalette ); | 342 | setPalette( mHolidayPalette ); |
343 | } else { | 343 | } else { |
344 | if ( mPrimary ) { | 344 | if ( mPrimary ) { |
345 | setPalette( mPrimaryPalette ); | 345 | setPalette( mPrimaryPalette ); |
346 | } else { | 346 | } else { |
347 | setPalette( mNonPrimaryPalette ); | 347 | setPalette( mNonPrimaryPalette ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | QPalette pal = palette(); | 350 | QPalette pal = palette(); |
351 | 351 | ||
352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
353 | } | 353 | } |
354 | QPalette MonthViewCell::getPalette () | 354 | QPalette MonthViewCell::getPalette () |
355 | { | 355 | { |
356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
357 | return mStandardPalette; | 357 | return mStandardPalette; |
358 | if ( mHoliday) { | 358 | if ( mHoliday) { |
359 | return mHolidayPalette ; | 359 | return mHolidayPalette ; |
360 | } else { | 360 | } else { |
361 | if ( mPrimary ) { | 361 | if ( mPrimary ) { |
362 | return mPrimaryPalette ; | 362 | return mPrimaryPalette ; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | return mNonPrimaryPalette; | 365 | return mNonPrimaryPalette; |
366 | } | 366 | } |
367 | bool MonthViewCell::isPrimary() const | 367 | bool MonthViewCell::isPrimary() const |
368 | { | 368 | { |
369 | return mPrimary; | 369 | return mPrimary; |
370 | } | 370 | } |
371 | 371 | ||
372 | void MonthViewCell::setHoliday( bool holiday ) | 372 | void MonthViewCell::setHoliday( bool holiday ) |
373 | { | 373 | { |
374 | mHoliday = holiday; | 374 | mHoliday = holiday; |
375 | //setMyPalette(); | 375 | //setMyPalette(); |
376 | } | 376 | } |
377 | 377 | ||
378 | void MonthViewCell::setHoliday( const QString &holiday ) | 378 | void MonthViewCell::setHoliday( const QString &holiday ) |
379 | { | 379 | { |
380 | mHolidayString = holiday; | 380 | mHolidayString = holiday; |
381 | 381 | ||
382 | if ( !holiday.isEmpty() ) { | 382 | if ( !holiday.isEmpty() ) { |
383 | setHoliday( true ); | 383 | setHoliday( true ); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
387 | { | 387 | { |
388 | 388 | ||
389 | e->ignore(); | 389 | e->ignore(); |
390 | 390 | ||
391 | } | 391 | } |
392 | void MonthViewCell::clear() | 392 | void MonthViewCell::clear() |
393 | { | 393 | { |
394 | mItemList->clear(); | 394 | mItemList->clear(); |
395 | QApplication::removePostedEvents ( mItemList ); | 395 | QApplication::removePostedEvents ( mItemList ); |
396 | QApplication::removePostedEvents ( mLabel ); | 396 | QApplication::removePostedEvents ( mLabel ); |
397 | QApplication::removePostedEvents ( this ); | 397 | QApplication::removePostedEvents ( this ); |
398 | } | 398 | } |
399 | 399 | ||
400 | void MonthViewCell::startUpdateCell() | 400 | void MonthViewCell::startUpdateCell() |
401 | { | 401 | { |
402 | 402 | ||
403 | if ( !mMonthView->isUpdatePossible() ) | 403 | if ( !mMonthView->isUpdatePossible() ) |
404 | return; | 404 | return; |
405 | /* | 405 | /* |
406 | if ( !isVisible() ){ | 406 | if ( !isVisible() ){ |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | */ | 409 | */ |
410 | // qDebug("MonthViewCell::updateCell() "); | 410 | // qDebug("MonthViewCell::updateCell() "); |
411 | setPrimary( mDate.month()%2 ); | 411 | setPrimary( mDate.month()%2 ); |
412 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 412 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
413 | if ( mDate == QDate::currentDate() ) { | 413 | if ( mDate == QDate::currentDate() ) { |
414 | mItemList->setLineWidth( 3 ); | 414 | mItemList->setLineWidth( 3 ); |
415 | } else { | 415 | } else { |
416 | mItemList->setLineWidth( 1 ); | 416 | mItemList->setLineWidth( 1 ); |
417 | } | 417 | } |
418 | mItemList->clear(); | 418 | mItemList->clear(); |
419 | 419 | ||
420 | #ifdef DESKTOP_VERSION | 420 | #ifdef DESKTOP_VERSION |
421 | QToolTip::remove(this); | 421 | QToolTip::remove(this); |
422 | #endif | 422 | #endif |
423 | mToolTip = ""; | 423 | mToolTip = ""; |
424 | //qApp->processEvents(); | 424 | //qApp->processEvents(); |
425 | if ( !mHolidayString.isEmpty() ) { | 425 | if ( !mHolidayString.isEmpty() ) { |
426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
427 | item->setPalette( mHolidayPalette ); | 427 | item->setPalette( mHolidayPalette ); |
428 | mItemList->insertItem( item ); | 428 | mItemList->insertItem( item ); |
429 | mToolTip += mHolidayString+"\n"; | 429 | mToolTip += mHolidayString+"\n"; |
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | void MonthViewCell::insertEvent(Event *event) | 433 | void MonthViewCell::insertEvent(Event *event) |
434 | { | 434 | { |
435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
437 | return; | 437 | return; |
438 | else | 438 | else |
439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | if ( event->categories().contains("Holiday") || | 443 | if ( event->categories().contains("Holiday") || |
444 | event->categories().contains(i18n("Holiday"))) { | 444 | event->categories().contains(i18n("Holiday"))) { |
445 | setHoliday( true ); | 445 | setHoliday( true ); |
446 | if ( mDate.dayOfWeek() == 7 ) | 446 | if ( mDate.dayOfWeek() == 7 ) |
447 | mItemList->setLineWidth( 3 ); | 447 | mItemList->setLineWidth( 3 ); |
448 | } | 448 | } |
449 | QString text; | 449 | QString text; |
450 | if (event->isMultiDay()) { | 450 | if (event->isMultiDay()) { |
451 | QString prefix = "<->"; | 451 | QString prefix = "<->"; |
452 | if ( event->doesRecur() ) { | 452 | if ( event->doesRecur() ) { |
453 | if ( event->recursOn( mDate) ) | 453 | if ( event->recursOn( mDate) ) |
454 | prefix ="->" ; | 454 | prefix ="->" ; |
455 | else { | 455 | else { |
456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
457 | if ( event->recursOn( mDate.addDays( -days)) ) | 457 | if ( event->recursOn( mDate.addDays( -days)) ) |
458 | prefix ="<-" ; | 458 | prefix ="<-" ; |
459 | } | 459 | } |
460 | 460 | ||
461 | } else { | 461 | } else { |
462 | if (mDate == event->dtStart().date()) { | 462 | if (mDate == event->dtStart().date()) { |
463 | prefix ="->" ; | 463 | prefix ="->" ; |
464 | } else if (mDate == event->dtEnd().date()) { | 464 | } else if (mDate == event->dtEnd().date()) { |
465 | prefix ="<-" ; | 465 | prefix ="<-" ; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | text = prefix + event->summary(); | 468 | text = prefix + event->summary(); |
469 | mToolTip += text; | 469 | mToolTip += text; |
470 | } else { | 470 | } else { |
471 | if (event->doesFloat()) { | 471 | if (event->doesFloat()) { |
472 | text = event->summary(); | 472 | text = event->summary(); |
473 | mToolTip += text; | 473 | mToolTip += text; |
474 | } | 474 | } |
475 | else { | 475 | else { |
476 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 476 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
477 | text += " " + event->summary(); | 477 | text += " " + event->summary(); |
478 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 478 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 482 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
483 | QPalette pal; | 483 | QPalette pal; |
484 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 484 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
485 | QStringList categories = event->categories(); | 485 | QStringList categories = event->categories(); |
486 | QString cat = categories.first(); | 486 | QString cat = categories.first(); |
487 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 487 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
488 | pal = getPalette(); | 488 | pal = getPalette(); |
489 | if (cat.isEmpty()) { | 489 | if (cat.isEmpty()) { |
490 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 490 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
491 | } else { | 491 | } else { |
492 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 492 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
493 | } | 493 | } |
494 | 494 | ||
495 | } else { | 495 | } else { |
496 | if (cat.isEmpty()) { | 496 | if (cat.isEmpty()) { |
497 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 497 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
498 | } else { | 498 | } else { |
499 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 499 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | 502 | ||
503 | } else { | 503 | } else { |
504 | pal = mStandardPalette ; | 504 | pal = mStandardPalette ; |
505 | } | 505 | } |
506 | item->setPalette( pal ); | 506 | item->setPalette( pal ); |
507 | item->setRecur( event->recurrence()->doesRecur() ); | 507 | item->setRecur( event->recurrence()->doesRecur() ); |
508 | item->setAlarm( event->isAlarmEnabled() ); | 508 | item->setAlarm( event->isAlarmEnabled() ); |
509 | item->setMoreInfo( event->description().length() > 0 ); | 509 | item->setMoreInfo( event->description().length() > 0 ); |
510 | #ifdef DESKTOP_VERSION | 510 | #ifdef DESKTOP_VERSION |
511 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 511 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
512 | KOPrefs::instance()->email()); | 512 | KOPrefs::instance()->email()); |
513 | if ( me != 0 ) { | 513 | if ( me != 0 ) { |
514 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 514 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
515 | item->setReply(true); | 515 | item->setReply(true); |
516 | else | 516 | else |
517 | item->setReply(false); | 517 | item->setReply(false); |
518 | } else | 518 | } else |
519 | item->setReply(false); | 519 | item->setReply(false); |
520 | #endif | 520 | #endif |
521 | mItemList->insertItem( item ); | 521 | mItemList->insertItem( item ); |
522 | mToolTip += "\n"; | 522 | mToolTip += "\n"; |
523 | } | 523 | } |
524 | void MonthViewCell::insertTodo(Todo *todo) | 524 | void MonthViewCell::insertTodo(Todo *todo) |
525 | { | 525 | { |
526 | QString text; | 526 | QString text; |
527 | if (todo->hasDueDate()) { | 527 | if (todo->hasDueDate()) { |
528 | if (!todo->doesFloat()) { | 528 | if (!todo->doesFloat()) { |
529 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 529 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
530 | text += " "; | 530 | text += " "; |
531 | } | 531 | } |
532 | } | 532 | } |
533 | text += i18n("To-Do: %1").arg(todo->summary()); | 533 | text += i18n("To-Do: %1").arg(todo->summary()); |
534 | 534 | ||
535 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 535 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
536 | //item->setPalette( mStandardPalette ); | 536 | //item->setPalette( mStandardPalette ); |
537 | QPalette pal; | 537 | QPalette pal; |
538 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 538 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
539 | QStringList categories = todo->categories(); | 539 | QStringList categories = todo->categories(); |
540 | QString cat = categories.first(); | 540 | QString cat = categories.first(); |
541 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 541 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
542 | pal = getPalette(); | 542 | pal = getPalette(); |
543 | if (cat.isEmpty()) { | 543 | if (cat.isEmpty()) { |
544 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 544 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
545 | } else { | 545 | } else { |
546 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 546 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
547 | } | 547 | } |
548 | 548 | ||
549 | } else { | 549 | } else { |
550 | if (cat.isEmpty()) { | 550 | if (cat.isEmpty()) { |
551 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 551 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
552 | } else { | 552 | } else { |
553 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 553 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | } else { | 557 | } else { |
558 | pal = mStandardPalette ; | 558 | pal = mStandardPalette ; |
559 | } | 559 | } |
560 | item->setPalette( pal ); | 560 | item->setPalette( pal ); |
561 | mItemList->insertItem( item ); | 561 | mItemList->insertItem( item ); |
562 | mToolTip += text+"\n"; | 562 | mToolTip += text+"\n"; |
563 | } | 563 | } |
564 | void MonthViewCell::finishUpdateCell() | 564 | void MonthViewCell::finishUpdateCell() |
565 | { | 565 | { |
566 | #ifdef DESKTOP_VERSION | 566 | #ifdef DESKTOP_VERSION |
567 | if (mToolTip != "") | 567 | if (mToolTip != "") |
568 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 568 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
569 | #endif | 569 | #endif |
570 | 570 | ||
571 | //setMyPalette(); | 571 | //setMyPalette(); |
572 | setMyPalette(); | 572 | setMyPalette(); |
573 | QString text; | 573 | QString text; |
574 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 574 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
575 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 575 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
576 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 576 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
577 | mLabel->resize( mLabelBigSize ); | 577 | mLabel->resize( mLabelBigSize ); |
578 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 578 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
579 | } else { | 579 | } else { |
580 | mLabel->resize( mLabelSize ); | 580 | mLabel->resize( mLabelSize ); |
581 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 581 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
582 | } | 582 | } |
583 | 583 | ||
584 | mLabel->setText( text ); | 584 | mLabel->setText( text ); |
585 | resizeEvent( 0 ); | 585 | resizeEvent( 0 ); |
586 | } | 586 | } |
587 | void MonthViewCell::updateCell() | 587 | void MonthViewCell::updateCell() |
588 | { | 588 | { |
589 | if ( !mMonthView->isUpdatePossible() ) | 589 | if ( !mMonthView->isUpdatePossible() ) |
590 | return; | 590 | return; |
591 | startUpdateCell(); | 591 | startUpdateCell(); |
592 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 592 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
593 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 593 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
594 | Event *event; | 594 | Event *event; |
595 | for( event = events.first(); event; event = events.next() ) { // for event | 595 | for( event = events.first(); event; event = events.next() ) { // for event |
596 | insertEvent(event); | 596 | insertEvent(event); |
597 | } | 597 | } |
598 | // insert due todos | 598 | // insert due todos |
599 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 599 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
600 | Todo *todo; | 600 | Todo *todo; |
601 | for(todo = todos.first(); todo; todo = todos.next()) { | 601 | for(todo = todos.first(); todo; todo = todos.next()) { |
602 | insertTodo( todo ); | 602 | insertTodo( todo ); |
603 | } | 603 | } |
604 | finishUpdateCell(); | 604 | finishUpdateCell(); |
605 | // if ( isVisible()) | 605 | // if ( isVisible()) |
606 | //qApp->processEvents(); | 606 | //qApp->processEvents(); |
607 | } | 607 | } |
608 | 608 | ||
609 | void MonthViewCell::updateConfig() | 609 | void MonthViewCell::updateConfig() |
610 | { | 610 | { |
611 | qDebug("MonthViewCell::updateConfig() "); | ||
612 | setFont( KOPrefs::instance()->mMonthViewFont ); | 611 | setFont( KOPrefs::instance()->mMonthViewFont ); |
613 | 612 | ||
614 | QFontMetrics fm( font() ); | 613 | QFontMetrics fm( font() ); |
615 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 614 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
616 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 615 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
617 | mHolidayPalette = mStandardPalette; | 616 | mHolidayPalette = mStandardPalette; |
618 | mPrimaryPalette = mStandardPalette; | 617 | mPrimaryPalette = mStandardPalette; |
619 | mNonPrimaryPalette = mStandardPalette; | 618 | mNonPrimaryPalette = mStandardPalette; |
620 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 619 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
621 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 620 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
622 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 621 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
623 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 622 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
624 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 623 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
625 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 624 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
626 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 625 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
627 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 626 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
628 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 627 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
629 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 628 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
630 | } | 629 | } |
631 | updateCell(); | 630 | //updateCell(); |
632 | } | 631 | } |
633 | 632 | ||
634 | void MonthViewCell::enableScrollBars( bool enabled ) | 633 | void MonthViewCell::enableScrollBars( bool enabled ) |
635 | { | 634 | { |
636 | if ( enabled ) { | 635 | if ( enabled ) { |
637 | mItemList->setVScrollBarMode(QScrollView::Auto); | 636 | mItemList->setVScrollBarMode(QScrollView::Auto); |
638 | mItemList->setHScrollBarMode(QScrollView::Auto); | 637 | mItemList->setHScrollBarMode(QScrollView::Auto); |
639 | } else { | 638 | } else { |
640 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 639 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
641 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 640 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
642 | } | 641 | } |
643 | } | 642 | } |
644 | 643 | ||
645 | Incidence *MonthViewCell::selectedIncidence() | 644 | Incidence *MonthViewCell::selectedIncidence() |
646 | { | 645 | { |
647 | int index = mItemList->currentItem(); | 646 | int index = mItemList->currentItem(); |
648 | if ( index < 0 ) return 0; | 647 | if ( index < 0 ) return 0; |
649 | 648 | ||
650 | MonthViewItem *item = | 649 | MonthViewItem *item = |
651 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 650 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
652 | 651 | ||
653 | if ( !item ) return 0; | 652 | if ( !item ) return 0; |
654 | 653 | ||
655 | return item->incidence(); | 654 | return item->incidence(); |
656 | } | 655 | } |
657 | 656 | ||
658 | QDate MonthViewCell::selectedIncidenceDate() | 657 | QDate MonthViewCell::selectedIncidenceDate() |
659 | { | 658 | { |
660 | QDate qd; | 659 | QDate qd; |
661 | int index = mItemList->currentItem(); | 660 | int index = mItemList->currentItem(); |
662 | if ( index < 0 ) return qd; | 661 | if ( index < 0 ) return qd; |
663 | 662 | ||
664 | MonthViewItem *item = | 663 | MonthViewItem *item = |
665 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 664 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
666 | 665 | ||
667 | if ( !item ) return qd; | 666 | if ( !item ) return qd; |
668 | 667 | ||
669 | return item->incidenceDate(); | 668 | return item->incidenceDate(); |
670 | } | 669 | } |
671 | 670 | ||
672 | void MonthViewCell::deselect() | 671 | void MonthViewCell::deselect() |
673 | { | 672 | { |
674 | mItemList->clearSelection(); | 673 | mItemList->clearSelection(); |
675 | enableScrollBars( false ); | 674 | enableScrollBars( false ); |
676 | // updateCell(); | 675 | // updateCell(); |
677 | } | 676 | } |
678 | void MonthViewCell::select() | 677 | void MonthViewCell::select() |
679 | { | 678 | { |
680 | ;// updateCell(); | 679 | ;// updateCell(); |
681 | } | 680 | } |
682 | 681 | ||
683 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 682 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
684 | { | 683 | { |
685 | if ( !mMonthView->isUpdatePossible() ) | 684 | if ( !mMonthView->isUpdatePossible() ) |
686 | return; | 685 | return; |
687 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
688 | if ( !isVisible() ){ | 687 | if ( !isVisible() ){ |
689 | return; | 688 | return; |
690 | } | 689 | } |
691 | #endif | 690 | #endif |
692 | int size = height() - mLabel->height(); | 691 | int size = height() - mLabel->height(); |
693 | if ( size > 0 ) | 692 | if ( size > 0 ) |
694 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 693 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
695 | size = width() - mLabel->width(); | 694 | size = width() - mLabel->width(); |
696 | if ( size > 0 ) | 695 | if ( size > 0 ) |
697 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 696 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
698 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 697 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
699 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 698 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
700 | } | 699 | } |
701 | 700 | ||
702 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 701 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
703 | { | 702 | { |
704 | if ( !item ) return; | 703 | if ( !item ) return; |
705 | 704 | ||
706 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 705 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
707 | Incidence *incidence = eventItem->incidence(); | 706 | Incidence *incidence = eventItem->incidence(); |
708 | if ( incidence ) mMonthView->defaultAction( incidence ); | 707 | if ( incidence ) mMonthView->defaultAction( incidence ); |
709 | } | 708 | } |
710 | void MonthViewCell::showDay() | 709 | void MonthViewCell::showDay() |
711 | { | 710 | { |
712 | emit showDaySignal( date() ); | 711 | emit showDaySignal( date() ); |
713 | } | 712 | } |
714 | void MonthViewCell::newEvent() | 713 | void MonthViewCell::newEvent() |
715 | { | 714 | { |
716 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 715 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
717 | emit newEventSignal( dt ); | 716 | emit newEventSignal( dt ); |
718 | } | 717 | } |
719 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 718 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
720 | { | 719 | { |
721 | static QListBoxItem * lastClicked = 0; | 720 | static QListBoxItem * lastClicked = 0; |
722 | if ( item == 0 ) { | 721 | if ( item == 0 ) { |
723 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 722 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
724 | emit newEventSignal( dt ); | 723 | emit newEventSignal( dt ); |
725 | return; | 724 | return; |
726 | } | 725 | } |
727 | /* | 726 | /* |
728 | if ( lastClicked ) | 727 | if ( lastClicked ) |
729 | if ( ! item ) { | 728 | if ( ! item ) { |
730 | if ( lastClicked->listBox() != item->listBox() ) | 729 | if ( lastClicked->listBox() != item->listBox() ) |
731 | lastClicked->listBox()->clearSelection(); | 730 | lastClicked->listBox()->clearSelection(); |
732 | } | 731 | } |
733 | */ | 732 | */ |
734 | 733 | ||
735 | mMonthView->setSelectedCell( this ); | 734 | mMonthView->setSelectedCell( this ); |
736 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); | 735 | if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); |
737 | select(); | 736 | select(); |
738 | } | 737 | } |
739 | 738 | ||
740 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 739 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
741 | { | 740 | { |
742 | if ( !item ) return; | 741 | if ( !item ) return; |
743 | 742 | ||
744 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 743 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
745 | Incidence *incidence = eventItem->incidence(); | 744 | Incidence *incidence = eventItem->incidence(); |
746 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 745 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
747 | } | 746 | } |
748 | 747 | ||
749 | void MonthViewCell::selection( QListBoxItem *item ) | 748 | void MonthViewCell::selection( QListBoxItem *item ) |
750 | { | 749 | { |
751 | if ( !item ) return; | 750 | if ( !item ) return; |
752 | 751 | ||
753 | mMonthView->setSelectedCell( this ); | 752 | mMonthView->setSelectedCell( this ); |
754 | } | 753 | } |
755 | 754 | ||
756 | 755 | ||
757 | // ******************************************************************************* | 756 | // ******************************************************************************* |
758 | // ******************************************************************************* | 757 | // ******************************************************************************* |
759 | // ******************************************************************************* | 758 | // ******************************************************************************* |
760 | 759 | ||
761 | 760 | ||
762 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 761 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
763 | : KOEventView( calendar, parent, name ), | 762 | : KOEventView( calendar, parent, name ), |
764 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 763 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
765 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 764 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
766 | { | 765 | { |
767 | 766 | ||
768 | updatePossible = false; | 767 | updatePossible = false; |
769 | mCells.setAutoDelete( true ); | 768 | mCells.setAutoDelete( true ); |
770 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 769 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
771 | // mDayLayout = new QGridLayout( this ); | 770 | // mDayLayout = new QGridLayout( this ); |
772 | // create the day of the week labels (Sun, Mon, etc) and add them to | 771 | // create the day of the week labels (Sun, Mon, etc) and add them to |
773 | // the layout. | 772 | // the layout. |
774 | mDayLabels.resize( mDaysPerWeek ); | 773 | mDayLabels.resize( mDaysPerWeek ); |
775 | QFont bfont = font(); | 774 | QFont bfont = font(); |
776 | if ( QApplication::desktop()->width() < 650 ) { | 775 | if ( QApplication::desktop()->width() < 650 ) { |
777 | bfont.setPointSize( bfont.pointSize() - 2 ); | 776 | bfont.setPointSize( bfont.pointSize() - 2 ); |
778 | } | 777 | } |
779 | bfont.setBold( true ); | 778 | bfont.setBold( true ); |
780 | int i; | 779 | int i; |
781 | 780 | ||
782 | for( i = 0; i < mDaysPerWeek; i++ ) { | 781 | for( i = 0; i < mDaysPerWeek; i++ ) { |
783 | QLabel *label = new QLabel( this ); | 782 | QLabel *label = new QLabel( this ); |
784 | label->setFont(bfont); | 783 | label->setFont(bfont); |
785 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 784 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
786 | label->setLineWidth(1); | 785 | label->setLineWidth(1); |
787 | label->setAlignment(AlignCenter); | 786 | label->setAlignment(AlignCenter); |
788 | mDayLabels.insert( i, label ); | 787 | mDayLabels.insert( i, label ); |
789 | } | 788 | } |
790 | 789 | ||
791 | bfont.setBold( false ); | 790 | bfont.setBold( false ); |
792 | mWeekLabels.resize( mNumWeeks+1 ); | 791 | mWeekLabels.resize( mNumWeeks+1 ); |
793 | for( i = 0; i < mNumWeeks+1; i++ ) { | 792 | for( i = 0; i < mNumWeeks+1; i++ ) { |
794 | KOWeekButton *label = new KOWeekButton( this ); | 793 | KOWeekButton *label = new KOWeekButton( this ); |
795 | label->setFont(bfont); | 794 | label->setFont(bfont); |
796 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | 795 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); |
797 | label->setFlat(true); | 796 | label->setFlat(true); |
798 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | 797 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); |
799 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 798 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
800 | //label->setLineWidth(1); | 799 | //label->setLineWidth(1); |
801 | //label->setAlignment(AlignCenter); | 800 | //label->setAlignment(AlignCenter); |
802 | mWeekLabels.insert( i, label ); | 801 | mWeekLabels.insert( i, label ); |
803 | } | 802 | } |
804 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 803 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
805 | int row, col; | 804 | int row, col; |
806 | mCells.resize( mNumCells ); | 805 | mCells.resize( mNumCells ); |
807 | for( row = 0; row < mNumWeeks; ++row ) { | 806 | for( row = 0; row < mNumWeeks; ++row ) { |
808 | for( col = 0; col < mDaysPerWeek; ++col ) { | 807 | for( col = 0; col < mDaysPerWeek; ++col ) { |
809 | MonthViewCell *cell = new MonthViewCell( this ); | 808 | MonthViewCell *cell = new MonthViewCell( this ); |
810 | mCells.insert( row * mDaysPerWeek + col, cell ); | 809 | mCells.insert( row * mDaysPerWeek + col, cell ); |
811 | 810 | ||
812 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 811 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
813 | SLOT( defaultAction( Incidence * ) ) ); | 812 | SLOT( defaultAction( Incidence * ) ) ); |
814 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 813 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
815 | SIGNAL( newEventSignal( QDateTime ) ) ); | 814 | SIGNAL( newEventSignal( QDateTime ) ) ); |
816 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 815 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
817 | SIGNAL( showDaySignal( QDate ) ) ); | 816 | SIGNAL( showDaySignal( QDate ) ) ); |
818 | } | 817 | } |
819 | } | 818 | } |
820 | 819 | ||
821 | mContextMenu = eventPopup(); | 820 | mContextMenu = eventPopup(); |
822 | // updateConfig(); //useless here | 821 | // updateConfig(); //useless here |
823 | 822 | ||
824 | emit incidenceSelected( 0 ); | 823 | emit incidenceSelected( 0 ); |
825 | } | 824 | } |
826 | 825 | ||
827 | KOMonthView::~KOMonthView() | 826 | KOMonthView::~KOMonthView() |
828 | { | 827 | { |
829 | delete mContextMenu; | 828 | delete mContextMenu; |
830 | } | 829 | } |
831 | 830 | ||
832 | int KOMonthView::maxDatesHint() | 831 | int KOMonthView::maxDatesHint() |
833 | { | 832 | { |
834 | return mNumCells; | 833 | return mNumCells; |
835 | } | 834 | } |
836 | 835 | ||
837 | int KOMonthView::currentDateCount() | 836 | int KOMonthView::currentDateCount() |
838 | { | 837 | { |
839 | return mNumCells; | 838 | return mNumCells; |
840 | } | 839 | } |
841 | 840 | ||
842 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 841 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
843 | { | 842 | { |
844 | QPtrList<Incidence> selected; | 843 | QPtrList<Incidence> selected; |
845 | 844 | ||
846 | if ( mSelectedCell ) { | 845 | if ( mSelectedCell ) { |
847 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 846 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
848 | if ( incidence ) selected.append( incidence ); | 847 | if ( incidence ) selected.append( incidence ); |
849 | } | 848 | } |
850 | 849 | ||
851 | return selected; | 850 | return selected; |
852 | } | 851 | } |
853 | 852 | ||
854 | DateList KOMonthView::selectedDates() | 853 | DateList KOMonthView::selectedDates() |
855 | { | 854 | { |
856 | DateList selected; | 855 | DateList selected; |
857 | 856 | ||
858 | if ( mSelectedCell ) { | 857 | if ( mSelectedCell ) { |
859 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 858 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
860 | if ( qd.isValid() ) selected.append( qd ); | 859 | if ( qd.isValid() ) selected.append( qd ); |
861 | } | 860 | } |
862 | 861 | ||
863 | return selected; | 862 | return selected; |
864 | } | 863 | } |
865 | 864 | ||
866 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 865 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
867 | const QDate &td) | 866 | const QDate &td) |
868 | { | 867 | { |
869 | #ifndef KORG_NOPRINTER | 868 | #ifndef KORG_NOPRINTER |
870 | calPrinter->preview(CalPrinter::Month, fd, td); | 869 | calPrinter->preview(CalPrinter::Month, fd, td); |
871 | #endif | 870 | #endif |
872 | } | 871 | } |
873 | 872 | ||
874 | void KOMonthView::updateConfig() | 873 | void KOMonthView::updateConfig() |
875 | { | 874 | { |
876 | 875 | ||
877 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 876 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
878 | 877 | ||
879 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 878 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
880 | mWidthLongDayLabel = 0; | 879 | mWidthLongDayLabel = 0; |
881 | 880 | ||
882 | for (int i = 0; i < 7; i++) { | 881 | for (int i = 0; i < 7; i++) { |
883 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 882 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
884 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 883 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
885 | } | 884 | } |
886 | bool temp = mShowSatSunComp ; | 885 | bool temp = mShowSatSunComp ; |
887 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 886 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
888 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 887 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
889 | computeLayout(); | 888 | computeLayout(); |
890 | updateDayLabels(); | 889 | updateDayLabels(); |
891 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 890 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
892 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 891 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
893 | //resizeEvent( 0 ); | 892 | //resizeEvent( 0 ); |
894 | for (uint i = 0; i < mCells.count(); ++i) { | 893 | for (uint i = 0; i < mCells.count(); ++i) { |
895 | mCells[i]->updateConfig(); | 894 | mCells[i]->updateConfig(); |
896 | } | 895 | } |
897 | #ifdef DESKTOP_VERSION | 896 | #ifdef DESKTOP_VERSION |
898 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 897 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
899 | #endif | 898 | #endif |
899 | updateView(); | ||
900 | } | 900 | } |
901 | 901 | ||
902 | void KOMonthView::updateDayLabels() | 902 | void KOMonthView::updateDayLabels() |
903 | { | 903 | { |
904 | 904 | ||
905 | for (int i = 0; i < 7; i++) { | 905 | for (int i = 0; i < 7; i++) { |
906 | if (mWeekStartsMonday) { | 906 | if (mWeekStartsMonday) { |
907 | bool show = mShortDayLabels; | 907 | bool show = mShortDayLabels; |
908 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 908 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
909 | show = true; | 909 | show = true; |
910 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 910 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
911 | } else { | 911 | } else { |
912 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 912 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
913 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 913 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
914 | 914 | ||
915 | } | 915 | } |
916 | } | 916 | } |
917 | } | 917 | } |
918 | 918 | ||
919 | void KOMonthView::showDates(const QDate &start, const QDate &) | 919 | void KOMonthView::showDates(const QDate &start, const QDate &) |
920 | { | 920 | { |
921 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 921 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
922 | 922 | ||
923 | 923 | ||
924 | mStartDate = start; | 924 | mStartDate = start; |
925 | 925 | ||
926 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 926 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
927 | 927 | ||
928 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 928 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
929 | mStartDate = mStartDate.addDays( -1 ); | 929 | mStartDate = mStartDate.addDays( -1 ); |
930 | } | 930 | } |
931 | 931 | ||
932 | bool primary = false; | 932 | bool primary = false; |
933 | uint i; | 933 | uint i; |
934 | for( i = 0; i < mCells.size(); ++i ) { | 934 | for( i = 0; i < mCells.size(); ++i ) { |
935 | QDate date = mStartDate.addDays( i ); | 935 | QDate date = mStartDate.addDays( i ); |
936 | mCells[i]->setDate( date ); | 936 | mCells[i]->setDate( date ); |
937 | 937 | ||
938 | #ifndef KORG_NOPLUGINS | 938 | #ifndef KORG_NOPLUGINS |
939 | // add holiday, if present | 939 | // add holiday, if present |
940 | QString hstring(KOCore::self()->holiday(date)); | 940 | QString hstring(KOCore::self()->holiday(date)); |
941 | mCells[i]->setHoliday( hstring ); | 941 | mCells[i]->setHoliday( hstring ); |
942 | #endif | 942 | #endif |
943 | 943 | ||
944 | } | 944 | } |
945 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 945 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
946 | for( i = 0; i < 6; ++i ) { | 946 | for( i = 0; i < 6; ++i ) { |
947 | int wno; | 947 | int wno; |
948 | // remember, according to ISO 8601, the first week of the year is the | 948 | // remember, according to ISO 8601, the first week of the year is the |
949 | // first week that contains a thursday. Thus we must subtract off 4, | 949 | // first week that contains a thursday. Thus we must subtract off 4, |
950 | // not just 1. | 950 | // not just 1. |
951 | int dayOfYear = date.dayOfYear(); | 951 | int dayOfYear = date.dayOfYear(); |
952 | if (dayOfYear % 7 != 0) | 952 | if (dayOfYear % 7 != 0) |
953 | wno = dayOfYear / 7 + 1; | 953 | wno = dayOfYear / 7 + 1; |
954 | else | 954 | else |
955 | wno =dayOfYear / 7; | 955 | wno =dayOfYear / 7; |
956 | mWeekLabels[i]->setWeekNum( wno ); | 956 | mWeekLabels[i]->setWeekNum( wno ); |
957 | date = date.addDays( 7 ); | 957 | date = date.addDays( 7 ); |
958 | } | 958 | } |
959 | updateView(); | 959 | updateView(); |
960 | } | 960 | } |
961 | 961 | ||
962 | void KOMonthView::showEvents(QPtrList<Event>) | 962 | void KOMonthView::showEvents(QPtrList<Event>) |
963 | { | 963 | { |
964 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 964 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
965 | } | 965 | } |
966 | 966 | ||
967 | void KOMonthView::changeEventDisplay(Event *, int) | 967 | void KOMonthView::changeEventDisplay(Event *, int) |
968 | { | 968 | { |
969 | // this should be re-written to be much more efficient, but this | 969 | // this should be re-written to be much more efficient, but this |
970 | // quick-and-dirty-hack gets the job done for right now. | 970 | // quick-and-dirty-hack gets the job done for right now. |
971 | updateView(); | 971 | updateView(); |
972 | } | 972 | } |
973 | 973 | ||
974 | void KOMonthView::updateView() | 974 | void KOMonthView::updateView() |
975 | { | 975 | { |
976 | 976 | ||
977 | if ( !updatePossible ) | 977 | if ( !updatePossible ) |
978 | return; | 978 | return; |
979 | QTime ti; | 979 | QTime ti; |
980 | ti.start(); | 980 | ti.start(); |
981 | #if 1 | 981 | #if 1 |
982 | int i; | 982 | int i; |
983 | for( i = 0; i < mCells.count(); ++i ) { | 983 | for( i = 0; i < mCells.count(); ++i ) { |
984 | mCells[i]->startUpdateCell(); | 984 | mCells[i]->startUpdateCell(); |
985 | } | 985 | } |
986 | 986 | ||
987 | QPtrList<Event> events = calendar()->events(); | 987 | QPtrList<Event> events = calendar()->events(); |
988 | Event *event; | 988 | Event *event; |
989 | QDateTime dt; | 989 | QDateTime dt; |
990 | bool ok; | 990 | bool ok; |
991 | int timeSpan = mCells.size()-1; | 991 | int timeSpan = mCells.size()-1; |
992 | QDate endDate = mStartDate.addDays( timeSpan ); | 992 | QDate endDate = mStartDate.addDays( timeSpan ); |
993 | for( event = events.first(); event; event = events.next() ) { // for event | 993 | for( event = events.first(); event; event = events.next() ) { // for event |
994 | if ( event->doesRecur() ) { | 994 | if ( event->doesRecur() ) { |
995 | bool last; | 995 | bool last; |
996 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 996 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
997 | QDateTime incidenceEnd; | 997 | QDateTime incidenceEnd; |
998 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 998 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
999 | bool invalid = false; | 999 | bool invalid = false; |
1000 | while( true ) { | 1000 | while( true ) { |
1001 | if ( incidenceStart.isValid() ) { | 1001 | if ( incidenceStart.isValid() ) { |
1002 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1002 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1003 | int st = incidenceStart.date().daysTo( endDate ); | 1003 | int st = incidenceStart.date().daysTo( endDate ); |
1004 | if ( st >= 0 ) { // start before timeend | 1004 | if ( st >= 0 ) { // start before timeend |
1005 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1005 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1006 | if ( end >= 0 ) { // end after timestart --- got one! | 1006 | if ( end >= 0 ) { // end after timestart --- got one! |
1007 | //normalize | 1007 | //normalize |
1008 | st = timeSpan - st; | 1008 | st = timeSpan - st; |
1009 | if ( st < 0 ) st = 0; | 1009 | if ( st < 0 ) st = 0; |
1010 | if ( end > timeSpan ) end = timeSpan; | 1010 | if ( end > timeSpan ) end = timeSpan; |
1011 | int iii; | 1011 | int iii; |
1012 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1012 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1013 | for ( iii = st;iii<= end;++iii) | 1013 | for ( iii = st;iii<= end;++iii) |
1014 | mCells[iii]->insertEvent( event ); | 1014 | mCells[iii]->insertEvent( event ); |
1015 | } | 1015 | } |
1016 | } | 1016 | } |
1017 | } else { | 1017 | } else { |
1018 | if ( invalid ) | 1018 | if ( invalid ) |
1019 | break; | 1019 | break; |
1020 | invalid = true; | 1020 | invalid = true; |
1021 | //qDebug("invalid %s", event->summary().latin1()); | 1021 | //qDebug("invalid %s", event->summary().latin1()); |
1022 | incidenceStart = QDateTime( mStartDate ); | 1022 | incidenceStart = QDateTime( mStartDate ); |
1023 | } | 1023 | } |
1024 | if ( last ) | 1024 | if ( last ) |
1025 | break; | 1025 | break; |
1026 | bool ok; | 1026 | bool ok; |
1027 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1027 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1028 | if ( ! ok ) | 1028 | if ( ! ok ) |
1029 | break; | 1029 | break; |
1030 | if ( incidenceStart.date() > endDate ) | 1030 | if ( incidenceStart.date() > endDate ) |
1031 | break; | 1031 | break; |
1032 | } | 1032 | } |
1033 | } else { // no recur | 1033 | } else { // no recur |
1034 | int st = event->dtStart().date().daysTo( endDate ); | 1034 | int st = event->dtStart().date().daysTo( endDate ); |
1035 | if ( st >= 0 ) { // start before timeend | 1035 | if ( st >= 0 ) { // start before timeend |
1036 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1036 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1037 | if ( end >= 0 ) { // end after timestart --- got one! | 1037 | if ( end >= 0 ) { // end after timestart --- got one! |
1038 | //normalize | 1038 | //normalize |
1039 | st = timeSpan - st; | 1039 | st = timeSpan - st; |
1040 | if ( st < 0 ) st = 0; | 1040 | if ( st < 0 ) st = 0; |
1041 | if ( end > timeSpan ) end = timeSpan; | 1041 | if ( end > timeSpan ) end = timeSpan; |
1042 | int iii; | 1042 | int iii; |
1043 | for ( iii = st;iii<= end;++iii) | 1043 | for ( iii = st;iii<= end;++iii) |
1044 | mCells[iii]->insertEvent( event ); | 1044 | mCells[iii]->insertEvent( event ); |
1045 | } | 1045 | } |
1046 | } | 1046 | } |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | // insert due todos | 1049 | // insert due todos |
1050 | QPtrList<Todo> todos = calendar()->todos( ); | 1050 | QPtrList<Todo> todos = calendar()->todos( ); |
1051 | Todo *todo; | 1051 | Todo *todo; |
1052 | for(todo = todos.first(); todo; todo = todos.next()) { | 1052 | for(todo = todos.first(); todo; todo = todos.next()) { |
1053 | //insertTodo( todo ); | 1053 | //insertTodo( todo ); |
1054 | if ( todo->hasDueDate() ) { | 1054 | if ( todo->hasDueDate() ) { |
1055 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1055 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1056 | if ( day >= 0 && day < mCells.size() ) { | 1056 | if ( day >= 0 && day < mCells.size() ) { |
1057 | mCells[day]->insertTodo( todo ); | 1057 | mCells[day]->insertTodo( todo ); |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | for( i = 0; i < mCells.count(); ++i ) { | 1062 | for( i = 0; i < mCells.count(); ++i ) { |
1063 | mCells[i]->finishUpdateCell(); | 1063 | mCells[i]->finishUpdateCell(); |
1064 | } | 1064 | } |
1065 | processSelectionChange(); | 1065 | processSelectionChange(); |
1066 | mCells[0]->setFocus(); | 1066 | mCells[0]->setFocus(); |
1067 | 1067 | ||
1068 | 1068 | ||
1069 | #else | 1069 | #else |
1070 | // old code | 1070 | // old code |
1071 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1071 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1072 | int i; | 1072 | int i; |
1073 | for( i = 0; i < mCells.count(); ++i ) { | 1073 | for( i = 0; i < mCells.count(); ++i ) { |
1074 | mCells[i]->updateCell(); | 1074 | mCells[i]->updateCell(); |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | //qDebug("KOMonthView::updateView() "); | 1077 | //qDebug("KOMonthView::updateView() "); |
1078 | processSelectionChange(); | 1078 | processSelectionChange(); |
1079 | // qDebug("---------------------------------------------------------------------+ "); | 1079 | // qDebug("---------------------------------------------------------------------+ "); |
1080 | mCells[0]->setFocus(); | 1080 | mCells[0]->setFocus(); |
1081 | #endif | 1081 | #endif |
1082 | 1082 | ||
1083 | qDebug("update time %d ", ti.elapsed()); | 1083 | qDebug("update time %d ", ti.elapsed()); |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1086 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1087 | { | 1087 | { |
1088 | computeLayout(); | 1088 | computeLayout(); |
1089 | mCells[0]->setFocus(); | 1089 | mCells[0]->setFocus(); |
1090 | } | 1090 | } |
1091 | void KOMonthView::computeLayout() | 1091 | void KOMonthView::computeLayout() |
1092 | { | 1092 | { |
1093 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1093 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1094 | // note this only changes the text if the requested size crosses the | 1094 | // note this only changes the text if the requested size crosses the |
1095 | // threshold between big enough to support the full name and not big | 1095 | // threshold between big enough to support the full name and not big |
1096 | // enough. | 1096 | // enough. |
1097 | 1097 | ||
1098 | int daysToShow = 7; | 1098 | int daysToShow = 7; |
1099 | bool combinedSatSun = false; | 1099 | bool combinedSatSun = false; |
1100 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1100 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1101 | daysToShow = 6; | 1101 | daysToShow = 6; |
1102 | combinedSatSun = true; | 1102 | combinedSatSun = true; |
1103 | } | 1103 | } |
1104 | int tWid = topLevelWidget()->size().width(); | 1104 | int tWid = topLevelWidget()->size().width(); |
1105 | int tHei = topLevelWidget()->size().height(); | 1105 | int tHei = topLevelWidget()->size().height(); |
1106 | 1106 | ||
1107 | int wid = size().width();//e | 1107 | int wid = size().width();//e |
1108 | int hei = size().height()-1; | 1108 | int hei = size().height()-1; |
1109 | 1109 | ||
1110 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1110 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1111 | return; | 1111 | return; |
1112 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1112 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1113 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1113 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1114 | int weeklabelwid = fm.width( "888" ); | 1114 | int weeklabelwid = fm.width( "888" ); |
1115 | wid -= weeklabelwid; | 1115 | wid -= weeklabelwid; |
1116 | 1116 | ||
1117 | int colWid = wid / daysToShow; | 1117 | int colWid = wid / daysToShow; |
1118 | int lastCol = wid - ( colWid*6 ); | 1118 | int lastCol = wid - ( colWid*6 ); |
1119 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1119 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1120 | int cellHei = (hei - dayLabelHei) /6; | 1120 | int cellHei = (hei - dayLabelHei) /6; |
1121 | int colModulo = wid % daysToShow; | 1121 | int colModulo = wid % daysToShow; |
1122 | int rowModulo = (hei- dayLabelHei) % 6; | 1122 | int rowModulo = (hei- dayLabelHei) % 6; |
1123 | //qDebug("rowmod %d ", rowModulo); | 1123 | //qDebug("rowmod %d ", rowModulo); |
1124 | int i; | 1124 | int i; |
1125 | int x,y,w,h; | 1125 | int x,y,w,h; |
1126 | x= 0; | 1126 | x= 0; |
1127 | y= 0; | 1127 | y= 0; |
1128 | w = colWid; | 1128 | w = colWid; |
1129 | h = dayLabelHei ; | 1129 | h = dayLabelHei ; |
1130 | for ( i = 0; i < 7; i++) { | 1130 | for ( i = 0; i < 7; i++) { |
1131 | if ( i == daysToShow-colModulo ) | 1131 | if ( i == daysToShow-colModulo ) |
1132 | ++w; | 1132 | ++w; |
1133 | if ( combinedSatSun ) { | 1133 | if ( combinedSatSun ) { |
1134 | if ( i >= daysToShow-1 ) { | 1134 | if ( i >= daysToShow-1 ) { |
1135 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1135 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1136 | x -= w/2 ; | 1136 | x -= w/2 ; |
1137 | } | 1137 | } |
1138 | else | 1138 | else |
1139 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1139 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1140 | } else | 1140 | } else |
1141 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1141 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1142 | x += w; | 1142 | x += w; |
1143 | } | 1143 | } |
1144 | x= 0; | 1144 | x= 0; |
1145 | y= dayLabelHei; | 1145 | y= dayLabelHei; |
1146 | w = colWid; | 1146 | w = colWid; |
1147 | h = cellHei ; | 1147 | h = cellHei ; |
1148 | for ( i = 0; i < mCells.count(); ++i) { | 1148 | for ( i = 0; i < mCells.count(); ++i) { |
1149 | 1149 | ||
1150 | w = colWid; | 1150 | w = colWid; |
1151 | if ( ((i) % 7) >= 7-colModulo ) { | 1151 | if ( ((i) % 7) >= 7-colModulo ) { |
1152 | ++w; | 1152 | ++w; |
1153 | } | 1153 | } |
1154 | if ( i == (6-rowModulo)*7) | 1154 | if ( i == (6-rowModulo)*7) |
1155 | ++h; | 1155 | ++h; |
1156 | if ( combinedSatSun ) { | 1156 | if ( combinedSatSun ) { |
1157 | if ( (i)%7 >= daysToShow-1 ) { | 1157 | if ( (i)%7 >= daysToShow-1 ) { |
1158 | if ( (i)%7 == daysToShow-1 ) { | 1158 | if ( (i)%7 == daysToShow-1 ) { |
1159 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1159 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1160 | x -= w ;y += h/2; | 1160 | x -= w ;y += h/2; |
1161 | } else { | 1161 | } else { |
1162 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1162 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1163 | y -= h/2; | 1163 | y -= h/2; |
1164 | } | 1164 | } |
1165 | } else | 1165 | } else |
1166 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1166 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1167 | 1167 | ||
1168 | } | 1168 | } |
1169 | else | 1169 | else |
1170 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1170 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1171 | x += w; | 1171 | x += w; |
1172 | if ( x + w/2 > wid ) { | 1172 | if ( x + w/2 > wid ) { |
1173 | x = 0; | 1173 | x = 0; |
1174 | y += h; | 1174 | y += h; |
1175 | } | 1175 | } |
1176 | } | 1176 | } |
1177 | y= dayLabelHei; | 1177 | y= dayLabelHei; |
1178 | h = cellHei ; | 1178 | h = cellHei ; |
1179 | for ( i = 0; i < 6; i++) { | 1179 | for ( i = 0; i < 6; i++) { |
1180 | if ( i == (6-rowModulo)) | 1180 | if ( i == (6-rowModulo)) |
1181 | ++h; | 1181 | ++h; |
1182 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1182 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1183 | y += h; | 1183 | y += h; |
1184 | } | 1184 | } |
1185 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1185 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1186 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1186 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1187 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1187 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1188 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1188 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1189 | updateDayLabels(); | 1189 | updateDayLabels(); |
1190 | bool forceUpdate = !updatePossible; | 1190 | bool forceUpdate = !updatePossible; |
1191 | updatePossible = true; | 1191 | updatePossible = true; |
1192 | if ( forceUpdate ) | 1192 | if ( forceUpdate ) |
1193 | updateView(); | 1193 | updateView(); |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1196 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1197 | { | 1197 | { |
1198 | mContextMenu->showIncidencePopup(incidence); | 1198 | mContextMenu->showIncidencePopup(incidence); |
1199 | /* | 1199 | /* |
1200 | if( incidence && incidence->type() == "Event" ) { | 1200 | if( incidence && incidence->type() == "Event" ) { |
1201 | Event *event = static_cast<Event *>(incidence); | 1201 | Event *event = static_cast<Event *>(incidence); |
1202 | mContextMenu->showEventPopup(event); | 1202 | mContextMenu->showEventPopup(event); |
1203 | } else { | 1203 | } else { |
1204 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1204 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1205 | } | 1205 | } |
1206 | */ | 1206 | */ |
1207 | } | 1207 | } |
1208 | MonthViewCell * KOMonthView::selectedCell( ) | 1208 | MonthViewCell * KOMonthView::selectedCell( ) |
1209 | { | 1209 | { |
1210 | return mSelectedCell; | 1210 | return mSelectedCell; |
1211 | } | 1211 | } |
1212 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1212 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1213 | { | 1213 | { |
1214 | // qDebug("KOMonthView::setSelectedCell "); | 1214 | // qDebug("KOMonthView::setSelectedCell "); |
1215 | if ( mSelectedCell && mSelectedCell != cell ) { | 1215 | if ( mSelectedCell && mSelectedCell != cell ) { |
1216 | MonthViewCell * mvc = mSelectedCell; | 1216 | MonthViewCell * mvc = mSelectedCell; |
1217 | mSelectedCell = cell; | 1217 | mSelectedCell = cell; |
1218 | mvc->deselect(); | 1218 | mvc->deselect(); |
1219 | } else | 1219 | } else |
1220 | mSelectedCell = cell; | 1220 | mSelectedCell = cell; |
1221 | // if ( mSelectedCell ) | 1221 | // if ( mSelectedCell ) |
1222 | // mSelectedCell->select(); | 1222 | // mSelectedCell->select(); |
1223 | if ( !mSelectedCell ) | 1223 | if ( !mSelectedCell ) |
1224 | emit incidenceSelected( 0 ); | 1224 | emit incidenceSelected( 0 ); |
1225 | else | 1225 | else |
1226 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1226 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | void KOMonthView::processSelectionChange() | 1229 | void KOMonthView::processSelectionChange() |
1230 | { | 1230 | { |
1231 | QPtrList<Incidence> incidences = selectedIncidences(); | 1231 | QPtrList<Incidence> incidences = selectedIncidences(); |
1232 | if (incidences.count() > 0) { | 1232 | if (incidences.count() > 0) { |
1233 | emit incidenceSelected( incidences.first() ); | 1233 | emit incidenceSelected( incidences.first() ); |
1234 | } else { | 1234 | } else { |
1235 | emit incidenceSelected( 0 ); | 1235 | emit incidenceSelected( 0 ); |
1236 | } | 1236 | } |
1237 | } | 1237 | } |
1238 | 1238 | ||
1239 | void KOMonthView::clearSelection() | 1239 | void KOMonthView::clearSelection() |
1240 | { | 1240 | { |
1241 | if ( mSelectedCell ) { | 1241 | if ( mSelectedCell ) { |
1242 | mSelectedCell->deselect(); | 1242 | mSelectedCell->deselect(); |
1243 | mSelectedCell = 0; | 1243 | mSelectedCell = 0; |
1244 | } | 1244 | } |
1245 | } | 1245 | } |
1246 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1246 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1247 | { | 1247 | { |
1248 | //qDebug("KOMonthView::keyPressEvent "); | 1248 | //qDebug("KOMonthView::keyPressEvent "); |
1249 | switch(e->key()) { | 1249 | switch(e->key()) { |
1250 | case Key_Up: | 1250 | case Key_Up: |
1251 | { | 1251 | { |
1252 | emit prevMonth(); | 1252 | emit prevMonth(); |
1253 | mCells[0]->setFocus(); | 1253 | mCells[0]->setFocus(); |
1254 | } | 1254 | } |
1255 | e->accept(); | 1255 | e->accept(); |
1256 | break; | 1256 | break; |
1257 | case Key_Down: | 1257 | case Key_Down: |
1258 | { | 1258 | { |
1259 | emit nextMonth(); | 1259 | emit nextMonth(); |
1260 | mCells[0]->setFocus(); | 1260 | mCells[0]->setFocus(); |
1261 | 1261 | ||
1262 | } | 1262 | } |
1263 | e->accept(); | 1263 | e->accept(); |
1264 | break; | 1264 | break; |
1265 | default: | 1265 | default: |
1266 | e->ignore(); | 1266 | e->ignore(); |
1267 | break; | 1267 | break; |
1268 | } | 1268 | } |
1269 | } | 1269 | } |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index c95917f..db23882 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,506 +1,505 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void KOViewManager::showDateView( int view, QDate date) | 102 | void KOViewManager::showDateView( int view, QDate date) |
103 | { | 103 | { |
104 | 104 | ||
105 | //qDebug("date %d %s", view, date.toString().latin1()); | 105 | //qDebug("date %d %s", view, date.toString().latin1()); |
106 | #if 0 | 106 | #if 0 |
107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); | 108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); |
109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); | 109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); |
110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); | 110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); |
111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
112 | #endif | 112 | #endif |
113 | if ( view == 3 ) { | 113 | if ( view == 3 ) { |
114 | mMainView->showDay( date ); | 114 | mMainView->showDay( date ); |
115 | } else if (view == 4 ) { | 115 | } else if (view == 4 ) { |
116 | mMainView->dateNavigator()->selectDates( date, 7 ); | 116 | mMainView->dateNavigator()->selectDates( date, 7 ); |
117 | } else if (view == 5 ) { | 117 | } else if (view == 5 ) { |
118 | mMainView->dateNavigator()->selectDates( date, 14); | 118 | mMainView->dateNavigator()->selectDates( date, 14); |
119 | } else if (view == 6 ) { | 119 | } else if (view == 6 ) { |
120 | mMainView->dateNavigator()->blockSignals( true ); | 120 | mMainView->dateNavigator()->blockSignals( true ); |
121 | showMonthView(); | 121 | showMonthView(); |
122 | qApp->processEvents(); | ||
123 | mMainView->dateNavigator()->selectMonthByDate( date ); | 122 | mMainView->dateNavigator()->selectMonthByDate( date ); |
124 | mMainView->dateNavigator()->blockSignals( false ); | 123 | mMainView->dateNavigator()->blockSignals( false ); |
125 | mMainView->dateNavigator()->selectDate( date ); | 124 | mMainView->dateNavigator()->selectDate( date ); |
126 | } else if (view == 7 ) { | 125 | } else if (view == 7 ) { |
127 | mMainView->dateNavigator()->selectDate( date ); | 126 | mMainView->dateNavigator()->selectDate( date ); |
128 | showJournalView(); | 127 | showJournalView(); |
129 | } else if (view == 8 ) { | 128 | } else if (view == 8 ) { |
130 | globalFlagBlockAgenda = 1; | 129 | globalFlagBlockAgenda = 1; |
131 | if ( mCurrentAgendaView != 3 ) | 130 | if ( mCurrentAgendaView != 3 ) |
132 | mCurrentAgendaView = -1; | 131 | mCurrentAgendaView = -1; |
133 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 132 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
134 | globalFlagBlockAgenda = 2; | 133 | globalFlagBlockAgenda = 2; |
135 | mMainView->dateNavigator()->selectDates( date , | 134 | mMainView->dateNavigator()->selectDates( date , |
136 | KOPrefs::instance()->mNextXDays ); | 135 | KOPrefs::instance()->mNextXDays ); |
137 | mFlagShowNextxDays = true; | 136 | mFlagShowNextxDays = true; |
138 | mCurrentAgendaView = 3 ; | 137 | mCurrentAgendaView = 3 ; |
139 | } | 138 | } |
140 | 139 | ||
141 | #if 0 | 140 | #if 0 |
142 | dateNavigator()->blockSignals( true ); | 141 | dateNavigator()->blockSignals( true ); |
143 | dateNavigator()->selectDate( d ); | 142 | dateNavigator()->selectDate( d ); |
144 | dateNavigator()->blockSignals( false ); | 143 | dateNavigator()->blockSignals( false ); |
145 | mViewManager->showDayView(); | 144 | mViewManager->showDayView(); |
146 | #endif | 145 | #endif |
147 | 146 | ||
148 | } | 147 | } |
149 | 148 | ||
150 | 149 | ||
151 | 150 | ||
152 | void KOViewManager::writeSettings(KConfig *config) | 151 | void KOViewManager::writeSettings(KConfig *config) |
153 | { | 152 | { |
154 | config->setGroup("General"); | 153 | config->setGroup("General"); |
155 | 154 | ||
156 | QString view; | 155 | QString view; |
157 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 156 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
158 | else if (mCurrentView == mMonthView) view = "Month"; | 157 | else if (mCurrentView == mMonthView) view = "Month"; |
159 | else if (mCurrentView == mListView) view = "List"; | 158 | else if (mCurrentView == mListView) view = "List"; |
160 | else if (mCurrentView == mJournalView) view = "Journal"; | 159 | else if (mCurrentView == mJournalView) view = "Journal"; |
161 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 160 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
162 | else if (mCurrentView == mTodoView) view = "Todo"; | 161 | else if (mCurrentView == mTodoView) view = "Todo"; |
163 | else view = "Agenda"; | 162 | else view = "Agenda"; |
164 | 163 | ||
165 | config->writeEntry("Current View",view); | 164 | config->writeEntry("Current View",view); |
166 | 165 | ||
167 | if (mAgendaView) { | 166 | if (mAgendaView) { |
168 | mAgendaView->writeSettings(config); | 167 | mAgendaView->writeSettings(config); |
169 | } | 168 | } |
170 | if (mTimeSpanView) { | 169 | if (mTimeSpanView) { |
171 | mTimeSpanView->writeSettings(config); | 170 | mTimeSpanView->writeSettings(config); |
172 | } | 171 | } |
173 | if (mListView) { | 172 | if (mListView) { |
174 | mListView->writeSettings(config); | 173 | mListView->writeSettings(config); |
175 | } | 174 | } |
176 | if (mTodoView) { | 175 | if (mTodoView) { |
177 | mTodoView->saveLayout(config,"Todo View"); | 176 | mTodoView->saveLayout(config,"Todo View"); |
178 | } | 177 | } |
179 | } | 178 | } |
180 | 179 | ||
181 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 180 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
182 | { | 181 | { |
183 | 182 | ||
184 | //mFlagShowNextxDays = false; | 183 | //mFlagShowNextxDays = false; |
185 | //if(view == mCurrentView) return; | 184 | //if(view == mCurrentView) return; |
186 | if ( view == 0 ) { | 185 | if ( view == 0 ) { |
187 | view = mCurrentView; | 186 | view = mCurrentView; |
188 | if ( view == 0 ) | 187 | if ( view == 0 ) |
189 | return; | 188 | return; |
190 | } | 189 | } |
191 | bool full = fullScreen; | 190 | bool full = fullScreen; |
192 | if(view == mCurrentView && view != mWhatsNextView ) { | 191 | if(view == mCurrentView && view != mWhatsNextView ) { |
193 | if ( mCurrentAgendaView < 0 ) | 192 | if ( mCurrentAgendaView < 0 ) |
194 | return; | 193 | return; |
195 | full = mMainView->leftFrame()->isVisible(); | 194 | full = mMainView->leftFrame()->isVisible(); |
196 | } else { | 195 | } else { |
197 | mCurrentView = view; | 196 | mCurrentView = view; |
198 | // bool full = fullScreen; | 197 | // bool full = fullScreen; |
199 | bool isFull = !mMainView->leftFrame()->isVisible(); | 198 | bool isFull = !mMainView->leftFrame()->isVisible(); |
200 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 199 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
201 | full = true; | 200 | full = true; |
202 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 201 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
203 | full = false; | 202 | full = false; |
204 | } | 203 | } |
205 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 204 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
206 | //raiseCurrentView( full ); | 205 | //raiseCurrentView( full ); |
207 | mMainView->processIncidenceSelection( 0 ); | 206 | mMainView->processIncidenceSelection( 0 ); |
208 | //mMainView->updateView(); | 207 | //mMainView->updateView(); |
209 | raiseCurrentView( full, true ); | 208 | raiseCurrentView( full, true ); |
210 | mMainView->adaptNavigationUnits(); | 209 | mMainView->adaptNavigationUnits(); |
211 | } | 210 | } |
212 | 211 | ||
213 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) | 212 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) |
214 | { | 213 | { |
215 | mCurrentAgendaView = 0; | 214 | mCurrentAgendaView = 0; |
216 | int wid = mMainView->width() ; | 215 | int wid = mMainView->width() ; |
217 | int hei = mMainView->height(); | 216 | int hei = mMainView->height(); |
218 | if ( mCurrentView == mMonthView ) { | 217 | if ( mCurrentView == mMonthView ) { |
219 | mMainView->navigatorBar()->show(); | 218 | mMainView->navigatorBar()->show(); |
220 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 219 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
221 | //mMainView->navigatorBar()->hide(); | 220 | //mMainView->navigatorBar()->hide(); |
222 | } else { | 221 | } else { |
223 | mMainView->navigatorBar()->hide(); | 222 | mMainView->navigatorBar()->hide(); |
224 | } | 223 | } |
225 | if ( fullScreen ) { | 224 | if ( fullScreen ) { |
226 | mMainView->leftFrame()->hide(); | 225 | mMainView->leftFrame()->hide(); |
227 | } else { | 226 | } else { |
228 | mMainView->leftFrame()->show(); | 227 | mMainView->leftFrame()->show(); |
229 | if ( KOPrefs::instance()->mVerticalScreen ) | 228 | if ( KOPrefs::instance()->mVerticalScreen ) |
230 | hei -= mMainView->leftFrame()->height(); | 229 | hei -= mMainView->leftFrame()->height(); |
231 | else | 230 | else |
232 | wid -= mMainView->leftFrame()->width(); | 231 | wid -= mMainView->leftFrame()->width(); |
233 | } | 232 | } |
234 | emit signalFullScreen( !fullScreen ); | 233 | emit signalFullScreen( !fullScreen ); |
235 | if ( callUpdateView ) | 234 | if ( callUpdateView ) |
236 | mMainView->updateView(); | 235 | mMainView->updateView(); |
237 | 236 | ||
238 | if ( globalFlagBlockAgenda == 5 ) { | 237 | if ( globalFlagBlockAgenda == 5 ) { |
239 | globalFlagBlockAgenda = 4; | 238 | globalFlagBlockAgenda = 4; |
240 | globalFlagBlockAgendaItemPaint = 1; | 239 | globalFlagBlockAgendaItemPaint = 1; |
241 | } | 240 | } |
242 | mMainView->viewStack()->raiseWidget(mCurrentView); | 241 | mMainView->viewStack()->raiseWidget(mCurrentView); |
243 | if ( globalFlagBlockAgenda == 4 ) { | 242 | if ( globalFlagBlockAgenda == 4 ) { |
244 | if ( mCurrentView == mAgendaView ) { | 243 | if ( mCurrentView == mAgendaView ) { |
245 | //globalFlagBlockAgenda =1 ; | 244 | //globalFlagBlockAgenda =1 ; |
246 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 245 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
247 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 246 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
248 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 247 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
249 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 248 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
250 | qApp->processEvents(); | 249 | qApp->processEvents(); |
251 | //qDebug("qApp->processEvents() "); | 250 | //qDebug("qApp->processEvents() "); |
252 | globalFlagBlockAgenda = 0; | 251 | globalFlagBlockAgenda = 0; |
253 | mAgendaView->repaintAgenda(); | 252 | mAgendaView->repaintAgenda(); |
254 | 253 | ||
255 | } | 254 | } |
256 | globalFlagBlockAgenda = 0; | 255 | globalFlagBlockAgenda = 0; |
257 | } | 256 | } |
258 | emit signalAgendaView( mCurrentView == mAgendaView ); | 257 | emit signalAgendaView( mCurrentView == mAgendaView ); |
259 | //qDebug("raiseCurrentView ende "); | 258 | //qDebug("raiseCurrentView ende "); |
260 | 259 | ||
261 | } | 260 | } |
262 | 261 | ||
263 | void KOViewManager::updateView() | 262 | void KOViewManager::updateView() |
264 | { | 263 | { |
265 | // qDebug("KOViewManager::updateView() "); | 264 | // qDebug("KOViewManager::updateView() "); |
266 | // if we are updating mTodoView, we get endless recursion | 265 | // if we are updating mTodoView, we get endless recursion |
267 | if ( mTodoView == mCurrentView ) | 266 | if ( mTodoView == mCurrentView ) |
268 | return; | 267 | return; |
269 | if ( mCurrentView ) mCurrentView->updateView(); | 268 | if ( mCurrentView ) mCurrentView->updateView(); |
270 | 269 | ||
271 | } | 270 | } |
272 | 271 | ||
273 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 272 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
274 | { | 273 | { |
275 | // kdDebug() << "KOViewManager::updateView()" << endl; | 274 | // kdDebug() << "KOViewManager::updateView()" << endl; |
276 | 275 | ||
277 | if (mCurrentView) mCurrentView->showDates(start, end); | 276 | if (mCurrentView) mCurrentView->showDates(start, end); |
278 | 277 | ||
279 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); | 278 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); |
280 | } | 279 | } |
281 | 280 | ||
282 | 281 | ||
283 | void KOViewManager::updateWNview() | 282 | void KOViewManager::updateWNview() |
284 | { | 283 | { |
285 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 284 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
286 | mWhatsNextView->updateView(); | 285 | mWhatsNextView->updateView(); |
287 | 286 | ||
288 | } | 287 | } |
289 | void KOViewManager::showWhatsNextView() | 288 | void KOViewManager::showWhatsNextView() |
290 | { | 289 | { |
291 | if (!mWhatsNextView) { | 290 | if (!mWhatsNextView) { |
292 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 291 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
293 | "KOViewManager::WhatsNextView"); | 292 | "KOViewManager::WhatsNextView"); |
294 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 293 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
295 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 294 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
296 | addView(mWhatsNextView); | 295 | addView(mWhatsNextView); |
297 | connect(this, SIGNAL( printWNV() ), | 296 | connect(this, SIGNAL( printWNV() ), |
298 | mWhatsNextView, SLOT( printMe() ) ); | 297 | mWhatsNextView, SLOT( printMe() ) ); |
299 | } | 298 | } |
300 | globalFlagBlockAgenda = 1; | 299 | globalFlagBlockAgenda = 1; |
301 | showView(mWhatsNextView, true ); | 300 | showView(mWhatsNextView, true ); |
302 | //mWhatsNextView->updateView(); | 301 | //mWhatsNextView->updateView(); |
303 | 302 | ||
304 | } | 303 | } |
305 | 304 | ||
306 | void KOViewManager::showListView() | 305 | void KOViewManager::showListView() |
307 | { | 306 | { |
308 | if (!mListView) { | 307 | if (!mListView) { |
309 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 308 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
310 | addView(mListView); | 309 | addView(mListView); |
311 | 310 | ||
312 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 311 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
313 | mMainView, SLOT(showIncidence(Incidence *))); | 312 | mMainView, SLOT(showIncidence(Incidence *))); |
314 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 313 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
315 | mMainView, SLOT(editIncidence(Incidence *))); | 314 | mMainView, SLOT(editIncidence(Incidence *))); |
316 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 315 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
317 | mMainView, SLOT(deleteIncidence(Incidence *))); | 316 | mMainView, SLOT(deleteIncidence(Incidence *))); |
318 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 317 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
319 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 318 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
320 | connect( mListView, SIGNAL( signalNewEvent() ), | 319 | connect( mListView, SIGNAL( signalNewEvent() ), |
321 | mMainView, SLOT( newEvent() ) ); | 320 | mMainView, SLOT( newEvent() ) ); |
322 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 321 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
323 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 322 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
324 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 323 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
325 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 324 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
326 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 325 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
327 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 326 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
328 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 327 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
329 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 328 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
330 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 329 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
331 | } | 330 | } |
332 | // bool temp = mFlagShowNextxDays; | 331 | // bool temp = mFlagShowNextxDays; |
333 | //globalFlagBlockPainting = true; | 332 | //globalFlagBlockPainting = true; |
334 | globalFlagBlockAgenda = 1; | 333 | globalFlagBlockAgenda = 1; |
335 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 334 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
336 | mMainView->setBlockShowDates( true ); | 335 | mMainView->setBlockShowDates( true ); |
337 | mMainView->dateNavigator()->selectMonth(); | 336 | mMainView->dateNavigator()->selectMonth(); |
338 | mMainView->setBlockShowDates( false ); | 337 | mMainView->setBlockShowDates( false ); |
339 | } | 338 | } |
340 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 339 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
341 | //mFlagShowNextxDays = temp; | 340 | //mFlagShowNextxDays = temp; |
342 | } | 341 | } |
343 | 342 | ||
344 | void KOViewManager::showAgendaView( bool fullScreen ) | 343 | void KOViewManager::showAgendaView( bool fullScreen ) |
345 | { | 344 | { |
346 | 345 | ||
347 | mMainView->dialogManager()->hideSearchDialog(); | 346 | mMainView->dialogManager()->hideSearchDialog(); |
348 | // qDebug("KOViewManager::showAgendaView "); | 347 | // qDebug("KOViewManager::showAgendaView "); |
349 | bool full; | 348 | bool full; |
350 | full = fullScreen; | 349 | full = fullScreen; |
351 | if (!mAgendaView) { | 350 | if (!mAgendaView) { |
352 | full = false; | 351 | full = false; |
353 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 352 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
354 | addView(mAgendaView); | 353 | addView(mAgendaView); |
355 | #ifndef DESKTOP_VERSION | 354 | #ifndef DESKTOP_VERSION |
356 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 355 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
357 | #endif | 356 | #endif |
358 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 357 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
359 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 358 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
360 | 359 | ||
361 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 360 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
362 | 361 | ||
363 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 362 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
364 | 363 | ||
365 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 364 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
366 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 365 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
367 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 366 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
368 | mMainView, SLOT(newEvent(QDateTime))); | 367 | mMainView, SLOT(newEvent(QDateTime))); |
369 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 368 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
370 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 369 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
371 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 370 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
372 | mMainView, SLOT(newEvent(QDate))); | 371 | mMainView, SLOT(newEvent(QDate))); |
373 | 372 | ||
374 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 373 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
375 | mMainView, SLOT(editIncidence(Incidence *))); | 374 | mMainView, SLOT(editIncidence(Incidence *))); |
376 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 375 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
377 | mMainView, SLOT(showIncidence(Incidence *))); | 376 | mMainView, SLOT(showIncidence(Incidence *))); |
378 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 377 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
379 | mMainView, SLOT(deleteIncidence(Incidence *))); | 378 | mMainView, SLOT(deleteIncidence(Incidence *))); |
380 | 379 | ||
381 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 380 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
382 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 381 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
383 | 382 | ||
384 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 383 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
385 | mMainView, SLOT( toggleExpand() ) ); | 384 | mMainView, SLOT( toggleExpand() ) ); |
386 | 385 | ||
387 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 386 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
388 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 387 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
389 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 388 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
390 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 389 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
391 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 390 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
392 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 391 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
393 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 392 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
394 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 393 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
395 | SLOT( updateTodo( Todo *, int ) ) ); | 394 | SLOT( updateTodo( Todo *, int ) ) ); |
396 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 395 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
397 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 396 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
398 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 397 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
399 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 398 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
400 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 399 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
401 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 400 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
402 | mAgendaView->readSettings(); | 401 | mAgendaView->readSettings(); |
403 | mAgendaView->updateConfig(); | 402 | mAgendaView->updateConfig(); |
404 | } | 403 | } |
405 | 404 | ||
406 | showView( mAgendaView, full); | 405 | showView( mAgendaView, full); |
407 | 406 | ||
408 | } | 407 | } |
409 | 408 | ||
410 | void KOViewManager::showDayView() | 409 | void KOViewManager::showDayView() |
411 | { | 410 | { |
412 | mFlagShowNextxDays = false; | 411 | mFlagShowNextxDays = false; |
413 | globalFlagBlockLabel = 1; | 412 | globalFlagBlockLabel = 1; |
414 | globalFlagBlockAgenda = 1; | 413 | globalFlagBlockAgenda = 1; |
415 | if ( mCurrentAgendaView != 1 ) | 414 | if ( mCurrentAgendaView != 1 ) |
416 | mCurrentAgendaView = -1; | 415 | mCurrentAgendaView = -1; |
417 | showAgendaView(); | 416 | showAgendaView(); |
418 | qApp->processEvents(); | 417 | qApp->processEvents(); |
419 | globalFlagBlockAgenda = 2; | 418 | globalFlagBlockAgenda = 2; |
420 | globalFlagBlockLabel = 0; | 419 | globalFlagBlockLabel = 0; |
421 | mMainView->dateNavigator()->selectDates( 1 ); | 420 | mMainView->dateNavigator()->selectDates( 1 ); |
422 | mCurrentAgendaView = 1 ; | 421 | mCurrentAgendaView = 1 ; |
423 | 422 | ||
424 | } | 423 | } |
425 | 424 | ||
426 | void KOViewManager::showWorkWeekView() | 425 | void KOViewManager::showWorkWeekView() |
427 | { | 426 | { |
428 | mFlagShowNextxDays = false; | 427 | mFlagShowNextxDays = false; |
429 | globalFlagBlockAgenda = 1; | 428 | globalFlagBlockAgenda = 1; |
430 | globalFlagBlockLabel = 1; | 429 | globalFlagBlockLabel = 1; |
431 | if ( mCurrentAgendaView != 5 ) | 430 | if ( mCurrentAgendaView != 5 ) |
432 | mCurrentAgendaView = -1; | 431 | mCurrentAgendaView = -1; |
433 | showAgendaView(); | 432 | showAgendaView(); |
434 | qApp->processEvents(); | 433 | qApp->processEvents(); |
435 | globalFlagBlockAgenda = 2; | 434 | globalFlagBlockAgenda = 2; |
436 | globalFlagBlockLabel = 0; | 435 | globalFlagBlockLabel = 0; |
437 | mMainView->dateNavigator()->selectWorkWeek(); | 436 | mMainView->dateNavigator()->selectWorkWeek(); |
438 | mCurrentAgendaView = 5 ; | 437 | mCurrentAgendaView = 5 ; |
439 | 438 | ||
440 | } | 439 | } |
441 | 440 | ||
442 | void KOViewManager::showWeekView() | 441 | void KOViewManager::showWeekView() |
443 | { | 442 | { |
444 | /* | 443 | /* |
445 | globalFlagBlockAgenda = 2; | 444 | globalFlagBlockAgenda = 2; |
446 | qDebug("4globalFlagBlockAgenda = 2; "); | 445 | qDebug("4globalFlagBlockAgenda = 2; "); |
447 | //globalFlagBlockPainting = true; | 446 | //globalFlagBlockPainting = true; |
448 | mMainView->dateNavigator()->selectWeek(); | 447 | mMainView->dateNavigator()->selectWeek(); |
449 | showAgendaView(); | 448 | showAgendaView(); |
450 | */ | 449 | */ |
451 | 450 | ||
452 | 451 | ||
453 | mFlagShowNextxDays = false; | 452 | mFlagShowNextxDays = false; |
454 | globalFlagBlockAgenda = 1; | 453 | globalFlagBlockAgenda = 1; |
455 | globalFlagBlockLabel = 1; | 454 | globalFlagBlockLabel = 1; |
456 | if ( mCurrentAgendaView != 7 ) | 455 | if ( mCurrentAgendaView != 7 ) |
457 | mCurrentAgendaView = -1; | 456 | mCurrentAgendaView = -1; |
458 | showAgendaView(); | 457 | showAgendaView(); |
459 | qApp->processEvents(); | 458 | qApp->processEvents(); |
460 | globalFlagBlockAgenda = 2; | 459 | globalFlagBlockAgenda = 2; |
461 | globalFlagBlockLabel = 0; | 460 | globalFlagBlockLabel = 0; |
462 | mMainView->dateNavigator()->selectWeek(); | 461 | mMainView->dateNavigator()->selectWeek(); |
463 | mCurrentAgendaView = 7 ; | 462 | mCurrentAgendaView = 7 ; |
464 | } | 463 | } |
465 | 464 | ||
466 | void KOViewManager::showNextXView() | 465 | void KOViewManager::showNextXView() |
467 | { | 466 | { |
468 | 467 | ||
469 | globalFlagBlockAgenda = 1; | 468 | globalFlagBlockAgenda = 1; |
470 | if ( mCurrentAgendaView != 3 ) | 469 | if ( mCurrentAgendaView != 3 ) |
471 | mCurrentAgendaView = -1; | 470 | mCurrentAgendaView = -1; |
472 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 471 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
473 | globalFlagBlockAgenda = 2; | 472 | globalFlagBlockAgenda = 2; |
474 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 473 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
475 | KOPrefs::instance()->mNextXDays ); | 474 | KOPrefs::instance()->mNextXDays ); |
476 | mFlagShowNextxDays = true; | 475 | mFlagShowNextxDays = true; |
477 | mCurrentAgendaView = 3 ; | 476 | mCurrentAgendaView = 3 ; |
478 | } | 477 | } |
479 | bool KOViewManager::showsNextDays() | 478 | bool KOViewManager::showsNextDays() |
480 | { | 479 | { |
481 | return mFlagShowNextxDays; | 480 | return mFlagShowNextxDays; |
482 | } | 481 | } |
483 | void KOViewManager::showMonthView() | 482 | void KOViewManager::showMonthView() |
484 | { | 483 | { |
485 | if (!mMonthView) { | 484 | if (!mMonthView) { |
486 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 485 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
487 | 486 | ||
488 | addView(mMonthView); | 487 | addView(mMonthView); |
489 | // mMonthView->show(); | 488 | // mMonthView->show(); |
490 | // SIGNALS/SLOTS FOR MONTH VIEW | 489 | // SIGNALS/SLOTS FOR MONTH VIEW |
491 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 490 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
492 | mMainView, SLOT(newEvent(QDateTime))); | 491 | mMainView, SLOT(newEvent(QDateTime))); |
493 | 492 | ||
494 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 493 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
495 | mMainView, SLOT(showIncidence(Incidence *))); | 494 | mMainView, SLOT(showIncidence(Incidence *))); |
496 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 495 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
497 | mMainView, SLOT(editIncidence(Incidence *))); | 496 | mMainView, SLOT(editIncidence(Incidence *))); |
498 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 497 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
499 | mMainView, SLOT(deleteIncidence(Incidence *))); | 498 | mMainView, SLOT(deleteIncidence(Incidence *))); |
500 | 499 | ||
501 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 500 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
502 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 501 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
503 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 502 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
504 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 503 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
505 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 504 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
506 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 505 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e75154b..0eba6a9 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -206,520 +206,519 @@ void CalendarLocal::deleteTodo( Todo *todo ) | |||
206 | mUndoIncidence = todo->clone(); | 206 | mUndoIncidence = todo->clone(); |
207 | 207 | ||
208 | if ( mTodoList.removeRef( todo ) ) { | 208 | if ( mTodoList.removeRef( todo ) ) { |
209 | setModified( true ); | 209 | setModified( true ); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | QPtrList<Todo> CalendarLocal::rawTodos() | 213 | QPtrList<Todo> CalendarLocal::rawTodos() |
214 | { | 214 | { |
215 | return mTodoList; | 215 | return mTodoList; |
216 | } | 216 | } |
217 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 217 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
218 | { | 218 | { |
219 | Todo *todo; | 219 | Todo *todo; |
220 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 220 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
221 | if ( todo->getID( syncProf ) == id ) return todo; | 221 | if ( todo->getID( syncProf ) == id ) return todo; |
222 | } | 222 | } |
223 | 223 | ||
224 | return 0; | 224 | return 0; |
225 | } | 225 | } |
226 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 226 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
227 | { | 227 | { |
228 | QPtrList<Incidence> all = rawIncidences() ; | 228 | QPtrList<Incidence> all = rawIncidences() ; |
229 | Incidence *inc; | 229 | Incidence *inc; |
230 | for ( inc = all.first(); inc; inc = all.next() ) { | 230 | for ( inc = all.first(); inc; inc = all.next() ) { |
231 | inc->removeID( syncProfile ); | 231 | inc->removeID( syncProfile ); |
232 | } | 232 | } |
233 | if ( syncProfile.isEmpty() ) { | 233 | if ( syncProfile.isEmpty() ) { |
234 | QPtrList<Event> el; | 234 | QPtrList<Event> el; |
235 | Event *todo; | 235 | Event *todo; |
236 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 236 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
237 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 237 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
238 | el.append( todo ); | 238 | el.append( todo ); |
239 | } | 239 | } |
240 | for ( todo = el.first(); todo; todo = el.next() ) { | 240 | for ( todo = el.first(); todo; todo = el.next() ) { |
241 | deleteIncidence ( todo ); | 241 | deleteIncidence ( todo ); |
242 | } | 242 | } |
243 | } else { | 243 | } else { |
244 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 244 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
245 | deleteIncidence ( lse ); | 245 | deleteIncidence ( lse ); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 248 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
249 | { | 249 | { |
250 | QPtrList<Event> el; | 250 | QPtrList<Event> el; |
251 | Event *todo; | 251 | Event *todo; |
252 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 252 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
253 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 253 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
254 | if ( todo->summary().left(3) == "E: " ) | 254 | if ( todo->summary().left(3) == "E: " ) |
255 | el.append( todo ); | 255 | el.append( todo ); |
256 | } | 256 | } |
257 | 257 | ||
258 | return el; | 258 | return el; |
259 | 259 | ||
260 | } | 260 | } |
261 | Event *CalendarLocal::event( QString syncProf, QString id ) | 261 | Event *CalendarLocal::event( QString syncProf, QString id ) |
262 | { | 262 | { |
263 | Event *todo; | 263 | Event *todo; |
264 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 264 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
265 | if ( todo->getID( syncProf ) == id ) return todo; | 265 | if ( todo->getID( syncProf ) == id ) return todo; |
266 | } | 266 | } |
267 | 267 | ||
268 | return 0; | 268 | return 0; |
269 | } | 269 | } |
270 | Todo *CalendarLocal::todo( const QString &uid ) | 270 | Todo *CalendarLocal::todo( const QString &uid ) |
271 | { | 271 | { |
272 | Todo *todo; | 272 | Todo *todo; |
273 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 273 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
274 | if ( todo->uid() == uid ) return todo; | 274 | if ( todo->uid() == uid ) return todo; |
275 | } | 275 | } |
276 | 276 | ||
277 | return 0; | 277 | return 0; |
278 | } | 278 | } |
279 | QString CalendarLocal::nextSummary() const | 279 | QString CalendarLocal::nextSummary() const |
280 | { | 280 | { |
281 | return mNextSummary; | 281 | return mNextSummary; |
282 | } | 282 | } |
283 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 283 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
284 | { | 284 | { |
285 | return mNextAlarmEventDateTime; | 285 | return mNextAlarmEventDateTime; |
286 | } | 286 | } |
287 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 287 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
288 | { | 288 | { |
289 | //mNextAlarmIncidence | 289 | //mNextAlarmIncidence |
290 | //mNextAlarmDateTime | 290 | //mNextAlarmDateTime |
291 | //return mNextSummary; | 291 | //return mNextSummary; |
292 | //return mNextAlarmEventDateTime; | 292 | //return mNextAlarmEventDateTime; |
293 | bool newNextAlarm = false; | 293 | bool newNextAlarm = false; |
294 | bool computeNextAlarm = false; | 294 | bool computeNextAlarm = false; |
295 | bool ok; | 295 | bool ok; |
296 | int offset; | 296 | int offset; |
297 | QDateTime nextA; | 297 | QDateTime nextA; |
298 | // QString nextSum; | 298 | // QString nextSum; |
299 | //QDateTime nextEvent; | 299 | //QDateTime nextEvent; |
300 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 300 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
301 | computeNextAlarm = true; | 301 | computeNextAlarm = true; |
302 | } else { | 302 | } else { |
303 | if ( ! deleted ) { | 303 | if ( ! deleted ) { |
304 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; | 304 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; |
305 | if ( ok ) { | 305 | if ( ok ) { |
306 | if ( nextA < mNextAlarmDateTime ) { | 306 | if ( nextA < mNextAlarmDateTime ) { |
307 | deRegisterAlarm(); | 307 | deRegisterAlarm(); |
308 | mNextAlarmDateTime = nextA; | 308 | mNextAlarmDateTime = nextA; |
309 | mNextSummary = incidence->summary(); | 309 | mNextSummary = incidence->summary(); |
310 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 310 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
311 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 311 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
312 | newNextAlarm = true; | 312 | newNextAlarm = true; |
313 | mNextAlarmIncidence = incidence; | 313 | mNextAlarmIncidence = incidence; |
314 | } else { | 314 | } else { |
315 | if ( incidence == mNextAlarmIncidence ) { | 315 | if ( incidence == mNextAlarmIncidence ) { |
316 | computeNextAlarm = true; | 316 | computeNextAlarm = true; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | } else { | 319 | } else { |
320 | if ( mNextAlarmIncidence == incidence ) { | 320 | if ( mNextAlarmIncidence == incidence ) { |
321 | computeNextAlarm = true; | 321 | computeNextAlarm = true; |
322 | } | 322 | } |
323 | } | 323 | } |
324 | } else { // deleted | 324 | } else { // deleted |
325 | if ( incidence == mNextAlarmIncidence ) { | 325 | if ( incidence == mNextAlarmIncidence ) { |
326 | computeNextAlarm = true; | 326 | computeNextAlarm = true; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | } | 329 | } |
330 | if ( computeNextAlarm ) { | 330 | if ( computeNextAlarm ) { |
331 | deRegisterAlarm(); | 331 | deRegisterAlarm(); |
332 | nextA = nextAlarm( 1000 ); | 332 | nextA = nextAlarm( 1000 ); |
333 | if (! mNextAlarmIncidence ) { | 333 | if (! mNextAlarmIncidence ) { |
334 | return; | 334 | return; |
335 | } | 335 | } |
336 | newNextAlarm = true; | 336 | newNextAlarm = true; |
337 | } | 337 | } |
338 | if ( newNextAlarm ) | 338 | if ( newNextAlarm ) |
339 | registerAlarm(); | 339 | registerAlarm(); |
340 | } | 340 | } |
341 | QString CalendarLocal:: getAlarmNotification() | 341 | QString CalendarLocal:: getAlarmNotification() |
342 | { | 342 | { |
343 | QString ret; | 343 | QString ret; |
344 | // this should not happen | 344 | // this should not happen |
345 | if (! mNextAlarmIncidence ) | 345 | if (! mNextAlarmIncidence ) |
346 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 346 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
347 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 347 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
348 | if ( alarm->type() == Alarm::Procedure ) { | 348 | if ( alarm->type() == Alarm::Procedure ) { |
349 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 349 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
350 | } else { | 350 | } else { |
351 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 351 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
352 | } | 352 | } |
353 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 353 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
354 | if ( mNextSummary.length() > 25 ) | 354 | if ( mNextSummary.length() > 25 ) |
355 | ret += "\n" + mNextSummary.mid(25, 25 ); | 355 | ret += "\n" + mNextSummary.mid(25, 25 ); |
356 | ret+= "\n"+mNextAlarmEventDateTimeString; | 356 | ret+= "\n"+mNextAlarmEventDateTimeString; |
357 | return ret; | 357 | return ret; |
358 | } | 358 | } |
359 | void CalendarLocal::registerAlarm() | 359 | void CalendarLocal::registerAlarm() |
360 | { | 360 | { |
361 | mLastAlarmNotificationString = getAlarmNotification(); | 361 | mLastAlarmNotificationString = getAlarmNotification(); |
362 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); | 362 | // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); |
363 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 363 | emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
364 | // #ifndef DESKTOP_VERSION | 364 | // #ifndef DESKTOP_VERSION |
365 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); | 365 | // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); |
366 | // #endif | 366 | // #endif |
367 | } | 367 | } |
368 | void CalendarLocal::deRegisterAlarm() | 368 | void CalendarLocal::deRegisterAlarm() |
369 | { | 369 | { |
370 | if ( mLastAlarmNotificationString.isNull() ) | 370 | if ( mLastAlarmNotificationString.isNull() ) |
371 | return; | 371 | return; |
372 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); | 372 | //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); |
373 | 373 | ||
374 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); | 374 | emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); |
375 | // #ifndef DESKTOP_VERSION | 375 | // #ifndef DESKTOP_VERSION |
376 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); | 376 | // AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); |
377 | // #endif | 377 | // #endif |
378 | } | 378 | } |
379 | 379 | ||
380 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) | 380 | QPtrList<Todo> CalendarLocal::todos( const QDate &date ) |
381 | { | 381 | { |
382 | QPtrList<Todo> todos; | 382 | QPtrList<Todo> todos; |
383 | 383 | ||
384 | Todo *todo; | 384 | Todo *todo; |
385 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 385 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
386 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { | 386 | if ( todo->hasDueDate() && todo->dtDue().date() == date ) { |
387 | todos.append( todo ); | 387 | todos.append( todo ); |
388 | } | 388 | } |
389 | } | 389 | } |
390 | 390 | ||
391 | filter()->apply( &todos ); | 391 | filter()->apply( &todos ); |
392 | return todos; | 392 | return todos; |
393 | } | 393 | } |
394 | void CalendarLocal::reInitAlarmSettings() | 394 | void CalendarLocal::reInitAlarmSettings() |
395 | { | 395 | { |
396 | if ( !mNextAlarmIncidence ) { | 396 | if ( !mNextAlarmIncidence ) { |
397 | nextAlarm( 1000 ); | 397 | nextAlarm( 1000 ); |
398 | } | 398 | } |
399 | deRegisterAlarm(); | 399 | deRegisterAlarm(); |
400 | mNextAlarmIncidence = 0; | 400 | mNextAlarmIncidence = 0; |
401 | checkAlarmForIncidence( 0, false ); | 401 | checkAlarmForIncidence( 0, false ); |
402 | 402 | ||
403 | } | 403 | } |
404 | 404 | ||
405 | 405 | ||
406 | 406 | ||
407 | QDateTime CalendarLocal::nextAlarm( int daysTo ) | 407 | QDateTime CalendarLocal::nextAlarm( int daysTo ) |
408 | { | 408 | { |
409 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); | 409 | QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); |
410 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); | 410 | QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); |
411 | QDateTime next; | 411 | QDateTime next; |
412 | Event *e; | 412 | Event *e; |
413 | bool ok; | 413 | bool ok; |
414 | bool found = false; | 414 | bool found = false; |
415 | int offset; | 415 | int offset; |
416 | mNextAlarmIncidence = 0; | 416 | mNextAlarmIncidence = 0; |
417 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 417 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
418 | next = e->getNextAlarmDateTime(& ok, &offset ) ; | 418 | next = e->getNextAlarmDateTime(& ok, &offset ) ; |
419 | if ( ok ) { | 419 | if ( ok ) { |
420 | if ( next < nextA ) { | 420 | if ( next < nextA ) { |
421 | nextA = next; | 421 | nextA = next; |
422 | found = true; | 422 | found = true; |
423 | mNextSummary = e->summary(); | 423 | mNextSummary = e->summary(); |
424 | mNextAlarmEventDateTime = next.addSecs(offset ) ; | 424 | mNextAlarmEventDateTime = next.addSecs(offset ) ; |
425 | mNextAlarmIncidence = (Incidence *) e; | 425 | mNextAlarmIncidence = (Incidence *) e; |
426 | } | 426 | } |
427 | } | 427 | } |
428 | } | 428 | } |
429 | Todo *t; | 429 | Todo *t; |
430 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 430 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
431 | next = t->getNextAlarmDateTime(& ok, &offset ) ; | 431 | next = t->getNextAlarmDateTime(& ok, &offset ) ; |
432 | if ( ok ) { | 432 | if ( ok ) { |
433 | if ( next < nextA ) { | 433 | if ( next < nextA ) { |
434 | nextA = next; | 434 | nextA = next; |
435 | found = true; | 435 | found = true; |
436 | mNextSummary = t->summary(); | 436 | mNextSummary = t->summary(); |
437 | mNextAlarmEventDateTime = next.addSecs(offset ); | 437 | mNextAlarmEventDateTime = next.addSecs(offset ); |
438 | mNextAlarmIncidence = (Incidence *) t; | 438 | mNextAlarmIncidence = (Incidence *) t; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | } | 441 | } |
442 | if ( mNextAlarmIncidence ) { | 442 | if ( mNextAlarmIncidence ) { |
443 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 443 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
444 | mNextAlarmDateTime = nextA; | 444 | mNextAlarmDateTime = nextA; |
445 | } | 445 | } |
446 | return nextA; | 446 | return nextA; |
447 | } | 447 | } |
448 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) | 448 | Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) |
449 | { | 449 | { |
450 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); | 450 | return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); |
451 | } | 451 | } |
452 | 452 | ||
453 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) | 453 | Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) |
454 | { | 454 | { |
455 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " | 455 | kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " |
456 | << to.toString() << ")\n"; | 456 | << to.toString() << ")\n"; |
457 | 457 | ||
458 | Alarm::List alarms; | 458 | Alarm::List alarms; |
459 | 459 | ||
460 | Event *e; | 460 | Event *e; |
461 | 461 | ||
462 | for( e = mEventList.first(); e; e = mEventList.next() ) { | 462 | for( e = mEventList.first(); e; e = mEventList.next() ) { |
463 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); | 463 | if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); |
464 | else appendAlarms( alarms, e, from, to ); | 464 | else appendAlarms( alarms, e, from, to ); |
465 | } | 465 | } |
466 | 466 | ||
467 | Todo *t; | 467 | Todo *t; |
468 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { | 468 | for( t = mTodoList.first(); t; t = mTodoList.next() ) { |
469 | appendAlarms( alarms, t, from, to ); | 469 | appendAlarms( alarms, t, from, to ); |
470 | } | 470 | } |
471 | 471 | ||
472 | return alarms; | 472 | return alarms; |
473 | } | 473 | } |
474 | 474 | ||
475 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, | 475 | void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, |
476 | const QDateTime &from, const QDateTime &to ) | 476 | const QDateTime &from, const QDateTime &to ) |
477 | { | 477 | { |
478 | QPtrList<Alarm> alarmList = incidence->alarms(); | 478 | QPtrList<Alarm> alarmList = incidence->alarms(); |
479 | Alarm *alarm; | 479 | Alarm *alarm; |
480 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 480 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
481 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() | 481 | // kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() |
482 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; | 482 | // << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; |
483 | if ( alarm->enabled() ) { | 483 | if ( alarm->enabled() ) { |
484 | if ( alarm->time() >= from && alarm->time() <= to ) { | 484 | if ( alarm->time() >= from && alarm->time() <= to ) { |
485 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() | 485 | kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() |
486 | << "': " << alarm->time().toString() << endl; | 486 | << "': " << alarm->time().toString() << endl; |
487 | alarms.append( alarm ); | 487 | alarms.append( alarm ); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } | 490 | } |
491 | } | 491 | } |
492 | 492 | ||
493 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | 493 | void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, |
494 | Incidence *incidence, | 494 | Incidence *incidence, |
495 | const QDateTime &from, | 495 | const QDateTime &from, |
496 | const QDateTime &to ) | 496 | const QDateTime &to ) |
497 | { | 497 | { |
498 | 498 | ||
499 | QPtrList<Alarm> alarmList = incidence->alarms(); | 499 | QPtrList<Alarm> alarmList = incidence->alarms(); |
500 | Alarm *alarm; | 500 | Alarm *alarm; |
501 | QDateTime qdt; | 501 | QDateTime qdt; |
502 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 502 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
503 | if (incidence->recursOn(from.date())) { | 503 | if (incidence->recursOn(from.date())) { |
504 | qdt.setTime(alarm->time().time()); | 504 | qdt.setTime(alarm->time().time()); |
505 | qdt.setDate(from.date()); | 505 | qdt.setDate(from.date()); |
506 | } | 506 | } |
507 | else qdt = alarm->time(); | 507 | else qdt = alarm->time(); |
508 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 508 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
509 | if ( alarm->enabled() ) { | 509 | if ( alarm->enabled() ) { |
510 | if ( qdt >= from && qdt <= to ) { | 510 | if ( qdt >= from && qdt <= to ) { |
511 | alarms.append( alarm ); | 511 | alarms.append( alarm ); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | } | 514 | } |
515 | } | 515 | } |
516 | 516 | ||
517 | 517 | ||
518 | /****************************** PROTECTED METHODS ****************************/ | 518 | /****************************** PROTECTED METHODS ****************************/ |
519 | 519 | ||
520 | // after changes are made to an event, this should be called. | 520 | // after changes are made to an event, this should be called. |
521 | void CalendarLocal::update( IncidenceBase *incidence ) | 521 | void CalendarLocal::update( IncidenceBase *incidence ) |
522 | { | 522 | { |
523 | incidence->setSyncStatus( Event::SYNCMOD ); | 523 | incidence->setSyncStatus( Event::SYNCMOD ); |
524 | incidence->setLastModified( QDateTime::currentDateTime() ); | 524 | incidence->setLastModified( QDateTime::currentDateTime() ); |
525 | // we should probably update the revision number here, | 525 | // we should probably update the revision number here, |
526 | // or internally in the Event itself when certain things change. | 526 | // or internally in the Event itself when certain things change. |
527 | // need to verify with ical documentation. | 527 | // need to verify with ical documentation. |
528 | 528 | ||
529 | setModified( true ); | 529 | setModified( true ); |
530 | } | 530 | } |
531 | 531 | ||
532 | void CalendarLocal::insertEvent( Event *event ) | 532 | void CalendarLocal::insertEvent( Event *event ) |
533 | { | 533 | { |
534 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 534 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
535 | } | 535 | } |
536 | 536 | ||
537 | 537 | ||
538 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 538 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
539 | { | 539 | { |
540 | QPtrList<Event> eventList; | 540 | QPtrList<Event> eventList; |
541 | 541 | ||
542 | Event *event; | 542 | Event *event; |
543 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 543 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
544 | if ( event->doesRecur() ) { | 544 | if ( event->doesRecur() ) { |
545 | if ( event->isMultiDay() ) { | 545 | if ( event->isMultiDay() ) { |
546 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 546 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
547 | int i; | 547 | int i; |
548 | for ( i = 0; i <= extraDays; i++ ) { | 548 | for ( i = 0; i <= extraDays; i++ ) { |
549 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 549 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
550 | eventList.append( event ); | 550 | eventList.append( event ); |
551 | break; | 551 | break; |
552 | } | 552 | } |
553 | } | 553 | } |
554 | } else { | 554 | } else { |
555 | if ( event->recursOn( qd ) ) | 555 | if ( event->recursOn( qd ) ) |
556 | eventList.append( event ); | 556 | eventList.append( event ); |
557 | } | 557 | } |
558 | } else { | 558 | } else { |
559 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 559 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
560 | eventList.append( event ); | 560 | eventList.append( event ); |
561 | } | 561 | } |
562 | } | 562 | } |
563 | } | 563 | } |
564 | 564 | ||
565 | if ( !sorted ) { | 565 | if ( !sorted ) { |
566 | return eventList; | 566 | return eventList; |
567 | } | 567 | } |
568 | 568 | ||
569 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 569 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
570 | // now, we have to sort it based on dtStart.time() | 570 | // now, we have to sort it based on dtStart.time() |
571 | QPtrList<Event> eventListSorted; | 571 | QPtrList<Event> eventListSorted; |
572 | Event *sortEvent; | 572 | Event *sortEvent; |
573 | for ( event = eventList.first(); event; event = eventList.next() ) { | 573 | for ( event = eventList.first(); event; event = eventList.next() ) { |
574 | sortEvent = eventListSorted.first(); | 574 | sortEvent = eventListSorted.first(); |
575 | int i = 0; | 575 | int i = 0; |
576 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 576 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
577 | { | 577 | { |
578 | i++; | 578 | i++; |
579 | sortEvent = eventListSorted.next(); | 579 | sortEvent = eventListSorted.next(); |
580 | } | 580 | } |
581 | eventListSorted.insert( i, event ); | 581 | eventListSorted.insert( i, event ); |
582 | } | 582 | } |
583 | return eventListSorted; | 583 | return eventListSorted; |
584 | } | 584 | } |
585 | 585 | ||
586 | 586 | ||
587 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 587 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
588 | bool inclusive ) | 588 | bool inclusive ) |
589 | { | 589 | { |
590 | qDebug("CalendarLocal::rawEvents called "); | ||
591 | Event *event = 0; | 590 | Event *event = 0; |
592 | 591 | ||
593 | QPtrList<Event> eventList; | 592 | QPtrList<Event> eventList; |
594 | 593 | ||
595 | // Get non-recurring events | 594 | // Get non-recurring events |
596 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 595 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
597 | if ( event->doesRecur() ) { | 596 | if ( event->doesRecur() ) { |
598 | QDate rStart = event->dtStart().date(); | 597 | QDate rStart = event->dtStart().date(); |
599 | bool found = false; | 598 | bool found = false; |
600 | if ( inclusive ) { | 599 | if ( inclusive ) { |
601 | if ( rStart >= start && rStart <= end ) { | 600 | if ( rStart >= start && rStart <= end ) { |
602 | // Start date of event is in range. Now check for end date. | 601 | // Start date of event is in range. Now check for end date. |
603 | // if duration is negative, event recurs forever, so do not include it. | 602 | // if duration is negative, event recurs forever, so do not include it. |
604 | if ( event->recurrence()->duration() == 0 ) { // End date set | 603 | if ( event->recurrence()->duration() == 0 ) { // End date set |
605 | QDate rEnd = event->recurrence()->endDate(); | 604 | QDate rEnd = event->recurrence()->endDate(); |
606 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 605 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
607 | found = true; | 606 | found = true; |
608 | } | 607 | } |
609 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 608 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
610 | // TODO: Calculate end date from duration. Should be done in Event | 609 | // TODO: Calculate end date from duration. Should be done in Event |
611 | // For now exclude all events with a duration. | 610 | // For now exclude all events with a duration. |
612 | } | 611 | } |
613 | } | 612 | } |
614 | } else { | 613 | } else { |
615 | bool founOne; | 614 | bool founOne; |
616 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 615 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
617 | if ( founOne ) { | 616 | if ( founOne ) { |
618 | if ( next <= end ) { | 617 | if ( next <= end ) { |
619 | found = true; | 618 | found = true; |
620 | } | 619 | } |
621 | } | 620 | } |
622 | 621 | ||
623 | /* | 622 | /* |
624 | // crap !!! | 623 | // crap !!! |
625 | if ( rStart <= end ) { // Start date not after range | 624 | if ( rStart <= end ) { // Start date not after range |
626 | if ( rStart >= start ) { // Start date within range | 625 | if ( rStart >= start ) { // Start date within range |
627 | found = true; | 626 | found = true; |
628 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 627 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
629 | found = true; | 628 | found = true; |
630 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 629 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
631 | QDate rEnd = event->recurrence()->endDate(); | 630 | QDate rEnd = event->recurrence()->endDate(); |
632 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 631 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
633 | found = true; | 632 | found = true; |
634 | } | 633 | } |
635 | } else { // Duration set | 634 | } else { // Duration set |
636 | // TODO: Calculate end date from duration. Should be done in Event | 635 | // TODO: Calculate end date from duration. Should be done in Event |
637 | // For now include all events with a duration. | 636 | // For now include all events with a duration. |
638 | found = true; | 637 | found = true; |
639 | } | 638 | } |
640 | } | 639 | } |
641 | */ | 640 | */ |
642 | 641 | ||
643 | } | 642 | } |
644 | 643 | ||
645 | if ( found ) eventList.append( event ); | 644 | if ( found ) eventList.append( event ); |
646 | } else { | 645 | } else { |
647 | QDate s = event->dtStart().date(); | 646 | QDate s = event->dtStart().date(); |
648 | QDate e = event->dtEnd().date(); | 647 | QDate e = event->dtEnd().date(); |
649 | 648 | ||
650 | if ( inclusive ) { | 649 | if ( inclusive ) { |
651 | if ( s >= start && e <= end ) { | 650 | if ( s >= start && e <= end ) { |
652 | eventList.append( event ); | 651 | eventList.append( event ); |
653 | } | 652 | } |
654 | } else { | 653 | } else { |
655 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 654 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { |
656 | eventList.append( event ); | 655 | eventList.append( event ); |
657 | } | 656 | } |
658 | } | 657 | } |
659 | } | 658 | } |
660 | } | 659 | } |
661 | 660 | ||
662 | return eventList; | 661 | return eventList; |
663 | } | 662 | } |
664 | 663 | ||
665 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 664 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
666 | { | 665 | { |
667 | return rawEventsForDate( qdt.date() ); | 666 | return rawEventsForDate( qdt.date() ); |
668 | } | 667 | } |
669 | 668 | ||
670 | QPtrList<Event> CalendarLocal::rawEvents() | 669 | QPtrList<Event> CalendarLocal::rawEvents() |
671 | { | 670 | { |
672 | return mEventList; | 671 | return mEventList; |
673 | } | 672 | } |
674 | 673 | ||
675 | bool CalendarLocal::addJournal(Journal *journal) | 674 | bool CalendarLocal::addJournal(Journal *journal) |
676 | { | 675 | { |
677 | if ( journal->dtStart().isValid()) | 676 | if ( journal->dtStart().isValid()) |
678 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 677 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
679 | else | 678 | else |
680 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 679 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
681 | 680 | ||
682 | mJournalList.append(journal); | 681 | mJournalList.append(journal); |
683 | 682 | ||
684 | journal->registerObserver( this ); | 683 | journal->registerObserver( this ); |
685 | 684 | ||
686 | setModified( true ); | 685 | setModified( true ); |
687 | 686 | ||
688 | return true; | 687 | return true; |
689 | } | 688 | } |
690 | 689 | ||
691 | void CalendarLocal::deleteJournal( Journal *journal ) | 690 | void CalendarLocal::deleteJournal( Journal *journal ) |
692 | { | 691 | { |
693 | if ( mUndoIncidence ) delete mUndoIncidence; | 692 | if ( mUndoIncidence ) delete mUndoIncidence; |
694 | mUndoIncidence = journal->clone(); | 693 | mUndoIncidence = journal->clone(); |
695 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | 694 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); |
696 | if ( mJournalList.removeRef(journal) ) { | 695 | if ( mJournalList.removeRef(journal) ) { |
697 | setModified( true ); | 696 | setModified( true ); |
698 | } | 697 | } |
699 | } | 698 | } |
700 | 699 | ||
701 | Journal *CalendarLocal::journal( const QDate &date ) | 700 | Journal *CalendarLocal::journal( const QDate &date ) |
702 | { | 701 | { |
703 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 702 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
704 | 703 | ||
705 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 704 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
706 | if ( it->dtStart().date() == date ) | 705 | if ( it->dtStart().date() == date ) |
707 | return it; | 706 | return it; |
708 | 707 | ||
709 | return 0; | 708 | return 0; |
710 | } | 709 | } |
711 | 710 | ||
712 | Journal *CalendarLocal::journal( const QString &uid ) | 711 | Journal *CalendarLocal::journal( const QString &uid ) |
713 | { | 712 | { |
714 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 713 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
715 | if ( it->uid() == uid ) | 714 | if ( it->uid() == uid ) |
716 | return it; | 715 | return it; |
717 | 716 | ||
718 | return 0; | 717 | return 0; |
719 | } | 718 | } |
720 | 719 | ||
721 | QPtrList<Journal> CalendarLocal::journals() | 720 | QPtrList<Journal> CalendarLocal::journals() |
722 | { | 721 | { |
723 | return mJournalList; | 722 | return mJournalList; |
724 | } | 723 | } |
725 | 724 | ||