author | zautrix <zautrix> | 2005-06-26 12:35:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-26 12:35:09 (UTC) |
commit | d9255cd129d42abf08efc11ff9b29e831e05e803 (patch) (unidiff) | |
tree | 68db283d33a569e71bdc186a36be004ff27c02b4 /korganizer/koagenda.cpp | |
parent | d45f07d85ab62205e07089f6e2f41b0d112ca757 (diff) | |
download | kdepimpi-d9255cd129d42abf08efc11ff9b29e831e05e803.zip kdepimpi-d9255cd129d42abf08efc11ff9b29e831e05e803.tar.gz kdepimpi-d9255cd129d42abf08efc11ff9b29e831e05e803.tar.bz2 |
fixx
-rw-r--r-- | korganizer/koagenda.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index b99625c..faddac4 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -364,203 +364,207 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | |||
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 || mPopupKind == 3 ) { | 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 && mPopupKind == 1 ) | 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 || mPopupKind == 4 ) { | 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 && mPopupKind == 2 ) | 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 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 416 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
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 | blockmoveDist = blockmoveDist*2; | 454 | blockmoveDist = blockmoveDist*2; |
455 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 455 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
456 | } else { | 456 | } else { |
457 | viewportPos = me->pos(); | 457 | viewportPos = me->pos(); |
458 | } | 458 | } |
459 | bool objIsNotViewport = (object != viewport()); | 459 | bool objIsNotViewport = (object != viewport()); |
460 | bool leftButt = false; | ||
461 | #ifdef DESKTOP_VERSION | ||
462 | leftButt = (me->button() == LeftButton); | ||
463 | #endif | ||
460 | switch (me->type()) { | 464 | switch (me->type()) { |
461 | case QEvent::MouseButtonPress: | 465 | case QEvent::MouseButtonPress: |
462 | if (me->button() == LeftButton) { | 466 | if (me->button() == LeftButton) { |
463 | mPopupTimer->start( 600 ); | 467 | mPopupTimer->start( 600 ); |
464 | mLeftMouseDown = true; | 468 | mLeftMouseDown = true; |
465 | } | 469 | } |
466 | blockMoving = true; | 470 | blockMoving = true; |
467 | startX = viewportPos.x(); | 471 | startX = viewportPos.x(); |
468 | startY = viewportPos.y(); | 472 | startY = viewportPos.y(); |
469 | mPopupPos = me->globalPos(); | 473 | mPopupPos = me->globalPos(); |
470 | if ( objIsNotViewport ) { | 474 | if ( objIsNotViewport && !leftButt ) { |
471 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 475 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
472 | if (mAllDayMode) { | 476 | if (mAllDayMode) { |
473 | if ( tempItem->height() > 10 ) { | 477 | if ( tempItem->height() > 10 ) { |
474 | int minV = tempItem->height()/4; | 478 | int minV = tempItem->height()/4; |
475 | if ( minV > (blockmoveDist/2)-2 ) | 479 | if ( minV > (blockmoveDist/2)-2 ) |
476 | minV = (blockmoveDist/2)-2; | 480 | minV = (blockmoveDist/2)-2; |
477 | bool border = false; | 481 | bool border = false; |
478 | int diff = tempItem->y() - viewportPos.y(); | 482 | int diff = tempItem->y() - viewportPos.y(); |
479 | if ( diff < 0 ) | 483 | if ( diff < 0 ) |
480 | diff *= -1; | 484 | diff *= -1; |
481 | if ( diff < minV ) { | 485 | if ( diff < minV ) { |
482 | border = true; | 486 | border = true; |
483 | objIsNotViewport = false; | 487 | objIsNotViewport = false; |
484 | } | 488 | } |
485 | if ( ! border ) { | 489 | if ( ! border ) { |
486 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 490 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
487 | if ( diff < 0 ) | 491 | if ( diff < 0 ) |
488 | diff *= -1; | 492 | diff *= -1; |
489 | if ( diff < minV ) { | 493 | if ( diff < minV ) { |
490 | border = true; | 494 | border = true; |
491 | objIsNotViewport = false; | 495 | objIsNotViewport = false; |
492 | } | 496 | } |
493 | } | 497 | } |
494 | } | 498 | } |
495 | } else { // not allday | 499 | } else { // not allday |
496 | if ( tempItem->width() > 10 ) { | 500 | if ( tempItem->width() > 10 ) { |
497 | int minH = tempItem->width()/4; | 501 | int minH = tempItem->width()/4; |
498 | if ( minH > (blockmoveDist/2)-2 ) | 502 | if ( minH > (blockmoveDist/2)-2 ) |
499 | minH = (blockmoveDist/2)-2; | 503 | minH = (blockmoveDist/2)-2; |
500 | bool border = false; | 504 | bool border = false; |
501 | int diff = tempItem->x() - viewportPos.x(); | 505 | int diff = tempItem->x() - viewportPos.x(); |
502 | if ( diff < 0 ) | 506 | if ( diff < 0 ) |
503 | diff *= -1; | 507 | diff *= -1; |
504 | if ( diff < minH ) { | 508 | if ( diff < minH ) { |
505 | border = true; | 509 | border = true; |
506 | objIsNotViewport = false; | 510 | objIsNotViewport = false; |
507 | } | 511 | } |
508 | if ( ! border ) { | 512 | if ( ! border ) { |
509 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 513 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
510 | if ( diff < 0 ) | 514 | if ( diff < 0 ) |
511 | diff *= -1; | 515 | diff *= -1; |
512 | if ( diff < minH ) { | 516 | if ( diff < minH ) { |
513 | border = true; | 517 | border = true; |
514 | objIsNotViewport = false; | 518 | objIsNotViewport = false; |
515 | } | 519 | } |
516 | } | 520 | } |
517 | } | 521 | } |
518 | } | 522 | } |
519 | } | 523 | } |
520 | if ( objIsNotViewport ) { | 524 | if ( objIsNotViewport ) { |
521 | mPopupItem = (KOAgendaItem *)object; | 525 | mPopupItem = (KOAgendaItem *)object; |
522 | mPopupKind = 1; | 526 | mPopupKind = 1; |
523 | if (me->button() == RightButton) { | 527 | if (me->button() == RightButton) { |
524 | mPopupKind = 3; | 528 | mPopupKind = 3; |
525 | popupMenu(); | 529 | popupMenu(); |
526 | } else if (me->button() == LeftButton) { | 530 | } else if (me->button() == LeftButton) { |
527 | mActionItem = (KOAgendaItem *)object; | 531 | mActionItem = (KOAgendaItem *)object; |
528 | if (mActionItem) { | 532 | if (mActionItem) { |
529 | emit signalClearSelection(); | 533 | emit signalClearSelection(); |
530 | slotClearSelection(); | 534 | slotClearSelection(); |
531 | selectItem(mActionItem); | 535 | selectItem(mActionItem); |
532 | Incidence *incidence = mActionItem->incidence(); | 536 | Incidence *incidence = mActionItem->incidence(); |
533 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 537 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
534 | mActionItem = 0; | 538 | mActionItem = 0; |
535 | } else { | 539 | } else { |
536 | startItemAction(viewportPos); | 540 | startItemAction(viewportPos); |
537 | } | 541 | } |
538 | } | 542 | } |
539 | } | 543 | } |
540 | } else { // ---------- viewport() | 544 | } else { // ---------- viewport() |
541 | mPopupItem = 0; | 545 | mPopupItem = 0; |
542 | mPopupKind = 2; | 546 | mPopupKind = 2; |
543 | selectItem(0); | 547 | selectItem(0); |
544 | mActionItem = 0; | 548 | mActionItem = 0; |
545 | if (me->button() == RightButton) { | 549 | if (me->button() == RightButton) { |
546 | int x,y; | 550 | int x,y; |
547 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 551 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
548 | int gx,gy; | 552 | int gx,gy; |
549 | contentsToGrid(x,y,gx,gy); | 553 | contentsToGrid(x,y,gx,gy); |
550 | mCurrentCellX = gx; | 554 | mCurrentCellX = gx; |
551 | mCurrentCellY = gy; | 555 | mCurrentCellY = gy; |
552 | mStartCellX = gx; | 556 | mStartCellX = gx; |
553 | mStartCellY = gy; | 557 | mStartCellY = gy; |
554 | mPopupKind = 4; | 558 | mPopupKind = 4; |
555 | popupMenu(); | 559 | popupMenu(); |
556 | } else if (me->button() == LeftButton) { | 560 | } else if (me->button() == LeftButton) { |
557 | setCursor(arrowCursor); | 561 | setCursor(arrowCursor); |
558 | startSelectAction(viewportPos); | 562 | startSelectAction(viewportPos); |
559 | } | 563 | } |
560 | } | 564 | } |
561 | break; | 565 | break; |
562 | 566 | ||
563 | case QEvent::MouseButtonRelease: | 567 | case QEvent::MouseButtonRelease: |
564 | if (me->button() == LeftButton ) { | 568 | if (me->button() == LeftButton ) { |
565 | mPopupTimer->stop(); | 569 | mPopupTimer->stop(); |
566 | } | 570 | } |