author | zautrix <zautrix> | 2005-06-28 11:19:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-28 11:19:58 (UTC) |
commit | 5861dc779cce151b7a05f3295ca11ffbf39e5a20 (patch) (unidiff) | |
tree | f9d2a06cd171f4269e7597fbc44afb76b8ff76b1 | |
parent | c26c9e0aa8c8a3b1d3e8dba018d56dbdb67c65b4 (diff) | |
download | kdepimpi-5861dc779cce151b7a05f3295ca11ffbf39e5a20.zip kdepimpi-5861dc779cce151b7a05f3295ca11ffbf39e5a20.tar.gz kdepimpi-5861dc779cce151b7a05f3295ca11ffbf39e5a20.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagenda.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index faddac4..ce73168 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -287,409 +287,417 @@ void KOAgenda::init() | |||
287 | 287 | ||
288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
289 | 289 | ||
290 | viewport()->update(); | 290 | viewport()->update(); |
291 | 291 | ||
292 | setMinimumSize(30, 1); | 292 | setMinimumSize(30, 1); |
293 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 293 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
294 | 294 | ||
295 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 295 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
296 | // controlled in a way that the contents horizontally always fits. Then it is | 296 | // controlled in a way that the contents horizontally always fits. Then it is |
297 | // not necessary to turn off the scrollbar. | 297 | // not necessary to turn off the scrollbar. |
298 | setHScrollBarMode(AlwaysOff); | 298 | setHScrollBarMode(AlwaysOff); |
299 | if ( ! mAllDayMode ) | 299 | if ( ! mAllDayMode ) |
300 | setVScrollBarMode(AlwaysOn); | 300 | setVScrollBarMode(AlwaysOn); |
301 | else | 301 | else |
302 | setVScrollBarMode(AlwaysOff); | 302 | setVScrollBarMode(AlwaysOff); |
303 | 303 | ||
304 | setStartHour(KOPrefs::instance()->mDayBegins); | 304 | setStartHour(KOPrefs::instance()->mDayBegins); |
305 | 305 | ||
306 | calculateWorkingHours(); | 306 | calculateWorkingHours(); |
307 | 307 | ||
308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
309 | SLOT(checkScrollBoundaries(int))); | 309 | SLOT(checkScrollBoundaries(int))); |
310 | 310 | ||
311 | // Create the Marcus Bains line. | 311 | // Create the Marcus Bains line. |
312 | if(mAllDayMode) | 312 | if(mAllDayMode) |
313 | mMarcusBains = 0; | 313 | mMarcusBains = 0; |
314 | else { | 314 | else { |
315 | mMarcusBains = new MarcusBains(this); | 315 | mMarcusBains = new MarcusBains(this); |
316 | addChild(mMarcusBains); | 316 | addChild(mMarcusBains); |
317 | } | 317 | } |
318 | mPopupKind = 0; | 318 | mPopupKind = 0; |
319 | mPopupItem = 0; | 319 | mPopupItem = 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | void KOAgenda::clear() | 322 | void KOAgenda::clear() |
323 | { | 323 | { |
324 | KOAgendaItem *item; | 324 | KOAgendaItem *item; |
325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
326 | mUnusedItems.append( item ); | 326 | mUnusedItems.append( item ); |
327 | //item->hide(); | 327 | //item->hide(); |
328 | } | 328 | } |
329 | mItems.clear(); | 329 | mItems.clear(); |
330 | mSelectedItem = 0; | 330 | mSelectedItem = 0; |
331 | clearSelection(); | 331 | clearSelection(); |
332 | } | 332 | } |
333 | 333 | ||
334 | void KOAgenda::clearSelection() | 334 | void KOAgenda::clearSelection() |
335 | { | 335 | { |
336 | mSelectionCellX = 0; | 336 | mSelectionCellX = 0; |
337 | mSelectionYTop = 0; | 337 | mSelectionYTop = 0; |
338 | mSelectionHeight = 0; | 338 | mSelectionHeight = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | void KOAgenda::marcus_bains() | 341 | void KOAgenda::marcus_bains() |
342 | { | 342 | { |
343 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 343 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | void KOAgenda::changeColumns(int columns) | 347 | void KOAgenda::changeColumns(int columns) |
348 | { | 348 | { |
349 | if (columns == 0) { | 349 | if (columns == 0) { |
350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | clear(); | 353 | clear(); |
354 | mColumns = columns; | 354 | mColumns = columns; |
355 | computeSizes(); | 355 | computeSizes(); |
356 | } | 356 | } |
357 | 357 | ||
358 | /* | 358 | /* |
359 | This is the eventFilter function, which gets all events from the KOAgendaItems | 359 | This is the eventFilter function, which gets all events from the KOAgendaItems |
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 || 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; | 460 | bool leftButt = false; |
461 | #ifdef DESKTOP_VERSION | 461 | #ifdef DESKTOP_VERSION |
462 | leftButt = (me->button() == LeftButton); | 462 | leftButt = (me->button() == LeftButton); |
463 | #endif | 463 | #endif |
464 | switch (me->type()) { | 464 | switch (me->type()) { |
465 | case QEvent::MouseButtonPress: | 465 | case QEvent::MouseButtonPress: |
466 | if (me->button() == LeftButton) { | 466 | if (me->button() == LeftButton) { |
467 | mPopupTimer->start( 600 ); | 467 | mPopupTimer->start( 600 ); |
468 | mLeftMouseDown = true; | 468 | mLeftMouseDown = true; |
469 | } | 469 | } |
470 | blockMoving = true; | 470 | blockMoving = true; |
471 | startX = viewportPos.x(); | 471 | startX = viewportPos.x(); |
472 | startY = viewportPos.y(); | 472 | startY = viewportPos.y(); |
473 | mPopupPos = me->globalPos(); | 473 | mPopupPos = me->globalPos(); |
474 | if ( objIsNotViewport && !leftButt ) { | 474 | if ( objIsNotViewport && !leftButt ) { |
475 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 475 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
476 | if (mAllDayMode) { | 476 | if (mAllDayMode) { |
477 | if ( tempItem->height() > 10 ) { | 477 | if ( tempItem->height() > 10 ) { |
478 | int minV = tempItem->height()/4; | 478 | int minV = tempItem->height()/4; |
479 | if ( minV > (blockmoveDist/2)-2 ) | 479 | if ( minV > (blockmoveDist/2)-2 ) { |
480 | minV = (blockmoveDist/2)-2; | 480 | if ( minV > blockmoveDist ) |
481 | minV = blockmoveDist; | ||
482 | else | ||
483 | minV = (blockmoveDist/2); | ||
484 | } | ||
481 | bool border = false; | 485 | bool border = false; |
482 | int diff = tempItem->y() - viewportPos.y(); | 486 | int diff = tempItem->y() - viewportPos.y(); |
483 | if ( diff < 0 ) | 487 | if ( diff < 0 ) |
484 | diff *= -1; | 488 | diff *= -1; |
485 | if ( diff < minV ) { | 489 | if ( diff < minV ) { |
486 | border = true; | 490 | border = true; |
487 | objIsNotViewport = false; | 491 | objIsNotViewport = false; |
488 | } | 492 | } |
489 | if ( ! border ) { | 493 | if ( ! border ) { |
490 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 494 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
491 | if ( diff < 0 ) | 495 | if ( diff < 0 ) |
492 | diff *= -1; | 496 | diff *= -1; |
493 | if ( diff < minV ) { | 497 | if ( diff < minV ) { |
494 | border = true; | 498 | border = true; |
495 | objIsNotViewport = false; | 499 | objIsNotViewport = false; |
496 | } | 500 | } |
497 | } | 501 | } |
498 | } | 502 | } |
499 | } else { // not allday | 503 | } else { // not allday |
500 | if ( tempItem->width() > 10 ) { | 504 | if ( tempItem->width() > 10 ) { |
501 | int minH = tempItem->width()/4; | 505 | int minH = tempItem->width()/4; |
502 | if ( minH > (blockmoveDist/2)-2 ) | 506 | if ( minH > (blockmoveDist/2)-2 ) { |
503 | minH = (blockmoveDist/2)-2; | 507 | if ( minH > blockmoveDist ) |
508 | minH = blockmoveDist; | ||
509 | else | ||
510 | minH = (blockmoveDist/2); | ||
511 | } | ||
504 | bool border = false; | 512 | bool border = false; |
505 | int diff = tempItem->x() - viewportPos.x(); | 513 | int diff = tempItem->x() - viewportPos.x(); |
506 | if ( diff < 0 ) | 514 | if ( diff < 0 ) |
507 | diff *= -1; | 515 | diff *= -1; |
508 | if ( diff < minH ) { | 516 | if ( diff < minH ) { |
509 | border = true; | 517 | border = true; |
510 | objIsNotViewport = false; | 518 | objIsNotViewport = false; |
511 | } | 519 | } |
512 | if ( ! border ) { | 520 | if ( ! border ) { |
513 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 521 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
514 | if ( diff < 0 ) | 522 | if ( diff < 0 ) |
515 | diff *= -1; | 523 | diff *= -1; |
516 | if ( diff < minH ) { | 524 | if ( diff < minH ) { |
517 | border = true; | 525 | border = true; |
518 | objIsNotViewport = false; | 526 | objIsNotViewport = false; |
519 | } | 527 | } |
520 | } | 528 | } |
521 | } | 529 | } |
522 | } | 530 | } |
523 | } | 531 | } |
524 | if ( objIsNotViewport ) { | 532 | if ( objIsNotViewport ) { |
525 | mPopupItem = (KOAgendaItem *)object; | 533 | mPopupItem = (KOAgendaItem *)object; |
526 | mPopupKind = 1; | 534 | mPopupKind = 1; |
527 | if (me->button() == RightButton) { | 535 | if (me->button() == RightButton) { |
528 | mPopupKind = 3; | 536 | mPopupKind = 3; |
529 | popupMenu(); | 537 | popupMenu(); |
530 | } else if (me->button() == LeftButton) { | 538 | } else if (me->button() == LeftButton) { |
531 | mActionItem = (KOAgendaItem *)object; | 539 | mActionItem = (KOAgendaItem *)object; |
532 | if (mActionItem) { | 540 | if (mActionItem) { |
533 | emit signalClearSelection(); | 541 | emit signalClearSelection(); |
534 | slotClearSelection(); | 542 | slotClearSelection(); |
535 | selectItem(mActionItem); | 543 | selectItem(mActionItem); |
536 | Incidence *incidence = mActionItem->incidence(); | 544 | Incidence *incidence = mActionItem->incidence(); |
537 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 545 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
538 | mActionItem = 0; | 546 | mActionItem = 0; |
539 | } else { | 547 | } else { |
540 | startItemAction(viewportPos); | 548 | startItemAction(viewportPos); |
541 | } | 549 | } |
542 | } | 550 | } |
543 | } | 551 | } |
544 | } else { // ---------- viewport() | 552 | } else { // ---------- viewport() |
545 | mPopupItem = 0; | 553 | mPopupItem = 0; |
546 | mPopupKind = 2; | 554 | mPopupKind = 2; |
547 | selectItem(0); | 555 | selectItem(0); |
548 | mActionItem = 0; | 556 | mActionItem = 0; |
549 | if (me->button() == RightButton) { | 557 | if (me->button() == RightButton) { |
550 | int x,y; | 558 | int x,y; |
551 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 559 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
552 | int gx,gy; | 560 | int gx,gy; |
553 | contentsToGrid(x,y,gx,gy); | 561 | contentsToGrid(x,y,gx,gy); |
554 | mCurrentCellX = gx; | 562 | mCurrentCellX = gx; |
555 | mCurrentCellY = gy; | 563 | mCurrentCellY = gy; |
556 | mStartCellX = gx; | 564 | mStartCellX = gx; |
557 | mStartCellY = gy; | 565 | mStartCellY = gy; |
558 | mPopupKind = 4; | 566 | mPopupKind = 4; |
559 | popupMenu(); | 567 | popupMenu(); |
560 | } else if (me->button() == LeftButton) { | 568 | } else if (me->button() == LeftButton) { |
561 | setCursor(arrowCursor); | 569 | setCursor(arrowCursor); |
562 | startSelectAction(viewportPos); | 570 | startSelectAction(viewportPos); |
563 | } | 571 | } |
564 | } | 572 | } |
565 | break; | 573 | break; |
566 | 574 | ||
567 | case QEvent::MouseButtonRelease: | 575 | case QEvent::MouseButtonRelease: |
568 | if (me->button() == LeftButton ) { | 576 | if (me->button() == LeftButton ) { |
569 | mPopupTimer->stop(); | 577 | mPopupTimer->stop(); |
570 | } | 578 | } |
571 | if (object != viewport()) { | 579 | if (object != viewport()) { |
572 | if (me->button() == LeftButton && mLeftMouseDown) { | 580 | if (me->button() == LeftButton && mLeftMouseDown) { |
573 | if (mActionItem) { | 581 | if (mActionItem) { |
574 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 582 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
575 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 583 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
576 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 584 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
577 | mScrollUpTimer.stop(); | 585 | mScrollUpTimer.stop(); |
578 | mScrollDownTimer.stop(); | 586 | mScrollDownTimer.stop(); |
579 | mActionItem->resetMove(); | 587 | mActionItem->resetMove(); |
580 | placeSubCells( mActionItem ); | 588 | placeSubCells( mActionItem ); |
581 | // emit startDragSignal( mActionItem->incidence() ); | 589 | // emit startDragSignal( mActionItem->incidence() ); |
582 | setCursor( arrowCursor ); | 590 | setCursor( arrowCursor ); |
583 | mActionItem = 0; | 591 | mActionItem = 0; |
584 | mActionType = NOP; | 592 | mActionType = NOP; |
585 | mItemMoved = 0; | 593 | mItemMoved = 0; |
586 | mLeftMouseDown = false; | 594 | mLeftMouseDown = false; |
587 | return true; | 595 | return true; |
588 | } | 596 | } |
589 | endItemAction(); | 597 | endItemAction(); |
590 | } | 598 | } |
591 | } | 599 | } |
592 | 600 | ||
593 | } else { // ---------- viewport() | 601 | } else { // ---------- viewport() |
594 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 602 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
595 | endSelectAction( true ); // emit new event signal | 603 | endSelectAction( true ); // emit new event signal |
596 | } | 604 | } |
597 | } | 605 | } |
598 | if (me->button() == LeftButton) | 606 | if (me->button() == LeftButton) |
599 | mLeftMouseDown = false; | 607 | mLeftMouseDown = false; |
600 | 608 | ||
601 | break; | 609 | break; |
602 | 610 | ||
603 | case QEvent::MouseMove: | 611 | case QEvent::MouseMove: |
604 | //qDebug("mm "); | 612 | //qDebug("mm "); |
605 | if ( !mLeftMouseDown ) | 613 | if ( !mLeftMouseDown ) |
606 | return false; | 614 | return false; |
607 | if ( blockMoving ) { | 615 | if ( blockMoving ) { |
608 | int dX, dY; | 616 | int dX, dY; |
609 | dX = startX - viewportPos.x(); | 617 | dX = startX - viewportPos.x(); |
610 | if ( dX < 0 ) | 618 | if ( dX < 0 ) |
611 | dX = -dX; | 619 | dX = -dX; |
612 | dY = viewportPos.y() - startY; | 620 | dY = viewportPos.y() - startY; |
613 | if ( dY < 0 ) | 621 | if ( dY < 0 ) |
614 | dY = -dY; | 622 | dY = -dY; |
615 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 623 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
616 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 624 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
617 | blockMoving = false; | 625 | blockMoving = false; |
618 | } | 626 | } |
619 | } | 627 | } |
620 | if ( ! blockMoving ) | 628 | if ( ! blockMoving ) |
621 | mPopupTimer->stop(); | 629 | mPopupTimer->stop(); |
622 | if (object != viewport()) { | 630 | if (object != viewport()) { |
623 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 631 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
624 | if (!moveItem->incidence()->isReadOnly() ) { | 632 | if (!moveItem->incidence()->isReadOnly() ) { |
625 | if (!mActionItem) | 633 | if (!mActionItem) |
626 | setNoActionCursor(moveItem,viewportPos); | 634 | setNoActionCursor(moveItem,viewportPos); |
627 | else { | 635 | else { |
628 | if ( !blockMoving ) | 636 | if ( !blockMoving ) |
629 | performItemAction(viewportPos); | 637 | performItemAction(viewportPos); |
630 | } | 638 | } |
631 | } | 639 | } |
632 | } else { // ---------- viewport() | 640 | } else { // ---------- viewport() |
633 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 641 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
634 | if ( mActionType == SELECT ) { | 642 | if ( mActionType == SELECT ) { |
635 | performSelectAction( viewportPos ); | 643 | performSelectAction( viewportPos ); |
636 | } | 644 | } |
637 | } | 645 | } |
638 | break; | 646 | break; |
639 | 647 | ||
640 | case QEvent::MouseButtonDblClick: | 648 | case QEvent::MouseButtonDblClick: |
641 | mPopupTimer->stop(); | 649 | mPopupTimer->stop(); |
642 | if (object == viewport()) { | 650 | if (object == viewport()) { |
643 | selectItem(0); | 651 | selectItem(0); |
644 | int x,y; | 652 | int x,y; |
645 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 653 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
646 | int gx,gy; | 654 | int gx,gy; |
647 | contentsToGrid(x,y,gx,gy); | 655 | contentsToGrid(x,y,gx,gy); |
648 | emit newEventSignal(gx,gy); | 656 | emit newEventSignal(gx,gy); |
649 | } else { | 657 | } else { |
650 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 658 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
651 | selectItem(doubleClickedItem); | 659 | selectItem(doubleClickedItem); |
652 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 660 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
653 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 661 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
654 | else | 662 | else |
655 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 663 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
656 | } | 664 | } |
657 | break; | 665 | break; |
658 | 666 | ||
659 | default: | 667 | default: |
660 | break; | 668 | break; |
661 | } | 669 | } |
662 | return true; | 670 | return true; |
663 | 671 | ||
664 | } | 672 | } |
665 | 673 | ||
666 | void KOAgenda::newItem( int item ) | 674 | void KOAgenda::newItem( int item ) |
667 | { | 675 | { |
668 | if ( item == 1 ) { //new event | 676 | if ( item == 1 ) { //new event |
669 | newEventSignal(mStartCellX ,mStartCellY ); | 677 | newEventSignal(mStartCellX ,mStartCellY ); |
670 | } else | 678 | } else |
671 | if ( item == 2 ) { //new event | 679 | if ( item == 2 ) { //new event |
672 | newTodoSignal(mStartCellX ,mStartCellY ); | 680 | newTodoSignal(mStartCellX ,mStartCellY ); |
673 | } else | 681 | } else |
674 | { | 682 | { |
675 | emit showDateView( item, mStartCellX ); | 683 | emit showDateView( item, mStartCellX ); |
676 | // 3Day view | 684 | // 3Day view |
677 | // 4Week view | 685 | // 4Week view |
678 | // 5Month view | 686 | // 5Month view |
679 | // 6Journal view | 687 | // 6Journal view |
680 | } | 688 | } |
681 | } | 689 | } |
682 | void KOAgenda::slotClearSelection() | 690 | void KOAgenda::slotClearSelection() |
683 | { | 691 | { |
684 | if (mSelectionHeight) { | 692 | if (mSelectionHeight) { |
685 | int selectionX = mSelectionCellX * mGridSpacingX; | 693 | int selectionX = mSelectionCellX * mGridSpacingX; |
686 | int top = mSelectionYTop - 2 *mGridSpacingY; | 694 | int top = mSelectionYTop - 2 *mGridSpacingY; |
687 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 695 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
688 | clearSelection(); | 696 | clearSelection(); |
689 | repaintContents( selectionX, top, | 697 | repaintContents( selectionX, top, |
690 | mGridSpacingX, hei ,false ); | 698 | mGridSpacingX, hei ,false ); |
691 | } | 699 | } |
692 | 700 | ||
693 | } | 701 | } |
694 | void KOAgenda::startSelectAction(QPoint viewportPos) | 702 | void KOAgenda::startSelectAction(QPoint viewportPos) |
695 | { | 703 | { |