author | zautrix <zautrix> | 2005-11-30 07:17:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-30 07:17:43 (UTC) |
commit | 14bd7cc7412ffdbca09e1cd63a230222a3fbfd53 (patch) (unidiff) | |
tree | 9255ef94ff9bdf2429f19e68c6ab5273878afdf5 | |
parent | 29c3ed5181b8a33aac73eec90956819b71641048 (diff) | |
download | kdepimpi-14bd7cc7412ffdbca09e1cd63a230222a3fbfd53.zip kdepimpi-14bd7cc7412ffdbca09e1cd63a230222a3fbfd53.tar.gz kdepimpi-14bd7cc7412ffdbca09e1cd63a230222a3fbfd53.tar.bz2 |
agenda fix
-rw-r--r-- | korganizer/koagenda.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index d9d1283..1d4d6de 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -334,1043 +334,1043 @@ void KOAgenda::shrinkPixmap() | |||
334 | } | 334 | } |
335 | void KOAgenda::slotContentMove(int,int) | 335 | void KOAgenda::slotContentMove(int,int) |
336 | { | 336 | { |
337 | emit sendPing(); | 337 | emit sendPing(); |
338 | if ( mActionType == NOP ) | 338 | if ( mActionType == NOP ) |
339 | slotClearSelection(); | 339 | slotClearSelection(); |
340 | if ( mSelectedItem && !mActionItem ) { | 340 | if ( mSelectedItem && !mActionItem ) { |
341 | deselectItem(); | 341 | deselectItem(); |
342 | emit incidenceSelected( 0 ); | 342 | emit incidenceSelected( 0 ); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | void KOAgenda::clear() | 345 | void KOAgenda::clear() |
346 | { | 346 | { |
347 | KOAgendaItem *item; | 347 | KOAgendaItem *item; |
348 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 348 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
349 | mUnusedItems.append( item ); | 349 | mUnusedItems.append( item ); |
350 | //item->hide(); | 350 | //item->hide(); |
351 | } | 351 | } |
352 | mItems.clear(); | 352 | mItems.clear(); |
353 | mSelectedItem = 0; | 353 | mSelectedItem = 0; |
354 | clearSelection(); | 354 | clearSelection(); |
355 | } | 355 | } |
356 | 356 | ||
357 | void KOAgenda::clearSelection() | 357 | void KOAgenda::clearSelection() |
358 | { | 358 | { |
359 | mSelectionCellX = 0; | 359 | mSelectionCellX = 0; |
360 | mSelectionYTop = 0; | 360 | mSelectionYTop = 0; |
361 | mSelectionHeight = 0; | 361 | mSelectionHeight = 0; |
362 | } | 362 | } |
363 | 363 | ||
364 | void KOAgenda::marcus_bains() | 364 | void KOAgenda::marcus_bains() |
365 | { | 365 | { |
366 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 366 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void KOAgenda::changeColumns(int columns) | 370 | void KOAgenda::changeColumns(int columns) |
371 | { | 371 | { |
372 | if (columns == 0) { | 372 | if (columns == 0) { |
373 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 373 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | clear(); | 376 | clear(); |
377 | mColumns = columns; | 377 | mColumns = columns; |
378 | computeSizes(); | 378 | computeSizes(); |
379 | if(mMarcusBains) mMarcusBains->hideMe(); | 379 | if(mMarcusBains) mMarcusBains->hideMe(); |
380 | } | 380 | } |
381 | 381 | ||
382 | /* | 382 | /* |
383 | This is the eventFilter function, which gets all events from the KOAgendaItems | 383 | This is the eventFilter function, which gets all events from the KOAgendaItems |
384 | contained in the agenda. It has to handle moving and resizing for all items. | 384 | contained in the agenda. It has to handle moving and resizing for all items. |
385 | */ | 385 | */ |
386 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 386 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
387 | { | 387 | { |
388 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 388 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
389 | switch(event->type()) { | 389 | switch(event->type()) { |
390 | case QEvent::MouseButtonPress: | 390 | case QEvent::MouseButtonPress: |
391 | case QEvent::MouseButtonDblClick: | 391 | case QEvent::MouseButtonDblClick: |
392 | case QEvent::MouseButtonRelease: | 392 | case QEvent::MouseButtonRelease: |
393 | case QEvent::MouseMove: | 393 | case QEvent::MouseMove: |
394 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 394 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
395 | 395 | ||
396 | case (QEvent::Leave): | 396 | case (QEvent::Leave): |
397 | if (!mActionItem) | 397 | if (!mActionItem) |
398 | setCursor(arrowCursor); | 398 | setCursor(arrowCursor); |
399 | return true; | 399 | return true; |
400 | 400 | ||
401 | default: | 401 | default: |
402 | return QScrollView::eventFilter(object,event); | 402 | return QScrollView::eventFilter(object,event); |
403 | } | 403 | } |
404 | } | 404 | } |
405 | void KOAgenda::popupMenu() | 405 | void KOAgenda::popupMenu() |
406 | { | 406 | { |
407 | mPopupTimer->stop(); | 407 | mPopupTimer->stop(); |
408 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 408 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
409 | if (mActionItem ) { | 409 | if (mActionItem ) { |
410 | endItemAction(); | 410 | endItemAction(); |
411 | } | 411 | } |
412 | mLeftMouseDown = false; // no more leftMouse computation | 412 | mLeftMouseDown = false; // no more leftMouse computation |
413 | if (mPopupItem) { | 413 | if (mPopupItem) { |
414 | //mClickedItem = mPopupItem; | 414 | //mClickedItem = mPopupItem; |
415 | selectItem(mPopupItem); | 415 | selectItem(mPopupItem); |
416 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 416 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
417 | mAllAgendaPopup->installEventFilter( this ); | 417 | mAllAgendaPopup->installEventFilter( this ); |
418 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 418 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
419 | 419 | ||
420 | } | 420 | } |
421 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 421 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
422 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 422 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
423 | endSelectAction( false ); // do not emit new event signal | 423 | endSelectAction( false ); // do not emit new event signal |
424 | mLeftMouseDown = false; // no more leftMouse computation | 424 | mLeftMouseDown = false; // no more leftMouse computation |
425 | } | 425 | } |
426 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 426 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
427 | mNewItemPopup->installEventFilter( this ); | 427 | mNewItemPopup->installEventFilter( this ); |
428 | mNewItemPopup->popup( mPopupPos); | 428 | mNewItemPopup->popup( mPopupPos); |
429 | 429 | ||
430 | } | 430 | } |
431 | mLeftMouseDown = false; | 431 | mLeftMouseDown = false; |
432 | mPopupItem = 0; | 432 | mPopupItem = 0; |
433 | mPopupKind = 0; | 433 | mPopupKind = 0; |
434 | } | 434 | } |
435 | void KOAgenda::categoryChanged(Incidence * inc) | 435 | void KOAgenda::categoryChanged(Incidence * inc) |
436 | { | 436 | { |
437 | KOAgendaItem *item; | 437 | KOAgendaItem *item; |
438 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 438 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
439 | if ( item->incidence() == inc ) { | 439 | if ( item->incidence() == inc ) { |
440 | item->initColor (); | 440 | item->initColor (); |
441 | item->updateItem(); | 441 | item->updateItem(); |
442 | } | 442 | } |
443 | } | 443 | } |
444 | } | 444 | } |
445 | bool KOAgenda::invalidPixmap() | 445 | bool KOAgenda::invalidPixmap() |
446 | { | 446 | { |
447 | return mInvalidPixmap; | 447 | return mInvalidPixmap; |
448 | } | 448 | } |
449 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 449 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
450 | { | 450 | { |
451 | 451 | ||
452 | if ( mInvalidPixmap ) { | 452 | if ( mInvalidPixmap ) { |
453 | mInvalidPixmap = false; | 453 | mInvalidPixmap = false; |
454 | qDebug("KO: efm Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); | 454 | qDebug("KO: efm Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); |
455 | computeSizes(); | 455 | computeSizes(); |
456 | emit updateViewSignal(); | 456 | emit updateViewSignal(); |
457 | return true; | 457 | return true; |
458 | } | 458 | } |
459 | emit sendPing(); | 459 | emit sendPing(); |
460 | static int startX = 0; | 460 | static int startX = 0; |
461 | static int startY = 0; | 461 | static int startY = 0; |
462 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 462 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
463 | static bool blockMoving = true; | 463 | static bool blockMoving = true; |
464 | 464 | ||
465 | //qDebug("KOAgenda::eventFilter_mous "); | 465 | //qDebug("KOAgenda::eventFilter_mous "); |
466 | if ( object == mNewItemPopup ) { | 466 | if ( object == mNewItemPopup ) { |
467 | //qDebug("mNewItemPopup "); | 467 | //qDebug("mNewItemPopup "); |
468 | if ( me->type() == QEvent::MouseButtonRelease ) { | 468 | if ( me->type() == QEvent::MouseButtonRelease ) { |
469 | mNewItemPopup->removeEventFilter( this ); | 469 | mNewItemPopup->removeEventFilter( this ); |
470 | int dX = me->globalPos().x() - mPopupPos.x();; | 470 | int dX = me->globalPos().x() - mPopupPos.x();; |
471 | if ( dX < 0 ) | 471 | if ( dX < 0 ) |
472 | dX = -dX; | 472 | dX = -dX; |
473 | int dY = me->globalPos().y() - mPopupPos.y(); | 473 | int dY = me->globalPos().y() - mPopupPos.y(); |
474 | if ( dY < 0 ) | 474 | if ( dY < 0 ) |
475 | dY = -dY; | 475 | dY = -dY; |
476 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 476 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
477 | mNewItemPopup->hide(); | 477 | mNewItemPopup->hide(); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | return true; | 480 | return true; |
481 | } | 481 | } |
482 | if ( object == mAllAgendaPopup ) { | 482 | if ( object == mAllAgendaPopup ) { |
483 | //qDebug(" mAllAgendaPopup "); | 483 | //qDebug(" mAllAgendaPopup "); |
484 | if ( me->type() == QEvent::MouseButtonRelease ) { | 484 | if ( me->type() == QEvent::MouseButtonRelease ) { |
485 | mAllAgendaPopup->removeEventFilter( this ); | 485 | mAllAgendaPopup->removeEventFilter( this ); |
486 | int dX = me->globalPos().x() - mPopupPos.x();; | 486 | int dX = me->globalPos().x() - mPopupPos.x();; |
487 | if ( dX < 0 ) | 487 | if ( dX < 0 ) |
488 | dX = -dX; | 488 | dX = -dX; |
489 | int dY = me->globalPos().y() - mPopupPos.y(); | 489 | int dY = me->globalPos().y() - mPopupPos.y(); |
490 | if ( dY < 0 ) | 490 | if ( dY < 0 ) |
491 | dY = -dY; | 491 | dY = -dY; |
492 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 492 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
493 | mAllAgendaPopup->hide(); | 493 | mAllAgendaPopup->hide(); |
494 | } | 494 | } |
495 | } | 495 | } |
496 | return true; | 496 | return true; |
497 | } | 497 | } |
498 | QPoint viewportPos; | 498 | QPoint viewportPos; |
499 | if (object != viewport()) { | 499 | if (object != viewport()) { |
500 | blockmoveDist = blockmoveDist*2; | 500 | blockmoveDist = blockmoveDist*2; |
501 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 501 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
502 | } else { | 502 | } else { |
503 | viewportPos = me->pos(); | 503 | viewportPos = me->pos(); |
504 | } | 504 | } |
505 | bool objIsNotViewport = (object != viewport()); | 505 | bool objIsNotViewport = (object != viewport()); |
506 | bool leftButt = false; | 506 | bool leftButt = false; |
507 | #ifdef DESKTOP_VERSION | 507 | #ifdef DESKTOP_VERSION |
508 | leftButt = (me->button() == LeftButton); | 508 | leftButt = (me->button() == LeftButton); |
509 | #endif | 509 | #endif |
510 | switch (me->type()) { | 510 | switch (me->type()) { |
511 | case QEvent::MouseButtonPress: | 511 | case QEvent::MouseButtonPress: |
512 | if (me->button() == LeftButton) { | 512 | if (me->button() == LeftButton) { |
513 | mPopupTimer->start( 600 ); | 513 | mPopupTimer->start( 600 ); |
514 | mLeftMouseDown = true; | 514 | mLeftMouseDown = true; |
515 | } | 515 | } |
516 | blockMoving = true; | 516 | blockMoving = true; |
517 | startX = viewportPos.x(); | 517 | startX = viewportPos.x(); |
518 | startY = viewportPos.y(); | 518 | startY = viewportPos.y(); |
519 | mPopupPos = me->globalPos(); | 519 | mPopupPos = me->globalPos(); |
520 | if ( objIsNotViewport && !leftButt ) { | 520 | if ( objIsNotViewport && !leftButt ) { |
521 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 521 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
522 | if (mAllDayMode) { | 522 | if (mAllDayMode) { |
523 | if ( tempItem->height() > 10 ) { | 523 | if ( tempItem->height() > 10 ) { |
524 | int minV = tempItem->height()/4; | 524 | int minV = tempItem->height()/4; |
525 | if ( minV > (blockmoveDist/2)-2 ) { | 525 | if ( minV > (blockmoveDist/2)-2 ) { |
526 | if ( minV > blockmoveDist ) | 526 | if ( minV > blockmoveDist ) |
527 | minV = blockmoveDist; | 527 | minV = blockmoveDist; |
528 | else | 528 | else |
529 | minV = (blockmoveDist/2); | 529 | minV = (blockmoveDist/2); |
530 | } | 530 | } |
531 | bool border = false; | 531 | bool border = false; |
532 | int diff = tempItem->y() - viewportPos.y(); | 532 | int diff = tempItem->y() - viewportPos.y(); |
533 | if ( diff < 0 ) | 533 | if ( diff < 0 ) |
534 | diff *= -1; | 534 | diff *= -1; |
535 | if ( diff < minV ) { | 535 | if ( diff < minV ) { |
536 | border = true; | 536 | border = true; |
537 | objIsNotViewport = false; | 537 | objIsNotViewport = false; |
538 | } | 538 | } |
539 | if ( ! border ) { | 539 | if ( ! border ) { |
540 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 540 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
541 | if ( diff < 0 ) | 541 | if ( diff < 0 ) |
542 | diff *= -1; | 542 | diff *= -1; |
543 | if ( diff < minV ) { | 543 | if ( diff < minV ) { |
544 | border = true; | 544 | border = true; |
545 | objIsNotViewport = false; | 545 | objIsNotViewport = false; |
546 | } | 546 | } |
547 | } | 547 | } |
548 | } | 548 | } |
549 | } else { // not allday | 549 | } else { // not allday |
550 | if ( tempItem->width() > 10 ) { | 550 | if ( tempItem->width() > 10 ) { |
551 | int minH = tempItem->width()/4; | 551 | int minH = tempItem->width()/4; |
552 | if ( minH > (blockmoveDist/2)-2 ) { | 552 | if ( minH > (blockmoveDist/2)-2 ) { |
553 | if ( minH > blockmoveDist ) | 553 | if ( minH > blockmoveDist ) |
554 | minH = blockmoveDist; | 554 | minH = blockmoveDist; |
555 | else | 555 | else |
556 | minH = (blockmoveDist/2); | 556 | minH = (blockmoveDist/2); |
557 | } | 557 | } |
558 | bool border = false; | 558 | bool border = false; |
559 | int diff = tempItem->x() - viewportPos.x(); | 559 | int diff = tempItem->x() - viewportPos.x(); |
560 | if ( diff < 0 ) | 560 | if ( diff < 0 ) |
561 | diff *= -1; | 561 | diff *= -1; |
562 | if ( diff < minH ) { | 562 | if ( diff < minH ) { |
563 | border = true; | 563 | border = true; |
564 | objIsNotViewport = false; | 564 | objIsNotViewport = false; |
565 | } | 565 | } |
566 | if ( ! border ) { | 566 | if ( ! border ) { |
567 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 567 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
568 | if ( diff < 0 ) | 568 | if ( diff < 0 ) |
569 | diff *= -1; | 569 | diff *= -1; |
570 | if ( diff < minH ) { | 570 | if ( diff < minH ) { |
571 | border = true; | 571 | border = true; |
572 | objIsNotViewport = false; | 572 | objIsNotViewport = false; |
573 | } | 573 | } |
574 | } | 574 | } |
575 | } | 575 | } |
576 | } | 576 | } |
577 | } | 577 | } |
578 | if ( objIsNotViewport ) { | 578 | if ( objIsNotViewport ) { |
579 | mPopupItem = (KOAgendaItem *)object; | 579 | mPopupItem = (KOAgendaItem *)object; |
580 | mPopupKind = 1; | 580 | mPopupKind = 1; |
581 | if (me->button() == RightButton) { | 581 | if (me->button() == RightButton) { |
582 | mPopupKind = 3; | 582 | mPopupKind = 3; |
583 | popupMenu(); | 583 | popupMenu(); |
584 | } else if (me->button() == LeftButton) { | 584 | } else if (me->button() == LeftButton) { |
585 | mActionItem = (KOAgendaItem *)object; | 585 | mActionItem = (KOAgendaItem *)object; |
586 | if (mActionItem) { | 586 | if (mActionItem) { |
587 | emit signalClearSelection(); | 587 | emit signalClearSelection(); |
588 | slotClearSelection(); | 588 | slotClearSelection(); |
589 | selectItem(mActionItem); | 589 | selectItem(mActionItem); |
590 | Incidence *incidence = mActionItem->incidence(); | 590 | Incidence *incidence = mActionItem->incidence(); |
591 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { | 591 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { |
592 | mActionItem = 0; | 592 | mActionItem = 0; |
593 | } else { | 593 | } else { |
594 | startItemAction(viewportPos); | 594 | startItemAction(viewportPos); |
595 | } | 595 | } |
596 | } | 596 | } |
597 | } | 597 | } |
598 | } else { // ---------- viewport() | 598 | } else { // ---------- viewport() |
599 | mPopupItem = 0; | 599 | mPopupItem = 0; |
600 | mPopupKind = 2; | 600 | mPopupKind = 2; |
601 | selectItem(0); | 601 | selectItem(0); |
602 | mActionItem = 0; | 602 | mActionItem = 0; |
603 | if (me->button() == RightButton) { | 603 | if (me->button() == RightButton) { |
604 | int x,y; | 604 | int x,y; |
605 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 605 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
606 | int gx,gy; | 606 | int gx,gy; |
607 | contentsToGrid(x,y,gx,gy); | 607 | contentsToGrid(x,y,gx,gy); |
608 | mCurrentCellX = gx; | 608 | mCurrentCellX = gx; |
609 | mCurrentCellY = gy; | 609 | mCurrentCellY = gy; |
610 | mStartCellX = gx; | 610 | mStartCellX = gx; |
611 | mStartCellY = gy; | 611 | mStartCellY = gy; |
612 | mPopupKind = 4; | 612 | mPopupKind = 4; |
613 | popupMenu(); | 613 | popupMenu(); |
614 | } else if (me->button() == LeftButton) { | 614 | } else if (me->button() == LeftButton) { |
615 | setCursor(arrowCursor); | 615 | setCursor(arrowCursor); |
616 | startSelectAction(viewportPos); | 616 | startSelectAction(viewportPos); |
617 | } | 617 | } |
618 | } | 618 | } |
619 | break; | 619 | break; |
620 | 620 | ||
621 | case QEvent::MouseButtonRelease: | 621 | case QEvent::MouseButtonRelease: |
622 | if (me->button() == LeftButton ) { | 622 | if (me->button() == LeftButton ) { |
623 | mPopupTimer->stop(); | 623 | mPopupTimer->stop(); |
624 | } | 624 | } |
625 | if (object != viewport()) { | 625 | if (object != viewport()) { |
626 | if (me->button() == LeftButton && mLeftMouseDown) { | 626 | if (me->button() == LeftButton && mLeftMouseDown) { |
627 | if (mActionItem) { | 627 | if (mActionItem) { |
628 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 628 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
629 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 629 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
630 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 630 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
631 | mScrollUpTimer.stop(); | 631 | mScrollUpTimer.stop(); |
632 | mScrollDownTimer.stop(); | 632 | mScrollDownTimer.stop(); |
633 | mActionItem->resetMove(); | 633 | mActionItem->resetMove(); |
634 | placeSubCells( mActionItem ); | 634 | placeSubCells( mActionItem ); |
635 | // emit startDragSignal( mActionItem->incidence() ); | 635 | // emit startDragSignal( mActionItem->incidence() ); |
636 | setCursor( arrowCursor ); | 636 | setCursor( arrowCursor ); |
637 | mActionItem = 0; | 637 | mActionItem = 0; |
638 | mActionType = NOP; | 638 | mActionType = NOP; |
639 | mItemMoved = 0; | 639 | mItemMoved = 0; |
640 | mLeftMouseDown = false; | 640 | mLeftMouseDown = false; |
641 | return true; | 641 | return true; |
642 | } | 642 | } |
643 | endItemAction(); | 643 | endItemAction(); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | 646 | ||
647 | } else { // ---------- viewport() | 647 | } else { // ---------- viewport() |
648 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 648 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
649 | endSelectAction( true ); // emit new event signal | 649 | endSelectAction( true ); // emit new event signal |
650 | } | 650 | } |
651 | } | 651 | } |
652 | if (me->button() == LeftButton) | 652 | if (me->button() == LeftButton) |
653 | mLeftMouseDown = false; | 653 | mLeftMouseDown = false; |
654 | 654 | ||
655 | break; | 655 | break; |
656 | 656 | ||
657 | case QEvent::MouseMove: | 657 | case QEvent::MouseMove: |
658 | //qDebug("mm "); | 658 | //qDebug("mm "); |
659 | if ( !mLeftMouseDown ) | 659 | if ( !mLeftMouseDown ) |
660 | return false; | 660 | return false; |
661 | if ( blockMoving ) { | 661 | if ( blockMoving ) { |
662 | int dX, dY; | 662 | int dX, dY; |
663 | dX = startX - viewportPos.x(); | 663 | dX = startX - viewportPos.x(); |
664 | if ( dX < 0 ) | 664 | if ( dX < 0 ) |
665 | dX = -dX; | 665 | dX = -dX; |
666 | dY = viewportPos.y() - startY; | 666 | dY = viewportPos.y() - startY; |
667 | if ( dY < 0 ) | 667 | if ( dY < 0 ) |
668 | dY = -dY; | 668 | dY = -dY; |
669 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 669 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
670 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 670 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
671 | blockMoving = false; | 671 | blockMoving = false; |
672 | } | 672 | } |
673 | } | 673 | } |
674 | if ( ! blockMoving ) | 674 | if ( ! blockMoving ) |
675 | mPopupTimer->stop(); | 675 | mPopupTimer->stop(); |
676 | if (object != viewport()) { | 676 | if (object != viewport()) { |
677 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 677 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
678 | if (!moveItem->incidence()->isReadOnly() ) { | 678 | if (!moveItem->incidence()->isReadOnly() ) { |
679 | if (!mActionItem) | 679 | if (!mActionItem) |
680 | setNoActionCursor(moveItem,viewportPos); | 680 | setNoActionCursor(moveItem,viewportPos); |
681 | else { | 681 | else { |
682 | if ( !blockMoving ) | 682 | if ( !blockMoving ) |
683 | performItemAction(viewportPos); | 683 | performItemAction(viewportPos); |
684 | } | 684 | } |
685 | } | 685 | } |
686 | } else { // ---------- viewport() | 686 | } else { // ---------- viewport() |
687 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 687 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
688 | if ( mActionType == SELECT ) { | 688 | if ( mActionType == SELECT ) { |
689 | performSelectAction( viewportPos ); | 689 | performSelectAction( viewportPos ); |
690 | } | 690 | } |
691 | } | 691 | } |
692 | break; | 692 | break; |
693 | 693 | ||
694 | case QEvent::MouseButtonDblClick: | 694 | case QEvent::MouseButtonDblClick: |
695 | mPopupTimer->stop(); | 695 | mPopupTimer->stop(); |
696 | if (object == viewport()) { | 696 | if (object == viewport()) { |
697 | selectItem(0); | 697 | selectItem(0); |
698 | int x,y; | 698 | int x,y; |
699 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 699 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
700 | int gx,gy; | 700 | int gx,gy; |
701 | contentsToGrid(x,y,gx,gy); | 701 | contentsToGrid(x,y,gx,gy); |
702 | emit newEventSignal(gx,gy); | 702 | emit newEventSignal(gx,gy); |
703 | } else { | 703 | } else { |
704 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 704 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
705 | selectItem(doubleClickedItem); | 705 | selectItem(doubleClickedItem); |
706 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 706 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
707 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 707 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
708 | else | 708 | else |
709 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 709 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
710 | } | 710 | } |
711 | break; | 711 | break; |
712 | 712 | ||
713 | default: | 713 | default: |
714 | break; | 714 | break; |
715 | } | 715 | } |
716 | return true; | 716 | return true; |
717 | 717 | ||
718 | } | 718 | } |
719 | 719 | ||
720 | void KOAgenda::newItem( int item ) | 720 | void KOAgenda::newItem( int item ) |
721 | { | 721 | { |
722 | if ( item == 1 ) { //new event | 722 | if ( item == 1 ) { //new event |
723 | newEventSignal(mStartCellX ,mStartCellY ); | 723 | newEventSignal(mStartCellX ,mStartCellY ); |
724 | } else | 724 | } else |
725 | if ( item == 2 ) { //new event | 725 | if ( item == 2 ) { //new event |
726 | newTodoSignal(mStartCellX ,mStartCellY ); | 726 | newTodoSignal(mStartCellX ,mStartCellY ); |
727 | } else | 727 | } else |
728 | { | 728 | { |
729 | emit showDateView( item, mStartCellX ); | 729 | emit showDateView( item, mStartCellX ); |
730 | // 3Day view | 730 | // 3Day view |
731 | // 4Week view | 731 | // 4Week view |
732 | // 5Month view | 732 | // 5Month view |
733 | // 6Journal view | 733 | // 6Journal view |
734 | } | 734 | } |
735 | } | 735 | } |
736 | void KOAgenda::slotClearSelection() | 736 | void KOAgenda::slotClearSelection() |
737 | { | 737 | { |
738 | if (mSelectionHeight) { | 738 | if (mSelectionHeight) { |
739 | int selectionX = mSelectionCellX * mGridSpacingX; | 739 | int selectionX = mSelectionCellX * mGridSpacingX; |
740 | int top = mSelectionYTop - 2 *mGridSpacingY; | 740 | int top = mSelectionYTop - 2 *mGridSpacingY; |
741 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 741 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
742 | clearSelection(); | 742 | clearSelection(); |
743 | repaintContents( selectionX, top, | 743 | repaintContents( selectionX, top, |
744 | mGridSpacingX, hei ,false ); | 744 | mGridSpacingX, hei ,false ); |
745 | } | 745 | } |
746 | 746 | ||
747 | } | 747 | } |
748 | void KOAgenda::startSelectAction(QPoint viewportPos) | 748 | void KOAgenda::startSelectAction(QPoint viewportPos) |
749 | { | 749 | { |
750 | 750 | ||
751 | emit signalClearSelection(); | 751 | emit signalClearSelection(); |
752 | slotClearSelection(); | 752 | slotClearSelection(); |
753 | 753 | ||
754 | mActionType = SELECT; | 754 | mActionType = SELECT; |
755 | 755 | ||
756 | int x,y; | 756 | int x,y; |
757 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 757 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
758 | int gx,gy; | 758 | int gx,gy; |
759 | contentsToGrid(x,y,gx,gy); | 759 | contentsToGrid(x,y,gx,gy); |
760 | 760 | ||
761 | mStartCellX = gx; | 761 | mStartCellX = gx; |
762 | mStartCellY = gy; | 762 | mStartCellY = gy; |
763 | mCurrentCellX = gx; | 763 | mCurrentCellX = gx; |
764 | mCurrentCellY = gy; | 764 | mCurrentCellY = gy; |
765 | 765 | ||
766 | // Store new selection | 766 | // Store new selection |
767 | mSelectionCellX = gx; | 767 | mSelectionCellX = gx; |
768 | mSelectionYTop = gy * mGridSpacingY; | 768 | mSelectionYTop = gy * mGridSpacingY; |
769 | mSelectionHeight = mGridSpacingY; | 769 | mSelectionHeight = mGridSpacingY; |
770 | 770 | ||
771 | // Paint new selection | 771 | // Paint new selection |
772 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 772 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
773 | mGridSpacingX-1, mSelectionHeight ); | 773 | mGridSpacingX-1, mSelectionHeight ); |
774 | } | 774 | } |
775 | 775 | ||
776 | void KOAgenda::performSelectAction(QPoint viewportPos) | 776 | void KOAgenda::performSelectAction(QPoint viewportPos) |
777 | { | 777 | { |
778 | int x,y; | 778 | int x,y; |
779 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 779 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
780 | int gx,gy; | 780 | int gx,gy; |
781 | contentsToGrid(x,y,gx,gy); | 781 | contentsToGrid(x,y,gx,gy); |
782 | 782 | ||
783 | QPoint clipperPos = clipper()-> | 783 | QPoint clipperPos = clipper()-> |
784 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 784 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
785 | 785 | ||
786 | // Scroll if cursor was moved to upper or lower end of agenda. | 786 | // Scroll if cursor was moved to upper or lower end of agenda. |
787 | if (clipperPos.y() < mScrollBorderWidth) { | 787 | if (clipperPos.y() < mScrollBorderWidth) { |
788 | mScrollUpTimer.start(mScrollDelay); | 788 | mScrollUpTimer.start(mScrollDelay); |
789 | } else if (visibleHeight() - clipperPos.y() < | 789 | } else if (visibleHeight() - clipperPos.y() < |
790 | mScrollBorderWidth) { | 790 | mScrollBorderWidth) { |
791 | mScrollDownTimer.start(mScrollDelay); | 791 | mScrollDownTimer.start(mScrollDelay); |
792 | } else { | 792 | } else { |
793 | mScrollUpTimer.stop(); | 793 | mScrollUpTimer.stop(); |
794 | mScrollDownTimer.stop(); | 794 | mScrollDownTimer.stop(); |
795 | } | 795 | } |
796 | 796 | ||
797 | if ( gy > mCurrentCellY ) { | 797 | if ( gy > mCurrentCellY ) { |
798 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 798 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
799 | 799 | ||
800 | 800 | ||
801 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 801 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
802 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 802 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
803 | mGridSpacingX, mSelectionYTop, | 803 | mGridSpacingX, mSelectionYTop, |
804 | mGridSpacingX, mSelectionHeight , false); | 804 | mGridSpacingX, mSelectionHeight , false); |
805 | 805 | ||
806 | mCurrentCellY = gy; | 806 | mCurrentCellY = gy; |
807 | } else if ( gy < mCurrentCellY ) { | 807 | } else if ( gy < mCurrentCellY ) { |
808 | if ( gy >= mStartCellY ) { | 808 | if ( gy >= mStartCellY ) { |
809 | int selectionHeight = mSelectionHeight; | 809 | int selectionHeight = mSelectionHeight; |
810 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 810 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
811 | 811 | ||
812 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 812 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
813 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 813 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
814 | mGridSpacingX, mSelectionYTop, | 814 | mGridSpacingX, mSelectionYTop, |
815 | mGridSpacingX, selectionHeight,false ); | 815 | mGridSpacingX, selectionHeight,false ); |
816 | 816 | ||
817 | mCurrentCellY = gy; | 817 | mCurrentCellY = gy; |
818 | } else { | 818 | } else { |
819 | } | 819 | } |
820 | } | 820 | } |
821 | } | 821 | } |
822 | 822 | ||
823 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 823 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
824 | { | 824 | { |
825 | mActionType = NOP; | 825 | mActionType = NOP; |
826 | mScrollUpTimer.stop(); | 826 | mScrollUpTimer.stop(); |
827 | mScrollDownTimer.stop(); | 827 | mScrollDownTimer.stop(); |
828 | 828 | ||
829 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 829 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
830 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 830 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
831 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 831 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
832 | } | 832 | } |
833 | } | 833 | } |
834 | 834 | ||
835 | void KOAgenda::startItemAction(QPoint viewportPos) | 835 | void KOAgenda::startItemAction(QPoint viewportPos) |
836 | { | 836 | { |
837 | int x,y; | 837 | int x,y; |
838 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 838 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
839 | int gx,gy; | 839 | int gx,gy; |
840 | contentsToGrid(x,y,gx,gy); | 840 | contentsToGrid(x,y,gx,gy); |
841 | 841 | ||
842 | mStartCellX = gx; | 842 | mStartCellX = gx; |
843 | mStartCellY = gy; | 843 | mStartCellY = gy; |
844 | mCurrentCellX = gx; | 844 | mCurrentCellX = gx; |
845 | mCurrentCellY = gy; | 845 | mCurrentCellY = gy; |
846 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | ||
846 | 847 | ||
847 | if (mAllDayMode) { | 848 | if (mAllDayMode) { |
848 | int gridDistanceX = (x - gx * mGridSpacingX); | 849 | int gridDistanceX = (x - gx * mGridSpacingX); |
849 | if (gridDistanceX < mResizeBorderWidth && | 850 | if ( allowResize && gridDistanceX < mResizeBorderWidth && |
850 | mActionItem->cellX() == mCurrentCellX) { | 851 | mActionItem->cellX() == mCurrentCellX) { |
851 | mActionType = RESIZELEFT; | 852 | mActionType = RESIZELEFT; |
852 | setCursor(sizeHorCursor); | 853 | setCursor(sizeHorCursor); |
853 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 854 | } else if ( allowResize && (mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
854 | mActionItem->cellXWidth() == mCurrentCellX) { | 855 | mActionItem->cellXWidth() == mCurrentCellX) { |
855 | mActionType = RESIZERIGHT; | 856 | mActionType = RESIZERIGHT; |
856 | setCursor(sizeHorCursor); | 857 | setCursor(sizeHorCursor); |
857 | } else { | 858 | } else { |
858 | mActionType = MOVE; | 859 | mActionType = MOVE; |
859 | mActionItem->startMove(); | 860 | mActionItem->startMove(); |
860 | setCursor(sizeAllCursor); | 861 | setCursor(sizeAllCursor); |
861 | } | 862 | } |
862 | } else { | 863 | } else { |
863 | int gridDistanceY = (y - gy * mGridSpacingY); | 864 | int gridDistanceY = (y - gy * mGridSpacingY); |
864 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | ||
865 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 865 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
866 | mActionItem->cellYTop() == mCurrentCellY && | 866 | mActionItem->cellYTop() == mCurrentCellY && |
867 | !mActionItem->firstMultiItem()) { | 867 | !mActionItem->firstMultiItem()) { |
868 | mActionType = RESIZETOP; | 868 | mActionType = RESIZETOP; |
869 | setCursor(sizeVerCursor); | 869 | setCursor(sizeVerCursor); |
870 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 870 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
871 | mActionItem->cellYBottom() == mCurrentCellY && | 871 | mActionItem->cellYBottom() == mCurrentCellY && |
872 | !mActionItem->lastMultiItem()) { | 872 | !mActionItem->lastMultiItem()) { |
873 | mActionType = RESIZEBOTTOM; | 873 | mActionType = RESIZEBOTTOM; |
874 | setCursor(sizeVerCursor); | 874 | setCursor(sizeVerCursor); |
875 | } else { | 875 | } else { |
876 | mActionType = MOVE; | 876 | mActionType = MOVE; |
877 | mActionItem->startMove(); | 877 | mActionItem->startMove(); |
878 | setCursor(sizeAllCursor); | 878 | setCursor(sizeAllCursor); |
879 | } | 879 | } |
880 | } | 880 | } |
881 | } | 881 | } |
882 | 882 | ||
883 | void KOAgenda::performItemAction(QPoint viewportPos) | 883 | void KOAgenda::performItemAction(QPoint viewportPos) |
884 | { | 884 | { |
885 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 885 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
886 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 886 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
887 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 887 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
888 | // point = clipper()->mapFromGlobal(point); | 888 | // point = clipper()->mapFromGlobal(point); |
889 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 889 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
890 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 890 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
891 | int x,y; | 891 | int x,y; |
892 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 892 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
893 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 893 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
894 | int gx,gy; | 894 | int gx,gy; |
895 | contentsToGrid(x,y,gx,gy); | 895 | contentsToGrid(x,y,gx,gy); |
896 | QPoint clipperPos = clipper()-> | 896 | QPoint clipperPos = clipper()-> |
897 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 897 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
898 | 898 | ||
899 | // Cursor left active agenda area. | 899 | // Cursor left active agenda area. |
900 | // This starts a drag. | 900 | // This starts a drag. |
901 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 901 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
902 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 902 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
903 | if ( mActionType == MOVE ) { | 903 | if ( mActionType == MOVE ) { |
904 | mScrollUpTimer.stop(); | 904 | mScrollUpTimer.stop(); |
905 | mScrollDownTimer.stop(); | 905 | mScrollDownTimer.stop(); |
906 | mActionItem->resetMove(); | 906 | mActionItem->resetMove(); |
907 | placeSubCells( mActionItem ); | 907 | placeSubCells( mActionItem ); |
908 | // emit startDragSignal( mActionItem->incidence() ); | 908 | // emit startDragSignal( mActionItem->incidence() ); |
909 | setCursor( arrowCursor ); | 909 | setCursor( arrowCursor ); |
910 | mActionItem = 0; | 910 | mActionItem = 0; |
911 | mActionType = NOP; | 911 | mActionType = NOP; |
912 | mItemMoved = 0; | 912 | mItemMoved = 0; |
913 | return; | 913 | return; |
914 | } | 914 | } |
915 | } else { | 915 | } else { |
916 | switch ( mActionType ) { | 916 | switch ( mActionType ) { |
917 | case MOVE: | 917 | case MOVE: |
918 | setCursor( sizeAllCursor ); | 918 | setCursor( sizeAllCursor ); |
919 | break; | 919 | break; |
920 | case RESIZETOP: | 920 | case RESIZETOP: |
921 | case RESIZEBOTTOM: | 921 | case RESIZEBOTTOM: |
922 | setCursor( sizeVerCursor ); | 922 | setCursor( sizeVerCursor ); |
923 | break; | 923 | break; |
924 | case RESIZELEFT: | 924 | case RESIZELEFT: |
925 | case RESIZERIGHT: | 925 | case RESIZERIGHT: |
926 | setCursor( sizeHorCursor ); | 926 | setCursor( sizeHorCursor ); |
927 | break; | 927 | break; |
928 | default: | 928 | default: |
929 | setCursor( arrowCursor ); | 929 | setCursor( arrowCursor ); |
930 | } | 930 | } |
931 | } | 931 | } |
932 | 932 | ||
933 | // Scroll if item was moved to upper or lower end of agenda. | 933 | // Scroll if item was moved to upper or lower end of agenda. |
934 | if (clipperPos.y() < mScrollBorderWidth) { | 934 | if (clipperPos.y() < mScrollBorderWidth) { |
935 | mScrollUpTimer.start(mScrollDelay); | 935 | mScrollUpTimer.start(mScrollDelay); |
936 | } else if (visibleHeight() - clipperPos.y() < | 936 | } else if (visibleHeight() - clipperPos.y() < |
937 | mScrollBorderWidth) { | 937 | mScrollBorderWidth) { |
938 | mScrollDownTimer.start(mScrollDelay); | 938 | mScrollDownTimer.start(mScrollDelay); |
939 | } else { | 939 | } else { |
940 | mScrollUpTimer.stop(); | 940 | mScrollUpTimer.stop(); |
941 | mScrollDownTimer.stop(); | 941 | mScrollDownTimer.stop(); |
942 | } | 942 | } |
943 | 943 | ||
944 | // Move or resize item if necessary | 944 | // Move or resize item if necessary |
945 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 945 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
946 | mItemMoved = true; | 946 | mItemMoved = true; |
947 | mActionItem->raise(); | 947 | mActionItem->raise(); |
948 | if (mActionType == MOVE) { | 948 | if (mActionType == MOVE) { |
949 | // Move all items belonging to a multi item | 949 | // Move all items belonging to a multi item |
950 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 950 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
951 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 951 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
952 | if (!moveItem) moveItem = mActionItem; | 952 | if (!moveItem) moveItem = mActionItem; |
953 | while (moveItem) { | 953 | while (moveItem) { |
954 | int dy; | 954 | int dy; |
955 | if (isMultiItem) dy = 0; | 955 | if (isMultiItem) dy = 0; |
956 | else dy = gy - mCurrentCellY; | 956 | else dy = gy - mCurrentCellY; |
957 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 957 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
958 | int x,y; | 958 | int x,y; |
959 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 959 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
960 | int diff = moveItem->resizeMe(mGridSpacingX, mGridSpacingX* moveItem->cellWidth(), | 960 | int diff = moveItem->resizeMe(mGridSpacingX, mGridSpacingX* moveItem->cellWidth(), |
961 | mGridSpacingY * moveItem->cellHeight()); | 961 | mGridSpacingY * moveItem->cellHeight()); |
962 | moveItem->raise(); | 962 | moveItem->raise(); |
963 | moveChild(moveItem,x+diff,y); | 963 | moveChild(moveItem,x+diff,y); |
964 | moveItem = moveItem->nextMultiItem(); | 964 | moveItem = moveItem->nextMultiItem(); |
965 | } | 965 | } |
966 | } else if (mActionType == RESIZETOP) { | 966 | } else if (mActionType == RESIZETOP) { |
967 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 967 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
968 | mActionItem->expandTop(gy - mCurrentCellY); | 968 | mActionItem->expandTop(gy - mCurrentCellY); |
969 | mActionItem->resize(mActionItem->width(), | 969 | mActionItem->resize(mActionItem->width(), |
970 | mGridSpacingY * mActionItem->cellHeight()); | 970 | mGridSpacingY * mActionItem->cellHeight()); |
971 | int x,y; | 971 | int x,y; |
972 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 972 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
973 | //moveChild(mActionItem,childX(mActionItem),y); | 973 | //moveChild(mActionItem,childX(mActionItem),y); |
974 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 974 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
975 | } | 975 | } |
976 | } else if (mActionType == RESIZEBOTTOM) { | 976 | } else if (mActionType == RESIZEBOTTOM) { |
977 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 977 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
978 | mActionItem->expandBottom(gy - mCurrentCellY); | 978 | mActionItem->expandBottom(gy - mCurrentCellY); |
979 | mActionItem->resize(mActionItem->width(), | 979 | mActionItem->resize(mActionItem->width(), |
980 | mGridSpacingY * mActionItem->cellHeight()); | 980 | mGridSpacingY * mActionItem->cellHeight()); |
981 | } | 981 | } |
982 | } else if (mActionType == RESIZELEFT) { | 982 | } else if (mActionType == RESIZELEFT) { |
983 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 983 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
984 | mActionItem->expandLeft(gx - mCurrentCellX); | 984 | mActionItem->expandLeft(gx - mCurrentCellX); |
985 | int diff = mActionItem->resizeMe(mGridSpacingX , | 985 | int diff = mActionItem->resizeMe(mGridSpacingX , |
986 | mGridSpacingX * mActionItem->cellWidth(), | 986 | mGridSpacingX * mActionItem->cellWidth(), |
987 | mActionItem->height()); | 987 | mActionItem->height()); |
988 | int x,y; | 988 | int x,y; |
989 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 989 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
990 | moveChild(mActionItem,x+diff,childY(mActionItem)); | 990 | moveChild(mActionItem,x+diff,childY(mActionItem)); |
991 | } | 991 | } |
992 | } else if (mActionType == RESIZERIGHT) { | 992 | } else if (mActionType == RESIZERIGHT) { |
993 | if (mCurrentCellX >= mActionItem->cellX()) { | 993 | if (mCurrentCellX >= mActionItem->cellX()) { |
994 | mActionItem->expandRight(gx - mCurrentCellX); | 994 | mActionItem->expandRight(gx - mCurrentCellX); |
995 | mActionItem->resizeMe(mGridSpacingX, mGridSpacingX * mActionItem->cellWidth(), | 995 | mActionItem->resizeMe(mGridSpacingX, mGridSpacingX * mActionItem->cellWidth(), |
996 | mActionItem->height()); | 996 | mActionItem->height()); |
997 | } | 997 | } |
998 | } | 998 | } |
999 | mCurrentCellX = gx; | 999 | mCurrentCellX = gx; |
1000 | mCurrentCellY = gy; | 1000 | mCurrentCellY = gy; |
1001 | } | 1001 | } |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | void KOAgenda::endItemAction() | 1004 | void KOAgenda::endItemAction() |
1005 | { | 1005 | { |
1006 | 1006 | ||
1007 | if ( mItemMoved ) { | 1007 | if ( mItemMoved ) { |
1008 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 1008 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
1009 | if ( !placeItem ) { | 1009 | if ( !placeItem ) { |
1010 | placeItem = mActionItem; | 1010 | placeItem = mActionItem; |
1011 | } | 1011 | } |
1012 | if ( placeItem->incidence()->doesRecur() ) { | 1012 | if ( placeItem->incidence()->doesRecur() ) { |
1013 | Incidence* oldInc = placeItem->incidence(); | 1013 | Incidence* oldInc = placeItem->incidence(); |
1014 | placeItem->recreateIncidence(); | 1014 | placeItem->recreateIncidence(); |
1015 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1015 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1016 | } | 1016 | } |
1017 | int type = mActionType; | 1017 | int type = mActionType; |
1018 | if ( mAllDayMode ) | 1018 | if ( mAllDayMode ) |
1019 | type = -1; | 1019 | type = -1; |
1020 | KOAgendaItem *modifiedItem = placeItem; | 1020 | KOAgendaItem *modifiedItem = placeItem; |
1021 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1021 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1022 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1022 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1023 | KOAgendaItem *item; | 1023 | KOAgendaItem *item; |
1024 | 1024 | ||
1025 | if ( placeItem->incidence()->typeID() == todoID ) { | 1025 | if ( placeItem->incidence()->typeID() == todoID ) { |
1026 | mSelectedItem = 0; | 1026 | mSelectedItem = 0; |
1027 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1027 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1028 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1028 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1029 | emit itemModified( modifiedItem, mActionType ); | 1029 | emit itemModified( modifiedItem, mActionType ); |
1030 | } | 1030 | } |
1031 | else { | 1031 | else { |
1032 | 1032 | ||
1033 | 1033 | ||
1034 | globalFlagBlockAgendaItemPaint = 1; | 1034 | globalFlagBlockAgendaItemPaint = 1; |
1035 | for ( item=oldconflictItems.first(); item != 0; | 1035 | for ( item=oldconflictItems.first(); item != 0; |
1036 | item=oldconflictItems.next() ) { | 1036 | item=oldconflictItems.next() ) { |
1037 | placeSubCells(item); | 1037 | placeSubCells(item); |
1038 | } | 1038 | } |
1039 | while ( placeItem ) { | 1039 | while ( placeItem ) { |
1040 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1040 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1041 | oldconflictItems = placeItem->conflictItems(); | 1041 | oldconflictItems = placeItem->conflictItems(); |
1042 | for ( item=oldconflictItems.first(); item != 0; | 1042 | for ( item=oldconflictItems.first(); item != 0; |
1043 | item=oldconflictItems.next() ) { | 1043 | item=oldconflictItems.next() ) { |
1044 | placeSubCells(item); | 1044 | placeSubCells(item); |
1045 | } | 1045 | } |
1046 | placeSubCells( placeItem ); | 1046 | placeSubCells( placeItem ); |
1047 | placeItem = placeItem->nextMultiItem(); | 1047 | placeItem = placeItem->nextMultiItem(); |
1048 | } | 1048 | } |
1049 | globalFlagBlockAgendaItemPaint = 0; | 1049 | globalFlagBlockAgendaItemPaint = 0; |
1050 | for ( item=oldconflictItems.first(); item != 0; | 1050 | for ( item=oldconflictItems.first(); item != 0; |
1051 | item=oldconflictItems.next() ) { | 1051 | item=oldconflictItems.next() ) { |
1052 | globalFlagBlockAgendaItemUpdate = 0; | 1052 | globalFlagBlockAgendaItemUpdate = 0; |
1053 | item->repaintMe(); | 1053 | item->repaintMe(); |
1054 | globalFlagBlockAgendaItemUpdate = 1; | 1054 | globalFlagBlockAgendaItemUpdate = 1; |
1055 | item->repaint( false ); | 1055 | item->repaint( false ); |
1056 | } | 1056 | } |
1057 | placeItem = modifiedItem; | 1057 | placeItem = modifiedItem; |
1058 | 1058 | ||
1059 | while ( placeItem ) { | 1059 | while ( placeItem ) { |
1060 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1060 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1061 | globalFlagBlockAgendaItemUpdate = 0; | 1061 | globalFlagBlockAgendaItemUpdate = 0; |
1062 | placeItem->repaintMe(); | 1062 | placeItem->repaintMe(); |
1063 | globalFlagBlockAgendaItemUpdate = 1; | 1063 | globalFlagBlockAgendaItemUpdate = 1; |
1064 | placeItem->repaint(false); | 1064 | placeItem->repaint(false); |
1065 | placeItem = placeItem->nextMultiItem(); | 1065 | placeItem = placeItem->nextMultiItem(); |
1066 | } | 1066 | } |
1067 | emit itemModified( modifiedItem, mActionType ); | 1067 | emit itemModified( modifiedItem, mActionType ); |
1068 | 1068 | ||
1069 | 1069 | ||
1070 | placeItem = modifiedItem; | 1070 | placeItem = modifiedItem; |
1071 | while ( placeItem ) { | 1071 | while ( placeItem ) { |
1072 | oldconflictItems = placeItem->conflictItems(); | 1072 | oldconflictItems = placeItem->conflictItems(); |
1073 | for ( item=oldconflictItems.first(); item != 0; | 1073 | for ( item=oldconflictItems.first(); item != 0; |
1074 | item=oldconflictItems.next() ) { | 1074 | item=oldconflictItems.next() ) { |
1075 | placeSubCells(item); | 1075 | placeSubCells(item); |
1076 | } | 1076 | } |
1077 | placeSubCells( placeItem ); | 1077 | placeSubCells( placeItem ); |
1078 | placeItem = placeItem->nextMultiItem(); | 1078 | placeItem = placeItem->nextMultiItem(); |
1079 | 1079 | ||
1080 | } | 1080 | } |
1081 | placeItem = modifiedItem; | 1081 | placeItem = modifiedItem; |
1082 | while ( placeItem ) { | 1082 | while ( placeItem ) { |
1083 | oldconflictItems = placeItem->conflictItems(); | 1083 | oldconflictItems = placeItem->conflictItems(); |
1084 | for ( item=oldconflictItems.first(); item != 0; | 1084 | for ( item=oldconflictItems.first(); item != 0; |
1085 | item=oldconflictItems.next() ) { | 1085 | item=oldconflictItems.next() ) { |
1086 | globalFlagBlockAgendaItemUpdate = 0; | 1086 | globalFlagBlockAgendaItemUpdate = 0; |
1087 | item->repaintMe(); | 1087 | item->repaintMe(); |
1088 | globalFlagBlockAgendaItemUpdate = 1; | 1088 | globalFlagBlockAgendaItemUpdate = 1; |
1089 | item->repaint(false); | 1089 | item->repaint(false); |
1090 | } | 1090 | } |
1091 | placeItem = placeItem->nextMultiItem(); | 1091 | placeItem = placeItem->nextMultiItem(); |
1092 | } | 1092 | } |
1093 | /* | 1093 | /* |
1094 | 1094 | ||
1095 | oldconflictItems = modifiedItem->conflictItems(); | 1095 | oldconflictItems = modifiedItem->conflictItems(); |
1096 | for ( item=oldconflictItems.first(); item != 0; | 1096 | for ( item=oldconflictItems.first(); item != 0; |
1097 | item=oldconflictItems.next() ) { | 1097 | item=oldconflictItems.next() ) { |
1098 | globalFlagBlockAgendaItemUpdate = 0; | 1098 | globalFlagBlockAgendaItemUpdate = 0; |
1099 | item->paintMe(false); | 1099 | item->paintMe(false); |
1100 | globalFlagBlockAgendaItemUpdate = 1; | 1100 | globalFlagBlockAgendaItemUpdate = 1; |
1101 | item->repaint(false); | 1101 | item->repaint(false); |
1102 | } | 1102 | } |
1103 | */ | 1103 | */ |
1104 | 1104 | ||
1105 | 1105 | ||
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | } | 1108 | } |
1109 | if ( mActionItem ) | 1109 | if ( mActionItem ) |
1110 | emit incidenceSelected( mActionItem->incidence() ); | 1110 | emit incidenceSelected( mActionItem->incidence() ); |
1111 | mScrollUpTimer.stop(); | 1111 | mScrollUpTimer.stop(); |
1112 | mScrollDownTimer.stop(); | 1112 | mScrollDownTimer.stop(); |
1113 | setCursor( arrowCursor ); | 1113 | setCursor( arrowCursor ); |
1114 | mActionItem = 0; | 1114 | mActionItem = 0; |
1115 | mActionType = NOP; | 1115 | mActionType = NOP; |
1116 | mItemMoved = 0; | 1116 | mItemMoved = 0; |
1117 | 1117 | ||
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1120 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1121 | { | 1121 | { |
1122 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1122 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1123 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1123 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1124 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1124 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1125 | // point = clipper()->mapFromGlobal(point); | 1125 | // point = clipper()->mapFromGlobal(point); |
1126 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1126 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1127 | 1127 | ||
1128 | int x,y; | 1128 | int x,y; |
1129 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1129 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1130 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1130 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1131 | int gx,gy; | 1131 | int gx,gy; |
1132 | contentsToGrid(x,y,gx,gy); | 1132 | contentsToGrid(x,y,gx,gy); |
1133 | 1133 | ||
1134 | // Change cursor to resize cursor if appropriate | 1134 | // Change cursor to resize cursor if appropriate |
1135 | if (mAllDayMode) { | 1135 | if (mAllDayMode) { |
1136 | int gridDistanceX = (x - gx * mGridSpacingX); | 1136 | int gridDistanceX = (x - gx * mGridSpacingX); |
1137 | if (gridDistanceX < mResizeBorderWidth && | 1137 | if (gridDistanceX < mResizeBorderWidth && |
1138 | moveItem->cellX() == gx) { | 1138 | moveItem->cellX() == gx) { |
1139 | setCursor(sizeHorCursor); | 1139 | setCursor(sizeHorCursor); |
1140 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1140 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1141 | moveItem->cellXWidth() == gx) { | 1141 | moveItem->cellXWidth() == gx) { |
1142 | setCursor(sizeHorCursor); | 1142 | setCursor(sizeHorCursor); |
1143 | } else { | 1143 | } else { |
1144 | setCursor(arrowCursor); | 1144 | setCursor(arrowCursor); |
1145 | } | 1145 | } |
1146 | } else { | 1146 | } else { |
1147 | int gridDistanceY = (y - gy * mGridSpacingY); | 1147 | int gridDistanceY = (y - gy * mGridSpacingY); |
1148 | if (gridDistanceY < mResizeBorderWidth && | 1148 | if (gridDistanceY < mResizeBorderWidth && |
1149 | moveItem->cellYTop() == gy && | 1149 | moveItem->cellYTop() == gy && |
1150 | !moveItem->firstMultiItem()) { | 1150 | !moveItem->firstMultiItem()) { |
1151 | setCursor(sizeVerCursor); | 1151 | setCursor(sizeVerCursor); |
1152 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1152 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1153 | moveItem->cellYBottom() == gy && | 1153 | moveItem->cellYBottom() == gy && |
1154 | !moveItem->lastMultiItem()) { | 1154 | !moveItem->lastMultiItem()) { |
1155 | setCursor(sizeVerCursor); | 1155 | setCursor(sizeVerCursor); |
1156 | } else { | 1156 | } else { |
1157 | setCursor(arrowCursor); | 1157 | setCursor(arrowCursor); |
1158 | } | 1158 | } |
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | 1162 | ||
1163 | /* | 1163 | /* |
1164 | Place item in cell and take care that multiple items using the same cell do | 1164 | Place item in cell and take care that multiple items using the same cell do |
1165 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1165 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1166 | it can get in all cases. | 1166 | it can get in all cases. |
1167 | At the moment the method has a bug: When an item is placed only the sub cell | 1167 | At the moment the method has a bug: When an item is placed only the sub cell |
1168 | widths of the items are changed, which are within the Y region the item to | 1168 | widths of the items are changed, which are within the Y region the item to |
1169 | place spans. When the sub cell width change of one of this items affects a | 1169 | place spans. When the sub cell width change of one of this items affects a |
1170 | cell, where other items are, which do not overlap in Y with the item to place, | 1170 | cell, where other items are, which do not overlap in Y with the item to place, |
1171 | the display gets corrupted, although the corruption looks quite nice. | 1171 | the display gets corrupted, although the corruption looks quite nice. |
1172 | */ | 1172 | */ |
1173 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1173 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1174 | { | 1174 | { |
1175 | 1175 | ||
1176 | QPtrList<KOAgendaItem> conflictItems; | 1176 | QPtrList<KOAgendaItem> conflictItems; |
1177 | int maxSubCells = 0; | 1177 | int maxSubCells = 0; |
1178 | QIntDict<KOAgendaItem> subCellDict(7); | 1178 | QIntDict<KOAgendaItem> subCellDict(7); |
1179 | 1179 | ||
1180 | KOAgendaItem *item; | 1180 | KOAgendaItem *item; |
1181 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1181 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1182 | if (item != placeItem) { | 1182 | if (item != placeItem) { |
1183 | if (placeItem->cellX() <= item->cellXWidth() && | 1183 | if (placeItem->cellX() <= item->cellXWidth() && |
1184 | placeItem->cellXWidth() >= item->cellX()) { | 1184 | placeItem->cellXWidth() >= item->cellX()) { |
1185 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1185 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1186 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1186 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1187 | conflictItems.append(item); | 1187 | conflictItems.append(item); |
1188 | if (item->subCells() > maxSubCells) | 1188 | if (item->subCells() > maxSubCells) |
1189 | maxSubCells = item->subCells(); | 1189 | maxSubCells = item->subCells(); |
1190 | subCellDict.insert(item->subCell(),item); | 1190 | subCellDict.insert(item->subCell(),item); |
1191 | } | 1191 | } |
1192 | } | 1192 | } |
1193 | } | 1193 | } |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | if (conflictItems.count() > 0) { | 1196 | if (conflictItems.count() > 0) { |
1197 | // Look for unused sub cell and insert item | 1197 | // Look for unused sub cell and insert item |
1198 | int i; | 1198 | int i; |
1199 | for(i=0;i<maxSubCells;++i) { | 1199 | for(i=0;i<maxSubCells;++i) { |
1200 | if (!subCellDict.find(i)) { | 1200 | if (!subCellDict.find(i)) { |
1201 | placeItem->setSubCell(i); | 1201 | placeItem->setSubCell(i); |
1202 | break; | 1202 | break; |
1203 | } | 1203 | } |
1204 | } | 1204 | } |
1205 | if (i == maxSubCells) { | 1205 | if (i == maxSubCells) { |
1206 | placeItem->setSubCell(maxSubCells); | 1206 | placeItem->setSubCell(maxSubCells); |
1207 | maxSubCells++; // add new item to number of sub cells | 1207 | maxSubCells++; // add new item to number of sub cells |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | // Prepare for sub cell geometry adjustment | 1210 | // Prepare for sub cell geometry adjustment |
1211 | int newSubCellWidth; | 1211 | int newSubCellWidth; |
1212 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1212 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1213 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1213 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1214 | conflictItems.append(placeItem); | 1214 | conflictItems.append(placeItem); |
1215 | 1215 | ||
1216 | 1216 | ||
1217 | // Adjust sub cell geometry of all direct conflict items | 1217 | // Adjust sub cell geometry of all direct conflict items |
1218 | for ( item=conflictItems.first(); item != 0; | 1218 | for ( item=conflictItems.first(); item != 0; |
1219 | item=conflictItems.next() ) { | 1219 | item=conflictItems.next() ) { |
1220 | item->setSubCells(maxSubCells); | 1220 | item->setSubCells(maxSubCells); |
1221 | int diff = 0; | 1221 | int diff = 0; |
1222 | if (mAllDayMode) { | 1222 | if (mAllDayMode) { |
1223 | diff = item->resizeMe( mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1223 | diff = item->resizeMe( mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1224 | } else { | 1224 | } else { |
1225 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1225 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1226 | } | 1226 | } |
1227 | int x,y; | 1227 | int x,y; |
1228 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1228 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1229 | if (mAllDayMode) { | 1229 | if (mAllDayMode) { |
1230 | y += item->subCell() * newSubCellWidth; | 1230 | y += item->subCell() * newSubCellWidth; |
1231 | } else { | 1231 | } else { |
1232 | x += item->subCell() * newSubCellWidth; | 1232 | x += item->subCell() * newSubCellWidth; |
1233 | } | 1233 | } |
1234 | moveChild(item,x+diff,y); | 1234 | moveChild(item,x+diff,y); |
1235 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1235 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1236 | //item->updateItem(); | 1236 | //item->updateItem(); |
1237 | } | 1237 | } |
1238 | // Adjust sub cell geometry of all conflict items of all conflict items | 1238 | // Adjust sub cell geometry of all conflict items of all conflict items |
1239 | for ( item=conflictItems.first(); item != 0; | 1239 | for ( item=conflictItems.first(); item != 0; |
1240 | item=conflictItems.next() ) { | 1240 | item=conflictItems.next() ) { |
1241 | if ( placeItem != item ) { | 1241 | if ( placeItem != item ) { |
1242 | KOAgendaItem *item2; | 1242 | KOAgendaItem *item2; |
1243 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1243 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1244 | for ( item2=conflictItems2.first(); item2 != 0; | 1244 | for ( item2=conflictItems2.first(); item2 != 0; |
1245 | item2=conflictItems2.next() ) { | 1245 | item2=conflictItems2.next() ) { |
1246 | if ( item2->subCells() != maxSubCells) { | 1246 | if ( item2->subCells() != maxSubCells) { |
1247 | item2->setSubCells(maxSubCells); | 1247 | item2->setSubCells(maxSubCells); |
1248 | int diff = 0; | 1248 | int diff = 0; |
1249 | if (mAllDayMode) { | 1249 | if (mAllDayMode) { |
1250 | diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1250 | diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1251 | } else { | 1251 | } else { |
1252 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1252 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1253 | } | 1253 | } |
1254 | int x,y; | 1254 | int x,y; |
1255 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1255 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1256 | if (mAllDayMode) { | 1256 | if (mAllDayMode) { |
1257 | y += item2->subCell() * newSubCellWidth; | 1257 | y += item2->subCell() * newSubCellWidth; |
1258 | } else { | 1258 | } else { |
1259 | x += item2->subCell() * newSubCellWidth; | 1259 | x += item2->subCell() * newSubCellWidth; |
1260 | } | 1260 | } |
1261 | moveChild(item2,x+diff,y); | 1261 | moveChild(item2,x+diff,y); |
1262 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1262 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1263 | } | 1263 | } |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | } | 1266 | } |
1267 | } else { | 1267 | } else { |
1268 | placeItem->setSubCell(0); | 1268 | placeItem->setSubCell(0); |
1269 | placeItem->setSubCells(1); | 1269 | placeItem->setSubCells(1); |
1270 | int diff = 0; | 1270 | int diff = 0; |
1271 | if (mAllDayMode) diff = placeItem->resizeMe( mGridSpacingX, placeItem->width(),mGridSpacingY); | 1271 | if (mAllDayMode) diff = placeItem->resizeMe( mGridSpacingX, placeItem->width(),mGridSpacingY); |
1272 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1272 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1273 | int x,y; | 1273 | int x,y; |
1274 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1274 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1275 | moveChild(placeItem,x+diff,y); | 1275 | moveChild(placeItem,x+diff,y); |
1276 | } | 1276 | } |
1277 | placeItem->setConflictItems(conflictItems); | 1277 | placeItem->setConflictItems(conflictItems); |
1278 | // for ( item=conflictItems.first(); item != 0; | 1278 | // for ( item=conflictItems.first(); item != 0; |
1279 | // item=conflictItems.next() ) { | 1279 | // item=conflictItems.next() ) { |
1280 | // //item->updateItem(); | 1280 | // //item->updateItem(); |
1281 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1281 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1282 | // } | 1282 | // } |
1283 | // placeItem->updateItem(); | 1283 | // placeItem->updateItem(); |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1286 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1287 | { | 1287 | { |
1288 | if ( globalFlagBlockAgenda ) | 1288 | if ( globalFlagBlockAgenda ) |
1289 | return; | 1289 | return; |
1290 | 1290 | ||
1291 | if ( mInvalidPixmap ) { | 1291 | if ( mInvalidPixmap ) { |
1292 | mInvalidPixmap = false; | 1292 | mInvalidPixmap = false; |
1293 | qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); | 1293 | qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); |
1294 | computeSizes(); | 1294 | computeSizes(); |
1295 | emit updateViewSignal(); | 1295 | emit updateViewSignal(); |
1296 | return; | 1296 | return; |
1297 | } | 1297 | } |
1298 | //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1()); | 1298 | //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1()); |
1299 | if ( ! mAllDayMode ) { | 1299 | if ( ! mAllDayMode ) { |
1300 | // currently not working for | 1300 | // currently not working for |
1301 | 1301 | ||
1302 | //qDebug("KOAgenda::drawContents "); | 1302 | //qDebug("KOAgenda::drawContents "); |
1303 | #if 0 | 1303 | #if 0 |
1304 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1304 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1305 | qDebug("WAU "); | 1305 | qDebug("WAU "); |
1306 | drawContentsToPainter(); | 1306 | drawContentsToPainter(); |
1307 | } | 1307 | } |
1308 | #endif | 1308 | #endif |
1309 | QPaintDevice* pd = p->device(); | 1309 | QPaintDevice* pd = p->device(); |
1310 | p->end(); | 1310 | p->end(); |
1311 | int vx, vy; | 1311 | int vx, vy; |
1312 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1312 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1313 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1313 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1314 | mSelectionCellX * mGridSpacingX; | 1314 | mSelectionCellX * mGridSpacingX; |
1315 | contentsToViewport ( cx, cy, vx,vy); | 1315 | contentsToViewport ( cx, cy, vx,vy); |
1316 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1316 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1317 | 1317 | ||
1318 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1318 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1319 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1319 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1320 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1320 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1321 | 1321 | ||
1322 | int vxSel, vySel; | 1322 | int vxSel, vySel; |
1323 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1323 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1324 | int off = mSelectionHeight; | 1324 | int off = mSelectionHeight; |
1325 | if ( vySel < 0 ) | 1325 | if ( vySel < 0 ) |
1326 | off += vySel; | 1326 | off += vySel; |
1327 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1327 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1328 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1328 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1329 | } else { | 1329 | } else { |
1330 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1330 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1331 | } | 1331 | } |
1332 | } | 1332 | } |
1333 | if ( mSelectionHeight > 0 ) { | 1333 | if ( mSelectionHeight > 0 ) { |
1334 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1334 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1335 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1335 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1336 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1336 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1337 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1337 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1338 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1338 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1339 | int hei = mSelectionHeight; | 1339 | int hei = mSelectionHeight; |
1340 | int offset = 0; | 1340 | int offset = 0; |
1341 | while ( hei > 0 ) { | 1341 | while ( hei > 0 ) { |
1342 | int p_hei = 5; | 1342 | int p_hei = 5; |
1343 | if ( hei < 5 ) p_hei = hei; | 1343 | if ( hei < 5 ) p_hei = hei; |
1344 | hei -= 5; | 1344 | hei -= 5; |
1345 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1345 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1346 | offset += 5; | 1346 | offset += 5; |
1347 | } | 1347 | } |
1348 | } | 1348 | } |
1349 | } | 1349 | } |
1350 | p->begin( pd ); | 1350 | p->begin( pd ); |
1351 | } else { | 1351 | } else { |
1352 | #if 0 | 1352 | #if 0 |
1353 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1353 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1354 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1354 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1355 | qDebug("WAUWAU "); | 1355 | qDebug("WAUWAU "); |
1356 | drawContentsToPainter(); | 1356 | drawContentsToPainter(); |
1357 | } | 1357 | } |
1358 | #endif | 1358 | #endif |
1359 | QPaintDevice* pd = p->device(); | 1359 | QPaintDevice* pd = p->device(); |
1360 | p->end(); | 1360 | p->end(); |
1361 | int vx, vy; | 1361 | int vx, vy; |
1362 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1362 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1363 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1363 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1364 | mSelectionCellX * mGridSpacingX; | 1364 | mSelectionCellX * mGridSpacingX; |
1365 | contentsToViewport ( cx, cy, vx,vy); | 1365 | contentsToViewport ( cx, cy, vx,vy); |
1366 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1366 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1367 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1367 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1368 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1368 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1369 | 1369 | ||
1370 | if ( mSelectionHeight > 0 ) { | 1370 | if ( mSelectionHeight > 0 ) { |
1371 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1371 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1372 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1372 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1373 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1373 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1374 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1374 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1375 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1375 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1376 | int hei = mSelectionHeight; | 1376 | int hei = mSelectionHeight; |