author | zautrix <zautrix> | 2005-01-31 16:29:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-31 16:29:05 (UTC) |
commit | ec037c4616342c1b3976c55db98b775f48e0d455 (patch) (unidiff) | |
tree | 9d568c8f6ad6005f822c12644596b7a553837c7f /korganizer | |
parent | 5d52c81be9b43887c13f8534a04164d3b44b821f (diff) | |
download | kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.zip kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.tar.gz kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.tar.bz2 |
fix
-rw-r--r-- | korganizer/komonthview.cpp | 165 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
2 files changed, 144 insertions, 26 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 770a42b..6646b98 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -303,387 +303,405 @@ MonthViewCell::MonthViewCell( KOMonthView *parent) | |||
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 | void MonthViewCell::updateCell() | 399 | |
400 | void MonthViewCell::startUpdateCell() | ||
400 | { | 401 | { |
402 | |||
401 | if ( !mMonthView->isUpdatePossible() ) | 403 | if ( !mMonthView->isUpdatePossible() ) |
402 | return; | 404 | return; |
403 | /* | 405 | /* |
404 | if ( !isVisible() ){ | 406 | if ( !isVisible() ){ |
405 | return; | 407 | return; |
406 | } | 408 | } |
407 | */ | 409 | */ |
408 | // qDebug("MonthViewCell::updateCell() "); | 410 | // qDebug("MonthViewCell::updateCell() "); |
409 | setPrimary( mDate.month()%2 ); | 411 | setPrimary( mDate.month()%2 ); |
410 | 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); |
411 | if ( mDate == QDate::currentDate() ) { | 413 | if ( mDate == QDate::currentDate() ) { |
412 | mItemList->setLineWidth( 3 ); | 414 | mItemList->setLineWidth( 3 ); |
413 | } else { | 415 | } else { |
414 | mItemList->setLineWidth( 1 ); | 416 | mItemList->setLineWidth( 1 ); |
415 | } | 417 | } |
416 | mItemList->clear(); | 418 | mItemList->clear(); |
417 | 419 | ||
418 | #ifdef DESKTOP_VERSION | 420 | #ifdef DESKTOP_VERSION |
419 | QToolTip::remove(this); | 421 | QToolTip::remove(this); |
420 | #endif | 422 | #endif |
421 | QString tipText(""); | 423 | mToolTip = ""; |
422 | //qApp->processEvents(); | 424 | //qApp->processEvents(); |
423 | if ( !mHolidayString.isEmpty() ) { | 425 | if ( !mHolidayString.isEmpty() ) { |
424 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
425 | item->setPalette( mHolidayPalette ); | 427 | item->setPalette( mHolidayPalette ); |
426 | mItemList->insertItem( item ); | 428 | mItemList->insertItem( item ); |
427 | tipText += mHolidayString+"\n"; | 429 | mToolTip += mHolidayString+"\n"; |
428 | } | 430 | } |
429 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 431 | } |
430 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | ||
431 | Event *event; | ||
432 | for( event = events.first(); event; event = events.next() ) { // for event | ||
433 | 432 | ||
433 | void MonthViewCell::insertEvent(Event *event) | ||
434 | { | ||
434 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
435 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
436 | continue; | 437 | return; |
437 | else | 438 | else |
438 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
439 | continue; | 440 | return; |
440 | } | 441 | } |
441 | 442 | ||
442 | if ( event->categories().contains("Holiday") || | 443 | if ( event->categories().contains("Holiday") || |
443 | event->categories().contains(i18n("Holiday"))) { | 444 | event->categories().contains(i18n("Holiday"))) { |
444 | setHoliday( true ); | 445 | setHoliday( true ); |
445 | if ( mDate.dayOfWeek() == 7 ) | 446 | if ( mDate.dayOfWeek() == 7 ) |
446 | mItemList->setLineWidth( 3 ); | 447 | mItemList->setLineWidth( 3 ); |
447 | } | 448 | } |
448 | QString text; | 449 | QString text; |
449 | if (event->isMultiDay()) { | 450 | if (event->isMultiDay()) { |
450 | QString prefix = "<->"; | 451 | QString prefix = "<->"; |
451 | if ( event->doesRecur() ) { | 452 | if ( event->doesRecur() ) { |
452 | if ( event->recursOn( mDate) ) | 453 | if ( event->recursOn( mDate) ) |
453 | prefix ="->" ; | 454 | prefix ="->" ; |
454 | else { | 455 | else { |
455 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
456 | if ( event->recursOn( mDate.addDays( -days)) ) | 457 | if ( event->recursOn( mDate.addDays( -days)) ) |
457 | prefix ="<-" ; | 458 | prefix ="<-" ; |
458 | } | 459 | } |
459 | 460 | ||
460 | } else { | 461 | } else { |
461 | if (mDate == event->dtStart().date()) { | 462 | if (mDate == event->dtStart().date()) { |
462 | prefix ="->" ; | 463 | prefix ="->" ; |
463 | } else if (mDate == event->dtEnd().date()) { | 464 | } else if (mDate == event->dtEnd().date()) { |
464 | prefix ="<-" ; | 465 | prefix ="<-" ; |
465 | } | 466 | } |
466 | } | 467 | } |
467 | text = prefix + event->summary(); | 468 | text = prefix + event->summary(); |
468 | tipText += text; | 469 | mToolTip += text; |
469 | } else { | 470 | } else { |
470 | if (event->doesFloat()) { | 471 | if (event->doesFloat()) { |
471 | text = event->summary(); | 472 | text = event->summary(); |
472 | tipText += text; | 473 | mToolTip += text; |
473 | } | 474 | } |
474 | else { | 475 | else { |
475 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 476 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
476 | text += " " + event->summary(); | 477 | text += " " + event->summary(); |
477 | tipText += 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(); |
478 | } | 479 | } |
479 | } | 480 | } |
480 | 481 | ||
481 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 482 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
482 | QPalette pal; | 483 | QPalette pal; |
483 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 484 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
484 | QStringList categories = event->categories(); | 485 | QStringList categories = event->categories(); |
485 | QString cat = categories.first(); | 486 | QString cat = categories.first(); |
486 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 487 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
487 | pal = getPalette(); | 488 | pal = getPalette(); |
488 | if (cat.isEmpty()) { | 489 | if (cat.isEmpty()) { |
489 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 490 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
490 | } else { | 491 | } else { |
491 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 492 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
492 | } | 493 | } |
493 | 494 | ||
494 | } else { | 495 | } else { |
495 | if (cat.isEmpty()) { | 496 | if (cat.isEmpty()) { |
496 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 497 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
497 | } else { | 498 | } else { |
498 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 499 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
499 | } | 500 | } |
500 | } | 501 | } |
501 | 502 | ||
502 | } else { | 503 | } else { |
503 | pal = mStandardPalette ; | 504 | pal = mStandardPalette ; |
504 | } | 505 | } |
505 | item->setPalette( pal ); | 506 | item->setPalette( pal ); |
506 | item->setRecur( event->recurrence()->doesRecur() ); | 507 | item->setRecur( event->recurrence()->doesRecur() ); |
507 | item->setAlarm( event->isAlarmEnabled() ); | 508 | item->setAlarm( event->isAlarmEnabled() ); |
508 | item->setMoreInfo( event->description().length() > 0 ); | 509 | item->setMoreInfo( event->description().length() > 0 ); |
509 | #ifdef DESKTOP_VERSION | 510 | #ifdef DESKTOP_VERSION |
510 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 511 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
511 | KOPrefs::instance()->email()); | 512 | KOPrefs::instance()->email()); |
512 | if ( me != 0 ) { | 513 | if ( me != 0 ) { |
513 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 514 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
514 | item->setReply(true); | 515 | item->setReply(true); |
515 | else | 516 | else |
516 | item->setReply(false); | 517 | item->setReply(false); |
517 | } else | 518 | } else |
518 | item->setReply(false); | 519 | item->setReply(false); |
519 | #endif | 520 | #endif |
520 | mItemList->insertItem( item ); | 521 | mItemList->insertItem( item ); |
521 | tipText += "\n"; | 522 | mToolTip += "\n"; |
522 | 523 | } | |
523 | } | 524 | void MonthViewCell::insertTodo(Todo *todo) |
524 | 525 | { | |
525 | // insert due todos | 526 | QString text; |
526 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | ||
527 | Todo *todo; | ||
528 | for(todo = todos.first(); todo; todo = todos.next()) { | ||
529 | QString text; | ||
530 | if (todo->hasDueDate()) { | 527 | if (todo->hasDueDate()) { |
531 | if (!todo->doesFloat()) { | 528 | if (!todo->doesFloat()) { |
532 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 529 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
533 | text += " "; | 530 | text += " "; |
534 | } | 531 | } |
535 | } | 532 | } |
536 | text += i18n("To-Do: %1").arg(todo->summary()); | 533 | text += i18n("To-Do: %1").arg(todo->summary()); |
537 | 534 | ||
538 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 535 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
539 | //item->setPalette( mStandardPalette ); | 536 | //item->setPalette( mStandardPalette ); |
540 | QPalette pal; | 537 | QPalette pal; |
541 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 538 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
542 | QStringList categories = todo->categories(); | 539 | QStringList categories = todo->categories(); |
543 | QString cat = categories.first(); | 540 | QString cat = categories.first(); |
544 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 541 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
545 | pal = getPalette(); | 542 | pal = getPalette(); |
546 | if (cat.isEmpty()) { | 543 | if (cat.isEmpty()) { |
547 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 544 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
548 | } else { | 545 | } else { |
549 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 546 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
550 | } | 547 | } |
551 | 548 | ||
552 | } else { | 549 | } else { |
553 | if (cat.isEmpty()) { | 550 | if (cat.isEmpty()) { |
554 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 551 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
555 | } else { | 552 | } else { |
556 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 553 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
557 | } | 554 | } |
558 | } | 555 | } |
559 | 556 | ||
560 | } else { | 557 | } else { |
561 | pal = mStandardPalette ; | 558 | pal = mStandardPalette ; |
562 | } | 559 | } |
563 | item->setPalette( pal ); | 560 | item->setPalette( pal ); |
564 | mItemList->insertItem( item ); | 561 | mItemList->insertItem( item ); |
565 | tipText += text+"\n"; | 562 | mToolTip += text+"\n"; |
566 | } | 563 | } |
564 | void MonthViewCell::finishUpdateCell() | ||
565 | { | ||
567 | #ifdef DESKTOP_VERSION | 566 | #ifdef DESKTOP_VERSION |
568 | if (tipText != "") | 567 | if (mToolTip != "") |
569 | QToolTip::add(this,tipText,toolTipGroup(),""); | 568 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
570 | #endif | 569 | #endif |
571 | 570 | ||
572 | //setMyPalette(); | 571 | //setMyPalette(); |
573 | setMyPalette(); | 572 | setMyPalette(); |
574 | QString text; | 573 | QString text; |
575 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 574 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
576 | 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) { |
577 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 576 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
578 | mLabel->resize( mLabelBigSize ); | 577 | mLabel->resize( mLabelBigSize ); |
579 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 578 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
580 | } else { | 579 | } else { |
581 | mLabel->resize( mLabelSize ); | 580 | mLabel->resize( mLabelSize ); |
582 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 581 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
583 | } | 582 | } |
584 | 583 | ||
585 | mLabel->setText( text ); | 584 | mLabel->setText( text ); |
586 | resizeEvent( 0 ); | 585 | resizeEvent( 0 ); |
586 | } | ||
587 | void MonthViewCell::updateCell() | ||
588 | { | ||
589 | if ( !mMonthView->isUpdatePossible() ) | ||
590 | return; | ||
591 | startUpdateCell(); | ||
592 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | ||
593 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | ||
594 | Event *event; | ||
595 | for( event = events.first(); event; event = events.next() ) { // for event | ||
596 | insertEvent(event); | ||
597 | } | ||
598 | // insert due todos | ||
599 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | ||
600 | Todo *todo; | ||
601 | for(todo = todos.first(); todo; todo = todos.next()) { | ||
602 | insertTodo( todo ); | ||
603 | } | ||
604 | finishUpdateCell(); | ||
587 | // if ( isVisible()) | 605 | // if ( isVisible()) |
588 | //qApp->processEvents(); | 606 | //qApp->processEvents(); |
589 | } | 607 | } |
590 | 608 | ||
591 | void MonthViewCell::updateConfig() | 609 | void MonthViewCell::updateConfig() |
592 | { | 610 | { |
593 | 611 | qDebug("MonthViewCell::updateConfig() "); | |
594 | setFont( KOPrefs::instance()->mMonthViewFont ); | 612 | setFont( KOPrefs::instance()->mMonthViewFont ); |
595 | 613 | ||
596 | QFontMetrics fm( font() ); | 614 | QFontMetrics fm( font() ); |
597 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 615 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
598 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 616 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
599 | mHolidayPalette = mStandardPalette; | 617 | mHolidayPalette = mStandardPalette; |
600 | mPrimaryPalette = mStandardPalette; | 618 | mPrimaryPalette = mStandardPalette; |
601 | mNonPrimaryPalette = mStandardPalette; | 619 | mNonPrimaryPalette = mStandardPalette; |
602 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 620 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
603 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 621 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
604 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 622 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
605 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 623 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
606 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 624 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
607 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 625 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
608 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 626 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
609 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 627 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
610 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 628 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
611 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 629 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
612 | } | 630 | } |
613 | updateCell(); | 631 | updateCell(); |
614 | } | 632 | } |
615 | 633 | ||
616 | void MonthViewCell::enableScrollBars( bool enabled ) | 634 | void MonthViewCell::enableScrollBars( bool enabled ) |
617 | { | 635 | { |
618 | if ( enabled ) { | 636 | if ( enabled ) { |
619 | mItemList->setVScrollBarMode(QScrollView::Auto); | 637 | mItemList->setVScrollBarMode(QScrollView::Auto); |
620 | mItemList->setHScrollBarMode(QScrollView::Auto); | 638 | mItemList->setHScrollBarMode(QScrollView::Auto); |
621 | } else { | 639 | } else { |
622 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 640 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
623 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 641 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
624 | } | 642 | } |
625 | } | 643 | } |
626 | 644 | ||
627 | Incidence *MonthViewCell::selectedIncidence() | 645 | Incidence *MonthViewCell::selectedIncidence() |
628 | { | 646 | { |
629 | int index = mItemList->currentItem(); | 647 | int index = mItemList->currentItem(); |
630 | if ( index < 0 ) return 0; | 648 | if ( index < 0 ) return 0; |
631 | 649 | ||
632 | MonthViewItem *item = | 650 | MonthViewItem *item = |
633 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 651 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
634 | 652 | ||
635 | if ( !item ) return 0; | 653 | if ( !item ) return 0; |
636 | 654 | ||
637 | return item->incidence(); | 655 | return item->incidence(); |
638 | } | 656 | } |
639 | 657 | ||
640 | QDate MonthViewCell::selectedIncidenceDate() | 658 | QDate MonthViewCell::selectedIncidenceDate() |
641 | { | 659 | { |
642 | QDate qd; | 660 | QDate qd; |
643 | int index = mItemList->currentItem(); | 661 | int index = mItemList->currentItem(); |
644 | if ( index < 0 ) return qd; | 662 | if ( index < 0 ) return qd; |
645 | 663 | ||
646 | MonthViewItem *item = | 664 | MonthViewItem *item = |
647 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 665 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
648 | 666 | ||
649 | if ( !item ) return qd; | 667 | if ( !item ) return qd; |
650 | 668 | ||
651 | return item->incidenceDate(); | 669 | return item->incidenceDate(); |
652 | } | 670 | } |
653 | 671 | ||
654 | void MonthViewCell::deselect() | 672 | void MonthViewCell::deselect() |
655 | { | 673 | { |
656 | mItemList->clearSelection(); | 674 | mItemList->clearSelection(); |
657 | enableScrollBars( false ); | 675 | enableScrollBars( false ); |
658 | // updateCell(); | 676 | // updateCell(); |
659 | } | 677 | } |
660 | void MonthViewCell::select() | 678 | void MonthViewCell::select() |
661 | { | 679 | { |
662 | ;// updateCell(); | 680 | ;// updateCell(); |
663 | } | 681 | } |
664 | 682 | ||
665 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 683 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
666 | { | 684 | { |
667 | if ( !mMonthView->isUpdatePossible() ) | 685 | if ( !mMonthView->isUpdatePossible() ) |
668 | return; | 686 | return; |
669 | #ifndef DESKTOP_VERSION | 687 | #ifndef DESKTOP_VERSION |
670 | if ( !isVisible() ){ | 688 | if ( !isVisible() ){ |
671 | return; | 689 | return; |
672 | } | 690 | } |
673 | #endif | 691 | #endif |
674 | int size = height() - mLabel->height(); | 692 | int size = height() - mLabel->height(); |
675 | if ( size > 0 ) | 693 | if ( size > 0 ) |
676 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 694 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
677 | size = width() - mLabel->width(); | 695 | size = width() - mLabel->width(); |
678 | if ( size > 0 ) | 696 | if ( size > 0 ) |
679 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 697 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
680 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 698 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
681 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 699 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
682 | } | 700 | } |
683 | 701 | ||
684 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 702 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
685 | { | 703 | { |
686 | if ( !item ) return; | 704 | if ( !item ) return; |
687 | 705 | ||
688 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 706 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
689 | Incidence *incidence = eventItem->incidence(); | 707 | Incidence *incidence = eventItem->incidence(); |
@@ -865,202 +883,297 @@ void KOMonthView::updateConfig() | |||
865 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 883 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
866 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 884 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
867 | } | 885 | } |
868 | bool temp = mShowSatSunComp ; | 886 | bool temp = mShowSatSunComp ; |
869 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 887 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
870 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 888 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
871 | computeLayout(); | 889 | computeLayout(); |
872 | updateDayLabels(); | 890 | updateDayLabels(); |
873 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 891 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
874 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 892 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
875 | //resizeEvent( 0 ); | 893 | //resizeEvent( 0 ); |
876 | for (uint i = 0; i < mCells.count(); ++i) { | 894 | for (uint i = 0; i < mCells.count(); ++i) { |
877 | mCells[i]->updateConfig(); | 895 | mCells[i]->updateConfig(); |
878 | } | 896 | } |
879 | #ifdef DESKTOP_VERSION | 897 | #ifdef DESKTOP_VERSION |
880 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 898 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
881 | #endif | 899 | #endif |
882 | } | 900 | } |
883 | 901 | ||
884 | void KOMonthView::updateDayLabels() | 902 | void KOMonthView::updateDayLabels() |
885 | { | 903 | { |
886 | 904 | ||
887 | for (int i = 0; i < 7; i++) { | 905 | for (int i = 0; i < 7; i++) { |
888 | if (mWeekStartsMonday) { | 906 | if (mWeekStartsMonday) { |
889 | bool show = mShortDayLabels; | 907 | bool show = mShortDayLabels; |
890 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 908 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
891 | show = true; | 909 | show = true; |
892 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 910 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
893 | } else { | 911 | } else { |
894 | 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)); |
895 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 913 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
896 | 914 | ||
897 | } | 915 | } |
898 | } | 916 | } |
899 | } | 917 | } |
900 | 918 | ||
901 | void KOMonthView::showDates(const QDate &start, const QDate &) | 919 | void KOMonthView::showDates(const QDate &start, const QDate &) |
902 | { | 920 | { |
903 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 921 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
904 | 922 | ||
905 | 923 | ||
906 | mStartDate = start; | 924 | mStartDate = start; |
907 | 925 | ||
908 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 926 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
909 | 927 | ||
910 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 928 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
911 | mStartDate = mStartDate.addDays( -1 ); | 929 | mStartDate = mStartDate.addDays( -1 ); |
912 | } | 930 | } |
913 | 931 | ||
914 | bool primary = false; | 932 | bool primary = false; |
915 | uint i; | 933 | uint i; |
916 | for( i = 0; i < mCells.size(); ++i ) { | 934 | for( i = 0; i < mCells.size(); ++i ) { |
917 | QDate date = mStartDate.addDays( i ); | 935 | QDate date = mStartDate.addDays( i ); |
918 | mCells[i]->setDate( date ); | 936 | mCells[i]->setDate( date ); |
919 | 937 | ||
920 | #ifndef KORG_NOPLUGINS | 938 | #ifndef KORG_NOPLUGINS |
921 | // add holiday, if present | 939 | // add holiday, if present |
922 | QString hstring(KOCore::self()->holiday(date)); | 940 | QString hstring(KOCore::self()->holiday(date)); |
923 | mCells[i]->setHoliday( hstring ); | 941 | mCells[i]->setHoliday( hstring ); |
924 | #endif | 942 | #endif |
925 | 943 | ||
926 | } | 944 | } |
927 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 945 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
928 | for( i = 0; i < 6; ++i ) { | 946 | for( i = 0; i < 6; ++i ) { |
929 | int wno; | 947 | int wno; |
930 | // 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 |
931 | // 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, |
932 | // not just 1. | 950 | // not just 1. |
933 | int dayOfYear = date.dayOfYear(); | 951 | int dayOfYear = date.dayOfYear(); |
934 | if (dayOfYear % 7 != 0) | 952 | if (dayOfYear % 7 != 0) |
935 | wno = dayOfYear / 7 + 1; | 953 | wno = dayOfYear / 7 + 1; |
936 | else | 954 | else |
937 | wno =dayOfYear / 7; | 955 | wno =dayOfYear / 7; |
938 | mWeekLabels[i]->setWeekNum( wno ); | 956 | mWeekLabels[i]->setWeekNum( wno ); |
939 | date = date.addDays( 7 ); | 957 | date = date.addDays( 7 ); |
940 | } | 958 | } |
941 | updateView(); | 959 | updateView(); |
942 | } | 960 | } |
943 | 961 | ||
944 | void KOMonthView::showEvents(QPtrList<Event>) | 962 | void KOMonthView::showEvents(QPtrList<Event>) |
945 | { | 963 | { |
946 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 964 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
947 | } | 965 | } |
948 | 966 | ||
949 | void KOMonthView::changeEventDisplay(Event *, int) | 967 | void KOMonthView::changeEventDisplay(Event *, int) |
950 | { | 968 | { |
951 | // 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 |
952 | // quick-and-dirty-hack gets the job done for right now. | 970 | // quick-and-dirty-hack gets the job done for right now. |
953 | updateView(); | 971 | updateView(); |
954 | } | 972 | } |
955 | 973 | ||
956 | void KOMonthView::updateView() | 974 | void KOMonthView::updateView() |
957 | { | 975 | { |
958 | 976 | ||
959 | if ( !updatePossible ) | 977 | if ( !updatePossible ) |
960 | return; | 978 | return; |
979 | QTime ti; | ||
980 | ti.start(); | ||
981 | #if 1 | ||
982 | int i; | ||
983 | for( i = 0; i < mCells.count(); ++i ) { | ||
984 | mCells[i]->startUpdateCell(); | ||
985 | } | ||
986 | |||
987 | QPtrList<Event> events = calendar()->events(); | ||
988 | Event *event; | ||
989 | QDateTime dt; | ||
990 | bool ok; | ||
991 | int timeSpan = mCells.size()-1; | ||
992 | QDate endDate = mStartDate.addDays( timeSpan ); | ||
993 | for( event = events.first(); event; event = events.next() ) { // for event | ||
994 | if ( event->doesRecur() ) { | ||
995 | bool last; | ||
996 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | ||
997 | QDateTime incidenceEnd; | ||
998 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | ||
999 | bool invalid = false; | ||
1000 | while( true ) { | ||
1001 | if ( incidenceStart.isValid() ) { | ||
1002 | incidenceEnd = incidenceStart.addDays( eventlen ); | ||
1003 | int st = incidenceStart.date().daysTo( endDate ); | ||
1004 | if ( st >= 0 ) { // start before timeend | ||
1005 | int end = mStartDate.daysTo( incidenceEnd.date() ); | ||
1006 | if ( end >= 0 ) { // end after timestart --- got one! | ||
1007 | //normalize | ||
1008 | st = timeSpan - st; | ||
1009 | if ( st < 0 ) st = 0; | ||
1010 | if ( end > timeSpan ) end = timeSpan; | ||
1011 | int iii; | ||
1012 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | ||
1013 | for ( iii = st;iii<= end;++iii) | ||
1014 | mCells[iii]->insertEvent( event ); | ||
1015 | } | ||
1016 | } | ||
1017 | } else { | ||
1018 | if ( invalid ) | ||
1019 | break; | ||
1020 | invalid = true; | ||
1021 | //qDebug("invalid %s", event->summary().latin1()); | ||
1022 | incidenceStart = QDateTime( mStartDate ); | ||
1023 | } | ||
1024 | if ( last ) | ||
1025 | break; | ||
1026 | bool ok; | ||
1027 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | ||
1028 | if ( ! ok ) | ||
1029 | break; | ||
1030 | if ( incidenceStart.date() > endDate ) | ||
1031 | break; | ||
1032 | } | ||
1033 | } else { // no recur | ||
1034 | int st = event->dtStart().date().daysTo( endDate ); | ||
1035 | if ( st >= 0 ) { // start before timeend | ||
1036 | int end = mStartDate.daysTo( event->dtEnd().date() ); | ||
1037 | if ( end >= 0 ) { // end after timestart --- got one! | ||
1038 | //normalize | ||
1039 | st = timeSpan - st; | ||
1040 | if ( st < 0 ) st = 0; | ||
1041 | if ( end > timeSpan ) end = timeSpan; | ||
1042 | int iii; | ||
1043 | for ( iii = st;iii<= end;++iii) | ||
1044 | mCells[iii]->insertEvent( event ); | ||
1045 | } | ||
1046 | } | ||
1047 | } | ||
1048 | } | ||
1049 | // insert due todos | ||
1050 | QPtrList<Todo> todos = calendar()->todos( ); | ||
1051 | Todo *todo; | ||
1052 | for(todo = todos.first(); todo; todo = todos.next()) { | ||
1053 | //insertTodo( todo ); | ||
1054 | if ( todo->hasDueDate() ) { | ||
1055 | int day = mStartDate.daysTo( todo->dtDue().date() ); | ||
1056 | if ( day >= 0 && day < mCells.size() ) { | ||
1057 | mCells[day]->insertTodo( todo ); | ||
1058 | } | ||
1059 | } | ||
1060 | } | ||
1061 | |||
1062 | for( i = 0; i < mCells.count(); ++i ) { | ||
1063 | mCells[i]->finishUpdateCell(); | ||
1064 | } | ||
1065 | processSelectionChange(); | ||
1066 | mCells[0]->setFocus(); | ||
1067 | |||
1068 | |||
1069 | #else | ||
1070 | // old code | ||
961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1071 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
962 | int i; | 1072 | int i; |
963 | for( i = 0; i < mCells.count(); ++i ) { | 1073 | for( i = 0; i < mCells.count(); ++i ) { |
964 | mCells[i]->updateCell(); | 1074 | mCells[i]->updateCell(); |
965 | } | 1075 | } |
966 | 1076 | ||
967 | //qDebug("KOMonthView::updateView() "); | 1077 | //qDebug("KOMonthView::updateView() "); |
968 | processSelectionChange(); | 1078 | processSelectionChange(); |
969 | // qDebug("---------------------------------------------------------------------+ "); | 1079 | // qDebug("---------------------------------------------------------------------+ "); |
970 | mCells[0]->setFocus(); | 1080 | mCells[0]->setFocus(); |
1081 | #endif | ||
1082 | |||
1083 | qDebug("update time %d ", ti.elapsed()); | ||
971 | } | 1084 | } |
972 | 1085 | ||
973 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1086 | void KOMonthView::resizeEvent(QResizeEvent * e) |
974 | { | 1087 | { |
975 | computeLayout(); | 1088 | computeLayout(); |
976 | mCells[0]->setFocus(); | 1089 | mCells[0]->setFocus(); |
977 | } | 1090 | } |
978 | void KOMonthView::computeLayout() | 1091 | void KOMonthView::computeLayout() |
979 | { | 1092 | { |
980 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1093 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
981 | // 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 |
982 | // 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 |
983 | // enough. | 1096 | // enough. |
984 | 1097 | ||
985 | int daysToShow = 7; | 1098 | int daysToShow = 7; |
986 | bool combinedSatSun = false; | 1099 | bool combinedSatSun = false; |
987 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1100 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
988 | daysToShow = 6; | 1101 | daysToShow = 6; |
989 | combinedSatSun = true; | 1102 | combinedSatSun = true; |
990 | } | 1103 | } |
991 | int tWid = topLevelWidget()->size().width(); | 1104 | int tWid = topLevelWidget()->size().width(); |
992 | int tHei = topLevelWidget()->size().height(); | 1105 | int tHei = topLevelWidget()->size().height(); |
993 | 1106 | ||
994 | int wid = size().width();//e | 1107 | int wid = size().width();//e |
995 | int hei = size().height()-1; | 1108 | int hei = size().height()-1; |
996 | 1109 | ||
997 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1110 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
998 | return; | 1111 | return; |
999 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1112 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1000 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1113 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1001 | int weeklabelwid = fm.width( "888" ); | 1114 | int weeklabelwid = fm.width( "888" ); |
1002 | wid -= weeklabelwid; | 1115 | wid -= weeklabelwid; |
1003 | 1116 | ||
1004 | int colWid = wid / daysToShow; | 1117 | int colWid = wid / daysToShow; |
1005 | int lastCol = wid - ( colWid*6 ); | 1118 | int lastCol = wid - ( colWid*6 ); |
1006 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1119 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1007 | int cellHei = (hei - dayLabelHei) /6; | 1120 | int cellHei = (hei - dayLabelHei) /6; |
1008 | int colModulo = wid % daysToShow; | 1121 | int colModulo = wid % daysToShow; |
1009 | int rowModulo = (hei- dayLabelHei) % 6; | 1122 | int rowModulo = (hei- dayLabelHei) % 6; |
1010 | //qDebug("rowmod %d ", rowModulo); | 1123 | //qDebug("rowmod %d ", rowModulo); |
1011 | int i; | 1124 | int i; |
1012 | int x,y,w,h; | 1125 | int x,y,w,h; |
1013 | x= 0; | 1126 | x= 0; |
1014 | y= 0; | 1127 | y= 0; |
1015 | w = colWid; | 1128 | w = colWid; |
1016 | h = dayLabelHei ; | 1129 | h = dayLabelHei ; |
1017 | for ( i = 0; i < 7; i++) { | 1130 | for ( i = 0; i < 7; i++) { |
1018 | if ( i == daysToShow-colModulo ) | 1131 | if ( i == daysToShow-colModulo ) |
1019 | ++w; | 1132 | ++w; |
1020 | if ( combinedSatSun ) { | 1133 | if ( combinedSatSun ) { |
1021 | if ( i >= daysToShow-1 ) { | 1134 | if ( i >= daysToShow-1 ) { |
1022 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1135 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1023 | x -= w/2 ; | 1136 | x -= w/2 ; |
1024 | } | 1137 | } |
1025 | else | 1138 | else |
1026 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1139 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1027 | } else | 1140 | } else |
1028 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1141 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1029 | x += w; | 1142 | x += w; |
1030 | } | 1143 | } |
1031 | x= 0; | 1144 | x= 0; |
1032 | y= dayLabelHei; | 1145 | y= dayLabelHei; |
1033 | w = colWid; | 1146 | w = colWid; |
1034 | h = cellHei ; | 1147 | h = cellHei ; |
1035 | for ( i = 0; i < mCells.count(); ++i) { | 1148 | for ( i = 0; i < mCells.count(); ++i) { |
1036 | 1149 | ||
1037 | w = colWid; | 1150 | w = colWid; |
1038 | if ( ((i) % 7) >= 7-colModulo ) { | 1151 | if ( ((i) % 7) >= 7-colModulo ) { |
1039 | ++w; | 1152 | ++w; |
1040 | } | 1153 | } |
1041 | if ( i == (6-rowModulo)*7) | 1154 | if ( i == (6-rowModulo)*7) |
1042 | ++h; | 1155 | ++h; |
1043 | if ( combinedSatSun ) { | 1156 | if ( combinedSatSun ) { |
1044 | if ( (i)%7 >= daysToShow-1 ) { | 1157 | if ( (i)%7 >= daysToShow-1 ) { |
1045 | if ( (i)%7 == daysToShow-1 ) { | 1158 | if ( (i)%7 == daysToShow-1 ) { |
1046 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1159 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1047 | x -= w ;y += h/2; | 1160 | x -= w ;y += h/2; |
1048 | } else { | 1161 | } else { |
1049 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1162 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1050 | y -= h/2; | 1163 | y -= h/2; |
1051 | } | 1164 | } |
1052 | } else | 1165 | } else |
1053 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1166 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1054 | 1167 | ||
1055 | } | 1168 | } |
1056 | else | 1169 | else |
1057 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1170 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1058 | x += w; | 1171 | x += w; |
1059 | if ( x + w/2 > wid ) { | 1172 | if ( x + w/2 > wid ) { |
1060 | x = 0; | 1173 | x = 0; |
1061 | y += h; | 1174 | y += h; |
1062 | } | 1175 | } |
1063 | } | 1176 | } |
1064 | y= dayLabelHei; | 1177 | y= dayLabelHei; |
1065 | h = cellHei ; | 1178 | h = cellHei ; |
1066 | for ( i = 0; i < 6; i++) { | 1179 | for ( i = 0; i < 6; i++) { |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 50903b3..b84065e 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -44,213 +44,218 @@ class KNOWhatsThis; | |||
44 | class KOWeekButton : public QPushButton | 44 | class KOWeekButton : public QPushButton |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 48 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
49 | QPushButton( parent, name) | 49 | QPushButton( parent, name) |
50 | { | 50 | { |
51 | connect( this, SIGNAL( clicked() ), | 51 | connect( this, SIGNAL( clicked() ), |
52 | SLOT( bottonClicked() )); | 52 | SLOT( bottonClicked() )); |
53 | mNumber = -1; | 53 | mNumber = -1; |
54 | } | 54 | } |
55 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 55 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
56 | signals: | 56 | signals: |
57 | void selectWeekNum ( int ); | 57 | void selectWeekNum ( int ); |
58 | private: | 58 | private: |
59 | int mNumber; | 59 | int mNumber; |
60 | private slots : | 60 | private slots : |
61 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 61 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
62 | }; | 62 | }; |
63 | 63 | ||
64 | class KNoScrollListBox: public QListBox | 64 | class KNoScrollListBox: public QListBox |
65 | { | 65 | { |
66 | Q_OBJECT | 66 | Q_OBJECT |
67 | public: | 67 | public: |
68 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 68 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
69 | ~KNoScrollListBox(); | 69 | ~KNoScrollListBox(); |
70 | QString getWhatsThisText(QPoint p) ; | 70 | QString getWhatsThisText(QPoint p) ; |
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void shiftDown(); | 73 | void shiftDown(); |
74 | void shiftUp(); | 74 | void shiftUp(); |
75 | void rightClick(); | 75 | void rightClick(); |
76 | 76 | ||
77 | protected slots: | 77 | protected slots: |
78 | void keyPressEvent(QKeyEvent *); | 78 | void keyPressEvent(QKeyEvent *); |
79 | void keyReleaseEvent(QKeyEvent *); | 79 | void keyReleaseEvent(QKeyEvent *); |
80 | void mousePressEvent(QMouseEvent *); | 80 | void mousePressEvent(QMouseEvent *); |
81 | 81 | ||
82 | private: | 82 | private: |
83 | KNOWhatsThis * mWT; | 83 | KNOWhatsThis * mWT; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | 86 | ||
87 | class MonthViewItem: public QListBoxItem | 87 | class MonthViewItem: public QListBoxItem |
88 | { | 88 | { |
89 | public: | 89 | public: |
90 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 90 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
91 | 91 | ||
92 | void setRecur(bool on) { mRecur = on; } | 92 | void setRecur(bool on) { mRecur = on; } |
93 | void setAlarm(bool on) { mAlarm = on; } | 93 | void setAlarm(bool on) { mAlarm = on; } |
94 | void setReply(bool on) { mReply = on; } | 94 | void setReply(bool on) { mReply = on; } |
95 | void setMoreInfo(bool on) { mInfo = on; } | 95 | void setMoreInfo(bool on) { mInfo = on; } |
96 | 96 | ||
97 | 97 | ||
98 | void setPalette(const QPalette &p) { mPalette = p; } | 98 | void setPalette(const QPalette &p) { mPalette = p; } |
99 | QPalette palette() const { return mPalette; } | 99 | QPalette palette() const { return mPalette; } |
100 | 100 | ||
101 | Incidence *incidence() const { return mIncidence; } | 101 | Incidence *incidence() const { return mIncidence; } |
102 | QDate incidenceDate() { return mDate; } | 102 | QDate incidenceDate() { return mDate; } |
103 | 103 | ||
104 | protected: | 104 | protected: |
105 | virtual void paint(QPainter *); | 105 | virtual void paint(QPainter *); |
106 | virtual int height(const QListBox *) const; | 106 | virtual int height(const QListBox *) const; |
107 | virtual int width(const QListBox *) const; | 107 | virtual int width(const QListBox *) const; |
108 | 108 | ||
109 | private: | 109 | private: |
110 | bool mRecur; | 110 | bool mRecur; |
111 | bool mAlarm; | 111 | bool mAlarm; |
112 | bool mReply; | 112 | bool mReply; |
113 | bool mInfo; | 113 | bool mInfo; |
114 | 114 | ||
115 | QPalette mPalette; | 115 | QPalette mPalette; |
116 | QDate mDate; | 116 | QDate mDate; |
117 | 117 | ||
118 | Incidence *mIncidence; | 118 | Incidence *mIncidence; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | 121 | ||
122 | class KOMonthView; | 122 | class KOMonthView; |
123 | 123 | ||
124 | class MonthViewCell : public QWidget | 124 | class MonthViewCell : public QWidget |
125 | { | 125 | { |
126 | Q_OBJECT | 126 | Q_OBJECT |
127 | public: | 127 | public: |
128 | MonthViewCell( KOMonthView * ); | 128 | MonthViewCell( KOMonthView * ); |
129 | 129 | ||
130 | void setDate( const QDate & ); | 130 | void setDate( const QDate & ); |
131 | QDate date() const; | 131 | QDate date() const; |
132 | 132 | ||
133 | void setPrimary( bool ); | 133 | void setPrimary( bool ); |
134 | bool isPrimary() const; | 134 | bool isPrimary() const; |
135 | 135 | ||
136 | void setHoliday( bool ); | 136 | void setHoliday( bool ); |
137 | void setHoliday( const QString & ); | 137 | void setHoliday( const QString & ); |
138 | 138 | ||
139 | void updateCell(); | 139 | void updateCell(); |
140 | void startUpdateCell(); | ||
141 | void finishUpdateCell(); | ||
142 | void insertEvent(Event *); | ||
143 | void insertTodo(Todo *); | ||
140 | 144 | ||
141 | void updateConfig(); | 145 | void updateConfig(); |
142 | 146 | ||
143 | void enableScrollBars( bool ); | 147 | void enableScrollBars( bool ); |
144 | 148 | ||
145 | Incidence *selectedIncidence(); | 149 | Incidence *selectedIncidence(); |
146 | QDate selectedIncidenceDate(); | 150 | QDate selectedIncidenceDate(); |
147 | 151 | ||
148 | void deselect(); | 152 | void deselect(); |
149 | void select(); | 153 | void select(); |
150 | void clear(); | 154 | void clear(); |
151 | 155 | ||
152 | #ifdef DESKTOP_VERSION | 156 | #ifdef DESKTOP_VERSION |
153 | static QToolTipGroup *toolTipGroup(); | 157 | static QToolTipGroup *toolTipGroup(); |
154 | #endif | 158 | #endif |
155 | signals: | 159 | signals: |
156 | void defaultAction( Incidence * ); | 160 | void defaultAction( Incidence * ); |
157 | void newEventSignal( QDateTime ); | 161 | void newEventSignal( QDateTime ); |
158 | void showDaySignal( QDate ); | 162 | void showDaySignal( QDate ); |
159 | 163 | ||
160 | protected: | 164 | protected: |
165 | QString mToolTip; | ||
161 | void resizeEvent( QResizeEvent * ); | 166 | void resizeEvent( QResizeEvent * ); |
162 | 167 | ||
163 | protected slots: | 168 | protected slots: |
164 | void defaultAction( QListBoxItem * ); | 169 | void defaultAction( QListBoxItem * ); |
165 | void contextMenu( QListBoxItem * ); | 170 | void contextMenu( QListBoxItem * ); |
166 | void selection( QListBoxItem * ); | 171 | void selection( QListBoxItem * ); |
167 | void cellClicked( QListBoxItem * ); | 172 | void cellClicked( QListBoxItem * ); |
168 | void newEvent(); | 173 | void newEvent(); |
169 | void showDay(); | 174 | void showDay(); |
170 | 175 | ||
171 | private: | 176 | private: |
172 | KOMonthView *mMonthView; | 177 | KOMonthView *mMonthView; |
173 | 178 | ||
174 | QDate mDate; | 179 | QDate mDate; |
175 | bool mPrimary; | 180 | bool mPrimary; |
176 | bool mHoliday; | 181 | bool mHoliday; |
177 | QString mHolidayString; | 182 | QString mHolidayString; |
178 | 183 | ||
179 | //QLabel *mLabel; | 184 | //QLabel *mLabel; |
180 | QPushButton *mLabel; | 185 | QPushButton *mLabel; |
181 | QListBox *mItemList; | 186 | QListBox *mItemList; |
182 | #ifdef DESKTOP_VERSION | 187 | #ifdef DESKTOP_VERSION |
183 | static QToolTipGroup *mToolTipGroup; | 188 | static QToolTipGroup *mToolTipGroup; |
184 | #endif | 189 | #endif |
185 | QSize mLabelSize; | 190 | QSize mLabelSize; |
186 | QSize mLabelBigSize; | 191 | QSize mLabelBigSize; |
187 | QPalette mHolidayPalette; | 192 | QPalette mHolidayPalette; |
188 | QPalette mStandardPalette; | 193 | QPalette mStandardPalette; |
189 | QPalette mPrimaryPalette; | 194 | QPalette mPrimaryPalette; |
190 | QPalette mNonPrimaryPalette; | 195 | QPalette mNonPrimaryPalette; |
191 | void setMyPalette(); | 196 | void setMyPalette(); |
192 | QPalette getPalette (); | 197 | QPalette getPalette (); |
193 | void keyPressEvent ( QKeyEvent * ) ; | 198 | void keyPressEvent ( QKeyEvent * ) ; |
194 | 199 | ||
195 | }; | 200 | }; |
196 | 201 | ||
197 | 202 | ||
198 | class KOMonthView: public KOEventView | 203 | class KOMonthView: public KOEventView |
199 | { | 204 | { |
200 | Q_OBJECT | 205 | Q_OBJECT |
201 | public: | 206 | public: |
202 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 207 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
203 | ~KOMonthView(); | 208 | ~KOMonthView(); |
204 | 209 | ||
205 | /** Returns maximum number of days supported by the komonthview */ | 210 | /** Returns maximum number of days supported by the komonthview */ |
206 | virtual int maxDatesHint(); | 211 | virtual int maxDatesHint(); |
207 | 212 | ||
208 | /** Returns number of currently shown dates. */ | 213 | /** Returns number of currently shown dates. */ |
209 | virtual int currentDateCount(); | 214 | virtual int currentDateCount(); |
210 | 215 | ||
211 | /** returns the currently selected events */ | 216 | /** returns the currently selected events */ |
212 | virtual QPtrList<Incidence> selectedIncidences(); | 217 | virtual QPtrList<Incidence> selectedIncidences(); |
213 | 218 | ||
214 | /** returns dates of the currently selected events */ | 219 | /** returns dates of the currently selected events */ |
215 | virtual DateList selectedDates(); | 220 | virtual DateList selectedDates(); |
216 | 221 | ||
217 | virtual void printPreview(CalPrinter *calPrinter, | 222 | virtual void printPreview(CalPrinter *calPrinter, |
218 | const QDate &, const QDate &); | 223 | const QDate &, const QDate &); |
219 | bool isMonthView() { return true; } | 224 | bool isMonthView() { return true; } |
220 | bool isUpdatePossible() { return updatePossible; } | 225 | bool isUpdatePossible() { return updatePossible; } |
221 | 226 | ||
222 | MonthViewCell * selectedCell(); | 227 | MonthViewCell * selectedCell(); |
223 | public slots: | 228 | public slots: |
224 | virtual void updateView(); | 229 | virtual void updateView(); |
225 | virtual void updateConfig(); | 230 | virtual void updateConfig(); |
226 | virtual void showDates(const QDate &start, const QDate &end); | 231 | virtual void showDates(const QDate &start, const QDate &end); |
227 | virtual void showEvents(QPtrList<Event> eventList); | 232 | virtual void showEvents(QPtrList<Event> eventList); |
228 | 233 | ||
229 | void changeEventDisplay(Event *, int); | 234 | void changeEventDisplay(Event *, int); |
230 | 235 | ||
231 | void clearSelection(); | 236 | void clearSelection(); |
232 | 237 | ||
233 | void showContextMenu( Incidence * ); | 238 | void showContextMenu( Incidence * ); |
234 | 239 | ||
235 | void setSelectedCell( MonthViewCell * ); | 240 | void setSelectedCell( MonthViewCell * ); |
236 | 241 | ||
237 | protected slots: | 242 | protected slots: |
238 | void processSelectionChange(); | 243 | void processSelectionChange(); |
239 | signals: | 244 | signals: |
240 | void nextMonth(); | 245 | void nextMonth(); |
241 | void prevMonth(); | 246 | void prevMonth(); |
242 | void selectWeekNum ( int ); | 247 | void selectWeekNum ( int ); |
243 | void showDaySignal( QDate ); | 248 | void showDaySignal( QDate ); |
244 | protected: | 249 | protected: |
245 | void resizeEvent(QResizeEvent *); | 250 | void resizeEvent(QResizeEvent *); |
246 | void viewChanged(); | 251 | void viewChanged(); |
247 | void updateDayLabels(); | 252 | void updateDayLabels(); |
248 | 253 | ||
249 | private: | 254 | private: |
250 | bool updatePossible; | 255 | bool updatePossible; |
251 | int mDaysPerWeek; | 256 | int mDaysPerWeek; |
252 | int mNumWeeks; | 257 | int mNumWeeks; |
253 | int mNumCells; | 258 | int mNumCells; |
254 | bool mWeekStartsMonday; | 259 | bool mWeekStartsMonday; |
255 | bool mShowSatSunComp; | 260 | bool mShowSatSunComp; |
256 | void computeLayout(); | 261 | void computeLayout(); |