summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-17 12:17:07 (UTC)
committer zautrix <zautrix>2005-04-17 12:17:07 (UTC)
commit2d81c75c4ffb8f144ae58e90e68496500d07a19e (patch) (unidiff)
tree1b27958fdc2948c1235579029188b1de78d7b820
parentf64384edcc1e3b3f7511480866b0900aa1ebdda6 (diff)
downloadkdepimpi-2d81c75c4ffb8f144ae58e90e68496500d07a19e.zip
kdepimpi-2d81c75c4ffb8f144ae58e90e68496500d07a19e.tar.gz
kdepimpi-2d81c75c4ffb8f144ae58e90e68496500d07a19e.tar.bz2
fixx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt4
-rw-r--r--korganizer/koagenda.cpp264
-rw-r--r--korganizer/koagenda.h2
-rw-r--r--korganizer/koagendaview.cpp22
4 files changed, 46 insertions, 246 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 44bf20b..03895fd 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,100 +1,104 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.0.28 ************ 3********** VERSION 2.0.28 ************
4 4
5KO/Pi:
6Fixed two problems in KO/Pi timetracking.
7Added context menu to month view for creating new events/todos.
8Fixed some other small bugs.
5 9
6 10
7********** VERSION 2.0.27 ************ 11********** VERSION 2.0.27 ************
8 12
9More bugfixes. 13More bugfixes.
10Added possibility to clone in KO/Pi a todo with all its subtodos. 14Added possibility to clone in KO/Pi a todo with all its subtodos.
11Added config option for alternate background in list views. 15Added config option for alternate background in list views.
12 16
13Added a timetracker funtionality in KO/Pi for todos in the todo view. 17Added a timetracker funtionality in KO/Pi for todos in the todo view.
14If a todo is set to started and then to stopped it is saving information about the runtime in 18If a todo is set to started and then to stopped it is saving information about the runtime in
15<yourhome>/kdepim/apps/timetrackerdir. 19<yourhome>/kdepim/apps/timetrackerdir.
16To read, display, print this information an external program is needed which will be developed. 20To read, display, print this information an external program is needed which will be developed.
17It will display the data in a Gantt timetable view with one row for each todo. 21It will display the data in a Gantt timetable view with one row for each todo.
18It will have many possibilities sorting the data after category, parent todos, attendees, ... and for creating/printing status reports/summaries. 22It will have many possibilities sorting the data after category, parent todos, attendees, ... and for creating/printing status reports/summaries.
19Merging of data from different computers/users will be quite easy because every run is stored in a single file. 23Merging of data from different computers/users will be quite easy because every run is stored in a single file.
20 24
21********** VERSION 2.0.26 ************ 25********** VERSION 2.0.26 ************
22 26
23Added two more fields to the KA/Pi view config: 27Added two more fields to the KA/Pi view config:
24A "Mobile (home)" and a "Mobile (work)" field. 28A "Mobile (home)" and a "Mobile (work)" field.
25Fixed utf8 import (e.g. for Japaneese text) in KA/Pi. 29Fixed utf8 import (e.g. for Japaneese text) in KA/Pi.
26 30
27Some alarm applet enhancements, e.g. sound stops automatically if value of suspend spinbox changes. 31Some alarm applet enhancements, e.g. sound stops automatically if value of suspend spinbox changes.
28And again fixed some more small bugs. 32And again fixed some more small bugs.
29 33
30********** VERSION 2.0.25 ************ 34********** VERSION 2.0.25 ************
31 35
32And again fixed some bugs. 36And again fixed some bugs.
33 37
34********** VERSION 2.0.24 ************ 38********** VERSION 2.0.24 ************
35 39
36Fixed again a lot of small bugs. 40Fixed again a lot of small bugs.
37Some performance optimizations in date navigator. 41Some performance optimizations in date navigator.
38Month view displays now multi days events on top of each cell, such that it is more likely that all multi days items of one event are in the same row. 42Month view displays now multi days events on top of each cell, such that it is more likely that all multi days items of one event are in the same row.
39 43
40********** VERSION 2.0.23 ************ 44********** VERSION 2.0.23 ************
41 45
42Fixed again a lot of small and strange bugs, e.g. the missing toolbar of KA/Pi after a new installation. 46Fixed again a lot of small and strange bugs, e.g. the missing toolbar of KA/Pi after a new installation.
43Fixed the (agenda) layout of KO/Pi on 5500er. 47Fixed the (agenda) layout of KO/Pi on 5500er.
44Some usebility enhancements (e.g. reselection the current item of the todo view after some changes). 48Some usebility enhancements (e.g. reselection the current item of the todo view after some changes).
45 49
46********** VERSION 2.0.22 ************ 50********** VERSION 2.0.22 ************
47 51
48KO/Pi: 52KO/Pi:
49Fix for creating events/todos via the abgenda context menu. 53Fix for creating events/todos via the abgenda context menu.
50Added option to split toolbar to 3 toolbars. 54Added option to split toolbar to 3 toolbars.
51(Toolbar moving s disabled for this option due to a bug in Qt somewhere). 55(Toolbar moving s disabled for this option due to a bug in Qt somewhere).
52Added option to show one small filter-view-toolbar. 56Added option to show one small filter-view-toolbar.
53Added a print option to the desktop version: 57Added a print option to the desktop version:
54Now you can print out the view of the "Event Viewer". 58Now you can print out the view of the "Event Viewer".
55That means you can print all data of one particular event/todo. 59That means you can print all data of one particular event/todo.
56Added scaling options to printout of Event Viewer and What'sNext View. 60Added scaling options to printout of Event Viewer and What'sNext View.
57Fixed some problems in the month view in "week start sunday" mode. 61Fixed some problems in the month view in "week start sunday" mode.
58KA/Pi: 62KA/Pi:
59Added two more config options. 63Added two more config options.
60Fixed resizing problem of address request dialog when orientation was switched. 64Fixed resizing problem of address request dialog when orientation was switched.
61Cleaned up the menu structure. 65Cleaned up the menu structure.
62Fixed some more problems. 66Fixed some more problems.
63 67
64Fixed the annoying problem that scrolling continued after the key was released in KO/Pi Monthview and the KA/Pi views. 68Fixed the annoying problem that scrolling continued after the key was released in KO/Pi Monthview and the KA/Pi views.
65 69
66And, this is a really cool option (Ben did suggest it): 70And, this is a really cool option (Ben did suggest it):
67Now KO/Pi and KA/Pi can be run from a USB stick: 71Now KO/Pi and KA/Pi can be run from a USB stick:
68All data is read from and written to the stick. 72All data is read from and written to the stick.
69You can enable this in the global configure option TAB with: 73You can enable this in the global configure option TAB with:
70Save using LOCAL storage. 74Save using LOCAL storage.
71Just put KDE-Pim/Pi on a memory stick and you can access all your PIM data on every computer with Windows XP. It will work with the ME and Linux versions as well. I will put a memory stick version for teh next stable release online. 75Just put KDE-Pim/Pi on a memory stick and you can access all your PIM data on every computer with Windows XP. It will work with the ME and Linux versions as well. I will put a memory stick version for teh next stable release online.
72 76
73********** VERSION 2.0.21 ************ 77********** VERSION 2.0.21 ************
74 78
75Fixed another SMTP problem in OM/Pi. 79Fixed another SMTP problem in OM/Pi.
76Some small changed in the new datenavigator in KO/Pi. 80Some small changed in the new datenavigator in KO/Pi.
77Changed default setting for new filter in KA/Pi to "exclude categories". 81Changed default setting for new filter in KA/Pi to "exclude categories".
78Changed the default font size for 640x480 display . 82Changed the default font size for 640x480 display .
79Changed popup menu behaviour in agenda and list view. 83Changed popup menu behaviour in agenda and list view.
80Fixed some layout problems of the date label size in the month view. 84Fixed some layout problems of the date label size in the month view.
81Made month view update faster. 85Made month view update faster.
82Made first datenavigator repainting faster. 86Made first datenavigator repainting faster.
83Changed the title of the event/todo edit dialogs. 87Changed the title of the event/todo edit dialogs.
84Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). 88Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course).
85Many small usebility fixes in KO/Pi. 89Many small usebility fixes in KO/Pi.
86Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi. 90Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi.
87The set of possible "next views" are the views you have toolbar buttons for. 91The set of possible "next views" are the views you have toolbar buttons for.
88 92
89Made alarm sound working on Linux. 93Made alarm sound working on Linux.
90 94
91KO/Pi alarm applet changed: 95KO/Pi alarm applet changed:
92Made buttons in alarm dialog much bigger. 96Made buttons in alarm dialog much bigger.
93Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger. 97Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger.
94The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings. 98The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings.
95 99
96And because this version is realeased at Easter, I added an Easter-egg: 100And because this version is realeased at Easter, I added an Easter-egg:
97With a new undocumented command you can get a message box about the next alarm. 101With a new undocumented command you can get a message box about the next alarm.
98Good luck to find it! 102Good luck to find it!
99 103
100 104
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 114ed75..355f4bb 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -381,619 +381,435 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
381void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
382{ 382{
383 mPopupTimer->stop(); 383 mPopupTimer->stop();
384 if ( mPopupKind == 1 ) { 384 if ( mPopupKind == 1 ) {
385 if (mActionItem ) { 385 if (mActionItem ) {
386 endItemAction(); 386 endItemAction();
387 } 387 }
388 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 389 if (mPopupItem) {
390 //mClickedItem = mPopupItem; 390 //mClickedItem = mPopupItem;
391 selectItem(mPopupItem); 391 selectItem(mPopupItem);
392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu ) 392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu )
393 mAllAgendaPopup->installEventFilter( this ); 393 mAllAgendaPopup->installEventFilter( this );
394 emit showIncidencePopupSignal(mPopupItem->incidence()); 394 emit showIncidencePopupSignal(mPopupItem->incidence());
395 395
396 } 396 }
397 } else if ( mPopupKind == 2 ) { 397 } else if ( mPopupKind == 2 ) {
398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
399 endSelectAction( false ); // do not emit new event signal 399 endSelectAction( false ); // do not emit new event signal
400 mLeftMouseDown = false; // no more leftMouse computation 400 mLeftMouseDown = false; // no more leftMouse computation
401 } 401 }
402 if ( KOPrefs::instance()->mBlockPopupMenu ) 402 if ( KOPrefs::instance()->mBlockPopupMenu )
403 mNewItemPopup->installEventFilter( this ); 403 mNewItemPopup->installEventFilter( this );
404 mNewItemPopup->popup( mPopupPos); 404 mNewItemPopup->popup( mPopupPos);
405 405
406 } 406 }
407 mLeftMouseDown = false; 407 mLeftMouseDown = false;
408 mPopupItem = 0; 408 mPopupItem = 0;
409 mPopupKind = 0; 409 mPopupKind = 0;
410} 410}
411 411
412bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 412bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
413{ 413{
414 static int startX = 0; 414 static int startX = 0;
415 static int startY = 0; 415 static int startY = 0;
416 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 416 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
417 static bool blockMoving = true; 417 static bool blockMoving = true;
418 418
419 //qDebug("KOAgenda::eventFilter_mous "); 419 //qDebug("KOAgenda::eventFilter_mous ");
420 if ( object == mNewItemPopup ) { 420 if ( object == mNewItemPopup ) {
421 //qDebug("mNewItemPopup "); 421 //qDebug("mNewItemPopup ");
422 if ( me->type() == QEvent::MouseButtonRelease ) { 422 if ( me->type() == QEvent::MouseButtonRelease ) {
423 mNewItemPopup->removeEventFilter( this ); 423 mNewItemPopup->removeEventFilter( this );
424 int dX = me->globalPos().x() - mPopupPos.x();; 424 int dX = me->globalPos().x() - mPopupPos.x();;
425 if ( dX < 0 ) 425 if ( dX < 0 )
426 dX = -dX; 426 dX = -dX;
427 int dY = me->globalPos().y() - mPopupPos.y(); 427 int dY = me->globalPos().y() - mPopupPos.y();
428 if ( dY < 0 ) 428 if ( dY < 0 )
429 dY = -dY; 429 dY = -dY;
430 if ( dX > blockmoveDist || dY > blockmoveDist ) { 430 if ( dX > blockmoveDist || dY > blockmoveDist ) {
431 mNewItemPopup->hide(); 431 mNewItemPopup->hide();
432 } 432 }
433 } 433 }
434 return true; 434 return true;
435 } 435 }
436 if ( object == mAllAgendaPopup ) { 436 if ( object == mAllAgendaPopup ) {
437 //qDebug(" mAllAgendaPopup "); 437 //qDebug(" mAllAgendaPopup ");
438 if ( me->type() == QEvent::MouseButtonRelease ) { 438 if ( me->type() == QEvent::MouseButtonRelease ) {
439 mAllAgendaPopup->removeEventFilter( this ); 439 mAllAgendaPopup->removeEventFilter( this );
440 int dX = me->globalPos().x() - mPopupPos.x();; 440 int dX = me->globalPos().x() - mPopupPos.x();;
441 if ( dX < 0 ) 441 if ( dX < 0 )
442 dX = -dX; 442 dX = -dX;
443 int dY = me->globalPos().y() - mPopupPos.y(); 443 int dY = me->globalPos().y() - mPopupPos.y();
444 if ( dY < 0 ) 444 if ( dY < 0 )
445 dY = -dY; 445 dY = -dY;
446 if ( dX > blockmoveDist || dY > blockmoveDist ) { 446 if ( dX > blockmoveDist || dY > blockmoveDist ) {
447 mAllAgendaPopup->hide(); 447 mAllAgendaPopup->hide();
448 } 448 }
449 } 449 }
450 return true; 450 return true;
451 } 451 }
452 QPoint viewportPos; 452 QPoint viewportPos;
453 if (object != viewport()) { 453 if (object != viewport()) {
454 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 454 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
455 } else { 455 } else {
456 viewportPos = me->pos(); 456 viewportPos = me->pos();
457 } 457 }
458 458
459 switch (me->type()) { 459 switch (me->type()) {
460 case QEvent::MouseButtonPress: 460 case QEvent::MouseButtonPress:
461 if (me->button() == LeftButton) { 461 if (me->button() == LeftButton) {
462 mPopupTimer->start( 600 ); 462 mPopupTimer->start( 600 );
463 mLeftMouseDown = true; 463 mLeftMouseDown = true;
464 } 464 }
465 blockMoving = true; 465 blockMoving = true;
466 startX = viewportPos.x(); 466 startX = viewportPos.x();
467 startY = viewportPos.y(); 467 startY = viewportPos.y();
468 mPopupPos = me->globalPos(); 468 mPopupPos = me->globalPos();
469 if (object != viewport()) { 469 if (object != viewport()) {
470 mPopupItem = (KOAgendaItem *)object; 470 mPopupItem = (KOAgendaItem *)object;
471 mPopupKind = 1; 471 mPopupKind = 1;
472 if (me->button() == RightButton) { 472 if (me->button() == RightButton) {
473 popupMenu(); 473 popupMenu();
474 } else if (me->button() == LeftButton) { 474 } else if (me->button() == LeftButton) {
475 mActionItem = (KOAgendaItem *)object; 475 mActionItem = (KOAgendaItem *)object;
476 if (mActionItem) { 476 if (mActionItem) {
477 if ( mSelectionHeight > 0 ) { 477 emit signalClearSelection();
478 int selectionCellX = mSelectionCellX * mGridSpacingX; 478 slotClearSelection();
479 int selectionYTop = mSelectionYTop;
480 int gridSpacingX = mGridSpacingX;
481 int selectionHeight = mSelectionHeight;
482 clearSelection();
483 repaintContents( selectionCellX, selectionYTop,
484 gridSpacingX, selectionHeight,false );
485 }
486 selectItem(mActionItem); 479 selectItem(mActionItem);
487 Incidence *incidence = mActionItem->incidence(); 480 Incidence *incidence = mActionItem->incidence();
488 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 481 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
489 mActionItem = 0; 482 mActionItem = 0;
490 } else { 483 } else {
491 startItemAction(viewportPos); 484 startItemAction(viewportPos);
492 } 485 }
493 } 486 }
494 } 487 }
495 } else { // ---------- viewport() 488 } else { // ---------- viewport()
496 mPopupItem = 0; 489 mPopupItem = 0;
497 mPopupKind = 2; 490 mPopupKind = 2;
498 selectItem(0); 491 selectItem(0);
499 mActionItem = 0; 492 mActionItem = 0;
500 if (me->button() == RightButton) { 493 if (me->button() == RightButton) {
501 int x,y; 494 int x,y;
502 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 495 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
503 int gx,gy; 496 int gx,gy;
504 contentsToGrid(x,y,gx,gy); 497 contentsToGrid(x,y,gx,gy);
505 mCurrentCellX = gx; 498 mCurrentCellX = gx;
506 mCurrentCellY = gy; 499 mCurrentCellY = gy;
507 mStartCellX = gx; 500 mStartCellX = gx;
508 mStartCellY = gy; 501 mStartCellY = gy;
509 popupMenu(); 502 popupMenu();
510 } else if (me->button() == LeftButton) { 503 } else if (me->button() == LeftButton) {
511 setCursor(arrowCursor); 504 setCursor(arrowCursor);
512 startSelectAction(viewportPos); 505 startSelectAction(viewportPos);
513 } 506 }
514 } 507 }
515 break; 508 break;
516 509
517 case QEvent::MouseButtonRelease: 510 case QEvent::MouseButtonRelease:
518 if (me->button() == LeftButton ) { 511 if (me->button() == LeftButton ) {
519 mPopupTimer->stop(); 512 mPopupTimer->stop();
520 } 513 }
521 if (object != viewport()) { 514 if (object != viewport()) {
522 if (me->button() == LeftButton && mLeftMouseDown) { 515 if (me->button() == LeftButton && mLeftMouseDown) {
523 if (mActionItem) { 516 if (mActionItem) {
524 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 517 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
525 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 518 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
526 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 519 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
527 mScrollUpTimer.stop(); 520 mScrollUpTimer.stop();
528 mScrollDownTimer.stop(); 521 mScrollDownTimer.stop();
529 mActionItem->resetMove(); 522 mActionItem->resetMove();
530 placeSubCells( mActionItem ); 523 placeSubCells( mActionItem );
531 // emit startDragSignal( mActionItem->incidence() ); 524 // emit startDragSignal( mActionItem->incidence() );
532 setCursor( arrowCursor ); 525 setCursor( arrowCursor );
533 mActionItem = 0; 526 mActionItem = 0;
534 mActionType = NOP; 527 mActionType = NOP;
535 mItemMoved = 0; 528 mItemMoved = 0;
536 mLeftMouseDown = false; 529 mLeftMouseDown = false;
537 return true; 530 return true;
538 } 531 }
539 endItemAction(); 532 endItemAction();
540 } 533 }
541 } 534 }
542 535
543 } else { // ---------- viewport() 536 } else { // ---------- viewport()
544 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 537 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
545 endSelectAction( true ); // emit new event signal 538 endSelectAction( true ); // emit new event signal
546 } 539 }
547 } 540 }
548 if (me->button() == LeftButton) 541 if (me->button() == LeftButton)
549 mLeftMouseDown = false; 542 mLeftMouseDown = false;
550 543
551 break; 544 break;
552 545
553 case QEvent::MouseMove: 546 case QEvent::MouseMove:
554 //qDebug("mm "); 547 //qDebug("mm ");
555 if ( !mLeftMouseDown ) 548 if ( !mLeftMouseDown )
556 return false; 549 return false;
557 if ( blockMoving ) { 550 if ( blockMoving ) {
558 int dX, dY; 551 int dX, dY;
559 dX = startX - viewportPos.x(); 552 dX = startX - viewportPos.x();
560 if ( dX < 0 ) 553 if ( dX < 0 )
561 dX = -dX; 554 dX = -dX;
562 dY = viewportPos.y() - startY; 555 dY = viewportPos.y() - startY;
563 if ( dY < 0 ) 556 if ( dY < 0 )
564 dY = -dY; 557 dY = -dY;
565 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 558 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
566 if ( dX > blockmoveDist || dY > blockmoveDist ) { 559 if ( dX > blockmoveDist || dY > blockmoveDist ) {
567 blockMoving = false; 560 blockMoving = false;
568 } 561 }
569 } 562 }
570 if ( ! blockMoving ) 563 if ( ! blockMoving )
571 mPopupTimer->stop(); 564 mPopupTimer->stop();
572 if (object != viewport()) { 565 if (object != viewport()) {
573 KOAgendaItem *moveItem = (KOAgendaItem *)object; 566 KOAgendaItem *moveItem = (KOAgendaItem *)object;
574 if (!moveItem->incidence()->isReadOnly() ) { 567 if (!moveItem->incidence()->isReadOnly() ) {
575 if (!mActionItem) 568 if (!mActionItem)
576 setNoActionCursor(moveItem,viewportPos); 569 setNoActionCursor(moveItem,viewportPos);
577 else { 570 else {
578 if ( !blockMoving ) 571 if ( !blockMoving )
579 performItemAction(viewportPos); 572 performItemAction(viewportPos);
580 } 573 }
581 } 574 }
582 } else { // ---------- viewport() 575 } else { // ---------- viewport()
583 mPopupPos = viewport()->mapToGlobal( me->pos() ); 576 mPopupPos = viewport()->mapToGlobal( me->pos() );
584 if ( mActionType == SELECT ) { 577 if ( mActionType == SELECT ) {
585 performSelectAction( viewportPos ); 578 performSelectAction( viewportPos );
586 } 579 }
587 } 580 }
588 break; 581 break;
589 582
590 case QEvent::MouseButtonDblClick: 583 case QEvent::MouseButtonDblClick:
591 mPopupTimer->stop(); 584 mPopupTimer->stop();
592 if (object == viewport()) { 585 if (object == viewport()) {
593 selectItem(0); 586 selectItem(0);
594 int x,y; 587 int x,y;
595 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 588 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
596 int gx,gy; 589 int gx,gy;
597 contentsToGrid(x,y,gx,gy); 590 contentsToGrid(x,y,gx,gy);
598 emit newEventSignal(gx,gy); 591 emit newEventSignal(gx,gy);
599 } else { 592 } else {
600 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 593 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
601 selectItem(doubleClickedItem); 594 selectItem(doubleClickedItem);
602 if ( KOPrefs::instance()->mEditOnDoubleClick ) 595 if ( KOPrefs::instance()->mEditOnDoubleClick )
603 emit editIncidenceSignal(doubleClickedItem->incidence()); 596 emit editIncidenceSignal(doubleClickedItem->incidence());
604 else 597 else
605 emit showIncidenceSignal(doubleClickedItem->incidence()); 598 emit showIncidenceSignal(doubleClickedItem->incidence());
606 } 599 }
607 break; 600 break;
608 601
609 default: 602 default:
610 break; 603 break;
611 } 604 }
612 return true; 605 return true;
613#if 0
614 //qDebug("KOAgenda::eventFilter_mous ");
615 QPoint viewportPos;
616 if (object != viewport()) {
617 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
618 } else {
619 viewportPos = me->pos();
620 }
621 static int startX = 0;
622 static int startY = 0;
623 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
624 static bool blockMoving = true;
625 static bool leftMouseDown = false;
626 bool rightButtonPressed = false;
627 switch (me->type()) {
628 case QEvent::MouseButtonPress:
629 if (me->button() == LeftButton) {
630 leftMouseDown = true;
631 }
632 else if (me->button() == RightButton) {
633 leftMouseDown = false;
634 }
635 blockMoving = true;
636 startX = viewportPos.x();
637 startY = viewportPos.y();
638 if (object != viewport()) { // item clicked **************
639 if (me->button() == RightButton) {
640 leftMouseDown = false;
641 mClickedItem = (KOAgendaItem *)object;
642 if (mActionItem ) {
643 endItemAction();
644 }
645 if (mClickedItem) {
646 selectItem(mClickedItem);
647 emit showIncidencePopupSignal(mClickedItem->incidence());
648 }
649 return true;
650 } else if (me->button() == LeftButton) {
651 mActionItem = (KOAgendaItem *)object;
652 if (mActionItem) {
653 if ( mSelectionHeight > 0 ) {
654 int selectionCellX = mSelectionCellX * mGridSpacingX;
655 int selectionYTop = mSelectionYTop;
656 int gridSpacingX = mGridSpacingX;
657 int selectionHeight = mSelectionHeight;
658 clearSelection();
659 repaintContents( selectionCellX, selectionYTop,
660 gridSpacingX, selectionHeight,false );
661 }
662 selectItem(mActionItem);
663 Incidence *incidence = mActionItem->incidence();
664 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
665 mActionItem = 0;
666 } else {
667 startItemAction(viewportPos);
668 }
669 }
670 }
671 } else { // ---------- viewport()
672 selectItem(0);
673 mActionItem = 0;
674 if (me->button() == LeftButton ) {
675 setCursor(arrowCursor);
676 startSelectAction(viewportPos);
677 } else if (me->button() == RightButton ) {
678 setCursor(arrowCursor);
679 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
680 endSelectAction( false ); // do not emit new event signal
681 leftMouseDown = false; // no more leftMouse computation
682 }
683 int x,y;
684 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
685 int gx,gy;
686 contentsToGrid(x,y,gx,gy);
687 mCurrentCellX = gx;
688 mCurrentCellY = gy;
689 mStartCellX = gx;
690 mStartCellY = gy;
691 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
692 }
693 }
694 break;
695
696 case QEvent::MouseButtonRelease:
697
698 if (object != viewport()) {
699 if (me->button() == LeftButton && leftMouseDown) {
700 if (mActionItem) {
701 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
702 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
703 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
704 mScrollUpTimer.stop();
705 mScrollDownTimer.stop();
706 mActionItem->resetMove();
707 placeSubCells( mActionItem );
708 // emit startDragSignal( mActionItem->incidence() );
709 setCursor( arrowCursor );
710 mActionItem = 0;
711 mActionType = NOP;
712 mItemMoved = 0;
713 leftMouseDown = false;
714 return true;
715 }
716 endItemAction();
717 }
718 }
719
720 } else { // ---------- viewport()
721 if (me->button() == LeftButton && leftMouseDown ) { //left click
722 endSelectAction( true ); // emit new event signal
723 }
724 }
725 if (me->button() == LeftButton)
726 leftMouseDown = false;
727
728 break;
729 606
730 case QEvent::MouseMove:
731 if ( !leftMouseDown )
732 return true;
733 if ( blockMoving ) {
734 int dX, dY;
735 dX = startX - viewportPos.x();
736 if ( dX < 0 )
737 dX = -dX;
738 dY = viewportPos.y() - startY;
739 if ( dY < 0 )
740 dY = -dY;
741 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
742 if ( dX > blockmoveDist || dY > blockmoveDist ) {
743 blockMoving = false;
744 }
745 }
746 if (object != viewport()) {
747 KOAgendaItem *moveItem = (KOAgendaItem *)object;
748 if (!moveItem->incidence()->isReadOnly() ) {
749 if (!mActionItem)
750 setNoActionCursor(moveItem,viewportPos);
751 else {
752 if ( !blockMoving )
753 performItemAction(viewportPos);
754 }
755 }
756 } else { // ---------- viewport()
757 if ( mActionType == SELECT ) {
758 performSelectAction( viewportPos );
759 }
760 }
761 break;
762
763 case QEvent::MouseButtonDblClick:
764 blockMoving = false;
765 leftMouseDown = false;
766 if (object == viewport()) {
767 selectItem(0);
768 int x,y;
769 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
770 int gx,gy;
771 contentsToGrid(x,y,gx,gy);
772 emit newEventSignal(gx,gy);
773 } else {
774 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
775 selectItem(doubleClickedItem);
776 if ( KOPrefs::instance()->mEditOnDoubleClick )
777 emit editIncidenceSignal(doubleClickedItem->incidence());
778 else
779 emit showIncidenceSignal(doubleClickedItem->incidence());
780 }
781 break;
782
783 default:
784 break;
785 }
786 return true;
787#endif
788} 607}
789 608
790void KOAgenda::newItem( int item ) 609void KOAgenda::newItem( int item )
791{ 610{
792 if ( item == 1 ) { //new event 611 if ( item == 1 ) { //new event
793 newEventSignal(mStartCellX ,mStartCellY ); 612 newEventSignal(mStartCellX ,mStartCellY );
794 } else 613 } else
795 if ( item == 2 ) { //new event 614 if ( item == 2 ) { //new event
796 newTodoSignal(mStartCellX ,mStartCellY ); 615 newTodoSignal(mStartCellX ,mStartCellY );
797 } else 616 } else
798 { 617 {
799 emit showDateView( item, mStartCellX ); 618 emit showDateView( item, mStartCellX );
800 // 3Day view 619 // 3Day view
801 // 4Week view 620 // 4Week view
802 // 5Month view 621 // 5Month view
803 // 6Journal view 622 // 6Journal view
804 } 623 }
805} 624}
625void KOAgenda::slotClearSelection()
626{
627 if (mSelectionHeight) {
628 int selectionX = mSelectionCellX * mGridSpacingX;
629 int top = mSelectionYTop - 2 *mGridSpacingY;
630 int hei = mSelectionHeight + 4 *mGridSpacingY;
631 clearSelection();
632 repaintContents( selectionX, top,
633 mGridSpacingX, hei ,false );
634 }
635
636}
806void KOAgenda::startSelectAction(QPoint viewportPos) 637void KOAgenda::startSelectAction(QPoint viewportPos)
807{ 638{
808 //emit newStartSelectSignal(); 639
640 emit signalClearSelection();
641 slotClearSelection();
809 642
810 mActionType = SELECT; 643 mActionType = SELECT;
811 644
812 int x,y; 645 int x,y;
813 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 646 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
814 int gx,gy; 647 int gx,gy;
815 contentsToGrid(x,y,gx,gy); 648 contentsToGrid(x,y,gx,gy);
816 649
817 mStartCellX = gx; 650 mStartCellX = gx;
818 mStartCellY = gy; 651 mStartCellY = gy;
819 mCurrentCellX = gx; 652 mCurrentCellX = gx;
820 mCurrentCellY = gy; 653 mCurrentCellY = gy;
821
822 // Store coordinates of old selection
823 int selectionX = mSelectionCellX * mGridSpacingX;
824 int selectionYTop = mSelectionYTop;
825 int selectionHeight = mSelectionHeight;
826 654
827 // Store new selection 655 // Store new selection
828 mSelectionCellX = gx; 656 mSelectionCellX = gx;
829 mSelectionYTop = gy * mGridSpacingY; 657 mSelectionYTop = gy * mGridSpacingY;
830 mSelectionHeight = mGridSpacingY; 658 mSelectionHeight = mGridSpacingY;
831 659
832 // Clear old selection 660 // Paint new selection
833 repaintContents( selectionX, selectionYTop, 661 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
834 mGridSpacingX, selectionHeight,false ); 662 mGridSpacingX-1, mSelectionHeight );
835
836 // Paint new selection
837 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
838 // mGridSpacingX, mSelectionHeight );
839} 663}
840 664
841void KOAgenda::performSelectAction(QPoint viewportPos) 665void KOAgenda::performSelectAction(QPoint viewportPos)
842{ 666{
843 int x,y; 667 int x,y;
844 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 668 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
845 int gx,gy; 669 int gx,gy;
846 contentsToGrid(x,y,gx,gy); 670 contentsToGrid(x,y,gx,gy);
847 671
848 QPoint clipperPos = clipper()-> 672 QPoint clipperPos = clipper()->
849 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 673 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
850 674
851 // Scroll if cursor was moved to upper or lower end of agenda. 675 // Scroll if cursor was moved to upper or lower end of agenda.
852 if (clipperPos.y() < mScrollBorderWidth) { 676 if (clipperPos.y() < mScrollBorderWidth) {
853 mScrollUpTimer.start(mScrollDelay); 677 mScrollUpTimer.start(mScrollDelay);
854 } else if (visibleHeight() - clipperPos.y() < 678 } else if (visibleHeight() - clipperPos.y() <
855 mScrollBorderWidth) { 679 mScrollBorderWidth) {
856 mScrollDownTimer.start(mScrollDelay); 680 mScrollDownTimer.start(mScrollDelay);
857 } else { 681 } else {
858 mScrollUpTimer.stop(); 682 mScrollUpTimer.stop();
859 mScrollDownTimer.stop(); 683 mScrollDownTimer.stop();
860 } 684 }
861 685
862 if ( gy > mCurrentCellY ) { 686 if ( gy > mCurrentCellY ) {
863 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 687 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
864 688
865#if 0 689
866 // FIXME: Repaint only the newly selected region
867 repaintContents( mSelectionCellX * mGridSpacingX,
868 mCurrentCellY + mGridSpacingY,
869 mGridSpacingX,
870 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
871#else
872 repaintContents( (KOGlobals::self()->reverseLayout() ? 690 repaintContents( (KOGlobals::self()->reverseLayout() ?
873 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 691 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
874 mGridSpacingX, mSelectionYTop, 692 mGridSpacingX, mSelectionYTop,
875 mGridSpacingX, mSelectionHeight , false); 693 mGridSpacingX, mSelectionHeight , false);
876#endif
877 694
878 mCurrentCellY = gy; 695 mCurrentCellY = gy;
879 } else if ( gy < mCurrentCellY ) { 696 } else if ( gy < mCurrentCellY ) {
880 if ( gy >= mStartCellY ) { 697 if ( gy >= mStartCellY ) {
881 int selectionHeight = mSelectionHeight; 698 int selectionHeight = mSelectionHeight;
882 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 699 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
883 700
884 repaintContents( (KOGlobals::self()->reverseLayout() ? 701 repaintContents( (KOGlobals::self()->reverseLayout() ?
885 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 702 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
886 mGridSpacingX, mSelectionYTop, 703 mGridSpacingX, mSelectionYTop,
887 mGridSpacingX, selectionHeight,false ); 704 mGridSpacingX, selectionHeight,false );
888 705
889 mCurrentCellY = gy; 706 mCurrentCellY = gy;
890 } else { 707 } else {
891 } 708 }
892 } 709 }
893} 710}
894 711
895void KOAgenda::endSelectAction( bool emitNewEvent ) 712void KOAgenda::endSelectAction( bool emitNewEvent )
896{ 713{
897 mActionType = NOP; 714 mActionType = NOP;
898 mScrollUpTimer.stop(); 715 mScrollUpTimer.stop();
899 mScrollDownTimer.stop(); 716 mScrollDownTimer.stop();
900 717
901 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 718 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
902 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 719 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
903 qDebug("ew event signal ");
904 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 720 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
905 } 721 }
906} 722}
907 723
908void KOAgenda::startItemAction(QPoint viewportPos) 724void KOAgenda::startItemAction(QPoint viewportPos)
909{ 725{
910 int x,y; 726 int x,y;
911 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 727 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
912 int gx,gy; 728 int gx,gy;
913 contentsToGrid(x,y,gx,gy); 729 contentsToGrid(x,y,gx,gy);
914 730
915 mStartCellX = gx; 731 mStartCellX = gx;
916 mStartCellY = gy; 732 mStartCellY = gy;
917 mCurrentCellX = gx; 733 mCurrentCellX = gx;
918 mCurrentCellY = gy; 734 mCurrentCellY = gy;
919 735
920 if (mAllDayMode) { 736 if (mAllDayMode) {
921 int gridDistanceX = (x - gx * mGridSpacingX); 737 int gridDistanceX = (x - gx * mGridSpacingX);
922 if (gridDistanceX < mResizeBorderWidth && 738 if (gridDistanceX < mResizeBorderWidth &&
923 mActionItem->cellX() == mCurrentCellX) { 739 mActionItem->cellX() == mCurrentCellX) {
924 mActionType = RESIZELEFT; 740 mActionType = RESIZELEFT;
925 setCursor(sizeHorCursor); 741 setCursor(sizeHorCursor);
926 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 742 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
927 mActionItem->cellXWidth() == mCurrentCellX) { 743 mActionItem->cellXWidth() == mCurrentCellX) {
928 mActionType = RESIZERIGHT; 744 mActionType = RESIZERIGHT;
929 setCursor(sizeHorCursor); 745 setCursor(sizeHorCursor);
930 } else { 746 } else {
931 mActionType = MOVE; 747 mActionType = MOVE;
932 mActionItem->startMove(); 748 mActionItem->startMove();
933 setCursor(sizeAllCursor); 749 setCursor(sizeAllCursor);
934 } 750 }
935 } else { 751 } else {
936 int gridDistanceY = (y - gy * mGridSpacingY); 752 int gridDistanceY = (y - gy * mGridSpacingY);
937 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 753 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
938 if (allowResize && gridDistanceY < mResizeBorderWidth && 754 if (allowResize && gridDistanceY < mResizeBorderWidth &&
939 mActionItem->cellYTop() == mCurrentCellY && 755 mActionItem->cellYTop() == mCurrentCellY &&
940 !mActionItem->firstMultiItem()) { 756 !mActionItem->firstMultiItem()) {
941 mActionType = RESIZETOP; 757 mActionType = RESIZETOP;
942 setCursor(sizeVerCursor); 758 setCursor(sizeVerCursor);
943 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 759 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
944 mActionItem->cellYBottom() == mCurrentCellY && 760 mActionItem->cellYBottom() == mCurrentCellY &&
945 !mActionItem->lastMultiItem()) { 761 !mActionItem->lastMultiItem()) {
946 mActionType = RESIZEBOTTOM; 762 mActionType = RESIZEBOTTOM;
947 setCursor(sizeVerCursor); 763 setCursor(sizeVerCursor);
948 } else { 764 } else {
949 mActionType = MOVE; 765 mActionType = MOVE;
950 mActionItem->startMove(); 766 mActionItem->startMove();
951 setCursor(sizeAllCursor); 767 setCursor(sizeAllCursor);
952 } 768 }
953 } 769 }
954} 770}
955 771
956void KOAgenda::performItemAction(QPoint viewportPos) 772void KOAgenda::performItemAction(QPoint viewportPos)
957{ 773{
958// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 774// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
959// QPoint point = viewport()->mapToGlobal(viewportPos); 775// QPoint point = viewport()->mapToGlobal(viewportPos);
960// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 776// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
961// point = clipper()->mapFromGlobal(point); 777// point = clipper()->mapFromGlobal(point);
962// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 778// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
963// kdDebug() << "visible height: " << visibleHeight() << endl; 779// kdDebug() << "visible height: " << visibleHeight() << endl;
964 int x,y; 780 int x,y;
965 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 781 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
966// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 782// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
967 int gx,gy; 783 int gx,gy;
968 contentsToGrid(x,y,gx,gy); 784 contentsToGrid(x,y,gx,gy);
969 QPoint clipperPos = clipper()-> 785 QPoint clipperPos = clipper()->
970 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 786 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
971 787
972 // Cursor left active agenda area. 788 // Cursor left active agenda area.
973 // This starts a drag. 789 // This starts a drag.
974 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 790 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
975 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 791 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
976 if ( mActionType == MOVE ) { 792 if ( mActionType == MOVE ) {
977 mScrollUpTimer.stop(); 793 mScrollUpTimer.stop();
978 mScrollDownTimer.stop(); 794 mScrollDownTimer.stop();
979 mActionItem->resetMove(); 795 mActionItem->resetMove();
980 placeSubCells( mActionItem ); 796 placeSubCells( mActionItem );
981 // emit startDragSignal( mActionItem->incidence() ); 797 // emit startDragSignal( mActionItem->incidence() );
982 setCursor( arrowCursor ); 798 setCursor( arrowCursor );
983 mActionItem = 0; 799 mActionItem = 0;
984 mActionType = NOP; 800 mActionType = NOP;
985 mItemMoved = 0; 801 mItemMoved = 0;
986 return; 802 return;
987 } 803 }
988 } else { 804 } else {
989 switch ( mActionType ) { 805 switch ( mActionType ) {
990 case MOVE: 806 case MOVE:
991 setCursor( sizeAllCursor ); 807 setCursor( sizeAllCursor );
992 break; 808 break;
993 case RESIZETOP: 809 case RESIZETOP:
994 case RESIZEBOTTOM: 810 case RESIZEBOTTOM:
995 setCursor( sizeVerCursor ); 811 setCursor( sizeVerCursor );
996 break; 812 break;
997 case RESIZELEFT: 813 case RESIZELEFT:
998 case RESIZERIGHT: 814 case RESIZERIGHT:
999 setCursor( sizeHorCursor ); 815 setCursor( sizeHorCursor );
@@ -1007,203 +823,193 @@ void KOAgenda::performItemAction(QPoint viewportPos)
1007 if (clipperPos.y() < mScrollBorderWidth) { 823 if (clipperPos.y() < mScrollBorderWidth) {
1008 mScrollUpTimer.start(mScrollDelay); 824 mScrollUpTimer.start(mScrollDelay);
1009 } else if (visibleHeight() - clipperPos.y() < 825 } else if (visibleHeight() - clipperPos.y() <
1010 mScrollBorderWidth) { 826 mScrollBorderWidth) {
1011 mScrollDownTimer.start(mScrollDelay); 827 mScrollDownTimer.start(mScrollDelay);
1012 } else { 828 } else {
1013 mScrollUpTimer.stop(); 829 mScrollUpTimer.stop();
1014 mScrollDownTimer.stop(); 830 mScrollDownTimer.stop();
1015 } 831 }
1016 832
1017 // Move or resize item if necessary 833 // Move or resize item if necessary
1018 if (mCurrentCellX != gx || mCurrentCellY != gy) { 834 if (mCurrentCellX != gx || mCurrentCellY != gy) {
1019 mItemMoved = true; 835 mItemMoved = true;
1020 mActionItem->raise(); 836 mActionItem->raise();
1021 if (mActionType == MOVE) { 837 if (mActionType == MOVE) {
1022 // Move all items belonging to a multi item 838 // Move all items belonging to a multi item
1023 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 839 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
1024 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 840 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
1025 if (!moveItem) moveItem = mActionItem; 841 if (!moveItem) moveItem = mActionItem;
1026 while (moveItem) { 842 while (moveItem) {
1027 int dy; 843 int dy;
1028 if (isMultiItem) dy = 0; 844 if (isMultiItem) dy = 0;
1029 else dy = gy - mCurrentCellY; 845 else dy = gy - mCurrentCellY;
1030 moveItem->moveRelative(gx - mCurrentCellX,dy); 846 moveItem->moveRelative(gx - mCurrentCellX,dy);
1031 int x,y; 847 int x,y;
1032 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 848 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
1033 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 849 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
1034 mGridSpacingY * moveItem->cellHeight()); 850 mGridSpacingY * moveItem->cellHeight());
1035 moveChild(moveItem,x,y); 851 moveChild(moveItem,x,y);
1036 moveItem = moveItem->nextMultiItem(); 852 moveItem = moveItem->nextMultiItem();
1037 } 853 }
1038 } else if (mActionType == RESIZETOP) { 854 } else if (mActionType == RESIZETOP) {
1039 if (mCurrentCellY <= mActionItem->cellYBottom()) { 855 if (mCurrentCellY <= mActionItem->cellYBottom()) {
1040 mActionItem->expandTop(gy - mCurrentCellY); 856 mActionItem->expandTop(gy - mCurrentCellY);
1041 mActionItem->resize(mActionItem->width(), 857 mActionItem->resize(mActionItem->width(),
1042 mGridSpacingY * mActionItem->cellHeight()); 858 mGridSpacingY * mActionItem->cellHeight());
1043 int x,y; 859 int x,y;
1044 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 860 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
1045 //moveChild(mActionItem,childX(mActionItem),y); 861 //moveChild(mActionItem,childX(mActionItem),y);
1046 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 862 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
1047 } 863 }
1048 } else if (mActionType == RESIZEBOTTOM) { 864 } else if (mActionType == RESIZEBOTTOM) {
1049 if (mCurrentCellY >= mActionItem->cellYTop()) { 865 if (mCurrentCellY >= mActionItem->cellYTop()) {
1050 mActionItem->expandBottom(gy - mCurrentCellY); 866 mActionItem->expandBottom(gy - mCurrentCellY);
1051 mActionItem->resize(mActionItem->width(), 867 mActionItem->resize(mActionItem->width(),
1052 mGridSpacingY * mActionItem->cellHeight()); 868 mGridSpacingY * mActionItem->cellHeight());
1053 } 869 }
1054 } else if (mActionType == RESIZELEFT) { 870 } else if (mActionType == RESIZELEFT) {
1055 if (mCurrentCellX <= mActionItem->cellXWidth()) { 871 if (mCurrentCellX <= mActionItem->cellXWidth()) {
1056 mActionItem->expandLeft(gx - mCurrentCellX); 872 mActionItem->expandLeft(gx - mCurrentCellX);
1057 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 873 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
1058 mActionItem->height()); 874 mActionItem->height());
1059 int x,y; 875 int x,y;
1060 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 876 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
1061 moveChild(mActionItem,x,childY(mActionItem)); 877 moveChild(mActionItem,x,childY(mActionItem));
1062 } 878 }
1063 } else if (mActionType == RESIZERIGHT) { 879 } else if (mActionType == RESIZERIGHT) {
1064 if (mCurrentCellX >= mActionItem->cellX()) { 880 if (mCurrentCellX >= mActionItem->cellX()) {
1065 mActionItem->expandRight(gx - mCurrentCellX); 881 mActionItem->expandRight(gx - mCurrentCellX);
1066 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 882 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
1067 mActionItem->height()); 883 mActionItem->height());
1068 } 884 }
1069 } 885 }
1070 mCurrentCellX = gx; 886 mCurrentCellX = gx;
1071 mCurrentCellY = gy; 887 mCurrentCellY = gy;
1072 } 888 }
1073} 889}
1074 890
1075void KOAgenda::endItemAction() 891void KOAgenda::endItemAction()
1076{ 892{
1077 893
1078 if ( mItemMoved ) { 894 if ( mItemMoved ) {
1079 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 895 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
1080 if ( !placeItem ) { 896 if ( !placeItem ) {
1081 placeItem = mActionItem; 897 placeItem = mActionItem;
1082 } 898 }
1083 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 899 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
1084 Incidence* oldInc = placeItem->incidence(); 900 Incidence* oldInc = placeItem->incidence();
1085 placeItem->recreateIncidence(); 901 placeItem->recreateIncidence();
1086 emit addToCalSignal(placeItem->incidence(), oldInc ); 902 emit addToCalSignal(placeItem->incidence(), oldInc );
1087 } 903 }
1088 int type = mActionType; 904 int type = mActionType;
1089 if ( mAllDayMode ) 905 if ( mAllDayMode )
1090 type = -1; 906 type = -1;
1091 KOAgendaItem *modifiedItem = placeItem; 907 KOAgendaItem *modifiedItem = placeItem;
1092 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 908 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1093 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 909 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1094 KOAgendaItem *item; 910 KOAgendaItem *item;
1095 911
1096 if ( placeItem->incidence()->type() == "Todo" ) { 912 if ( placeItem->incidence()->type() == "Todo" ) {
1097 mSelectedItem = 0; 913 mSelectedItem = 0;
1098 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 914 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1099 modifiedItem->mLastMoveXPos = mCurrentCellX; 915 modifiedItem->mLastMoveXPos = mCurrentCellX;
1100 emit itemModified( modifiedItem, mActionType ); 916 emit itemModified( modifiedItem, mActionType );
1101 } 917 }
1102 else { 918 else {
1103#if 0 919
1104 for ( item=oldconflictItems.first(); item != 0;
1105 item=oldconflictItems.next() ) {
1106 placeSubCells(item);
1107 }
1108 while ( placeItem ) {
1109 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1110 placeSubCells( placeItem );
1111 placeItem = placeItem->nextMultiItem();
1112 }
1113#endif
1114 920
1115 globalFlagBlockAgendaItemPaint = 1; 921 globalFlagBlockAgendaItemPaint = 1;
1116 for ( item=oldconflictItems.first(); item != 0; 922 for ( item=oldconflictItems.first(); item != 0;
1117 item=oldconflictItems.next() ) { 923 item=oldconflictItems.next() ) {
1118 placeSubCells(item); 924 placeSubCells(item);
1119 } 925 }
1120 while ( placeItem ) { 926 while ( placeItem ) {
1121 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 927 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1122 oldconflictItems = placeItem->conflictItems(); 928 oldconflictItems = placeItem->conflictItems();
1123 for ( item=oldconflictItems.first(); item != 0; 929 for ( item=oldconflictItems.first(); item != 0;
1124 item=oldconflictItems.next() ) { 930 item=oldconflictItems.next() ) {
1125 placeSubCells(item); 931 placeSubCells(item);
1126 } 932 }
1127 placeSubCells( placeItem ); 933 placeSubCells( placeItem );
1128 placeItem = placeItem->nextMultiItem(); 934 placeItem = placeItem->nextMultiItem();
1129 } 935 }
1130 globalFlagBlockAgendaItemPaint = 0; 936 globalFlagBlockAgendaItemPaint = 0;
1131 for ( item=oldconflictItems.first(); item != 0; 937 for ( item=oldconflictItems.first(); item != 0;
1132 item=oldconflictItems.next() ) { 938 item=oldconflictItems.next() ) {
1133 globalFlagBlockAgendaItemUpdate = 0; 939 globalFlagBlockAgendaItemUpdate = 0;
1134 item->repaintMe(); 940 item->repaintMe();
1135 globalFlagBlockAgendaItemUpdate = 1; 941 globalFlagBlockAgendaItemUpdate = 1;
1136 item->repaint( false ); 942 item->repaint( false );
1137 } 943 }
1138 placeItem = modifiedItem; 944 placeItem = modifiedItem;
1139 945
1140 while ( placeItem ) { 946 while ( placeItem ) {
1141 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 947 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1142 globalFlagBlockAgendaItemUpdate = 0; 948 globalFlagBlockAgendaItemUpdate = 0;
1143 placeItem->repaintMe(); 949 placeItem->repaintMe();
1144 globalFlagBlockAgendaItemUpdate = 1; 950 globalFlagBlockAgendaItemUpdate = 1;
1145 placeItem->repaint(false); 951 placeItem->repaint(false);
1146 placeItem = placeItem->nextMultiItem(); 952 placeItem = placeItem->nextMultiItem();
1147 } 953 }
1148 emit itemModified( modifiedItem, mActionType ); 954 emit itemModified( modifiedItem, mActionType );
1149 955
1150 956
1151 placeItem = modifiedItem; 957 placeItem = modifiedItem;
1152 while ( placeItem ) { 958 while ( placeItem ) {
1153 oldconflictItems = placeItem->conflictItems(); 959 oldconflictItems = placeItem->conflictItems();
1154 for ( item=oldconflictItems.first(); item != 0; 960 for ( item=oldconflictItems.first(); item != 0;
1155 item=oldconflictItems.next() ) { 961 item=oldconflictItems.next() ) {
1156 placeSubCells(item); 962 placeSubCells(item);
1157 } 963 }
1158 placeSubCells( placeItem ); 964 placeSubCells( placeItem );
1159 placeItem = placeItem->nextMultiItem(); 965 placeItem = placeItem->nextMultiItem();
1160 966
1161 } 967 }
1162 placeItem = modifiedItem; 968 placeItem = modifiedItem;
1163 while ( placeItem ) { 969 while ( placeItem ) {
1164 oldconflictItems = placeItem->conflictItems(); 970 oldconflictItems = placeItem->conflictItems();
1165 for ( item=oldconflictItems.first(); item != 0; 971 for ( item=oldconflictItems.first(); item != 0;
1166 item=oldconflictItems.next() ) { 972 item=oldconflictItems.next() ) {
1167 globalFlagBlockAgendaItemUpdate = 0; 973 globalFlagBlockAgendaItemUpdate = 0;
1168 item->repaintMe(); 974 item->repaintMe();
1169 globalFlagBlockAgendaItemUpdate = 1; 975 globalFlagBlockAgendaItemUpdate = 1;
1170 item->repaint(false); 976 item->repaint(false);
1171 } 977 }
1172 placeItem = placeItem->nextMultiItem(); 978 placeItem = placeItem->nextMultiItem();
1173 } 979 }
1174 /* 980 /*
1175 981
1176 oldconflictItems = modifiedItem->conflictItems(); 982 oldconflictItems = modifiedItem->conflictItems();
1177 for ( item=oldconflictItems.first(); item != 0; 983 for ( item=oldconflictItems.first(); item != 0;
1178 item=oldconflictItems.next() ) { 984 item=oldconflictItems.next() ) {
1179 globalFlagBlockAgendaItemUpdate = 0; 985 globalFlagBlockAgendaItemUpdate = 0;
1180 item->paintMe(false); 986 item->paintMe(false);
1181 globalFlagBlockAgendaItemUpdate = 1; 987 globalFlagBlockAgendaItemUpdate = 1;
1182 item->repaint(false); 988 item->repaint(false);
1183 } 989 }
1184 */ 990 */
1185 991
1186 992
1187 } 993 }
1188 994
1189 } 995 }
1190 996
1191 mScrollUpTimer.stop(); 997 mScrollUpTimer.stop();
1192 mScrollDownTimer.stop(); 998 mScrollDownTimer.stop();
1193 setCursor( arrowCursor ); 999 setCursor( arrowCursor );
1194 mActionItem = 0; 1000 mActionItem = 0;
1195 mActionType = NOP; 1001 mActionType = NOP;
1196 mItemMoved = 0; 1002 mItemMoved = 0;
1197 1003
1198} 1004}
1199 1005
1200void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1006void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1201{ 1007{
1202// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1008// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1203// QPoint point = viewport()->mapToGlobal(viewportPos); 1009// QPoint point = viewport()->mapToGlobal(viewportPos);
1204// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1010// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1205// point = clipper()->mapFromGlobal(point); 1011// point = clipper()->mapFromGlobal(point);
1206// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1012// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1207 1013
1208 int x,y; 1014 int x,y;
1209 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1015 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 4f1fdb9..fb9983e 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -34,211 +34,213 @@
34#include "koeventview.h" 34#include "koeventview.h"
35 35
36class QPopupMenu; 36class QPopupMenu;
37class QTime; 37class QTime;
38class KConfig; 38class KConfig;
39class QFrame; 39class QFrame;
40class KOAgenda; 40class KOAgenda;
41class KCal::Event; 41class KCal::Event;
42class KCal::Todo; 42class KCal::Todo;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46class MarcusBains : public QFrame { 46class MarcusBains : public QFrame {
47 Q_OBJECT 47 Q_OBJECT
48 public: 48 public:
49 MarcusBains(KOAgenda *agenda=0,const char *name=0); 49 MarcusBains(KOAgenda *agenda=0,const char *name=0);
50 virtual ~MarcusBains(); 50 virtual ~MarcusBains();
51 51
52 public slots: 52 public slots:
53 void updateLocation(bool recalculate=false); 53 void updateLocation(bool recalculate=false);
54 void updateLoc(); 54 void updateLoc();
55 55
56 private: 56 private:
57 int todayColumn(); 57 int todayColumn();
58 QTimer *minutes; 58 QTimer *minutes;
59 QLabel *mTimeBox; 59 QLabel *mTimeBox;
60 KOAgenda *agenda; 60 KOAgenda *agenda;
61 QTime oldTime; 61 QTime oldTime;
62 int oldToday; 62 int oldToday;
63}; 63};
64 64
65 65
66class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 public: 69 public:
70 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
72 72
73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
74 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
75 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
76 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
77 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
78 78
79 Incidence *selectedIncidence() const; 79 Incidence *selectedIncidence() const;
80 QDate selectedIncidenceDate() const; 80 QDate selectedIncidenceDate() const;
81 81
82 virtual bool eventFilter ( QObject *, QEvent * ); 82 virtual bool eventFilter ( QObject *, QEvent * );
83 83
84 void contentsToGrid (int x, int y, int& gx, int& gy); 84 void contentsToGrid (int x, int y, int& gx, int& gy);
85 void gridToContents (int gx, int gy, int& x, int& y); 85 void gridToContents (int gx, int gy, int& x, int& y);
86 86
87 int timeToY (const QTime &time); 87 int timeToY (const QTime &time);
88 QTime gyToTime (int y); 88 QTime gyToTime (int y);
89 89
90 void setStartHour(int startHour); 90 void setStartHour(int startHour);
91 91
92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
95 int YTop,int YBottom); 95 int YTop,int YBottom);
96 96
97 void changeColumns(int columns); 97 void changeColumns(int columns);
98 98
99 int columns() { return mColumns; } 99 int columns() { return mColumns; }
100 int rows() { return mRows; } 100 int rows() { return mRows; }
101 101
102 int gridSpacingX() const { return mGridSpacingX; } 102 int gridSpacingX() const { return mGridSpacingX; }
103 int gridSpacingY() const { return mGridSpacingY; } 103 int gridSpacingY() const { return mGridSpacingY; }
104 104
105// virtual QSizePolicy sizePolicy() const; 105// virtual QSizePolicy sizePolicy() const;
106 106
107 void clear(); 107 void clear();
108 108
109 void clearSelection(); 109 void clearSelection();
110 void hideUnused(); 110 void hideUnused();
111 111
112 /** Calculates the minimum width */ 112 /** Calculates the minimum width */
113 virtual int minimumWidth() const; 113 virtual int minimumWidth() const;
114 /** Update configuration from preference settings */ 114 /** Update configuration from preference settings */
115 void updateConfig(); 115 void updateConfig();
116 116
117 void checkScrollBoundaries(); 117 void checkScrollBoundaries();
118 118
119 void setHolidayMask(QMemArray<bool> *); 119 void setHolidayMask(QMemArray<bool> *);
120 void setDateList(const DateList &selectedDates); 120 void setDateList(const DateList &selectedDates);
121 DateList dateList() const; 121 DateList dateList() const;
122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
123 void finishUpdate(); 123 void finishUpdate();
124 void printSelection(); 124 void printSelection();
125 void storePosition(); 125 void storePosition();
126 void restorePosition(); 126 void restorePosition();
127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } 127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
128 128
129 public slots: 129 public slots:
130 void slotClearSelection();
130 void popupMenu(); 131 void popupMenu();
131 void newItem( int ); 132 void newItem( int );
132 void moveChild( QWidget *, int, int ); 133 void moveChild( QWidget *, int, int );
133 void scrollUp(); 134 void scrollUp();
134 void scrollDown(); 135 void scrollDown();
135 void updateTodo( Todo * t, int , bool ); 136 void updateTodo( Todo * t, int , bool );
136 void popupAlarm(); 137 void popupAlarm();
137 138
138 void checkScrollBoundaries(int); 139 void checkScrollBoundaries(int);
139 140
140 /** Deselect selected items. This function does not emit any signals. */ 141 /** Deselect selected items. This function does not emit any signals. */
141 void deselectItem(); 142 void deselectItem();
142 /** Select item. If the argument is 0, the currently selected item gets 143 /** Select item. If the argument is 0, the currently selected item gets
143 deselected. This function emits the itemSelected(bool) signal to inform 144 deselected. This function emits the itemSelected(bool) signal to inform
144 about selection/deseelction of events. */ 145 about selection/deseelction of events. */
145 void selectItem(KOAgendaItem *); 146 void selectItem(KOAgendaItem *);
146 void finishResize(); 147 void finishResize();
147 148
148 signals: 149 signals:
150 void signalClearSelection();
149 void showDateView( int, int); 151 void showDateView( int, int);
150 void newEventSignal(); 152 void newEventSignal();
151 void newEventSignal(int gx,int gy); 153 void newEventSignal(int gx,int gy);
152 void newTodoSignal(int gx,int gy); 154 void newTodoSignal(int gx,int gy);
153 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 155 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
154 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 156 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
155 void newStartSelectSignal(); 157 void newStartSelectSignal();
156 void showIncidenceSignal(Incidence *); 158 void showIncidenceSignal(Incidence *);
157 void editIncidenceSignal(Incidence *); 159 void editIncidenceSignal(Incidence *);
158 void deleteIncidenceSignal(Incidence *); 160 void deleteIncidenceSignal(Incidence *);
159 void showIncidencePopupSignal(Incidence *); 161 void showIncidencePopupSignal(Incidence *);
160 162
161 void itemModified(KOAgendaItem *item, int ); 163 void itemModified(KOAgendaItem *item, int );
162 void incidenceSelected(Incidence *); 164 void incidenceSelected(Incidence *);
163 165
164 void lowerYChanged(int); 166 void lowerYChanged(int);
165 void upperYChanged(int); 167 void upperYChanged(int);
166 168
167 void startDragSignal(Incidence *); 169 void startDragSignal(Incidence *);
168 void addToCalSignal(Incidence *, Incidence *); 170 void addToCalSignal(Incidence *, Incidence *);
169 void resizedSignal(); 171 void resizedSignal();
170 172
171 protected: 173 protected:
172 KOEventPopupMenu * mAllAgendaPopup; 174 KOEventPopupMenu * mAllAgendaPopup;
173 QPainter mPixPainter; 175 QPainter mPixPainter;
174 QPixmap mPaintPixmap; 176 QPixmap mPaintPixmap;
175 QPixmap mHighlightPixmap; 177 QPixmap mHighlightPixmap;
176 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 178 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
177 virtual void resizeEvent ( QResizeEvent * ); 179 virtual void resizeEvent ( QResizeEvent * );
178 180
179 /** Handles mouse events. Called from eventFilter */ 181 /** Handles mouse events. Called from eventFilter */
180 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 182 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
181 183
182 /** Start selecting time span. */ 184 /** Start selecting time span. */
183 void startSelectAction(QPoint viewportPos); 185 void startSelectAction(QPoint viewportPos);
184 186
185 /** Select time span. */ 187 /** Select time span. */
186 void performSelectAction(QPoint viewportPos); 188 void performSelectAction(QPoint viewportPos);
187 189
188 /** Emd selecting time span. */ 190 /** Emd selecting time span. */
189 void endSelectAction( bool emitNewEvent = false ); 191 void endSelectAction( bool emitNewEvent = false );
190 192
191 /** Start moving/resizing agenda item */ 193 /** Start moving/resizing agenda item */
192 void startItemAction(QPoint viewportPos); 194 void startItemAction(QPoint viewportPos);
193 195
194 /** Move/resize agenda item */ 196 /** Move/resize agenda item */
195 void performItemAction(QPoint viewportPos); 197 void performItemAction(QPoint viewportPos);
196 198
197 /** End moving/resizing agenda item */ 199 /** End moving/resizing agenda item */
198 void endItemAction(); 200 void endItemAction();
199 201
200 /** Set cursor, when no item action is in progress */ 202 /** Set cursor, when no item action is in progress */
201 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 203 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
202 204
203 /** Place agenda item in agenda and adjust other cells if necessary */ 205 /** Place agenda item in agenda and adjust other cells if necessary */
204 void placeSubCells(KOAgendaItem *placeItem); 206 void placeSubCells(KOAgendaItem *placeItem);
205 207
206 /** Process the keyevent, including the ignored keyevents of eventwidgets. 208 /** Process the keyevent, including the ignored keyevents of eventwidgets.
207 * Implements pgup/pgdn and cursor key navigation in the view. 209 * Implements pgup/pgdn and cursor key navigation in the view.
208 */ 210 */
209 void keyPressEvent( QKeyEvent * ); 211 void keyPressEvent( QKeyEvent * );
210 212
211 void calculateWorkingHours(); 213 void calculateWorkingHours();
212 214
213 virtual void contentsMousePressEvent ( QMouseEvent * ); 215 virtual void contentsMousePressEvent ( QMouseEvent * );
214 216
215 private: 217 private:
216 void init(); 218 void init();
217 void marcus_bains(); 219 void marcus_bains();
218 bool mAllDayMode; 220 bool mAllDayMode;
219 bool blockResize; 221 bool blockResize;
220 bool mLeftMouseDown; 222 bool mLeftMouseDown;
221 KOAgendaItem *mPopupItem; 223 KOAgendaItem *mPopupItem;
222 QTimer* mPopupTimer; 224 QTimer* mPopupTimer;
223 int mPopupKind; 225 int mPopupKind;
224 QPoint mPopupPos; 226 QPoint mPopupPos;
225 QTimer mResizeTimer; 227 QTimer mResizeTimer;
226 double mContentPosition; 228 double mContentPosition;
227 229
228 // Width and height of agenda cells 230 // Width and height of agenda cells
229 int mGridSpacingX; 231 int mGridSpacingX;
230 int mGridSpacingY; 232 int mGridSpacingY;
231 233
232 // size of border, where mouse action will resize the KOAgendaItem 234 // size of border, where mouse action will resize the KOAgendaItem
233 int mResizeBorderWidth; 235 int mResizeBorderWidth;
234 236
235 // size of border, where mouse mve will cause a scroll of the agenda 237 // size of border, where mouse mve will cause a scroll of the agenda
236 int mScrollBorderWidth; 238 int mScrollBorderWidth;
237 int mScrollDelay; 239 int mScrollDelay;
238 int mScrollOffset; 240 int mScrollOffset;
239 241
240 QTimer mScrollUpTimer; 242 QTimer mScrollUpTimer;
241 QTimer mScrollDownTimer; 243 QTimer mScrollDownTimer;
242 244
243 // Number of Columns/Rows of agenda grid 245 // Number of Columns/Rows of agenda grid
244 int mColumns; 246 int mColumns;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 17f791d..b43c40e 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -341,489 +341,486 @@ void EventIndicator::drawContents(QPainter *p)
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 // FIX
438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
439#endif 438#endif
440 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
441 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
442 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
443 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
445 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
446 445
447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
448 agendaFrame); 447 agendaFrame);
449 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
450 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
451 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
452 451
453 // Create time labels 452 // Create time labels
454 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
455 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
456 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
457 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
458 457
459 // Create agenda 458 // Create agenda
460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
462 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
463 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
464 // Create event context menu for agenda 463 // Create event context menu for agenda
465 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
466 465
467#if 0 466#if 0
468 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
469 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
470 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
471 470
472#endif 471#endif
473 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
474 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
475 474
476 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
477 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
478 mAgenda->setPopup( mAllAgendaPopup ); 477 mAgenda->setPopup( mAllAgendaPopup );
479 mAllDayAgenda->setPopup( mAllAgendaPopup ); 478 mAllDayAgenda->setPopup( mAllAgendaPopup );
480 // make connections between dependent widgets 479 // make connections between dependent widgets
481 mTimeLabels->setAgenda(mAgenda); 480 mTimeLabels->setAgenda(mAgenda);
482 481
483 // Update widgets to reflect user preferences 482 // Update widgets to reflect user preferences
484 // updateConfig(); 483 // updateConfig();
485 484
486 // createDayLabels(); 485 // createDayLabels();
487 486
488 // these blank widgets make the All Day Event box line up with the agenda 487 // these blank widgets make the All Day Event box line up with the agenda
489 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
491 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
492 491
493 // Scrolling 492 // Scrolling
494 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
495 mTimeLabels, SLOT(positionChanged())); 494 mTimeLabels, SLOT(positionChanged()));
496 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
497 SLOT(setContentsPos(int))); 496 SLOT(setContentsPos(int)));
498 497
499 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
500 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
501 500
502 // Create/Show/Edit/Delete Event 501 // Create/Show/Edit/Delete Event
503 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 502 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
504 SLOT(newEvent(int,int))); 503 SLOT(newEvent(int,int)));
505 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
506 SLOT(newTodo(int,int))); 505 SLOT(newTodo(int,int)));
507 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
508 SLOT(newEvent(int,int,int,int))); 507 SLOT(newEvent(int,int,int,int)));
509 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
510 SLOT(newEventAllDay(int,int))); 509 SLOT(newEventAllDay(int,int)));
511 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
512 SLOT(newTodoAllDay(int,int))); 511 SLOT(newTodoAllDay(int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
514 SLOT(newEventAllDay(int,int))); 513 SLOT(newEventAllDay(int,int)));
515 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
516 SLOT(newTimeSpanSelected(int,int,int,int))); 515 SLOT(newTimeSpanSelected(int,int,int,int)));
517 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
518 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
519 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
521 520
522 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
523 SIGNAL(editIncidenceSignal(Incidence *))); 522 SIGNAL(editIncidenceSignal(Incidence *)));
524 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
525 SIGNAL(editIncidenceSignal(Incidence *))); 524 SIGNAL(editIncidenceSignal(Incidence *)));
526 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
527 SIGNAL(showIncidenceSignal(Incidence *))); 526 SIGNAL(showIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
529 SIGNAL(showIncidenceSignal(Incidence *))); 528 SIGNAL(showIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
531 SIGNAL(deleteIncidenceSignal(Incidence *))); 530 SIGNAL(deleteIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
533 SIGNAL(deleteIncidenceSignal(Incidence *))); 532 SIGNAL(deleteIncidenceSignal(Incidence *)));
534 533
535 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
536 SLOT(updateEventDates(KOAgendaItem *, int ))); 535 SLOT(updateEventDates(KOAgendaItem *, int )));
537 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
538 SLOT(updateEventDates(KOAgendaItem *, int))); 537 SLOT(updateEventDates(KOAgendaItem *, int)));
539 538
540 // event indicator update 539 // event indicator update
541 connect(mAgenda,SIGNAL(lowerYChanged(int)), 540 connect(mAgenda,SIGNAL(lowerYChanged(int)),
542 SLOT(updateEventIndicatorTop(int))); 541 SLOT(updateEventIndicatorTop(int)));
543 connect(mAgenda,SIGNAL(upperYChanged(int)), 542 connect(mAgenda,SIGNAL(upperYChanged(int)),
544 SLOT(updateEventIndicatorBottom(int))); 543 SLOT(updateEventIndicatorBottom(int)));
545 // drag signals 544 // drag signals
546 /* 545 /*
547 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 546 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
548 SLOT(startDrag(Event *))); 547 SLOT(startDrag(Event *)));
549 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
550 SLOT(startDrag(Event *))); 549 SLOT(startDrag(Event *)));
551 */ 550 */
552 // synchronize selections 551 // synchronize selections
553 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
554 mAllDayAgenda, SLOT( deselectItem() ) ); 553 mAllDayAgenda, SLOT( deselectItem() ) );
555 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
556 mAgenda, SLOT( deselectItem() ) ); 555 mAgenda, SLOT( deselectItem() ) );
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 SIGNAL( incidenceSelected( Incidence * ) ) ); 557 SIGNAL( incidenceSelected( Incidence * ) ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 SIGNAL( incidenceSelected( Incidence * ) ) ); 559 SIGNAL( incidenceSelected( Incidence * ) ) );
561 connect( mAgenda, SIGNAL( resizedSignal() ), 560 connect( mAgenda, SIGNAL( resizedSignal() ),
562 SLOT( updateConfig( ) ) ); 561 SLOT( updateConfig( ) ) );
563 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
564 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
565 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
566 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 565 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
567 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
569 568
569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
570 571
571} 572}
572 573
573void KOAgendaView::toggleAllDay() 574void KOAgendaView::toggleAllDay()
574{ 575{
575 if ( mSplitterAgenda->firstHandle() ) 576 if ( mSplitterAgenda->firstHandle() )
576 mSplitterAgenda->firstHandle()->toggle(); 577 mSplitterAgenda->firstHandle()->toggle();
577} 578}
578void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
579{ 580{
580 calendar()->addIncidence( inc ); 581 calendar()->addIncidence( inc );
581 582
582 if ( incOld ) { 583 if ( incOld ) {
583 if ( incOld->type() == "Todo" ) 584 if ( incOld->type() == "Todo" )
584 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
585 else 586 else
586 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
587 } 588 }
588 589
589} 590}
590 591
591KOAgendaView::~KOAgendaView() 592KOAgendaView::~KOAgendaView()
592{ 593{
593 delete mAllAgendaPopup; 594 delete mAllAgendaPopup;
594 //delete mAllDayAgendaPopup; 595 //delete mAllDayAgendaPopup;
595 delete KOAgendaItem::paintPix(); 596 delete KOAgendaItem::paintPix();
596 delete KOAgendaItem::paintPixSel(); 597 delete KOAgendaItem::paintPixSel();
597} 598}
598void KOAgendaView::resizeEvent( QResizeEvent* e ) 599void KOAgendaView::resizeEvent( QResizeEvent* e )
599{ 600{
600 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
601 bool uc = false; 602 bool uc = false;
602 int ow = e->oldSize().width(); 603 int ow = e->oldSize().width();
603 int oh = e->oldSize().height(); 604 int oh = e->oldSize().height();
604 int w = e->size().width(); 605 int w = e->size().width();
605 int h = e->size().height(); 606 int h = e->size().height();
606 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
607 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
608 uc = true; 609 uc = true;
609 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
610 } 611 }
611 mUpcomingWidth = e->size().width() ; 612 mUpcomingWidth = e->size().width() ;
612 if ( mBlockUpdating || uc ) { 613 if ( mBlockUpdating || uc ) {
613 mBlockUpdating = false; 614 mBlockUpdating = false;
614 //mAgenda->setMinimumSize(800 , 600 ); 615 //mAgenda->setMinimumSize(800 , 600 );
615 //qDebug("mAgenda->resize+++++++++++++++ "); 616 //qDebug("mAgenda->resize+++++++++++++++ ");
616 updateConfig(); 617 updateConfig();
617 //qDebug("KOAgendaView::Updating now possible "); 618 //qDebug("KOAgendaView::Updating now possible ");
618 } else 619 } else
619 createDayLabels(); 620 createDayLabels();
620 //qDebug("resizeEvent end "); 621 //qDebug("resizeEvent end ");
621 622
622} 623}
623void KOAgendaView::slotDaylabelClicked( int num ) 624void KOAgendaView::slotDaylabelClicked( int num )
624{ 625{
625 626
626 QDate firstDate = mSelectedDates.first(); 627 QDate firstDate = mSelectedDates.first();
627 if ( num == -1 ) 628 if ( num == -1 )
628 emit showDateView( 6, firstDate ); 629 emit showDateView( 6, firstDate );
629 else if (num >= 0 ) { 630 else if (num >= 0 ) {
630 if ( mSelectedDates.count() == 1) 631 if ( mSelectedDates.count() == 1)
631 emit showDateView( 9, firstDate.addDays( num ) ); 632 emit showDateView( 9, firstDate.addDays( num ) );
632 else 633 else
633 emit showDateView( 3, firstDate.addDays( num ) ); 634 emit showDateView( 3, firstDate.addDays( num ) );
634 } 635 }
635 else 636 else
636 showDateView( 10, firstDate.addDays(1) ); 637 showDateView( 10, firstDate.addDays(1) );
637} 638}
638 639
639KOAgendaButton* KOAgendaView::getNewDaylabel() 640KOAgendaButton* KOAgendaView::getNewDaylabel()
640{ 641{
641 642
642 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
643 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
644 mDayLabelsList.append( dayLabel ); 645 mDayLabelsList.append( dayLabel );
645 mLayoutDayLabels->addWidget(dayLabel); 646 mLayoutDayLabels->addWidget(dayLabel);
646 return dayLabel ; 647 return dayLabel ;
647} 648}
648 649
649void KOAgendaView::createDayLabels() 650void KOAgendaView::createDayLabels()
650{ 651{
651 652
652 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 653 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
653 // qDebug(" KOAgendaView::createDayLabels() blocked "); 654 // qDebug(" KOAgendaView::createDayLabels() blocked ");
654 return; 655 return;
655 656
656 } 657 }
657 int newHight; 658 int newHight;
658 if ( !mSelectedDates.count()) 659 if ( !mSelectedDates.count())
659 return; 660 return;
660 661
661 // ### Before deleting and recreating we could check if mSelectedDates changed... 662 // ### Before deleting and recreating we could check if mSelectedDates changed...
662 // It would remove some flickering and gain speed (since this is called by 663 // It would remove some flickering and gain speed (since this is called by
663 // each updateView() call) 664 // each updateView() call)
664 665
665 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
666 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
667 if ( maxWid < 20 ) 668 if ( maxWid < 20 )
668 maxWid = 20; 669 maxWid = 20;
669 670
670 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
671 QFontMetrics fm ( dlf ); 672 QFontMetrics fm ( dlf );
672 int selCount = mSelectedDates.count(); 673 int selCount = mSelectedDates.count();
673 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 674 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
674 QString dayTest = "Mon 20"; 675 QString dayTest = "Mon 20";
675 //QString dayTest = "Mon 20"; 676 //QString dayTest = "Mon 20";
676 int wid = fm.width( dayTest ); 677 int wid = fm.width( dayTest );
677 //maxWid -= ( selCount * 3 ); //working for QLabels 678 //maxWid -= ( selCount * 3 ); //working for QLabels
678 if ( QApplication::desktop()->width() <= 320 ) 679 if ( QApplication::desktop()->width() <= 320 )
679 maxWid -= ( selCount * 3 ); //working for QPushButton 680 maxWid -= ( selCount * 3 ); //working for QPushButton
680 else 681 else
681 maxWid -= ( selCount * 3 ); //working for QPushButton 682 maxWid -= ( selCount * 3 ); //working for QPushButton
682 if ( maxWid < 0 ) 683 if ( maxWid < 0 )
683 maxWid = 20; 684 maxWid = 20;
684 int needWid = wid * selCount; 685 int needWid = wid * selCount;
685 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
686 //if ( needWid > maxWid ) 687 //if ( needWid > maxWid )
687 // qDebug("DAYLABELS TOOOOOOO BIG "); 688 // qDebug("DAYLABELS TOOOOOOO BIG ");
688 while ( needWid > maxWid ) { 689 while ( needWid > maxWid ) {
689 dayTest = dayTest.left( dayTest.length() - 1 ); 690 dayTest = dayTest.left( dayTest.length() - 1 );
690 wid = fm.width( dayTest ); 691 wid = fm.width( dayTest );
691 needWid = wid * selCount; 692 needWid = wid * selCount;
692 } 693 }
693 int maxLen = dayTest.length(); 694 int maxLen = dayTest.length();
694 int fontPoint = dlf.pointSize(); 695 int fontPoint = dlf.pointSize();
695 if ( maxLen < 2 ) { 696 if ( maxLen < 2 ) {
696 int fontPoint = dlf.pointSize(); 697 int fontPoint = dlf.pointSize();
697 while ( fontPoint > 4 ) { 698 while ( fontPoint > 4 ) {
698 --fontPoint; 699 --fontPoint;
699 dlf.setPointSize( fontPoint ); 700 dlf.setPointSize( fontPoint );
700 QFontMetrics f( dlf ); 701 QFontMetrics f( dlf );
701 wid = f.width( "30" ); 702 wid = f.width( "30" );
702 needWid = wid * selCount; 703 needWid = wid * selCount;
703 if ( needWid < maxWid ) 704 if ( needWid < maxWid )
704 break; 705 break;
705 } 706 }
706 maxLen = 2; 707 maxLen = 2;
707 } 708 }
708 //qDebug("Max len %d ", dayTest.length() ); 709 //qDebug("Max len %d ", dayTest.length() );
709 710
710 QFontMetrics tempF( dlf ); 711 QFontMetrics tempF( dlf );
711 newHight = tempF.height(); 712 newHight = tempF.height();
712 mDayLabels->setFont( dlf ); 713 mDayLabels->setFont( dlf );
713 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
714 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 715 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
715 //mLayoutDayLabels->addSpacing( 2 ); 716 //mLayoutDayLabels->addSpacing( 2 );
716 // QFont lFont = dlf; 717 // QFont lFont = dlf;
717 bool appendLabels = false; 718 bool appendLabels = false;
718 KOAgendaButton *dayLabel; 719 KOAgendaButton *dayLabel;
719 dayLabel = mDayLabelsList.first(); 720 dayLabel = mDayLabelsList.first();
720 if ( !dayLabel ) { 721 if ( !dayLabel ) {
721 appendLabels = true; 722 appendLabels = true;
722 dayLabel = getNewDaylabel(); 723 dayLabel = getNewDaylabel();
723 } 724 }
724 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 725 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
725 dayLabel->setFont( dlf ); 726 dayLabel->setFont( dlf );
726 dayLabel->setNum( -1 ); 727 dayLabel->setNum( -1 );
727 //dayLabel->setAlignment(QLabel::AlignHCenter); 728 //dayLabel->setAlignment(QLabel::AlignHCenter);
728#if 0 729
729 if ( QApplication::desktop()->width() <= 320 ) 730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
731 else
732#endif
733 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
734 dayLabel->show(); 731 dayLabel->show();
735 DateList::ConstIterator dit; 732 DateList::ConstIterator dit;
736 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 733 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
737 int counter = -1; 734 int counter = -1;
738 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 735 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
739 ++counter; 736 ++counter;
740 QDate date = *dit; 737 QDate date = *dit;
741 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 738 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
742 if ( ! appendLabels ) { 739 if ( ! appendLabels ) {
743 dayLabel = mDayLabelsList.next(); 740 dayLabel = mDayLabelsList.next();
744 if ( !dayLabel ) 741 if ( !dayLabel )
745 appendLabels = true; 742 appendLabels = true;
746 } 743 }
747 if ( appendLabels ) { 744 if ( appendLabels ) {
748 dayLabel = getNewDaylabel(); 745 dayLabel = getNewDaylabel();
749 } 746 }
750 dayLabel->setMinimumWidth( 1 ); 747 dayLabel->setMinimumWidth( 1 );
751 dayLabel->setMaximumWidth( 10240 ); 748 dayLabel->setMaximumWidth( 10240 );
752 dayLabel->setFont( dlf ); 749 dayLabel->setFont( dlf );
753 dayLabel->show(); 750 dayLabel->show();
754 dayLabel->setAutoRepeat( false ); 751 dayLabel->setAutoRepeat( false );
755 dayLabel->setNum( counter ); 752 dayLabel->setNum( counter );
756 QString str; 753 QString str;
757 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 754 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
758 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 755 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
759 switch ( maxLen ) { 756 switch ( maxLen ) {
760 case 2: 757 case 2:
761 str = QString::number( date.day() ); 758 str = QString::number( date.day() );
762 break; 759 break;
763 760
764 case 3: 761 case 3:
765 str = dayName.left( 1 ) +QString::number( date.day()); 762 str = dayName.left( 1 ) +QString::number( date.day());
766 763
767 break; 764 break;
768 case 4: 765 case 4:
769 str = dayName.left( 1 ) + " " +QString::number( date.day()); 766 str = dayName.left( 1 ) + " " +QString::number( date.day());
770 767
771 break; 768 break;
772 case 5: 769 case 5:
773 str = dayName.left( 2 ) + " " +QString::number( date.day()); 770 str = dayName.left( 2 ) + " " +QString::number( date.day());
774 771
775 break; 772 break;
776 case 6: 773 case 6:
777 str = dayName.left( 3 ) + " " +QString::number( date.day()); 774 str = dayName.left( 3 ) + " " +QString::number( date.day());
778 break; 775 break;
779 776
780 default: 777 default:
781 break; 778 break;
782 } 779 }
783 if ( oneday ) { 780 if ( oneday ) {
784 QString addString; 781 QString addString;
785 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 782 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
786 addString = i18n("Today"); 783 addString = i18n("Today");
787 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
788 addString = i18n("Tomorrow"); 785 addString = i18n("Tomorrow");
789 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
790 addString = i18n("Yesterday"); 787 addString = i18n("Yesterday");
791 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
792 addString = i18n("Day before yesterday"); 789 addString = i18n("Day before yesterday");
793 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
794 addString = i18n("Day after tomorrow"); 791 addString = i18n("Day after tomorrow");
795 if ( !addString.isEmpty() ) { 792 if ( !addString.isEmpty() ) {
796 str = addString+", " + str; 793 str = addString+", " + str;
797 } else { 794 } else {
798 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 795 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
799 } 796 }
800 } 797 }
801 dayLabel->setText(str); 798 dayLabel->setText(str);
802 //dayLabel->setAlignment(QLabel::AlignHCenter); 799 //dayLabel->setAlignment(QLabel::AlignHCenter);
803 if (date == QDate::currentDate()) { 800 if (date == QDate::currentDate()) {
804 QFont bFont = dlf; 801 QFont bFont = dlf;
805 bFont.setBold( true ); 802 bFont.setBold( true );
806 dayLabel->setFont(bFont); 803 dayLabel->setFont(bFont);
807 } 804 }
808 //dayLayout->addWidget(dayLabel); 805 //dayLayout->addWidget(dayLabel);
809 806
810#ifndef KORG_NOPLUGINS 807#ifndef KORG_NOPLUGINS
811 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
812 CalendarDecoration *it; 809 CalendarDecoration *it;
813 for(it = cds.first(); it; it = cds.next()) { 810 for(it = cds.first(); it; it = cds.next()) {
814 QString text = it->shortText( date ); 811 QString text = it->shortText( date );
815 if ( !text.isEmpty() ) { 812 if ( !text.isEmpty() ) {
816 QLabel *label = new QLabel(text,mDayLabels); 813 QLabel *label = new QLabel(text,mDayLabels);
817 label->setAlignment(AlignCenter); 814 label->setAlignment(AlignCenter);
818 dayLayout->addWidget(label); 815 dayLayout->addWidget(label);
819 } 816 }
820 } 817 }
821 818
822 for(it = cds.first(); it; it = cds.next()) { 819 for(it = cds.first(); it; it = cds.next()) {
823 QWidget *wid = it->smallWidget(mDayLabels,date); 820 QWidget *wid = it->smallWidget(mDayLabels,date);
824 if ( wid ) { 821 if ( wid ) {
825 // wid->setHeight(20); 822 // wid->setHeight(20);
826 dayLayout->addWidget(wid); 823 dayLayout->addWidget(wid);
827 } 824 }
828 } 825 }
829#endif 826#endif
@@ -1086,202 +1083,193 @@ void KOAgendaView::fillAgenda(const QDate &)
1086 // qDebug("KOAgendaView::fillAgenda "); 1083 // qDebug("KOAgendaView::fillAgenda ");
1087 fillAgenda(); 1084 fillAgenda();
1088} 1085}
1089 1086
1090void KOAgendaView::fillAgenda() 1087void KOAgendaView::fillAgenda()
1091{ 1088{
1092 if ( globalFlagBlockStartup ) 1089 if ( globalFlagBlockStartup )
1093 return; 1090 return;
1094 if ( globalFlagBlockAgenda == 1 ) 1091 if ( globalFlagBlockAgenda == 1 )
1095 return; 1092 return;
1096 static bool onlyOne = false; 1093 static bool onlyOne = false;
1097 if ( onlyOne ) 1094 if ( onlyOne )
1098 return; 1095 return;
1099 onlyOne = true; 1096 onlyOne = true;
1100 //if ( globalFlagBlockAgenda == 2 ) 1097 //if ( globalFlagBlockAgenda == 2 )
1101 //globalFlagBlockAgenda = 0; 1098 //globalFlagBlockAgenda = 0;
1102 // globalFlagBlockPainting = false; 1099 // globalFlagBlockPainting = false;
1103 if ( globalFlagBlockAgenda == 0 ) 1100 if ( globalFlagBlockAgenda == 0 )
1104 globalFlagBlockAgenda = 1; 1101 globalFlagBlockAgenda = 1;
1105 // clearView(); 1102 // clearView();
1106 //qDebug("fillAgenda()++++ "); 1103 //qDebug("fillAgenda()++++ ");
1107 globalFlagBlockAgendaItemPaint = 1; 1104 globalFlagBlockAgendaItemPaint = 1;
1108 1105
1109 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1106 mAllDayAgenda->changeColumns(mSelectedDates.count());
1110 mAgenda->changeColumns(mSelectedDates.count()); 1107 mAgenda->changeColumns(mSelectedDates.count());
1111 qApp->processEvents(); 1108 qApp->processEvents();
1112 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1109 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1113 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1110 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1114 setHolidayMasks(); 1111 setHolidayMasks();
1115 1112
1116 //mAgenda->hideUnused(); 1113 //mAgenda->hideUnused();
1117 //mAllDayAgenda->hideUnused(); 1114 //mAllDayAgenda->hideUnused();
1118 1115
1119 // mAgenda->blockNextRepaint( false ); 1116 // mAgenda->blockNextRepaint( false );
1120 // mAgenda->viewport()->repaint(); 1117 // mAgenda->viewport()->repaint();
1121 // mAgenda->blockNextRepaint( true ); 1118 // mAgenda->blockNextRepaint( true );
1122 mMinY.resize(mSelectedDates.count()); 1119 mMinY.resize(mSelectedDates.count());
1123 mMaxY.resize(mSelectedDates.count()); 1120 mMaxY.resize(mSelectedDates.count());
1124 1121
1125 QPtrList<Event> dayEvents; 1122 QPtrList<Event> dayEvents;
1126 1123
1127 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1124 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1128 // Therefore, gtodoset all of them. 1125 // Therefore, gtodoset all of them.
1129 QPtrList<Todo> todos = calendar()->todos(); 1126 QPtrList<Todo> todos = calendar()->todos();
1130 1127
1131 mAgenda->setDateList(mSelectedDates); 1128 mAgenda->setDateList(mSelectedDates);
1132 1129
1133 QDate today = QDate::currentDate(); 1130 QDate today = QDate::currentDate();
1134 1131
1135 DateList::ConstIterator dit; 1132 DateList::ConstIterator dit;
1136 int curCol = 0; 1133 int curCol = 0;
1137 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1134 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1138 QDate currentDate = *dit; 1135 QDate currentDate = *dit;
1139 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1136 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1140 // << endl; 1137 // << endl;
1141 1138
1142 dayEvents = calendar()->events(currentDate,true); 1139 dayEvents = calendar()->events(currentDate,true);
1143 1140
1144 // Default values, which can never be reached 1141 // Default values, which can never be reached
1145 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1142 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1146 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1143 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1147 1144
1148 unsigned int numEvent; 1145 unsigned int numEvent;
1149 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1146 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1150 Event *event = dayEvents.at(numEvent); 1147 Event *event = dayEvents.at(numEvent);
1151 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1148 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1152 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1149 if ( event->uid().left(15) == QString("last-syncEvent-") )
1153 continue; 1150 continue;
1154 // kdDebug() << " Event: " << event->summary() << endl; 1151 // kdDebug() << " Event: " << event->summary() << endl;
1155 1152
1156 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1153 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1157 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1154 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1158 1155
1159 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1156 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1160 1157
1161 if (event->doesFloat()) { 1158 if (event->doesFloat()) {
1162 if (event->recurrence()->doesRecur()) { 1159 if (event->recurrence()->doesRecur()) {
1163 if (event->isMultiDay() ) { 1160 if (event->isMultiDay() ) {
1164 endX = endX - beginX;// endX is now number of days 1161 endX = endX - beginX;// endX is now number of days
1165 if ( event->recursOn( currentDate ) ) { 1162 if ( event->recursOn( currentDate ) ) {
1166 endX += curCol; 1163 endX += curCol;
1167 beginX = curCol; 1164 beginX = curCol;
1168 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1165 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1169 } else { 1166 } else {
1170 qDebug("days %d %s",endX , currentDate.toString().latin1()); 1167 qDebug("days %d %s",endX , currentDate.toString().latin1());
1171 QDate dateit = currentDate.addDays( -endX ); 1168 QDate dateit = currentDate.addDays( -endX );
1172 if ( event->recursOn( dateit ) ) { 1169 if ( event->recursOn( dateit ) ) {
1173 qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1170 qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1174 if ( curCol-endX < 0 ) { 1171 if ( curCol-endX < 0 ) {
1175 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1172 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1176 } 1173 }
1177 } 1174 }
1178 } 1175 }
1179 } else { 1176 } else {
1180 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1177 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1181 } 1178 }
1182#if 0 1179
1183 if (beginX <= 0 && curCol == 0) {
1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1185 } else if (beginX == curCol) {
1186 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1187 } else {
1188 qDebug("skipped %d %d %d ",beginX , endX, curCol);
1189 }
1190#endif
1191 //mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1192 } else { 1180 } else {
1193 if (beginX <= 0 && curCol == 0) { 1181 if (beginX <= 0 && curCol == 0) {
1194 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1182 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1195 } else if (beginX == curCol) { 1183 } else if (beginX == curCol) {
1196 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1197 } 1185 }
1198 } 1186 }
1199 } else if (event->isMultiDay()) { 1187 } else if (event->isMultiDay()) {
1200 if ( event->doesRecur () ) { 1188 if ( event->doesRecur () ) {
1201 QDate dateit = currentDate; 1189 QDate dateit = currentDate;
1202 int count = 0; 1190 int count = 0;
1203 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1191 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1204 while (! event->recursOn( dateit ) && count <= max ) { 1192 while (! event->recursOn( dateit ) && count <= max ) {
1205 ++count; 1193 ++count;
1206 dateit = dateit.addDays( -1 ); 1194 dateit = dateit.addDays( -1 );
1207 } 1195 }
1208 bool ok; 1196 bool ok;
1209 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1197 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1210 if ( ok ) 1198 if ( ok )
1211 { 1199 {
1212 int secs = event->dtStart().secsTo( event->dtEnd() ); 1200 int secs = event->dtStart().secsTo( event->dtEnd() );
1213 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1201 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1214 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1202 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1215 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1203 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1216 1204
1217 } 1205 }
1218 } 1206 }
1219 int startY = mAgenda->timeToY(event->dtStart().time()); 1207 int startY = mAgenda->timeToY(event->dtStart().time());
1220 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1208 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1221 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1209 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1222 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1210 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1223 //qDebug("insert!!! "); 1211 //qDebug("insert!!! ");
1224 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1212 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1225 } 1213 }
1226 if (beginX == curCol) { 1214 if (beginX == curCol) {
1227 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1215 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1228 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1216 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1229 } else if (endX == curCol) { 1217 } else if (endX == curCol) {
1230 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1218 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1231 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1219 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1232 } else { 1220 } else {
1233 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1221 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1234 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1222 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1235 } 1223 }
1236 } else { 1224 } else {
1237 int startY = mAgenda->timeToY(event->dtStart().time()); 1225 int startY = mAgenda->timeToY(event->dtStart().time());
1238 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1226 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1239 if (endY < startY) endY = startY; 1227 if (endY < startY) endY = startY;
1240 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1228 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1241 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1229 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1242 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1243 } 1231 }
1244 } 1232 }
1245 // ---------- [display Todos -------------- 1233 // ---------- [display Todos --------------
1246 unsigned int numTodo; 1234 unsigned int numTodo;
1247 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1235 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1248 Todo *todo = todos.at(numTodo); 1236 Todo *todo = todos.at(numTodo);
1249 1237
1250 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1238 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1251 1239
1252 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1240 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1253 // Already completed items can be displayed on their original due date 1241 // Already completed items can be displayed on their original due date
1254 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1242 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1255 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1243 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1256 bool fillIn = false; 1244 bool fillIn = false;
1257 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1245 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1258 fillIn = true; 1246 fillIn = true;
1259 if ( ! fillIn && !todo->hasCompletedDate() ) 1247 if ( ! fillIn && !todo->hasCompletedDate() )
1260 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1248 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1261 if ( fillIn ) { 1249 if ( fillIn ) {
1262 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1250 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1263 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1251 if ( KOPrefs::instance()->mShowTodoInAgenda )
1264 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1252 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1265 } 1253 }
1266 else { 1254 else {
1267 QDateTime dt; 1255 QDateTime dt;
1268 if ( todo->hasCompletedDate() ) 1256 if ( todo->hasCompletedDate() )
1269 dt = todo->completed(); 1257 dt = todo->completed();
1270 else 1258 else
1271 dt = todo->dtDue();; 1259 dt = todo->dtDue();;
1272 1260
1273 1261
1274 int endY = mAgenda->timeToY(dt.time()) - 1; 1262 int endY = mAgenda->timeToY(dt.time()) - 1;
1275 int hi = (18/KOPrefs::instance()->mHourSize); 1263 int hi = (18/KOPrefs::instance()->mHourSize);
1276 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1264 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1277 int startY = endY -hi; 1265 int startY = endY -hi;
1278 1266
1279 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1267 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1280 1268
1281 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1269 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1282 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1270 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1283 } 1271 }
1284 } 1272 }
1285 } 1273 }
1286 // ---------- display Todos] -------------- 1274 // ---------- display Todos] --------------
1287 1275