summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 9720f43..deadfc9 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -417,194 +417,195 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
417 static bool blockMoving = true; 417 static bool blockMoving = true;
418 switch (me->type()) { 418 switch (me->type()) {
419 case QEvent::MouseButtonPress: 419 case QEvent::MouseButtonPress:
420 if (me->button() == LeftButton) { 420 if (me->button() == LeftButton) {
421 mPopupTimer->start( 600 ); 421 mPopupTimer->start( 600 );
422 mLeftMouseDown = true; 422 mLeftMouseDown = true;
423 } 423 }
424 blockMoving = true; 424 blockMoving = true;
425 startX = viewportPos.x(); 425 startX = viewportPos.x();
426 startY = viewportPos.y(); 426 startY = viewportPos.y();
427 if (object != viewport()) { 427 if (object != viewport()) {
428 mPopupItem = (KOAgendaItem *)object; 428 mPopupItem = (KOAgendaItem *)object;
429 mPopupKind = 1; 429 mPopupKind = 1;
430 if (me->button() == RightButton) { 430 if (me->button() == RightButton) {
431 popupMenu(); 431 popupMenu();
432 } else if (me->button() == LeftButton) { 432 } else if (me->button() == LeftButton) {
433 mActionItem = (KOAgendaItem *)object; 433 mActionItem = (KOAgendaItem *)object;
434 if (mActionItem) { 434 if (mActionItem) {
435 if ( mSelectionHeight > 0 ) { 435 if ( mSelectionHeight > 0 ) {
436 int selectionCellX = mSelectionCellX * mGridSpacingX; 436 int selectionCellX = mSelectionCellX * mGridSpacingX;
437 int selectionYTop = mSelectionYTop; 437 int selectionYTop = mSelectionYTop;
438 int gridSpacingX = mGridSpacingX; 438 int gridSpacingX = mGridSpacingX;
439 int selectionHeight = mSelectionHeight; 439 int selectionHeight = mSelectionHeight;
440 clearSelection(); 440 clearSelection();
441 repaintContents( selectionCellX, selectionYTop, 441 repaintContents( selectionCellX, selectionYTop,
442 gridSpacingX, selectionHeight,false ); 442 gridSpacingX, selectionHeight,false );
443 } 443 }
444 selectItem(mActionItem); 444 selectItem(mActionItem);
445 Incidence *incidence = mActionItem->incidence(); 445 Incidence *incidence = mActionItem->incidence();
446 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 446 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
447 mActionItem = 0; 447 mActionItem = 0;
448 } else { 448 } else {
449 startItemAction(viewportPos); 449 startItemAction(viewportPos);
450 } 450 }
451 } 451 }
452 } 452 }
453 } else { // ---------- viewport() 453 } else { // ---------- viewport()
454 mPopupItem = 0; 454 mPopupItem = 0;
455 mPopupKind = 2; 455 mPopupKind = 2;
456 selectItem(0); 456 selectItem(0);
457 mActionItem = 0; 457 mActionItem = 0;
458 mPopupPos = viewport()->mapToGlobal( me->pos() ); 458 mPopupPos = viewport()->mapToGlobal( me->pos() );
459 if (me->button() == RightButton) { 459 if (me->button() == RightButton) {
460 int x,y; 460 int x,y;
461 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 461 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
462 int gx,gy; 462 int gx,gy;
463 contentsToGrid(x,y,gx,gy); 463 contentsToGrid(x,y,gx,gy);
464 mCurrentCellX = gx; 464 mCurrentCellX = gx;
465 mCurrentCellY = gy; 465 mCurrentCellY = gy;
466 mStartCellX = gx; 466 mStartCellX = gx;
467 mStartCellY = gy; 467 mStartCellY = gy;
468 popupMenu(); 468 popupMenu();
469 } else if (me->button() == LeftButton) { 469 } else if (me->button() == LeftButton) {
470 setCursor(arrowCursor); 470 setCursor(arrowCursor);
471 startSelectAction(viewportPos); 471 startSelectAction(viewportPos);
472 } 472 }
473 } 473 }
474 break; 474 break;
475 475
476 case QEvent::MouseButtonRelease: 476 case QEvent::MouseButtonRelease:
477 if (me->button() == LeftButton ) { 477 if (me->button() == LeftButton ) {
478 mPopupTimer->stop(); 478 mPopupTimer->stop();
479 } 479 }
480 if (object != viewport()) { 480 if (object != viewport()) {
481 if (me->button() == LeftButton && mLeftMouseDown) { 481 if (me->button() == LeftButton && mLeftMouseDown) {
482 if (mActionItem) { 482 if (mActionItem) {
483 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 483 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
484 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 484 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
485 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 485 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
486 mScrollUpTimer.stop(); 486 mScrollUpTimer.stop();
487 mScrollDownTimer.stop(); 487 mScrollDownTimer.stop();
488 mActionItem->resetMove(); 488 mActionItem->resetMove();
489 placeSubCells( mActionItem ); 489 placeSubCells( mActionItem );
490 // emit startDragSignal( mActionItem->incidence() ); 490 // emit startDragSignal( mActionItem->incidence() );
491 setCursor( arrowCursor ); 491 setCursor( arrowCursor );
492 mActionItem = 0; 492 mActionItem = 0;
493 mActionType = NOP; 493 mActionType = NOP;
494 mItemMoved = 0; 494 mItemMoved = 0;
495 mLeftMouseDown = false; 495 mLeftMouseDown = false;
496 return true; 496 return true;
497 } 497 }
498 endItemAction(); 498 endItemAction();
499 } 499 }
500 } 500 }
501 501
502 } else { // ---------- viewport() 502 } else { // ---------- viewport()
503 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 503 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
504 endSelectAction( true ); // emit new event signal 504 endSelectAction( true ); // emit new event signal
505 } 505 }
506 } 506 }
507 if (me->button() == LeftButton) 507 if (me->button() == LeftButton)
508 mLeftMouseDown = false; 508 mLeftMouseDown = false;
509 509
510 break; 510 break;
511 511
512 case QEvent::MouseMove: 512 case QEvent::MouseMove:
513 //qDebug("mm ");
513 if ( !mLeftMouseDown ) 514 if ( !mLeftMouseDown )
514 return true; 515 return false;
515 if ( blockMoving ) { 516 if ( blockMoving ) {
516 int dX, dY; 517 int dX, dY;
517 dX = startX - viewportPos.x(); 518 dX = startX - viewportPos.x();
518 if ( dX < 0 ) 519 if ( dX < 0 )
519 dX = -dX; 520 dX = -dX;
520 dY = viewportPos.y() - startY; 521 dY = viewportPos.y() - startY;
521 if ( dY < 0 ) 522 if ( dY < 0 )
522 dY = -dY; 523 dY = -dY;
523 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 524 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
524 if ( dX > blockmoveDist || dY > blockmoveDist ) { 525 if ( dX > blockmoveDist || dY > blockmoveDist ) {
525 blockMoving = false; 526 blockMoving = false;
526 } 527 }
527 } 528 }
528 if ( ! blockMoving ) 529 if ( ! blockMoving )
529 mPopupTimer->stop(); 530 mPopupTimer->stop();
530 if (object != viewport()) { 531 if (object != viewport()) {
531 KOAgendaItem *moveItem = (KOAgendaItem *)object; 532 KOAgendaItem *moveItem = (KOAgendaItem *)object;
532 if (!moveItem->incidence()->isReadOnly() ) { 533 if (!moveItem->incidence()->isReadOnly() ) {
533 if (!mActionItem) 534 if (!mActionItem)
534 setNoActionCursor(moveItem,viewportPos); 535 setNoActionCursor(moveItem,viewportPos);
535 else { 536 else {
536 if ( !blockMoving ) 537 if ( !blockMoving )
537 performItemAction(viewportPos); 538 performItemAction(viewportPos);
538 } 539 }
539 } 540 }
540 } else { // ---------- viewport() 541 } else { // ---------- viewport()
541 mPopupPos = viewport()->mapToGlobal( me->pos() ); 542 mPopupPos = viewport()->mapToGlobal( me->pos() );
542 if ( mActionType == SELECT ) { 543 if ( mActionType == SELECT ) {
543 performSelectAction( viewportPos ); 544 performSelectAction( viewportPos );
544 } 545 }
545 } 546 }
546 break; 547 break;
547 548
548 case QEvent::MouseButtonDblClick: 549 case QEvent::MouseButtonDblClick:
549 mPopupTimer->stop(); 550 mPopupTimer->stop();
550 if (object == viewport()) { 551 if (object == viewport()) {
551 selectItem(0); 552 selectItem(0);
552 int x,y; 553 int x,y;
553 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 554 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
554 int gx,gy; 555 int gx,gy;
555 contentsToGrid(x,y,gx,gy); 556 contentsToGrid(x,y,gx,gy);
556 emit newEventSignal(gx,gy); 557 emit newEventSignal(gx,gy);
557 } else { 558 } else {
558 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 559 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
559 selectItem(doubleClickedItem); 560 selectItem(doubleClickedItem);
560 if ( KOPrefs::instance()->mEditOnDoubleClick ) 561 if ( KOPrefs::instance()->mEditOnDoubleClick )
561 emit editIncidenceSignal(doubleClickedItem->incidence()); 562 emit editIncidenceSignal(doubleClickedItem->incidence());
562 else 563 else
563 emit showIncidenceSignal(doubleClickedItem->incidence()); 564 emit showIncidenceSignal(doubleClickedItem->incidence());
564 } 565 }
565 break; 566 break;
566 567
567 default: 568 default:
568 break; 569 break;
569 } 570 }
570 return true; 571 return true;
571#if 0 572#if 0
572 //qDebug("KOAgenda::eventFilter_mous "); 573 //qDebug("KOAgenda::eventFilter_mous ");
573 QPoint viewportPos; 574 QPoint viewportPos;
574 if (object != viewport()) { 575 if (object != viewport()) {
575 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 576 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
576 } else { 577 } else {
577 viewportPos = me->pos(); 578 viewportPos = me->pos();
578 } 579 }
579 static int startX = 0; 580 static int startX = 0;
580 static int startY = 0; 581 static int startY = 0;
581 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 582 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
582 static bool blockMoving = true; 583 static bool blockMoving = true;
583 static bool leftMouseDown = false; 584 static bool leftMouseDown = false;
584 bool rightButtonPressed = false; 585 bool rightButtonPressed = false;
585 switch (me->type()) { 586 switch (me->type()) {
586 case QEvent::MouseButtonPress: 587 case QEvent::MouseButtonPress:
587 if (me->button() == LeftButton) { 588 if (me->button() == LeftButton) {
588 leftMouseDown = true; 589 leftMouseDown = true;
589 } 590 }
590 else if (me->button() == RightButton) { 591 else if (me->button() == RightButton) {
591 leftMouseDown = false; 592 leftMouseDown = false;
592 } 593 }
593 blockMoving = true; 594 blockMoving = true;
594 startX = viewportPos.x(); 595 startX = viewportPos.x();
595 startY = viewportPos.y(); 596 startY = viewportPos.y();
596 if (object != viewport()) { // item clicked ************** 597 if (object != viewport()) { // item clicked **************
597 if (me->button() == RightButton) { 598 if (me->button() == RightButton) {
598 leftMouseDown = false; 599 leftMouseDown = false;
599 mClickedItem = (KOAgendaItem *)object; 600 mClickedItem = (KOAgendaItem *)object;
600 if (mActionItem ) { 601 if (mActionItem ) {
601 endItemAction(); 602 endItemAction();
602 } 603 }
603 if (mClickedItem) { 604 if (mClickedItem) {
604 selectItem(mClickedItem); 605 selectItem(mClickedItem);
605 emit showIncidencePopupSignal(mClickedItem->incidence()); 606 emit showIncidencePopupSignal(mClickedItem->incidence());
606 } 607 }
607 return true; 608 return true;
608 } else if (me->button() == LeftButton) { 609 } else if (me->button() == LeftButton) {
609 mActionItem = (KOAgendaItem *)object; 610 mActionItem = (KOAgendaItem *)object;
610 if (mActionItem) { 611 if (mActionItem) {