author | zautrix <zautrix> | 2005-01-20 01:24:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-20 01:24:07 (UTC) |
commit | dbb59deb5c0949f83b2d6fd79ec599e7b9e8ebf1 (patch) (unidiff) | |
tree | 3fac729225892ee1a4570a5852ee287f35e74ce7 | |
parent | ade7e8fcdcf45d5bc73ea73da6f9a1b06964a64e (diff) | |
download | kdepimpi-dbb59deb5c0949f83b2d6fd79ec599e7b9e8ebf1.zip kdepimpi-dbb59deb5c0949f83b2d6fd79ec599e7b9e8ebf1.tar.gz kdepimpi-dbb59deb5c0949f83b2d6fd79ec599e7b9e8ebf1.tar.bz2 |
more view fixes
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 26 | ||||
-rw-r--r-- | korganizer/komonthview.h | 1 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 3 |
4 files changed, 23 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index f9af769..8f05276 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -408,194 +408,194 @@ void CalendarView::init() | |||
408 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 408 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
409 | SLOT( purgeCompleted() ) ); | 409 | SLOT( purgeCompleted() ) ); |
410 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 410 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
411 | SIGNAL( todoModified( Todo *, int ) ) ); | 411 | SIGNAL( todoModified( Todo *, int ) ) ); |
412 | 412 | ||
413 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 413 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
414 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 414 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
415 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 415 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
416 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 416 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
417 | 417 | ||
418 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 418 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
419 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 419 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
420 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 420 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
421 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 421 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
422 | 422 | ||
423 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 423 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
424 | this, SLOT ( todo_unsub( Todo * ) ) ); | 424 | this, SLOT ( todo_unsub( Todo * ) ) ); |
425 | 425 | ||
426 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 426 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
427 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 427 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
428 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 428 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
429 | SLOT( updateTodo( Todo *, int ) ) ); | 429 | SLOT( updateTodo( Todo *, int ) ) ); |
430 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 430 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
431 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 431 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
432 | 432 | ||
433 | 433 | ||
434 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 434 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
435 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 435 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
436 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 436 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
437 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 437 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
438 | 438 | ||
439 | 439 | ||
440 | 440 | ||
441 | 441 | ||
442 | 442 | ||
443 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 443 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
444 | SLOT(checkClipboard())); | 444 | SLOT(checkClipboard())); |
445 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 445 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
446 | SLOT( processTodoListSelection( Incidence * ) ) ); | 446 | SLOT( processTodoListSelection( Incidence * ) ) ); |
447 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 447 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
448 | 448 | ||
449 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 449 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
450 | 450 | ||
451 | mDateFrame = new QVBox(0,0,WType_Popup); | 451 | mDateFrame = new QVBox(0,0,WType_Popup); |
452 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 452 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
453 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 453 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
454 | mDateFrame->setLineWidth(3); | 454 | mDateFrame->setLineWidth(3); |
455 | mDateFrame->hide(); | 455 | mDateFrame->hide(); |
456 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 456 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
457 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 457 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
458 | 458 | ||
459 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 459 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
460 | 460 | ||
461 | mEventEditor = mDialogManager->getEventEditor(); | 461 | mEventEditor = mDialogManager->getEventEditor(); |
462 | mTodoEditor = mDialogManager->getTodoEditor(); | 462 | mTodoEditor = mDialogManager->getTodoEditor(); |
463 | 463 | ||
464 | mFlagEditDescription = false; | 464 | mFlagEditDescription = false; |
465 | 465 | ||
466 | mSuspendTimer = new QTimer( this ); | 466 | mSuspendTimer = new QTimer( this ); |
467 | mAlarmTimer = new QTimer( this ); | 467 | mAlarmTimer = new QTimer( this ); |
468 | mRecheckAlarmTimer = new QTimer( this ); | 468 | mRecheckAlarmTimer = new QTimer( this ); |
469 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 469 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
470 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 470 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
471 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 471 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
472 | mAlarmDialog = new AlarmDialog( this ); | 472 | mAlarmDialog = new AlarmDialog( this ); |
473 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 473 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
474 | mAlarmDialog->setServerNotification( false ); | 474 | mAlarmDialog->setServerNotification( false ); |
475 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 475 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
476 | 476 | ||
477 | 477 | ||
478 | #ifndef DESKTOP_VERSION | 478 | #ifndef DESKTOP_VERSION |
479 | //US listen for arriving address resultsets | 479 | //US listen for arriving address resultsets |
480 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 480 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
481 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 481 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
482 | #endif | 482 | #endif |
483 | 483 | ||
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | CalendarView::~CalendarView() | 487 | CalendarView::~CalendarView() |
488 | { | 488 | { |
489 | // kdDebug() << "~CalendarView()" << endl; | 489 | // kdDebug() << "~CalendarView()" << endl; |
490 | //qDebug("CalendarView::~CalendarView() "); | 490 | //qDebug("CalendarView::~CalendarView() "); |
491 | delete mDialogManager; | 491 | delete mDialogManager; |
492 | delete mViewManager; | 492 | delete mViewManager; |
493 | delete mStorage; | 493 | delete mStorage; |
494 | delete mDateFrame ; | 494 | delete mDateFrame ; |
495 | delete beamDialog; | 495 | delete beamDialog; |
496 | //kdDebug() << "~CalendarView() done" << endl; | 496 | //kdDebug() << "~CalendarView() done" << endl; |
497 | } | 497 | } |
498 | 498 | ||
499 | void CalendarView::showDay( QDate d ) | 499 | void CalendarView::showDay( QDate d ) |
500 | { | 500 | { |
501 | dateNavigator()->blockSignals( true ); | 501 | dateNavigator()->blockSignals( true ); |
502 | dateNavigator()->selectDate( d ); | 502 | dateNavigator()->selectDate( d ); |
503 | dateNavigator()->blockSignals( false ); | 503 | dateNavigator()->blockSignals( false ); |
504 | mViewManager->showWeekView(); | 504 | mViewManager->showDayView(); |
505 | dateNavigator()->selectDate( d ); | 505 | //dateNavigator()->selectDate( d ); |
506 | } | 506 | } |
507 | void CalendarView::timerAlarm() | 507 | void CalendarView::timerAlarm() |
508 | { | 508 | { |
509 | //qDebug("CalendarView::timerAlarm() "); | 509 | //qDebug("CalendarView::timerAlarm() "); |
510 | computeAlarm(mAlarmNotification ); | 510 | computeAlarm(mAlarmNotification ); |
511 | } | 511 | } |
512 | 512 | ||
513 | void CalendarView::suspendAlarm() | 513 | void CalendarView::suspendAlarm() |
514 | { | 514 | { |
515 | //qDebug(" CalendarView::suspendAlarm() "); | 515 | //qDebug(" CalendarView::suspendAlarm() "); |
516 | computeAlarm(mSuspendAlarmNotification ); | 516 | computeAlarm(mSuspendAlarmNotification ); |
517 | 517 | ||
518 | } | 518 | } |
519 | 519 | ||
520 | void CalendarView::startAlarm( QString mess , QString filename) | 520 | void CalendarView::startAlarm( QString mess , QString filename) |
521 | { | 521 | { |
522 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 522 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
523 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 523 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
524 | 524 | ||
525 | } | 525 | } |
526 | 526 | ||
527 | void CalendarView::checkNextTimerAlarm() | 527 | void CalendarView::checkNextTimerAlarm() |
528 | { | 528 | { |
529 | mCalendar->checkAlarmForIncidence( 0, true ); | 529 | mCalendar->checkAlarmForIncidence( 0, true ); |
530 | } | 530 | } |
531 | 531 | ||
532 | void CalendarView::computeAlarm( QString msg ) | 532 | void CalendarView::computeAlarm( QString msg ) |
533 | { | 533 | { |
534 | 534 | ||
535 | QString mess = msg; | 535 | QString mess = msg; |
536 | QString mAlarmMessage = mess.mid( 9 ); | 536 | QString mAlarmMessage = mess.mid( 9 ); |
537 | QString filename = MainWindow::resourcePath(); | 537 | QString filename = MainWindow::resourcePath(); |
538 | filename += "koalarm.wav"; | 538 | filename += "koalarm.wav"; |
539 | QString tempfilename; | 539 | QString tempfilename; |
540 | if ( mess.left( 13 ) == "suspend_alarm") { | 540 | if ( mess.left( 13 ) == "suspend_alarm") { |
541 | bool error = false; | 541 | bool error = false; |
542 | int len = mess.mid( 13 ).find("+++"); | 542 | int len = mess.mid( 13 ).find("+++"); |
543 | if ( len < 2 ) | 543 | if ( len < 2 ) |
544 | error = true; | 544 | error = true; |
545 | else { | 545 | else { |
546 | tempfilename = mess.mid( 13, len ); | 546 | tempfilename = mess.mid( 13, len ); |
547 | if ( !QFile::exists( tempfilename ) ) | 547 | if ( !QFile::exists( tempfilename ) ) |
548 | error = true; | 548 | error = true; |
549 | } | 549 | } |
550 | if ( ! error ) { | 550 | if ( ! error ) { |
551 | filename = tempfilename; | 551 | filename = tempfilename; |
552 | } | 552 | } |
553 | mAlarmMessage = mess.mid( 13+len+3 ); | 553 | mAlarmMessage = mess.mid( 13+len+3 ); |
554 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 554 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
555 | startAlarm( mAlarmMessage, filename); | 555 | startAlarm( mAlarmMessage, filename); |
556 | return; | 556 | return; |
557 | } | 557 | } |
558 | if ( mess.left( 11 ) == "timer_alarm") { | 558 | if ( mess.left( 11 ) == "timer_alarm") { |
559 | //mTimerTime = 0; | 559 | //mTimerTime = 0; |
560 | startAlarm( mess.mid( 11 ), filename ); | 560 | startAlarm( mess.mid( 11 ), filename ); |
561 | return; | 561 | return; |
562 | } | 562 | } |
563 | if ( mess.left( 10 ) == "proc_alarm") { | 563 | if ( mess.left( 10 ) == "proc_alarm") { |
564 | bool error = false; | 564 | bool error = false; |
565 | int len = mess.mid( 10 ).find("+++"); | 565 | int len = mess.mid( 10 ).find("+++"); |
566 | if ( len < 2 ) | 566 | if ( len < 2 ) |
567 | error = true; | 567 | error = true; |
568 | else { | 568 | else { |
569 | tempfilename = mess.mid( 10, len ); | 569 | tempfilename = mess.mid( 10, len ); |
570 | if ( !QFile::exists( tempfilename ) ) | 570 | if ( !QFile::exists( tempfilename ) ) |
571 | error = true; | 571 | error = true; |
572 | } | 572 | } |
573 | if ( error ) { | 573 | if ( error ) { |
574 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 574 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
575 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 575 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
576 | } else { | 576 | } else { |
577 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 577 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
578 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 578 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
579 | #ifndef _WIN32_ | 579 | #ifndef _WIN32_ |
580 | if ( vfork () == 0 ) { | 580 | if ( vfork () == 0 ) { |
581 | execl ( tempfilename.latin1(), 0 ); | 581 | execl ( tempfilename.latin1(), 0 ); |
582 | return; | 582 | return; |
583 | } | 583 | } |
584 | #else | 584 | #else |
585 | QProcess* p = new QProcess(); | 585 | QProcess* p = new QProcess(); |
586 | p->addArgument( tempfilename.latin1() ); | 586 | p->addArgument( tempfilename.latin1() ); |
587 | p->start(); | 587 | p->start(); |
588 | return; | 588 | return; |
589 | #endif | 589 | #endif |
590 | 590 | ||
591 | return; | 591 | return; |
592 | } | 592 | } |
593 | 593 | ||
594 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 594 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
595 | } | 595 | } |
596 | if ( mess.left( 11 ) == "audio_alarm") { | 596 | if ( mess.left( 11 ) == "audio_alarm") { |
597 | bool error = false; | 597 | bool error = false; |
598 | int len = mess.mid( 11 ).find("+++"); | 598 | int len = mess.mid( 11 ).find("+++"); |
599 | if ( len < 2 ) | 599 | if ( len < 2 ) |
600 | error = true; | 600 | error = true; |
601 | else { | 601 | else { |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 842f6eb..b819eec 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,173 +1,173 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.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 | 35 | ||
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | #include "calprinter.h" | 45 | #include "calprinter.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #ifndef KORG_NOPLUGINS | 48 | #ifndef KORG_NOPLUGINS |
49 | #include "kocore.h" | 49 | #include "kocore.h" |
50 | #endif | 50 | #endif |
51 | #include "koglobals.h" | 51 | #include "koglobals.h" |
52 | #include <libkcal/kincidenceformatter.h> | 52 | #include <libkcal/kincidenceformatter.h> |
53 | 53 | ||
54 | #include "komonthview.h" | 54 | #include "komonthview.h" |
55 | 55 | ||
56 | #define PIXMAP_SIZE 5 | 56 | #define PIXMAP_SIZE 5 |
57 | #ifdef DESKTOP_VERSION | 57 | #ifdef DESKTOP_VERSION |
58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
59 | #endif | 59 | #endif |
60 | class KNOWhatsThis :public QWhatsThis | 60 | class KNOWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | virtual QString text( const QPoint& p) | 66 | virtual QString text( const QPoint& p) |
67 | { | 67 | { |
68 | return _wid->getWhatsThisText(p) ; | 68 | return _wid->getWhatsThisText(p) ; |
69 | }; | 69 | }; |
70 | private: | 70 | private: |
71 | KNoScrollListBox* _wid; | 71 | KNoScrollListBox* _wid; |
72 | 72 | ||
73 | }; | 73 | }; |
74 | 74 | ||
75 | 75 | ||
76 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 76 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
77 | : QListBox(parent, name) | 77 | : QListBox(parent, name, WRepaintNoErase) |
78 | { | 78 | { |
79 | #ifndef DESKTOP_VERSION | 79 | #ifndef DESKTOP_VERSION |
80 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 80 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
81 | #endif | 81 | #endif |
82 | mWT = new KNOWhatsThis(this); | 82 | mWT = new KNOWhatsThis(this); |
83 | } | 83 | } |
84 | KNoScrollListBox::~KNoScrollListBox() | 84 | KNoScrollListBox::~KNoScrollListBox() |
85 | { | 85 | { |
86 | delete mWT; | 86 | delete mWT; |
87 | } | 87 | } |
88 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 88 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
89 | { | 89 | { |
90 | QListBoxItem* item = itemAt ( p ); | 90 | QListBoxItem* item = itemAt ( p ); |
91 | if ( ! item ) { | 91 | if ( ! item ) { |
92 | return i18n("Click in the cell\nto add an event!"); | 92 | return i18n("Click in the cell\nto add an event!"); |
93 | } | 93 | } |
94 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 94 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
95 | } | 95 | } |
96 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 96 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
97 | { | 97 | { |
98 | 98 | ||
99 | switch(e->key()) { | 99 | switch(e->key()) { |
100 | case Key_Right: | 100 | case Key_Right: |
101 | // if ( e->state() == Qt::ControlButton ) | 101 | // if ( e->state() == Qt::ControlButton ) |
102 | { | 102 | { |
103 | e->ignore(); | 103 | e->ignore(); |
104 | return; | 104 | return; |
105 | } | 105 | } |
106 | scrollBy(4,0); | 106 | scrollBy(4,0); |
107 | break; | 107 | break; |
108 | case Key_Left: | 108 | case Key_Left: |
109 | // if ( e->state() == Qt::ControlButton ) | 109 | // if ( e->state() == Qt::ControlButton ) |
110 | { | 110 | { |
111 | e->ignore(); | 111 | e->ignore(); |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | scrollBy(-4,0); | 114 | scrollBy(-4,0); |
115 | break; | 115 | break; |
116 | case Key_Up: | 116 | case Key_Up: |
117 | if(!count()) break; | 117 | if(!count()) break; |
118 | setCurrentItem((currentItem()+count()-1)%count()); | 118 | setCurrentItem((currentItem()+count()-1)%count()); |
119 | if(!itemVisible(currentItem())) { | 119 | if(!itemVisible(currentItem())) { |
120 | if((unsigned int) currentItem() == (count()-1)) { | 120 | if((unsigned int) currentItem() == (count()-1)) { |
121 | setTopItem(currentItem()-numItemsVisible()+1); | 121 | setTopItem(currentItem()-numItemsVisible()+1); |
122 | } else { | 122 | } else { |
123 | setTopItem(topItem()-1); | 123 | setTopItem(topItem()-1); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | break; | 126 | break; |
127 | case Key_Down: | 127 | case Key_Down: |
128 | if(!count()) break; | 128 | if(!count()) break; |
129 | setCurrentItem((currentItem()+1)%count()); | 129 | setCurrentItem((currentItem()+1)%count()); |
130 | if(!itemVisible(currentItem())) { | 130 | if(!itemVisible(currentItem())) { |
131 | if(currentItem() == 0) { | 131 | if(currentItem() == 0) { |
132 | setTopItem(0); | 132 | setTopItem(0); |
133 | } else { | 133 | } else { |
134 | setTopItem(topItem()+1); | 134 | setTopItem(topItem()+1); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | break; | 137 | break; |
138 | case Key_Shift: | 138 | case Key_Shift: |
139 | emit shiftDown(); | 139 | emit shiftDown(); |
140 | break; | 140 | break; |
141 | default: | 141 | default: |
142 | e->ignore(); | 142 | e->ignore(); |
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 147 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
148 | { | 148 | { |
149 | switch(e->key()) { | 149 | switch(e->key()) { |
150 | case Key_Shift: | 150 | case Key_Shift: |
151 | emit shiftUp(); | 151 | emit shiftUp(); |
152 | break; | 152 | break; |
153 | default: | 153 | default: |
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 158 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
159 | { | 159 | { |
160 | QListBox::mousePressEvent(e); | 160 | QListBox::mousePressEvent(e); |
161 | 161 | ||
162 | if(e->button() == RightButton) { | 162 | if(e->button() == RightButton) { |
163 | emit rightClick(); | 163 | emit rightClick(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 167 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
168 | : QListBoxItem() | 168 | : QListBoxItem() |
169 | { | 169 | { |
170 | setText( s ); | 170 | setText( s ); |
171 | 171 | ||
172 | mIncidence = incidence; | 172 | mIncidence = incidence; |
173 | mDate = qd; | 173 | mDate = qd; |
@@ -289,380 +289,389 @@ MonthViewCell::MonthViewCell( KOMonthView *parent) | |||
289 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 289 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
290 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 290 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
291 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 291 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
292 | SLOT( defaultAction( QListBoxItem * ) ) ); | 292 | SLOT( defaultAction( QListBoxItem * ) ) ); |
293 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 293 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
294 | const QPoint &) ), | 294 | const QPoint &) ), |
295 | SLOT( contextMenu( QListBoxItem * ) ) ); | 295 | SLOT( contextMenu( QListBoxItem * ) ) ); |
296 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 296 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
297 | SLOT( selection( QListBoxItem * ) ) ); | 297 | SLOT( selection( QListBoxItem * ) ) ); |
298 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 298 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
299 | SLOT( cellClicked( QListBoxItem * ) ) ); | 299 | SLOT( cellClicked( QListBoxItem * ) ) ); |
300 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 300 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
301 | SLOT( selection( QListBoxItem * ) ) ); | 301 | SLOT( selection( QListBoxItem * ) ) ); |
302 | } | 302 | } |
303 | #ifdef DESKTOP_VERSION | 303 | #ifdef DESKTOP_VERSION |
304 | QToolTipGroup *MonthViewCell::toolTipGroup() | 304 | QToolTipGroup *MonthViewCell::toolTipGroup() |
305 | { | 305 | { |
306 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 306 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
307 | return mToolTipGroup; | 307 | return mToolTipGroup; |
308 | } | 308 | } |
309 | #endif | 309 | #endif |
310 | 310 | ||
311 | void MonthViewCell::setDate( const QDate &date ) | 311 | void MonthViewCell::setDate( const QDate &date ) |
312 | { | 312 | { |
313 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 313 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
314 | mDate = date; | 314 | mDate = date; |
315 | 315 | ||
316 | 316 | ||
317 | 317 | ||
318 | //resizeEvent( 0 ); | 318 | //resizeEvent( 0 ); |
319 | } | 319 | } |
320 | 320 | ||
321 | QDate MonthViewCell::date() const | 321 | QDate MonthViewCell::date() const |
322 | { | 322 | { |
323 | return mDate; | 323 | return mDate; |
324 | } | 324 | } |
325 | 325 | ||
326 | void MonthViewCell::setPrimary( bool primary ) | 326 | void MonthViewCell::setPrimary( bool primary ) |
327 | { | 327 | { |
328 | mPrimary = primary; | 328 | mPrimary = primary; |
329 | //setMyPalette(); | 329 | //setMyPalette(); |
330 | } | 330 | } |
331 | void MonthViewCell::setMyPalette() | 331 | void MonthViewCell::setMyPalette() |
332 | { | 332 | { |
333 | 333 | ||
334 | if ( mHoliday) { | 334 | if ( mHoliday) { |
335 | setPalette( mHolidayPalette ); | 335 | setPalette( mHolidayPalette ); |
336 | } else { | 336 | } else { |
337 | if ( mPrimary ) { | 337 | if ( mPrimary ) { |
338 | setPalette( mPrimaryPalette ); | 338 | setPalette( mPrimaryPalette ); |
339 | } else { | 339 | } else { |
340 | setPalette( mNonPrimaryPalette ); | 340 | setPalette( mNonPrimaryPalette ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | QPalette pal = palette(); | 343 | QPalette pal = palette(); |
344 | 344 | ||
345 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 345 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
346 | } | 346 | } |
347 | QPalette MonthViewCell::getPalette () | 347 | QPalette MonthViewCell::getPalette () |
348 | { | 348 | { |
349 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 349 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
350 | return mStandardPalette; | 350 | return mStandardPalette; |
351 | if ( mHoliday) { | 351 | if ( mHoliday) { |
352 | return mHolidayPalette ; | 352 | return mHolidayPalette ; |
353 | } else { | 353 | } else { |
354 | if ( mPrimary ) { | 354 | if ( mPrimary ) { |
355 | return mPrimaryPalette ; | 355 | return mPrimaryPalette ; |
356 | } | 356 | } |
357 | } | 357 | } |
358 | return mNonPrimaryPalette; | 358 | return mNonPrimaryPalette; |
359 | } | 359 | } |
360 | bool MonthViewCell::isPrimary() const | 360 | bool MonthViewCell::isPrimary() const |
361 | { | 361 | { |
362 | return mPrimary; | 362 | return mPrimary; |
363 | } | 363 | } |
364 | 364 | ||
365 | void MonthViewCell::setHoliday( bool holiday ) | 365 | void MonthViewCell::setHoliday( bool holiday ) |
366 | { | 366 | { |
367 | mHoliday = holiday; | 367 | mHoliday = holiday; |
368 | //setMyPalette(); | 368 | //setMyPalette(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void MonthViewCell::setHoliday( const QString &holiday ) | 371 | void MonthViewCell::setHoliday( const QString &holiday ) |
372 | { | 372 | { |
373 | mHolidayString = holiday; | 373 | mHolidayString = holiday; |
374 | 374 | ||
375 | if ( !holiday.isEmpty() ) { | 375 | if ( !holiday.isEmpty() ) { |
376 | setHoliday( true ); | 376 | setHoliday( true ); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 379 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
380 | { | 380 | { |
381 | 381 | ||
382 | e->ignore(); | 382 | e->ignore(); |
383 | 383 | ||
384 | } | 384 | } |
385 | void MonthViewCell::clear() | ||
386 | { | ||
387 | mItemList->clear(); | ||
388 | QApplication::removePostedEvents ( mItemList ); | ||
389 | QApplication::removePostedEvents ( mLabel ); | ||
390 | QApplication::removePostedEvents ( this ); | ||
391 | } | ||
385 | void MonthViewCell::updateCell() | 392 | void MonthViewCell::updateCell() |
386 | { | 393 | { |
387 | if ( !mMonthView->isUpdatePossible() ) | 394 | if ( !mMonthView->isUpdatePossible() ) |
388 | return; | 395 | return; |
389 | if ( !isVisible() ){ | 396 | /* |
397 | if ( !isVisible() ){ | ||
390 | return; | 398 | return; |
391 | } | 399 | } |
400 | */ | ||
401 | // qDebug("MonthViewCell::updateCell() "); | ||
392 | setPrimary( mDate.month()%2 ); | 402 | setPrimary( mDate.month()%2 ); |
393 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 403 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
394 | if ( mDate == QDate::currentDate() ) { | 404 | if ( mDate == QDate::currentDate() ) { |
395 | mItemList->setLineWidth( 3 ); | 405 | mItemList->setLineWidth( 3 ); |
396 | } else { | 406 | } else { |
397 | mItemList->setLineWidth( 1 ); | 407 | mItemList->setLineWidth( 1 ); |
398 | } | 408 | } |
399 | mItemList->clear(); | 409 | mItemList->clear(); |
400 | 410 | ||
401 | |||
402 | |||
403 | #ifdef DESKTOP_VERSION | 411 | #ifdef DESKTOP_VERSION |
404 | QToolTip::remove(this); | 412 | QToolTip::remove(this); |
405 | #endif | 413 | #endif |
406 | QString tipText(""); | 414 | QString tipText(""); |
407 | //qApp->processEvents(); | 415 | //qApp->processEvents(); |
408 | if ( !mHolidayString.isEmpty() ) { | 416 | if ( !mHolidayString.isEmpty() ) { |
409 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 417 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
410 | item->setPalette( mHolidayPalette ); | 418 | item->setPalette( mHolidayPalette ); |
411 | mItemList->insertItem( item ); | 419 | mItemList->insertItem( item ); |
412 | tipText += mHolidayString+"\n"; | 420 | tipText += mHolidayString+"\n"; |
413 | } | 421 | } |
414 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 422 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
415 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 423 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
416 | Event *event; | 424 | Event *event; |
417 | for( event = events.first(); event; event = events.next() ) { // for event | 425 | for( event = events.first(); event; event = events.next() ) { // for event |
418 | 426 | ||
419 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 427 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
420 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 428 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
421 | continue; | 429 | continue; |
422 | else | 430 | else |
423 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 431 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
424 | continue; | 432 | continue; |
425 | } | 433 | } |
426 | 434 | ||
427 | if ( event->categories().contains("Holiday") || | 435 | if ( event->categories().contains("Holiday") || |
428 | event->categories().contains(i18n("Holiday"))) { | 436 | event->categories().contains(i18n("Holiday"))) { |
429 | setHoliday( true ); | 437 | setHoliday( true ); |
430 | if ( mDate.dayOfWeek() == 7 ) | 438 | if ( mDate.dayOfWeek() == 7 ) |
431 | mItemList->setLineWidth( 3 ); | 439 | mItemList->setLineWidth( 3 ); |
432 | } | 440 | } |
433 | QString text; | 441 | QString text; |
434 | if (event->isMultiDay()) { | 442 | if (event->isMultiDay()) { |
435 | QString prefix = "<->"; | 443 | QString prefix = "<->"; |
436 | if ( event->doesRecur() ) { | 444 | if ( event->doesRecur() ) { |
437 | if ( event->recursOn( mDate) ) | 445 | if ( event->recursOn( mDate) ) |
438 | prefix ="->" ; | 446 | prefix ="->" ; |
439 | else { | 447 | else { |
440 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 448 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
441 | if ( event->recursOn( mDate.addDays( -days)) ) | 449 | if ( event->recursOn( mDate.addDays( -days)) ) |
442 | prefix ="<-" ; | 450 | prefix ="<-" ; |
443 | } | 451 | } |
444 | 452 | ||
445 | } else { | 453 | } else { |
446 | if (mDate == event->dtStart().date()) { | 454 | if (mDate == event->dtStart().date()) { |
447 | prefix ="->" ; | 455 | prefix ="->" ; |
448 | } else if (mDate == event->dtEnd().date()) { | 456 | } else if (mDate == event->dtEnd().date()) { |
449 | prefix ="<-" ; | 457 | prefix ="<-" ; |
450 | } | 458 | } |
451 | } | 459 | } |
452 | text = prefix + event->summary(); | 460 | text = prefix + event->summary(); |
453 | tipText += text; | 461 | tipText += text; |
454 | } else { | 462 | } else { |
455 | if (event->doesFloat()) { | 463 | if (event->doesFloat()) { |
456 | text = event->summary(); | 464 | text = event->summary(); |
457 | tipText += text; | 465 | tipText += text; |
458 | } | 466 | } |
459 | else { | 467 | else { |
460 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 468 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
461 | text += " " + event->summary(); | 469 | text += " " + event->summary(); |
462 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 470 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
463 | } | 471 | } |
464 | } | 472 | } |
465 | 473 | ||
466 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 474 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
467 | QPalette pal; | 475 | QPalette pal; |
468 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 476 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
469 | QStringList categories = event->categories(); | 477 | QStringList categories = event->categories(); |
470 | QString cat = categories.first(); | 478 | QString cat = categories.first(); |
471 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 479 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
472 | pal = getPalette(); | 480 | pal = getPalette(); |
473 | if (cat.isEmpty()) { | 481 | if (cat.isEmpty()) { |
474 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 482 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
475 | } else { | 483 | } else { |
476 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 484 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
477 | } | 485 | } |
478 | 486 | ||
479 | } else { | 487 | } else { |
480 | if (cat.isEmpty()) { | 488 | if (cat.isEmpty()) { |
481 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 489 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
482 | } else { | 490 | } else { |
483 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 491 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
484 | } | 492 | } |
485 | } | 493 | } |
486 | 494 | ||
487 | } else { | 495 | } else { |
488 | pal = mStandardPalette ; | 496 | pal = mStandardPalette ; |
489 | } | 497 | } |
490 | item->setPalette( pal ); | 498 | item->setPalette( pal ); |
491 | item->setRecur( event->recurrence()->doesRecur() ); | 499 | item->setRecur( event->recurrence()->doesRecur() ); |
492 | item->setAlarm( event->isAlarmEnabled() ); | 500 | item->setAlarm( event->isAlarmEnabled() ); |
493 | item->setMoreInfo( event->description().length() > 0 ); | 501 | item->setMoreInfo( event->description().length() > 0 ); |
494 | #ifdef DESKTOP_VERSION | 502 | #ifdef DESKTOP_VERSION |
495 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 503 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
496 | KOPrefs::instance()->email()); | 504 | KOPrefs::instance()->email()); |
497 | if ( me != 0 ) { | 505 | if ( me != 0 ) { |
498 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 506 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
499 | item->setReply(true); | 507 | item->setReply(true); |
500 | else | 508 | else |
501 | item->setReply(false); | 509 | item->setReply(false); |
502 | } else | 510 | } else |
503 | item->setReply(false); | 511 | item->setReply(false); |
504 | #endif | 512 | #endif |
505 | mItemList->insertItem( item ); | 513 | mItemList->insertItem( item ); |
506 | tipText += "\n"; | 514 | tipText += "\n"; |
507 | 515 | ||
508 | } | 516 | } |
509 | 517 | ||
510 | // insert due todos | 518 | // insert due todos |
511 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 519 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
512 | Todo *todo; | 520 | Todo *todo; |
513 | for(todo = todos.first(); todo; todo = todos.next()) { | 521 | for(todo = todos.first(); todo; todo = todos.next()) { |
514 | QString text; | 522 | QString text; |
515 | if (todo->hasDueDate()) { | 523 | if (todo->hasDueDate()) { |
516 | if (!todo->doesFloat()) { | 524 | if (!todo->doesFloat()) { |
517 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 525 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
518 | text += " "; | 526 | text += " "; |
519 | } | 527 | } |
520 | } | 528 | } |
521 | text += i18n("To-Do: %1").arg(todo->summary()); | 529 | text += i18n("To-Do: %1").arg(todo->summary()); |
522 | 530 | ||
523 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 531 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
524 | //item->setPalette( mStandardPalette ); | 532 | //item->setPalette( mStandardPalette ); |
525 | QPalette pal; | 533 | QPalette pal; |
526 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 534 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
527 | QStringList categories = todo->categories(); | 535 | QStringList categories = todo->categories(); |
528 | QString cat = categories.first(); | 536 | QString cat = categories.first(); |
529 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 537 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
530 | pal = getPalette(); | 538 | pal = getPalette(); |
531 | if (cat.isEmpty()) { | 539 | if (cat.isEmpty()) { |
532 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 540 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
533 | } else { | 541 | } else { |
534 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 542 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
535 | } | 543 | } |
536 | 544 | ||
537 | } else { | 545 | } else { |
538 | if (cat.isEmpty()) { | 546 | if (cat.isEmpty()) { |
539 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 547 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
540 | } else { | 548 | } else { |
541 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 549 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
542 | } | 550 | } |
543 | } | 551 | } |
544 | 552 | ||
545 | } else { | 553 | } else { |
546 | pal = mStandardPalette ; | 554 | pal = mStandardPalette ; |
547 | } | 555 | } |
548 | item->setPalette( pal ); | 556 | item->setPalette( pal ); |
549 | mItemList->insertItem( item ); | 557 | mItemList->insertItem( item ); |
550 | tipText += text+"\n"; | 558 | tipText += text+"\n"; |
551 | } | 559 | } |
552 | #ifdef DESKTOP_VERSION | 560 | #ifdef DESKTOP_VERSION |
553 | if (tipText != "") | 561 | if (tipText != "") |
554 | QToolTip::add(this,tipText,toolTipGroup(),""); | 562 | QToolTip::add(this,tipText,toolTipGroup(),""); |
555 | #endif | 563 | #endif |
556 | 564 | ||
557 | //setMyPalette(); | 565 | //setMyPalette(); |
558 | setMyPalette(); | 566 | setMyPalette(); |
559 | QString text; | 567 | QString text; |
560 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 568 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
561 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 569 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
562 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 570 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
563 | mLabel->resize( mLabelBigSize ); | 571 | mLabel->resize( mLabelBigSize ); |
564 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 572 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
565 | } else { | 573 | } else { |
566 | mLabel->resize( mLabelSize ); | 574 | mLabel->resize( mLabelSize ); |
567 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 575 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
568 | } | 576 | } |
577 | |||
569 | mLabel->setText( text ); | 578 | mLabel->setText( text ); |
570 | resizeEvent( 0 ); | 579 | resizeEvent( 0 ); |
571 | // if ( isVisible()) | 580 | // if ( isVisible()) |
572 | qApp->processEvents(); | 581 | //qApp->processEvents(); |
573 | } | 582 | } |
574 | 583 | ||
575 | void MonthViewCell::updateConfig() | 584 | void MonthViewCell::updateConfig() |
576 | { | 585 | { |
577 | 586 | ||
578 | setFont( KOPrefs::instance()->mMonthViewFont ); | 587 | setFont( KOPrefs::instance()->mMonthViewFont ); |
579 | 588 | ||
580 | QFontMetrics fm( font() ); | 589 | QFontMetrics fm( font() ); |
581 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 590 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
582 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 591 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
583 | mHolidayPalette = mStandardPalette; | 592 | mHolidayPalette = mStandardPalette; |
584 | mPrimaryPalette = mStandardPalette; | 593 | mPrimaryPalette = mStandardPalette; |
585 | mNonPrimaryPalette = mStandardPalette; | 594 | mNonPrimaryPalette = mStandardPalette; |
586 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 595 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
587 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 596 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
588 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 597 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
589 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 598 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
590 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 599 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
591 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 600 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
592 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 601 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
593 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 602 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
594 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 603 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
595 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 604 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
596 | } | 605 | } |
597 | updateCell(); | 606 | updateCell(); |
598 | } | 607 | } |
599 | 608 | ||
600 | void MonthViewCell::enableScrollBars( bool enabled ) | 609 | void MonthViewCell::enableScrollBars( bool enabled ) |
601 | { | 610 | { |
602 | if ( enabled ) { | 611 | if ( enabled ) { |
603 | mItemList->setVScrollBarMode(QScrollView::Auto); | 612 | mItemList->setVScrollBarMode(QScrollView::Auto); |
604 | mItemList->setHScrollBarMode(QScrollView::Auto); | 613 | mItemList->setHScrollBarMode(QScrollView::Auto); |
605 | } else { | 614 | } else { |
606 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 615 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
607 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 616 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
608 | } | 617 | } |
609 | } | 618 | } |
610 | 619 | ||
611 | Incidence *MonthViewCell::selectedIncidence() | 620 | Incidence *MonthViewCell::selectedIncidence() |
612 | { | 621 | { |
613 | int index = mItemList->currentItem(); | 622 | int index = mItemList->currentItem(); |
614 | if ( index < 0 ) return 0; | 623 | if ( index < 0 ) return 0; |
615 | 624 | ||
616 | MonthViewItem *item = | 625 | MonthViewItem *item = |
617 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 626 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
618 | 627 | ||
619 | if ( !item ) return 0; | 628 | if ( !item ) return 0; |
620 | 629 | ||
621 | return item->incidence(); | 630 | return item->incidence(); |
622 | } | 631 | } |
623 | 632 | ||
624 | QDate MonthViewCell::selectedIncidenceDate() | 633 | QDate MonthViewCell::selectedIncidenceDate() |
625 | { | 634 | { |
626 | QDate qd; | 635 | QDate qd; |
627 | int index = mItemList->currentItem(); | 636 | int index = mItemList->currentItem(); |
628 | if ( index < 0 ) return qd; | 637 | if ( index < 0 ) return qd; |
629 | 638 | ||
630 | MonthViewItem *item = | 639 | MonthViewItem *item = |
631 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 640 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
632 | 641 | ||
633 | if ( !item ) return qd; | 642 | if ( !item ) return qd; |
634 | 643 | ||
635 | return item->incidenceDate(); | 644 | return item->incidenceDate(); |
636 | } | 645 | } |
637 | 646 | ||
638 | void MonthViewCell::deselect() | 647 | void MonthViewCell::deselect() |
639 | { | 648 | { |
640 | mItemList->clearSelection(); | 649 | mItemList->clearSelection(); |
641 | enableScrollBars( false ); | 650 | enableScrollBars( false ); |
642 | // updateCell(); | 651 | // updateCell(); |
643 | } | 652 | } |
644 | void MonthViewCell::select() | 653 | void MonthViewCell::select() |
645 | { | 654 | { |
646 | ;// updateCell(); | 655 | ;// updateCell(); |
647 | } | 656 | } |
648 | 657 | ||
649 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 658 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
650 | { | 659 | { |
651 | if ( !mMonthView->isUpdatePossible() ) | 660 | if ( !mMonthView->isUpdatePossible() ) |
652 | return; | 661 | return; |
653 | if ( !isVisible() ){ | 662 | if ( !isVisible() ){ |
654 | return; | 663 | return; |
655 | } | 664 | } |
656 | int size = height() - mLabel->height(); | 665 | int size = height() - mLabel->height(); |
657 | if ( size > 0 ) | 666 | if ( size > 0 ) |
658 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 667 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
659 | size = width() - mLabel->width(); | 668 | size = width() - mLabel->width(); |
660 | if ( size > 0 ) | 669 | if ( size > 0 ) |
661 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 670 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
662 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 671 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
663 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 672 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
664 | } | 673 | } |
665 | 674 | ||
666 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 675 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
667 | { | 676 | { |
668 | if ( !item ) return; | 677 | if ( !item ) return; |
@@ -843,202 +852,203 @@ void KOMonthView::updateConfig() | |||
843 | mWidthLongDayLabel = 0; | 852 | mWidthLongDayLabel = 0; |
844 | 853 | ||
845 | for (int i = 0; i < 7; i++) { | 854 | for (int i = 0; i < 7; i++) { |
846 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 855 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
847 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 856 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
848 | } | 857 | } |
849 | bool temp = mShowSatSunComp ; | 858 | bool temp = mShowSatSunComp ; |
850 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 859 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
851 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 860 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
852 | computeLayout(); | 861 | computeLayout(); |
853 | updateDayLabels(); | 862 | updateDayLabels(); |
854 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 863 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
855 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 864 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
856 | //resizeEvent( 0 ); | 865 | //resizeEvent( 0 ); |
857 | for (uint i = 0; i < mCells.count(); ++i) { | 866 | for (uint i = 0; i < mCells.count(); ++i) { |
858 | mCells[i]->updateConfig(); | 867 | mCells[i]->updateConfig(); |
859 | } | 868 | } |
860 | #ifdef DESKTOP_VERSION | 869 | #ifdef DESKTOP_VERSION |
861 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 870 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
862 | #endif | 871 | #endif |
863 | } | 872 | } |
864 | 873 | ||
865 | void KOMonthView::updateDayLabels() | 874 | void KOMonthView::updateDayLabels() |
866 | { | 875 | { |
867 | 876 | ||
868 | for (int i = 0; i < 7; i++) { | 877 | for (int i = 0; i < 7; i++) { |
869 | if (mWeekStartsMonday) { | 878 | if (mWeekStartsMonday) { |
870 | bool show = mShortDayLabels; | 879 | bool show = mShortDayLabels; |
871 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 880 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
872 | show = true; | 881 | show = true; |
873 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 882 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
874 | } else { | 883 | } else { |
875 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 884 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
876 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 885 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
877 | 886 | ||
878 | } | 887 | } |
879 | } | 888 | } |
880 | } | 889 | } |
881 | 890 | ||
882 | void KOMonthView::showDates(const QDate &start, const QDate &) | 891 | void KOMonthView::showDates(const QDate &start, const QDate &) |
883 | { | 892 | { |
884 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 893 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
885 | 894 | ||
886 | 895 | ||
887 | mStartDate = start; | 896 | mStartDate = start; |
888 | 897 | ||
889 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 898 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
890 | 899 | ||
891 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 900 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
892 | mStartDate = mStartDate.addDays( -1 ); | 901 | mStartDate = mStartDate.addDays( -1 ); |
893 | } | 902 | } |
894 | 903 | ||
895 | bool primary = false; | 904 | bool primary = false; |
896 | uint i; | 905 | uint i; |
897 | for( i = 0; i < mCells.size(); ++i ) { | 906 | for( i = 0; i < mCells.size(); ++i ) { |
898 | QDate date = mStartDate.addDays( i ); | 907 | QDate date = mStartDate.addDays( i ); |
899 | mCells[i]->setDate( date ); | 908 | mCells[i]->setDate( date ); |
900 | 909 | ||
901 | #ifndef KORG_NOPLUGINS | 910 | #ifndef KORG_NOPLUGINS |
902 | // add holiday, if present | 911 | // add holiday, if present |
903 | QString hstring(KOCore::self()->holiday(date)); | 912 | QString hstring(KOCore::self()->holiday(date)); |
904 | mCells[i]->setHoliday( hstring ); | 913 | mCells[i]->setHoliday( hstring ); |
905 | #endif | 914 | #endif |
906 | 915 | ||
907 | } | 916 | } |
908 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 917 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
909 | for( i = 0; i < 6; ++i ) { | 918 | for( i = 0; i < 6; ++i ) { |
910 | int wno; | 919 | int wno; |
911 | // remember, according to ISO 8601, the first week of the year is the | 920 | // remember, according to ISO 8601, the first week of the year is the |
912 | // first week that contains a thursday. Thus we must subtract off 4, | 921 | // first week that contains a thursday. Thus we must subtract off 4, |
913 | // not just 1. | 922 | // not just 1. |
914 | int dayOfYear = date.dayOfYear(); | 923 | int dayOfYear = date.dayOfYear(); |
915 | if (dayOfYear % 7 != 0) | 924 | if (dayOfYear % 7 != 0) |
916 | wno = dayOfYear / 7 + 1; | 925 | wno = dayOfYear / 7 + 1; |
917 | else | 926 | else |
918 | wno =dayOfYear / 7; | 927 | wno =dayOfYear / 7; |
919 | mWeekLabels[i]->setWeekNum( wno ); | 928 | mWeekLabels[i]->setWeekNum( wno ); |
920 | date = date.addDays( 7 ); | 929 | date = date.addDays( 7 ); |
921 | } | 930 | } |
922 | updateView(); | 931 | updateView(); |
923 | } | 932 | } |
924 | 933 | ||
925 | void KOMonthView::showEvents(QPtrList<Event>) | 934 | void KOMonthView::showEvents(QPtrList<Event>) |
926 | { | 935 | { |
927 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 936 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
928 | } | 937 | } |
929 | 938 | ||
930 | void KOMonthView::changeEventDisplay(Event *, int) | 939 | void KOMonthView::changeEventDisplay(Event *, int) |
931 | { | 940 | { |
932 | // this should be re-written to be much more efficient, but this | 941 | // this should be re-written to be much more efficient, but this |
933 | // quick-and-dirty-hack gets the job done for right now. | 942 | // quick-and-dirty-hack gets the job done for right now. |
934 | updateView(); | 943 | updateView(); |
935 | } | 944 | } |
936 | 945 | ||
937 | void KOMonthView::updateView() | 946 | void KOMonthView::updateView() |
938 | { | 947 | { |
939 | static int iii = 0; | ||
940 | ++iii; | ||
941 | if ( !updatePossible ) | 948 | if ( !updatePossible ) |
942 | return; | 949 | return; |
943 | uint i; | 950 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
951 | int i; | ||
944 | for( i = 0; i < mCells.count(); ++i ) { | 952 | for( i = 0; i < mCells.count(); ++i ) { |
945 | mCells[i]->updateCell(); | 953 | mCells[i]->updateCell(); |
946 | } | 954 | } |
955 | |||
947 | //qDebug("KOMonthView::updateView() "); | 956 | //qDebug("KOMonthView::updateView() "); |
948 | processSelectionChange(); | 957 | processSelectionChange(); |
958 | // qDebug("---------------------------------------------------------------------+ "); | ||
949 | } | 959 | } |
950 | 960 | ||
951 | void KOMonthView::resizeEvent(QResizeEvent * e) | 961 | void KOMonthView::resizeEvent(QResizeEvent * e) |
952 | { | 962 | { |
953 | computeLayout(); | 963 | computeLayout(); |
954 | } | 964 | } |
955 | void KOMonthView::computeLayout() | 965 | void KOMonthView::computeLayout() |
956 | { | 966 | { |
957 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 967 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
958 | // note this only changes the text if the requested size crosses the | 968 | // note this only changes the text if the requested size crosses the |
959 | // threshold between big enough to support the full name and not big | 969 | // threshold between big enough to support the full name and not big |
960 | // enough. | 970 | // enough. |
961 | 971 | ||
962 | int daysToShow = 7; | 972 | int daysToShow = 7; |
963 | bool combinedSatSun = false; | 973 | bool combinedSatSun = false; |
964 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 974 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
965 | daysToShow = 6; | 975 | daysToShow = 6; |
966 | combinedSatSun = true; | 976 | combinedSatSun = true; |
967 | } | 977 | } |
968 | int tWid = topLevelWidget()->size().width(); | 978 | int tWid = topLevelWidget()->size().width(); |
969 | int tHei = topLevelWidget()->size().height(); | 979 | int tHei = topLevelWidget()->size().height(); |
970 | 980 | ||
971 | int wid = size().width();//e | 981 | int wid = size().width();//e |
972 | int hei = size().height()-1; | 982 | int hei = size().height()-1; |
973 | 983 | ||
974 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 984 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
975 | return; | 985 | return; |
976 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 986 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
977 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 987 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
978 | int weeklabelwid = fm.width( "888" ); | 988 | int weeklabelwid = fm.width( "888" ); |
979 | wid -= weeklabelwid; | 989 | wid -= weeklabelwid; |
980 | 990 | ||
981 | int colWid = wid / daysToShow; | 991 | int colWid = wid / daysToShow; |
982 | int lastCol = wid - ( colWid*6 ); | 992 | int lastCol = wid - ( colWid*6 ); |
983 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 993 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
984 | int cellHei = (hei - dayLabelHei) /6; | 994 | int cellHei = (hei - dayLabelHei) /6; |
985 | int colModulo = wid % daysToShow; | 995 | int colModulo = wid % daysToShow; |
986 | int rowModulo = (hei- dayLabelHei) % 6; | 996 | int rowModulo = (hei- dayLabelHei) % 6; |
987 | //qDebug("rowmod %d ", rowModulo); | 997 | //qDebug("rowmod %d ", rowModulo); |
988 | int i; | 998 | int i; |
989 | int x,y,w,h; | 999 | int x,y,w,h; |
990 | x= 0; | 1000 | x= 0; |
991 | y= 0; | 1001 | y= 0; |
992 | w = colWid; | 1002 | w = colWid; |
993 | h = dayLabelHei ; | 1003 | h = dayLabelHei ; |
994 | for ( i = 0; i < 7; i++) { | 1004 | for ( i = 0; i < 7; i++) { |
995 | if ( i == daysToShow-colModulo ) | 1005 | if ( i == daysToShow-colModulo ) |
996 | ++w; | 1006 | ++w; |
997 | if ( combinedSatSun ) { | 1007 | if ( combinedSatSun ) { |
998 | if ( i >= daysToShow-1 ) { | 1008 | if ( i >= daysToShow-1 ) { |
999 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1009 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1000 | x -= w/2 ; | 1010 | x -= w/2 ; |
1001 | } | 1011 | } |
1002 | else | 1012 | else |
1003 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1013 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1004 | } else | 1014 | } else |
1005 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1015 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1006 | x += w; | 1016 | x += w; |
1007 | } | 1017 | } |
1008 | x= 0; | 1018 | x= 0; |
1009 | y= dayLabelHei; | 1019 | y= dayLabelHei; |
1010 | w = colWid; | 1020 | w = colWid; |
1011 | h = cellHei ; | 1021 | h = cellHei ; |
1012 | for ( i = 0; i < mCells.count(); ++i) { | 1022 | for ( i = 0; i < mCells.count(); ++i) { |
1013 | 1023 | ||
1014 | w = colWid; | 1024 | w = colWid; |
1015 | if ( ((i) % 7) >= 7-colModulo ) { | 1025 | if ( ((i) % 7) >= 7-colModulo ) { |
1016 | ++w; | 1026 | ++w; |
1017 | } | 1027 | } |
1018 | if ( i == (6-rowModulo)*7) | 1028 | if ( i == (6-rowModulo)*7) |
1019 | ++h; | 1029 | ++h; |
1020 | if ( combinedSatSun ) { | 1030 | if ( combinedSatSun ) { |
1021 | if ( (i)%7 >= daysToShow-1 ) { | 1031 | if ( (i)%7 >= daysToShow-1 ) { |
1022 | if ( (i)%7 == daysToShow-1 ) { | 1032 | if ( (i)%7 == daysToShow-1 ) { |
1023 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1033 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1024 | x -= w ;y += h/2; | 1034 | x -= w ;y += h/2; |
1025 | } else { | 1035 | } else { |
1026 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1036 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1027 | y -= h/2; | 1037 | y -= h/2; |
1028 | } | 1038 | } |
1029 | } else | 1039 | } else |
1030 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1040 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1031 | 1041 | ||
1032 | } | 1042 | } |
1033 | else | 1043 | else |
1034 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1044 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1035 | x += w; | 1045 | x += w; |
1036 | if ( x + w/2 > wid ) { | 1046 | if ( x + w/2 > wid ) { |
1037 | x = 0; | 1047 | x = 0; |
1038 | y += h; | 1048 | y += h; |
1039 | } | 1049 | } |
1040 | } | 1050 | } |
1041 | y= dayLabelHei; | 1051 | y= dayLabelHei; |
1042 | h = cellHei ; | 1052 | h = cellHei ; |
1043 | for ( i = 0; i < 6; i++) { | 1053 | for ( i = 0; i < 6; i++) { |
1044 | if ( i == (6-rowModulo)) | 1054 | if ( i == (6-rowModulo)) |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 727f511..a965bf3 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -54,192 +54,193 @@ class KOWeekButton : public QPushButton | |||
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 | 140 | ||
141 | void updateConfig(); | 141 | void updateConfig(); |
142 | 142 | ||
143 | void enableScrollBars( bool ); | 143 | void enableScrollBars( bool ); |
144 | 144 | ||
145 | Incidence *selectedIncidence(); | 145 | Incidence *selectedIncidence(); |
146 | QDate selectedIncidenceDate(); | 146 | QDate selectedIncidenceDate(); |
147 | 147 | ||
148 | void deselect(); | 148 | void deselect(); |
149 | void select(); | 149 | void select(); |
150 | void clear(); | ||
150 | 151 | ||
151 | #ifdef DESKTOP_VERSION | 152 | #ifdef DESKTOP_VERSION |
152 | static QToolTipGroup *toolTipGroup(); | 153 | static QToolTipGroup *toolTipGroup(); |
153 | #endif | 154 | #endif |
154 | signals: | 155 | signals: |
155 | void defaultAction( Incidence * ); | 156 | void defaultAction( Incidence * ); |
156 | void newEventSignal( QDateTime ); | 157 | void newEventSignal( QDateTime ); |
157 | void showDaySignal( QDate ); | 158 | void showDaySignal( QDate ); |
158 | 159 | ||
159 | protected: | 160 | protected: |
160 | void resizeEvent( QResizeEvent * ); | 161 | void resizeEvent( QResizeEvent * ); |
161 | 162 | ||
162 | protected slots: | 163 | protected slots: |
163 | void defaultAction( QListBoxItem * ); | 164 | void defaultAction( QListBoxItem * ); |
164 | void contextMenu( QListBoxItem * ); | 165 | void contextMenu( QListBoxItem * ); |
165 | void selection( QListBoxItem * ); | 166 | void selection( QListBoxItem * ); |
166 | void cellClicked( QListBoxItem * ); | 167 | void cellClicked( QListBoxItem * ); |
167 | void newEvent(); | 168 | void newEvent(); |
168 | void showDay(); | 169 | void showDay(); |
169 | 170 | ||
170 | private: | 171 | private: |
171 | KOMonthView *mMonthView; | 172 | KOMonthView *mMonthView; |
172 | 173 | ||
173 | QDate mDate; | 174 | QDate mDate; |
174 | bool mPrimary; | 175 | bool mPrimary; |
175 | bool mHoliday; | 176 | bool mHoliday; |
176 | QString mHolidayString; | 177 | QString mHolidayString; |
177 | 178 | ||
178 | //QLabel *mLabel; | 179 | //QLabel *mLabel; |
179 | QPushButton *mLabel; | 180 | QPushButton *mLabel; |
180 | QListBox *mItemList; | 181 | QListBox *mItemList; |
181 | #ifdef DESKTOP_VERSION | 182 | #ifdef DESKTOP_VERSION |
182 | static QToolTipGroup *mToolTipGroup; | 183 | static QToolTipGroup *mToolTipGroup; |
183 | #endif | 184 | #endif |
184 | QSize mLabelSize; | 185 | QSize mLabelSize; |
185 | QSize mLabelBigSize; | 186 | QSize mLabelBigSize; |
186 | QPalette mHolidayPalette; | 187 | QPalette mHolidayPalette; |
187 | QPalette mStandardPalette; | 188 | QPalette mStandardPalette; |
188 | QPalette mPrimaryPalette; | 189 | QPalette mPrimaryPalette; |
189 | QPalette mNonPrimaryPalette; | 190 | QPalette mNonPrimaryPalette; |
190 | void setMyPalette(); | 191 | void setMyPalette(); |
191 | QPalette getPalette (); | 192 | QPalette getPalette (); |
192 | void keyPressEvent ( QKeyEvent * ) ; | 193 | void keyPressEvent ( QKeyEvent * ) ; |
193 | 194 | ||
194 | }; | 195 | }; |
195 | 196 | ||
196 | 197 | ||
197 | class KOMonthView: public KOEventView | 198 | class KOMonthView: public KOEventView |
198 | { | 199 | { |
199 | Q_OBJECT | 200 | Q_OBJECT |
200 | public: | 201 | public: |
201 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 202 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
202 | ~KOMonthView(); | 203 | ~KOMonthView(); |
203 | 204 | ||
204 | /** Returns maximum number of days supported by the komonthview */ | 205 | /** Returns maximum number of days supported by the komonthview */ |
205 | virtual int maxDatesHint(); | 206 | virtual int maxDatesHint(); |
206 | 207 | ||
207 | /** Returns number of currently shown dates. */ | 208 | /** Returns number of currently shown dates. */ |
208 | virtual int currentDateCount(); | 209 | virtual int currentDateCount(); |
209 | 210 | ||
210 | /** returns the currently selected events */ | 211 | /** returns the currently selected events */ |
211 | virtual QPtrList<Incidence> selectedIncidences(); | 212 | virtual QPtrList<Incidence> selectedIncidences(); |
212 | 213 | ||
213 | /** returns dates of the currently selected events */ | 214 | /** returns dates of the currently selected events */ |
214 | virtual DateList selectedDates(); | 215 | virtual DateList selectedDates(); |
215 | 216 | ||
216 | virtual void printPreview(CalPrinter *calPrinter, | 217 | virtual void printPreview(CalPrinter *calPrinter, |
217 | const QDate &, const QDate &); | 218 | const QDate &, const QDate &); |
218 | bool isMonthView() { return true; } | 219 | bool isMonthView() { return true; } |
219 | bool isUpdatePossible() { return updatePossible; } | 220 | bool isUpdatePossible() { return updatePossible; } |
220 | 221 | ||
221 | MonthViewCell * selectedCell(); | 222 | MonthViewCell * selectedCell(); |
222 | public slots: | 223 | public slots: |
223 | virtual void updateView(); | 224 | virtual void updateView(); |
224 | virtual void updateConfig(); | 225 | virtual void updateConfig(); |
225 | virtual void showDates(const QDate &start, const QDate &end); | 226 | virtual void showDates(const QDate &start, const QDate &end); |
226 | virtual void showEvents(QPtrList<Event> eventList); | 227 | virtual void showEvents(QPtrList<Event> eventList); |
227 | 228 | ||
228 | void changeEventDisplay(Event *, int); | 229 | void changeEventDisplay(Event *, int); |
229 | 230 | ||
230 | void clearSelection(); | 231 | void clearSelection(); |
231 | 232 | ||
232 | void showContextMenu( Incidence * ); | 233 | void showContextMenu( Incidence * ); |
233 | 234 | ||
234 | void setSelectedCell( MonthViewCell * ); | 235 | void setSelectedCell( MonthViewCell * ); |
235 | 236 | ||
236 | protected slots: | 237 | protected slots: |
237 | void processSelectionChange(); | 238 | void processSelectionChange(); |
238 | signals: | 239 | signals: |
239 | void selectWeekNum ( int ); | 240 | void selectWeekNum ( int ); |
240 | void showDaySignal( QDate ); | 241 | void showDaySignal( QDate ); |
241 | protected: | 242 | protected: |
242 | void resizeEvent(QResizeEvent *); | 243 | void resizeEvent(QResizeEvent *); |
243 | void viewChanged(); | 244 | void viewChanged(); |
244 | void updateDayLabels(); | 245 | void updateDayLabels(); |
245 | 246 | ||
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 00a5842..f6b7718 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -60,195 +60,196 @@ int globalFlagBlockAgendaItemUpdate = 1; | |||
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 | void KOViewManager::writeSettings(KConfig *config) | 101 | void KOViewManager::writeSettings(KConfig *config) |
102 | { | 102 | { |
103 | config->setGroup("General"); | 103 | config->setGroup("General"); |
104 | 104 | ||
105 | QString view; | 105 | QString view; |
106 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 106 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
107 | else if (mCurrentView == mMonthView) view = "Month"; | 107 | else if (mCurrentView == mMonthView) view = "Month"; |
108 | else if (mCurrentView == mListView) view = "List"; | 108 | else if (mCurrentView == mListView) view = "List"; |
109 | else if (mCurrentView == mJournalView) view = "Journal"; | 109 | else if (mCurrentView == mJournalView) view = "Journal"; |
110 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 110 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
111 | else if (mCurrentView == mTodoView) view = "Todo"; | 111 | else if (mCurrentView == mTodoView) view = "Todo"; |
112 | else view = "Agenda"; | 112 | else view = "Agenda"; |
113 | 113 | ||
114 | config->writeEntry("Current View",view); | 114 | config->writeEntry("Current View",view); |
115 | 115 | ||
116 | if (mAgendaView) { | 116 | if (mAgendaView) { |
117 | mAgendaView->writeSettings(config); | 117 | mAgendaView->writeSettings(config); |
118 | } | 118 | } |
119 | if (mTimeSpanView) { | 119 | if (mTimeSpanView) { |
120 | mTimeSpanView->writeSettings(config); | 120 | mTimeSpanView->writeSettings(config); |
121 | } | 121 | } |
122 | if (mListView) { | 122 | if (mListView) { |
123 | mListView->writeSettings(config); | 123 | mListView->writeSettings(config); |
124 | } | 124 | } |
125 | if (mTodoView) { | 125 | if (mTodoView) { |
126 | mTodoView->saveLayout(config,"Todo View"); | 126 | mTodoView->saveLayout(config,"Todo View"); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 130 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
131 | { | 131 | { |
132 | 132 | ||
133 | //mFlagShowNextxDays = false; | 133 | //mFlagShowNextxDays = false; |
134 | //if(view == mCurrentView) return; | 134 | //if(view == mCurrentView) return; |
135 | if ( view == 0 ) { | 135 | if ( view == 0 ) { |
136 | view = mCurrentView; | 136 | view = mCurrentView; |
137 | if ( view == 0 ) | 137 | if ( view == 0 ) |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | bool full = fullScreen; | 140 | bool full = fullScreen; |
141 | if(view == mCurrentView && view != mWhatsNextView ) { | 141 | if(view == mCurrentView && view != mWhatsNextView ) { |
142 | if ( mCurrentAgendaView < 0 ) | 142 | if ( mCurrentAgendaView < 0 ) |
143 | return; | 143 | return; |
144 | full = mMainView->leftFrame()->isVisible(); | 144 | full = mMainView->leftFrame()->isVisible(); |
145 | } else { | 145 | } else { |
146 | mCurrentView = view; | 146 | mCurrentView = view; |
147 | 147 | ||
148 | // bool full = fullScreen; | 148 | // bool full = fullScreen; |
149 | bool isFull = !mMainView->leftFrame()->isVisible(); | 149 | bool isFull = !mMainView->leftFrame()->isVisible(); |
150 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 150 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
151 | full = true; | 151 | full = true; |
152 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 152 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
153 | full = false; | 153 | full = false; |
154 | } | 154 | } |
155 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 155 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
156 | raiseCurrentView( full ); | 156 | //raiseCurrentView( full ); |
157 | mMainView->processIncidenceSelection( 0 ); | 157 | mMainView->processIncidenceSelection( 0 ); |
158 | mMainView->updateView(); | 158 | mMainView->updateView(); |
159 | raiseCurrentView( full ); | ||
159 | mMainView->adaptNavigationUnits(); | 160 | mMainView->adaptNavigationUnits(); |
160 | } | 161 | } |
161 | 162 | ||
162 | void KOViewManager::raiseCurrentView( bool fullScreen ) | 163 | void KOViewManager::raiseCurrentView( bool fullScreen ) |
163 | { | 164 | { |
164 | //qDebug("raiseCurrentView "); | 165 | //qDebug("raiseCurrentView "); |
165 | mCurrentAgendaView = 0; | 166 | mCurrentAgendaView = 0; |
166 | int wid = mMainView->width() ; | 167 | int wid = mMainView->width() ; |
167 | int hei = mMainView->height(); | 168 | int hei = mMainView->height(); |
168 | if ( mCurrentView == mMonthView ) { | 169 | if ( mCurrentView == mMonthView ) { |
169 | mMainView->navigatorBar()->show(); | 170 | mMainView->navigatorBar()->show(); |
170 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 171 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
171 | //mMainView->navigatorBar()->hide(); | 172 | //mMainView->navigatorBar()->hide(); |
172 | } else { | 173 | } else { |
173 | mMainView->navigatorBar()->hide(); | 174 | mMainView->navigatorBar()->hide(); |
174 | } | 175 | } |
175 | if ( fullScreen ) { | 176 | if ( fullScreen ) { |
176 | mMainView->leftFrame()->hide(); | 177 | mMainView->leftFrame()->hide(); |
177 | } else { | 178 | } else { |
178 | mMainView->leftFrame()->show(); | 179 | mMainView->leftFrame()->show(); |
179 | if ( KOPrefs::instance()->mVerticalScreen ) | 180 | if ( KOPrefs::instance()->mVerticalScreen ) |
180 | hei -= mMainView->leftFrame()->height(); | 181 | hei -= mMainView->leftFrame()->height(); |
181 | else | 182 | else |
182 | wid -= mMainView->leftFrame()->width(); | 183 | wid -= mMainView->leftFrame()->width(); |
183 | } | 184 | } |
184 | 185 | ||
185 | if ( globalFlagBlockAgenda == 5 ) { | 186 | if ( globalFlagBlockAgenda == 5 ) { |
186 | globalFlagBlockAgenda = 4; | 187 | globalFlagBlockAgenda = 4; |
187 | globalFlagBlockAgendaItemPaint = 1; | 188 | globalFlagBlockAgendaItemPaint = 1; |
188 | } | 189 | } |
189 | mMainView->viewStack()->raiseWidget(mCurrentView); | 190 | mMainView->viewStack()->raiseWidget(mCurrentView); |
190 | if ( globalFlagBlockAgenda == 4 ) { | 191 | if ( globalFlagBlockAgenda == 4 ) { |
191 | if ( mCurrentView == mAgendaView ) { | 192 | if ( mCurrentView == mAgendaView ) { |
192 | //globalFlagBlockAgenda =1 ; | 193 | //globalFlagBlockAgenda =1 ; |
193 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 194 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
194 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 195 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
195 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 196 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
196 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 197 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
197 | qApp->processEvents(); | 198 | qApp->processEvents(); |
198 | //qDebug("qApp->processEvents() "); | 199 | //qDebug("qApp->processEvents() "); |
199 | globalFlagBlockAgenda = 0; | 200 | globalFlagBlockAgenda = 0; |
200 | mAgendaView->repaintAgenda(); | 201 | mAgendaView->repaintAgenda(); |
201 | 202 | ||
202 | } | 203 | } |
203 | globalFlagBlockAgenda = 0; | 204 | globalFlagBlockAgenda = 0; |
204 | } | 205 | } |
205 | //qDebug("raiseCurrentView ende "); | 206 | //qDebug("raiseCurrentView ende "); |
206 | } | 207 | } |
207 | 208 | ||
208 | void KOViewManager::updateView() | 209 | void KOViewManager::updateView() |
209 | { | 210 | { |
210 | // qDebug("KOViewManager::updateView() "); | 211 | // qDebug("KOViewManager::updateView() "); |
211 | // if we are updating mTodoView, we get endless recursion | 212 | // if we are updating mTodoView, we get endless recursion |
212 | if ( mTodoView == mCurrentView ) | 213 | if ( mTodoView == mCurrentView ) |
213 | return; | 214 | return; |
214 | if ( mCurrentView ) mCurrentView->updateView(); | 215 | if ( mCurrentView ) mCurrentView->updateView(); |
215 | 216 | ||
216 | } | 217 | } |
217 | 218 | ||
218 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 219 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
219 | { | 220 | { |
220 | // kdDebug() << "KOViewManager::updateView()" << endl; | 221 | // kdDebug() << "KOViewManager::updateView()" << endl; |
221 | 222 | ||
222 | if (mCurrentView) mCurrentView->showDates(start, end); | 223 | if (mCurrentView) mCurrentView->showDates(start, end); |
223 | 224 | ||
224 | if (mTodoView) mTodoView->updateView(); | 225 | if (mTodoView) mTodoView->updateView(); |
225 | } | 226 | } |
226 | 227 | ||
227 | 228 | ||
228 | void KOViewManager::updateWNview() | 229 | void KOViewManager::updateWNview() |
229 | { | 230 | { |
230 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 231 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
231 | mWhatsNextView->updateView(); | 232 | mWhatsNextView->updateView(); |
232 | 233 | ||
233 | } | 234 | } |
234 | void KOViewManager::showWhatsNextView() | 235 | void KOViewManager::showWhatsNextView() |
235 | { | 236 | { |
236 | if (!mWhatsNextView) { | 237 | if (!mWhatsNextView) { |
237 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 238 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
238 | "KOViewManager::WhatsNextView"); | 239 | "KOViewManager::WhatsNextView"); |
239 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 240 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
240 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 241 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
241 | addView(mWhatsNextView); | 242 | addView(mWhatsNextView); |
242 | connect(this, SIGNAL( printWNV() ), | 243 | connect(this, SIGNAL( printWNV() ), |
243 | mWhatsNextView, SLOT( printMe() ) ); | 244 | mWhatsNextView, SLOT( printMe() ) ); |
244 | } | 245 | } |
245 | globalFlagBlockAgenda = 1; | 246 | globalFlagBlockAgenda = 1; |
246 | showView(mWhatsNextView, true ); | 247 | showView(mWhatsNextView, true ); |
247 | //mWhatsNextView->updateView(); | 248 | //mWhatsNextView->updateView(); |
248 | 249 | ||
249 | } | 250 | } |
250 | 251 | ||
251 | void KOViewManager::showListView() | 252 | void KOViewManager::showListView() |
252 | { | 253 | { |
253 | if (!mListView) { | 254 | if (!mListView) { |
254 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 255 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |