summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp179
-rw-r--r--korganizer/koagenda.h1
2 files changed, 86 insertions, 94 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ec81d44..e8b7c94 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -397,7 +397,15 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
397 static int startY = 0; 397 static int startY = 0;
398 static bool block = true; 398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
399 static bool blockMoving = true;
400 static bool leftMouseDown = false;
401 static bool rightMouseDown = false;
399 switch (me->type()) { 402 switch (me->type()) {
400 case QEvent::MouseButtonPress: 403 case QEvent::MouseButtonPress:
401 //qDebug("QEvent::MouseButtonPress: "); 404 if (me->button() == LeftButton)
402 // kdDebug() << "koagenda: filtered button press" << endl; 405 leftMouseDown = true;
406 else if (me->button() == RightButton)
407 rightMouseDown = true;
408 blockMoving = true;
409 startX = viewportPos.x();
410 startY = viewportPos.y();
403 if (object != viewport()) { 411 if (object != viewport()) {
@@ -407,6 +415,4 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
407 selectItem(mClickedItem); 415 selectItem(mClickedItem);
408 // emit showIncidencePopupSignal(mClickedItem->incidence());
409 } 416 }
410 //mItemPopup->popup(QCursor::pos()); 417 } else if (me->button() == LeftButton) {
411 } else {
412 mActionItem = (KOAgendaItem *)object; 418 mActionItem = (KOAgendaItem *)object;
@@ -428,5 +434,2 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
428 startItemAction(viewportPos); 434 startItemAction(viewportPos);
429 startX = viewportPos.x();
430 startY = viewportPos.y();
431 block = true;
432 } 435 }
@@ -434,10 +437,6 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
434 } 437 }
435 } else { 438 } else { // ---------- viewport()
436 selectItem(0); 439 selectItem(0);
437 mActionItem = 0; 440 mActionItem = 0;
438 if (me->button() == RightButton ) { 441 if (me->button() == LeftButton ) {
439 blockNewEvent = true;
440 block = false;
441 } else {
442 blockNewEvent = false;
443 setCursor(arrowCursor); 442 setCursor(arrowCursor);
@@ -449,11 +448,46 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
449 case QEvent::MouseButtonRelease: 448 case QEvent::MouseButtonRelease:
450 //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); 449 if (object != viewport()) {
451 if (me->button() == RightButton && blockNewEvent && !block) { 450 if (me->button() == RightButton) {
452 int x,y; 451 if ( blockMoving ) {
453 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 452 mClickedItem = (KOAgendaItem *)object;
454 int gx,gy; 453 if (mActionItem ) {
455 contentsToGrid(x,y,gx,gy); 454 endItemAction();
456 if ( object == viewport() ) { 455 }
457 if ( mCurrentCellY < mStartCellY +1 ) { 456 leftMouseDown = false; // no more leftMouse computation
458 //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); 457 if (mClickedItem) {
458 selectItem(mClickedItem);
459 emit showIncidencePopupSignal(mClickedItem->incidence());
460 }
461 }
462 } else if (me->button() == LeftButton && leftMouseDown) {
463 if (mActionItem) {
464 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
465 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
466 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
467 mScrollUpTimer.stop();
468 mScrollDownTimer.stop();
469 mActionItem->resetMove();
470 placeSubCells( mActionItem );
471 // emit startDragSignal( mActionItem->incidence() );
472 setCursor( arrowCursor );
473 mActionItem = 0;
474 mActionType = NOP;
475 mItemMoved = 0;
476 return true;
477 }
478 endItemAction();
479 }
480 }
481
482 } else { // ---------- viewport()
483 if (me->button() == RightButton) { //right click
484 if ( blockMoving ) { // we did mot moved the mouse much - popup menu
485 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
486 endSelectAction( false ); // do not emit new event signal
487 leftMouseDown = false; // no more leftMouse computation
488 }
489 int x,y;
490 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
491 int gx,gy;
492 contentsToGrid(x,y,gx,gy);
459 mCurrentCellX = gx; 493 mCurrentCellX = gx;
@@ -463,52 +497,12 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
463 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 497 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
464 break;
465 } else {
466 blockNewEvent = false;
467 } 498 }
468 } else {
469 mClickedItem = (KOAgendaItem *)object;
470 if (mActionItem ) {
471 endItemAction();
472 }
473 if (mClickedItem) {
474 selectItem(mClickedItem);
475 emit showIncidencePopupSignal(mClickedItem->incidence());
476 }
477 }
478 } else if (me->button() == RightButton && block ) {
479 if (object != viewport()) {
480 mClickedItem = (KOAgendaItem *)object;
481 if (mActionItem ) {
482 endItemAction();
483 }
484 if (mClickedItem) {
485 selectItem(mClickedItem);
486 emit showIncidencePopupSignal(mClickedItem->incidence());
487 }
488 }
489 break;
490 }
491 block = true;
492 if (mActionItem) {
493 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
494 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
495 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
496 mScrollUpTimer.stop();
497 mScrollDownTimer.stop();
498 mActionItem->resetMove();
499 placeSubCells( mActionItem );
500 // emit startDragSignal( mActionItem->incidence() );
501 setCursor( arrowCursor );
502 mActionItem = 0;
503 mActionType = NOP;
504 mItemMoved = 0;
505 return true;
506 } 499 }
507 endItemAction(); 500 else if (me->button() == LeftButton && leftMouseDown ) { //left click
508 } else if ( mActionType == SELECT ) { 501 endSelectAction( true ); // emit new event signal
509 if (me->button() == RightButton ) {
510 } else {
511 endSelectAction( !blockNewEvent );
512 } 502 }
513 } 503 }
504 if (me->button() == LeftButton)
505 leftMouseDown = false;
506 else if (me->button() == RightButton)
507 rightMouseDown = false;
514 break; 508 break;
@@ -516,7 +510,20 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
516 case QEvent::MouseMove: 510 case QEvent::MouseMove:
511 if ( !rightMouseDown && !leftMouseDown )
512 return true;
513 if ( blockMoving ) {
514 int dX, dY;
515 dX = startX - viewportPos.x();
516 if ( dX < 0 )
517 dX = -dX;
518 dY = viewportPos.y() - startY;
519 if ( dY < 0 )
520 dY = -dY;
521 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
522 if ( dX > blockmoveDist || dY > blockmoveDist ) {
523 blockMoving = false;
524 }
525 }
517 if (object != viewport()) { 526 if (object != viewport()) {
518 KOAgendaItem *moveItem = (KOAgendaItem *)object; 527 KOAgendaItem *moveItem = (KOAgendaItem *)object;
519 //qDebug("moveItem %d ",moveItem ); 528 if (!moveItem->incidence()->isReadOnly() ) {
520 if (!moveItem->incidence()->isReadOnly() /*&&
521 !moveItem->incidence()->recurrence()->doesRecur()*/ )
522 if (!mActionItem) 529 if (!mActionItem)
@@ -524,22 +531,7 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
524 else { 531 else {
525 if ( block ) { 532 if ( !blockMoving )
526 int dX, dY;
527 dX = startX - viewportPos.x();
528 if ( dX < 0 )
529 dX = -dX;
530 dY = viewportPos.y() - startY;
531 if ( dY < 0 )
532 dY = -dY;
533 int diff = 30;
534 if ( QApplication::desktop()->width() < 480 )
535 diff = 15;
536 // qDebug(" %d %d ",dX, dY );
537 if ( dX > diff || dY > diff ) {
538 block = false;
539 }
540 }
541 if ( !block )
542 performItemAction(viewportPos); 533 performItemAction(viewportPos);
543 } 534 }
544 } else { 535 }
536 } else { // ---------- viewport()
545 if ( mActionType == SELECT ) { 537 if ( mActionType == SELECT ) {
@@ -571,3 +563,2 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
571 } 563 }
572
573 return true; 564 return true;
@@ -688,4 +679,6 @@ void KOAgenda::endSelectAction( bool emitNewEvent )
688 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 679 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
689 if ( emitNewEvent && mStartCellY < mCurrentCellY ) 680 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
681 qDebug("ew event signal ");
690 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 682 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
683 }
691} 684}
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 2069b22..f3f1772 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -212,3 +212,2 @@ class KOAgenda : public QScrollView
212 private: 212 private:
213 bool blockNewEvent;
214 void init(); 213 void init();