summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ffa2678..a72e470 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -309,254 +309,264 @@ void KOAgenda::init()
309 if(mAllDayMode) 309 if(mAllDayMode)
310 mMarcusBains = 0; 310 mMarcusBains = 0;
311 else { 311 else {
312 mMarcusBains = new MarcusBains(this); 312 mMarcusBains = new MarcusBains(this);
313 addChild(mMarcusBains); 313 addChild(mMarcusBains);
314 } 314 }
315} 315}
316 316
317void KOAgenda::clear() 317void KOAgenda::clear()
318{ 318{
319 KOAgendaItem *item; 319 KOAgendaItem *item;
320 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 320 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
321 mUnusedItems.append( item ); 321 mUnusedItems.append( item );
322 //item->hide(); 322 //item->hide();
323 } 323 }
324 mItems.clear(); 324 mItems.clear();
325 mSelectedItem = 0; 325 mSelectedItem = 0;
326 clearSelection(); 326 clearSelection();
327} 327}
328 328
329void KOAgenda::clearSelection() 329void KOAgenda::clearSelection()
330{ 330{
331 mSelectionCellX = 0; 331 mSelectionCellX = 0;
332 mSelectionYTop = 0; 332 mSelectionYTop = 0;
333 mSelectionHeight = 0; 333 mSelectionHeight = 0;
334} 334}
335 335
336void KOAgenda::marcus_bains() 336void KOAgenda::marcus_bains()
337{ 337{
338 if(mMarcusBains) mMarcusBains->updateLocation(true); 338 if(mMarcusBains) mMarcusBains->updateLocation(true);
339} 339}
340 340
341 341
342void KOAgenda::changeColumns(int columns) 342void KOAgenda::changeColumns(int columns)
343{ 343{
344 if (columns == 0) { 344 if (columns == 0) {
345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; 345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
346 return; 346 return;
347 } 347 }
348 348
349 clear(); 349 clear();
350 350
351 mColumns = columns; 351 mColumns = columns;
352// setMinimumSize(mColumns * 10, mGridSpacingY + 1); 352// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
353// init(); 353// init();
354// update(); 354// update();
355 //qDebug("KOAgenda::changeColumns "); 355 //qDebug("KOAgenda::changeColumns ");
356 computeSizes(); 356 computeSizes();
357 // QResizeEvent event( size(), size() ); 357 // QResizeEvent event( size(), size() );
358 358
359 //QApplication::sendEvent( this, &event ); 359 //QApplication::sendEvent( this, &event );
360} 360}
361 361
362/* 362/*
363 This is the eventFilter function, which gets all events from the KOAgendaItems 363 This is the eventFilter function, which gets all events from the KOAgendaItems
364 contained in the agenda. It has to handle moving and resizing for all items. 364 contained in the agenda. It has to handle moving and resizing for all items.
365*/ 365*/
366bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 366bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
367{ 367{
368// kdDebug() << "KOAgenda::eventFilter" << endl; 368// kdDebug() << "KOAgenda::eventFilter" << endl;
369 switch(event->type()) { 369 switch(event->type()) {
370 case QEvent::MouseButtonPress: 370 case QEvent::MouseButtonPress:
371 case QEvent::MouseButtonDblClick: 371 case QEvent::MouseButtonDblClick:
372 case QEvent::MouseButtonRelease: 372 case QEvent::MouseButtonRelease:
373 case QEvent::MouseMove: 373 case QEvent::MouseMove:
374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
375 375
376 case (QEvent::Leave): 376 case (QEvent::Leave):
377 if (!mActionItem) 377 if (!mActionItem)
378 setCursor(arrowCursor); 378 setCursor(arrowCursor);
379 return true; 379 return true;
380 380
381 default: 381 default:
382 return QScrollView::eventFilter(object,event); 382 return QScrollView::eventFilter(object,event);
383 } 383 }
384} 384}
385 385
386 386
387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
388{ 388{
389 //qDebug("KOAgenda::eventFilter_mous "); 389 //qDebug("KOAgenda::eventFilter_mous ");
390 QPoint viewportPos; 390 QPoint viewportPos;
391 if (object != viewport()) { 391 if (object != viewport()) {
392 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 392 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
393 } else { 393 } else {
394 viewportPos = me->pos(); 394 viewportPos = me->pos();
395 } 395 }
396 static int startX = 0; 396 static int startX = 0;
397 static int startY = 0; 397 static int startY = 0;
398 static bool block = true; 398 static bool block = true;
399 switch (me->type()) { 399 switch (me->type()) {
400 case QEvent::MouseButtonPress: 400 case QEvent::MouseButtonPress:
401 //qDebug("QEvent::MouseButtonPress: "); 401 //qDebug("QEvent::MouseButtonPress: ");
402 // kdDebug() << "koagenda: filtered button press" << endl; 402 // kdDebug() << "koagenda: filtered button press" << endl;
403 if (object != viewport()) { 403 if (object != viewport()) {
404 if (me->button() == RightButton) { 404 if (me->button() == RightButton) {
405
406 mClickedItem = (KOAgendaItem *)object; 405 mClickedItem = (KOAgendaItem *)object;
407 if (mClickedItem) { 406 if (mClickedItem) {
408 selectItem(mClickedItem); 407 selectItem(mClickedItem);
409 // emit showIncidencePopupSignal(mClickedItem->incidence()); 408 // emit showIncidencePopupSignal(mClickedItem->incidence());
410 } 409 }
411 //mItemPopup->popup(QCursor::pos()); 410 //mItemPopup->popup(QCursor::pos());
412 } else { 411 } else {
413 mActionItem = (KOAgendaItem *)object; 412 mActionItem = (KOAgendaItem *)object;
414 if (mActionItem) { 413 if (mActionItem) {
415 if ( mSelectionHeight > 0 ) { 414 if ( mSelectionHeight > 0 ) {
416 int selectionCellX = mSelectionCellX * mGridSpacingX; 415 int selectionCellX = mSelectionCellX * mGridSpacingX;
417 int selectionYTop = mSelectionYTop; 416 int selectionYTop = mSelectionYTop;
418 int gridSpacingX = mGridSpacingX; 417 int gridSpacingX = mGridSpacingX;
419 int selectionHeight = mSelectionHeight; 418 int selectionHeight = mSelectionHeight;
420 clearSelection(); 419 clearSelection();
421 repaintContents( selectionCellX, selectionYTop, 420 repaintContents( selectionCellX, selectionYTop,
422 gridSpacingX, selectionHeight,false ); 421 gridSpacingX, selectionHeight,false );
423 } 422 }
424 selectItem(mActionItem); 423 selectItem(mActionItem);
425 Incidence *incidence = mActionItem->incidence(); 424 Incidence *incidence = mActionItem->incidence();
426 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 425 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
427 mActionItem = 0; 426 mActionItem = 0;
428 } else { 427 } else {
429 startItemAction(viewportPos); 428 startItemAction(viewportPos);
430 startX = viewportPos.x(); 429 startX = viewportPos.x();
431 startY = viewportPos.y(); 430 startY = viewportPos.y();
432 block = true; 431 block = true;
433 } 432 }
434 } 433 }
435 } 434 }
436 } else { 435 } else {
437 selectItem(0); 436 selectItem(0);
438 mActionItem = 0; 437 mActionItem = 0;
439 if (me->button() == RightButton ) { 438 if (me->button() == RightButton ) {
440 blockNewEvent = true; 439 blockNewEvent = true;
441 block = false; 440 block = false;
442 } else { 441 } else {
443 blockNewEvent = false; 442 blockNewEvent = false;
444 setCursor(arrowCursor); 443 setCursor(arrowCursor);
445 startSelectAction(viewportPos); 444 startSelectAction(viewportPos);
446 } 445 }
447 } 446 }
448 break; 447 break;
449 448
450 case QEvent::MouseButtonRelease: 449 case QEvent::MouseButtonRelease:
451 //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); 450 //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent );
452 if (me->button() == RightButton && blockNewEvent && !block) { 451 if (me->button() == RightButton && blockNewEvent && !block) {
453 int x,y; 452 int x,y;
454 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 453 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
455 int gx,gy; 454 int gx,gy;
456 contentsToGrid(x,y,gx,gy); 455 contentsToGrid(x,y,gx,gy);
457 if ( mCurrentCellY < mStartCellY +1 ) { 456 if ( object == viewport() ) {
458 //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); 457 if ( mCurrentCellY < mStartCellY +1 ) {
459 mCurrentCellX = gx; 458 //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY);
460 mCurrentCellY = gy; 459 mCurrentCellX = gx;
461 mStartCellX = gx; 460 mCurrentCellY = gy;
462 mStartCellY = gy; 461 mStartCellX = gx;
463 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 462 mStartCellY = gy;
464 break; 463 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
464 break;
465 } else {
466 blockNewEvent = false;
467 }
465 } else { 468 } else {
466 blockNewEvent = false; 469 mClickedItem = (KOAgendaItem *)object;
470 if (mActionItem ) {
471 endItemAction();
472 }
473 if (mClickedItem) {
474 selectItem(mClickedItem);
475 emit showIncidencePopupSignal(mClickedItem->incidence());
476 }
467 } 477 }
468 } else if (me->button() == RightButton && block ) { 478 } else if (me->button() == RightButton && block ) {
469 if (object != viewport()) { 479 if (object != viewport()) {
470 mClickedItem = (KOAgendaItem *)object; 480 mClickedItem = (KOAgendaItem *)object;
471 if (mActionItem ) { 481 if (mActionItem ) {
472 endItemAction(); 482 endItemAction();
473 } 483 }
474 if (mClickedItem) { 484 if (mClickedItem) {
475 selectItem(mClickedItem); 485 selectItem(mClickedItem);
476 emit showIncidencePopupSignal(mClickedItem->incidence()); 486 emit showIncidencePopupSignal(mClickedItem->incidence());
477 } 487 }
478 } 488 }
479 break; 489 break;
480 } 490 }
481 block = true; 491 block = true;
482 if (mActionItem) { 492 if (mActionItem) {
483 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 493 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
484 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 494 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
485 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 495 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
486 mScrollUpTimer.stop(); 496 mScrollUpTimer.stop();
487 mScrollDownTimer.stop(); 497 mScrollDownTimer.stop();
488 mActionItem->resetMove(); 498 mActionItem->resetMove();
489 placeSubCells( mActionItem ); 499 placeSubCells( mActionItem );
490 // emit startDragSignal( mActionItem->incidence() ); 500 // emit startDragSignal( mActionItem->incidence() );
491 setCursor( arrowCursor ); 501 setCursor( arrowCursor );
492 mActionItem = 0; 502 mActionItem = 0;
493 mActionType = NOP; 503 mActionType = NOP;
494 mItemMoved = 0; 504 mItemMoved = 0;
495 return true; 505 return true;
496 } 506 }
497 endItemAction(); 507 endItemAction();
498 } else if ( mActionType == SELECT ) { 508 } else if ( mActionType == SELECT ) {
499 if (me->button() == RightButton ) { 509 if (me->button() == RightButton ) {
500 } else { 510 } else {
501 endSelectAction( !blockNewEvent ); 511 endSelectAction( !blockNewEvent );
502 } 512 }
503 } 513 }
504 break; 514 break;
505 515
506 case QEvent::MouseMove: 516 case QEvent::MouseMove:
507 if (object != viewport()) { 517 if (object != viewport()) {
508 KOAgendaItem *moveItem = (KOAgendaItem *)object; 518 KOAgendaItem *moveItem = (KOAgendaItem *)object;
509 //qDebug("moveItem %d ",moveItem ); 519 //qDebug("moveItem %d ",moveItem );
510 if (!moveItem->incidence()->isReadOnly() /*&& 520 if (!moveItem->incidence()->isReadOnly() /*&&
511 !moveItem->incidence()->recurrence()->doesRecur()*/ ) 521 !moveItem->incidence()->recurrence()->doesRecur()*/ )
512 if (!mActionItem) 522 if (!mActionItem)
513 setNoActionCursor(moveItem,viewportPos); 523 setNoActionCursor(moveItem,viewportPos);
514 else { 524 else {
515 if ( block ) { 525 if ( block ) {
516 int dX, dY; 526 int dX, dY;
517 dX = startX - viewportPos.x(); 527 dX = startX - viewportPos.x();
518 if ( dX < 0 ) 528 if ( dX < 0 )
519 dX = -dX; 529 dX = -dX;
520 dY = viewportPos.y() - startY; 530 dY = viewportPos.y() - startY;
521 if ( dY < 0 ) 531 if ( dY < 0 )
522 dY = -dY; 532 dY = -dY;
523 int diff = 30; 533 int diff = 30;
524 if ( QApplication::desktop()->width() < 480 ) 534 if ( QApplication::desktop()->width() < 480 )
525 diff = 15; 535 diff = 15;
526 // qDebug(" %d %d ",dX, dY ); 536 // qDebug(" %d %d ",dX, dY );
527 if ( dX > diff || dY > diff ) { 537 if ( dX > diff || dY > diff ) {
528 block = false; 538 block = false;
529 } 539 }
530 } 540 }
531 if ( !block ) 541 if ( !block )
532 performItemAction(viewportPos); 542 performItemAction(viewportPos);
533 } 543 }
534 } else { 544 } else {
535 if ( mActionType == SELECT ) { 545 if ( mActionType == SELECT ) {
536 performSelectAction( viewportPos ); 546 performSelectAction( viewportPos );
537 } 547 }
538 } 548 }
539 break; 549 break;
540 550
541 case QEvent::MouseButtonDblClick: 551 case QEvent::MouseButtonDblClick:
542 if (object == viewport()) { 552 if (object == viewport()) {
543 selectItem(0); 553 selectItem(0);
544 int x,y; 554 int x,y;
545 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 555 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
546 int gx,gy; 556 int gx,gy;
547 contentsToGrid(x,y,gx,gy); 557 contentsToGrid(x,y,gx,gy);
548 emit newEventSignal(gx,gy); 558 emit newEventSignal(gx,gy);
549 } else { 559 } else {
550 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 560 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
551 selectItem(doubleClickedItem); 561 selectItem(doubleClickedItem);
552 if ( KOPrefs::instance()->mEditOnDoubleClick ) 562 if ( KOPrefs::instance()->mEditOnDoubleClick )
553 emit editIncidenceSignal(doubleClickedItem->incidence()); 563 emit editIncidenceSignal(doubleClickedItem->incidence());
554 else 564 else
555 emit showIncidenceSignal(doubleClickedItem->incidence()); 565 emit showIncidenceSignal(doubleClickedItem->incidence());
556 } 566 }
557 break; 567 break;
558 568
559 default: 569 default:
560 break; 570 break;
561 } 571 }
562 572