author | zautrix <zautrix> | 2005-05-24 19:56:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-05-24 19:56:05 (UTC) |
commit | bebdc6ca63f4bcbfb735c3d75710ca53959ef48f (patch) (unidiff) | |
tree | ed755ca04104d571799e91a31443fe94bbf00fdd | |
parent | b441ef64338079e3e29c07d8884a02588050a54a (diff) | |
download | kdepimpi-bebdc6ca63f4bcbfb735c3d75710ca53959ef48f.zip kdepimpi-bebdc6ca63f4bcbfb735c3d75710ca53959ef48f.tar.gz kdepimpi-bebdc6ca63f4bcbfb735c3d75710ca53959ef48f.tar.bz2 |
menu fix
-rw-r--r-- | korganizer/koagenda.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 355f4bb..99009a5 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -360,67 +360,67 @@ void KOAgenda::changeColumns(int columns) | |||
360 | contained in the agenda. It has to handle moving and resizing for all items. | 360 | contained in the agenda. It has to handle moving and resizing for all items. |
361 | */ | 361 | */ |
362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
363 | { | 363 | { |
364 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 364 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
365 | switch(event->type()) { | 365 | switch(event->type()) { |
366 | case QEvent::MouseButtonPress: | 366 | case QEvent::MouseButtonPress: |
367 | case QEvent::MouseButtonDblClick: | 367 | case QEvent::MouseButtonDblClick: |
368 | case QEvent::MouseButtonRelease: | 368 | case QEvent::MouseButtonRelease: |
369 | case QEvent::MouseMove: | 369 | case QEvent::MouseMove: |
370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
371 | 371 | ||
372 | case (QEvent::Leave): | 372 | case (QEvent::Leave): |
373 | if (!mActionItem) | 373 | if (!mActionItem) |
374 | setCursor(arrowCursor); | 374 | setCursor(arrowCursor); |
375 | return true; | 375 | return true; |
376 | 376 | ||
377 | default: | 377 | default: |
378 | return QScrollView::eventFilter(object,event); | 378 | return QScrollView::eventFilter(object,event); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | void KOAgenda::popupMenu() | 381 | void KOAgenda::popupMenu() |
382 | { | 382 | { |
383 | mPopupTimer->stop(); | 383 | mPopupTimer->stop(); |
384 | if ( mPopupKind == 1 ) { | 384 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
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 && mPopupKind == 1 ) |
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 || mPopupKind == 4 ) { |
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 && mPopupKind == 2 ) |
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 | ||
412 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 412 | bool 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; |
@@ -449,77 +449,79 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | |||
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 | mPopupKind = 3; | ||
473 | popupMenu(); | 474 | popupMenu(); |
474 | } else if (me->button() == LeftButton) { | 475 | } else if (me->button() == LeftButton) { |
475 | mActionItem = (KOAgendaItem *)object; | 476 | mActionItem = (KOAgendaItem *)object; |
476 | if (mActionItem) { | 477 | if (mActionItem) { |
477 | emit signalClearSelection(); | 478 | emit signalClearSelection(); |
478 | slotClearSelection(); | 479 | slotClearSelection(); |
479 | selectItem(mActionItem); | 480 | selectItem(mActionItem); |
480 | Incidence *incidence = mActionItem->incidence(); | 481 | Incidence *incidence = mActionItem->incidence(); |
481 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 482 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
482 | mActionItem = 0; | 483 | mActionItem = 0; |
483 | } else { | 484 | } else { |
484 | startItemAction(viewportPos); | 485 | startItemAction(viewportPos); |
485 | } | 486 | } |
486 | } | 487 | } |
487 | } | 488 | } |
488 | } else { // ---------- viewport() | 489 | } else { // ---------- viewport() |
489 | mPopupItem = 0; | 490 | mPopupItem = 0; |
490 | mPopupKind = 2; | 491 | mPopupKind = 2; |
491 | selectItem(0); | 492 | selectItem(0); |
492 | mActionItem = 0; | 493 | mActionItem = 0; |
493 | if (me->button() == RightButton) { | 494 | if (me->button() == RightButton) { |
494 | int x,y; | 495 | int x,y; |
495 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 496 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
496 | int gx,gy; | 497 | int gx,gy; |
497 | contentsToGrid(x,y,gx,gy); | 498 | contentsToGrid(x,y,gx,gy); |
498 | mCurrentCellX = gx; | 499 | mCurrentCellX = gx; |
499 | mCurrentCellY = gy; | 500 | mCurrentCellY = gy; |
500 | mStartCellX = gx; | 501 | mStartCellX = gx; |
501 | mStartCellY = gy; | 502 | mStartCellY = gy; |
503 | mPopupKind = 4; | ||
502 | popupMenu(); | 504 | popupMenu(); |
503 | } else if (me->button() == LeftButton) { | 505 | } else if (me->button() == LeftButton) { |
504 | setCursor(arrowCursor); | 506 | setCursor(arrowCursor); |
505 | startSelectAction(viewportPos); | 507 | startSelectAction(viewportPos); |
506 | } | 508 | } |
507 | } | 509 | } |
508 | break; | 510 | break; |
509 | 511 | ||
510 | case QEvent::MouseButtonRelease: | 512 | case QEvent::MouseButtonRelease: |
511 | if (me->button() == LeftButton ) { | 513 | if (me->button() == LeftButton ) { |
512 | mPopupTimer->stop(); | 514 | mPopupTimer->stop(); |
513 | } | 515 | } |
514 | if (object != viewport()) { | 516 | if (object != viewport()) { |
515 | if (me->button() == LeftButton && mLeftMouseDown) { | 517 | if (me->button() == LeftButton && mLeftMouseDown) { |
516 | if (mActionItem) { | 518 | if (mActionItem) { |
517 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 519 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
518 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 520 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
519 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 521 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
520 | mScrollUpTimer.stop(); | 522 | mScrollUpTimer.stop(); |
521 | mScrollDownTimer.stop(); | 523 | mScrollDownTimer.stop(); |
522 | mActionItem->resetMove(); | 524 | mActionItem->resetMove(); |
523 | placeSubCells( mActionItem ); | 525 | placeSubCells( mActionItem ); |
524 | // emit startDragSignal( mActionItem->incidence() ); | 526 | // emit startDragSignal( mActionItem->incidence() ); |
525 | setCursor( arrowCursor ); | 527 | setCursor( arrowCursor ); |