summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp54
1 files changed, 52 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index fc213d8..b99625c 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -267,396 +267,446 @@ void KOAgenda::init()
267 mStartCellY = 0; 267 mStartCellY = 0;
268 mCurrentCellX = 0; 268 mCurrentCellX = 0;
269 mCurrentCellY = 0; 269 mCurrentCellY = 0;
270 270
271 mSelectionCellX = 0; 271 mSelectionCellX = 0;
272 mSelectionYTop = 0; 272 mSelectionYTop = 0;
273 mSelectionHeight = 0; 273 mSelectionHeight = 0;
274 274
275 mOldLowerScrollValue = -1; 275 mOldLowerScrollValue = -1;
276 mOldUpperScrollValue = -1; 276 mOldUpperScrollValue = -1;
277 277
278 mClickedItem = 0; 278 mClickedItem = 0;
279 279
280 mActionItem = 0; 280 mActionItem = 0;
281 mActionType = NOP; 281 mActionType = NOP;
282 mItemMoved = false; 282 mItemMoved = false;
283 283
284 mSelectedItem = 0; 284 mSelectedItem = 0;
285 285
286 // mItems.setAutoDelete(true); 286 // mItems.setAutoDelete(true);
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
322void KOAgenda::clear() 322void 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
334void KOAgenda::clearSelection() 334void 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
341void KOAgenda::marcus_bains() 341void KOAgenda::marcus_bains()
342{ 342{
343 if(mMarcusBains) mMarcusBains->updateLocation(true); 343 if(mMarcusBains) mMarcusBains->updateLocation(true);
344} 344}
345 345
346 346
347void KOAgenda::changeColumns(int columns) 347void 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*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool 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}
381void KOAgenda::popupMenu() 381void 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
412bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 412bool 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 459 bool objIsNotViewport = (object != viewport());
460 switch (me->type()) { 460 switch (me->type()) {
461 case QEvent::MouseButtonPress: 461 case QEvent::MouseButtonPress:
462 if (me->button() == LeftButton) { 462 if (me->button() == LeftButton) {
463 mPopupTimer->start( 600 ); 463 mPopupTimer->start( 600 );
464 mLeftMouseDown = true; 464 mLeftMouseDown = true;
465 } 465 }
466 blockMoving = true; 466 blockMoving = true;
467 startX = viewportPos.x(); 467 startX = viewportPos.x();
468 startY = viewportPos.y(); 468 startY = viewportPos.y();
469 mPopupPos = me->globalPos(); 469 mPopupPos = me->globalPos();
470 if (object != viewport()) { 470 if ( objIsNotViewport ) {
471 KOAgendaItem * tempItem = (KOAgendaItem *)object;
472 if (mAllDayMode) {
473 if ( tempItem->height() > 10 ) {
474 int minV = tempItem->height()/4;
475 if ( minV > (blockmoveDist/2)-2 )
476 minV = (blockmoveDist/2)-2;
477 bool border = false;
478 int diff = tempItem->y() - viewportPos.y();
479 if ( diff < 0 )
480 diff *= -1;
481 if ( diff < minV ) {
482 border = true;
483 objIsNotViewport = false;
484 }
485 if ( ! border ) {
486 diff = tempItem->y() + tempItem->height()- viewportPos.y();
487 if ( diff < 0 )
488 diff *= -1;
489 if ( diff < minV ) {
490 border = true;
491 objIsNotViewport = false;
492 }
493 }
494 }
495 } else { // not allday
496 if ( tempItem->width() > 10 ) {
497 int minH = tempItem->width()/4;
498 if ( minH > (blockmoveDist/2)-2 )
499 minH = (blockmoveDist/2)-2;
500 bool border = false;
501 int diff = tempItem->x() - viewportPos.x();
502 if ( diff < 0 )
503 diff *= -1;
504 if ( diff < minH ) {
505 border = true;
506 objIsNotViewport = false;
507 }
508 if ( ! border ) {
509 diff = tempItem->x() + tempItem->width() - viewportPos.x();
510 if ( diff < 0 )
511 diff *= -1;
512 if ( diff < minH ) {
513 border = true;
514 objIsNotViewport = false;
515 }
516 }
517 }
518 }
519 }
520 if ( objIsNotViewport ) {
471 mPopupItem = (KOAgendaItem *)object; 521 mPopupItem = (KOAgendaItem *)object;
472 mPopupKind = 1; 522 mPopupKind = 1;
473 if (me->button() == RightButton) { 523 if (me->button() == RightButton) {
474 mPopupKind = 3; 524 mPopupKind = 3;
475 popupMenu(); 525 popupMenu();
476 } else if (me->button() == LeftButton) { 526 } else if (me->button() == LeftButton) {
477 mActionItem = (KOAgendaItem *)object; 527 mActionItem = (KOAgendaItem *)object;
478 if (mActionItem) { 528 if (mActionItem) {
479 emit signalClearSelection(); 529 emit signalClearSelection();
480 slotClearSelection(); 530 slotClearSelection();
481 selectItem(mActionItem); 531 selectItem(mActionItem);
482 Incidence *incidence = mActionItem->incidence(); 532 Incidence *incidence = mActionItem->incidence();
483 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 533 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
484 mActionItem = 0; 534 mActionItem = 0;
485 } else { 535 } else {
486 startItemAction(viewportPos); 536 startItemAction(viewportPos);
487 } 537 }
488 } 538 }
489 } 539 }
490 } else { // ---------- viewport() 540 } else { // ---------- viewport()
491 mPopupItem = 0; 541 mPopupItem = 0;
492 mPopupKind = 2; 542 mPopupKind = 2;
493 selectItem(0); 543 selectItem(0);
494 mActionItem = 0; 544 mActionItem = 0;
495 if (me->button() == RightButton) { 545 if (me->button() == RightButton) {
496 int x,y; 546 int x,y;
497 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 547 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
498 int gx,gy; 548 int gx,gy;
499 contentsToGrid(x,y,gx,gy); 549 contentsToGrid(x,y,gx,gy);
500 mCurrentCellX = gx; 550 mCurrentCellX = gx;
501 mCurrentCellY = gy; 551 mCurrentCellY = gy;
502 mStartCellX = gx; 552 mStartCellX = gx;
503 mStartCellY = gy; 553 mStartCellY = gy;
504 mPopupKind = 4; 554 mPopupKind = 4;
505 popupMenu(); 555 popupMenu();
506 } else if (me->button() == LeftButton) { 556 } else if (me->button() == LeftButton) {
507 setCursor(arrowCursor); 557 setCursor(arrowCursor);
508 startSelectAction(viewportPos); 558 startSelectAction(viewportPos);
509 } 559 }
510 } 560 }
511 break; 561 break;
512 562
513 case QEvent::MouseButtonRelease: 563 case QEvent::MouseButtonRelease:
514 if (me->button() == LeftButton ) { 564 if (me->button() == LeftButton ) {
515 mPopupTimer->stop(); 565 mPopupTimer->stop();
516 } 566 }
517 if (object != viewport()) { 567 if (object != viewport()) {
518 if (me->button() == LeftButton && mLeftMouseDown) { 568 if (me->button() == LeftButton && mLeftMouseDown) {
519 if (mActionItem) { 569 if (mActionItem) {
520 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 570 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
521 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 571 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
522 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 572 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
523 mScrollUpTimer.stop(); 573 mScrollUpTimer.stop();
524 mScrollDownTimer.stop(); 574 mScrollDownTimer.stop();
525 mActionItem->resetMove(); 575 mActionItem->resetMove();
526 placeSubCells( mActionItem ); 576 placeSubCells( mActionItem );
527 // emit startDragSignal( mActionItem->incidence() ); 577 // emit startDragSignal( mActionItem->incidence() );
528 setCursor( arrowCursor ); 578 setCursor( arrowCursor );
529 mActionItem = 0; 579 mActionItem = 0;
530 mActionType = NOP; 580 mActionType = NOP;
531 mItemMoved = 0; 581 mItemMoved = 0;
532 mLeftMouseDown = false; 582 mLeftMouseDown = false;
533 return true; 583 return true;
534 } 584 }
535 endItemAction(); 585 endItemAction();
536 } 586 }
537 } 587 }
538 588
539 } else { // ---------- viewport() 589 } else { // ---------- viewport()
540 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 590 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
541 endSelectAction( true ); // emit new event signal 591 endSelectAction( true ); // emit new event signal
542 } 592 }
543 } 593 }
544 if (me->button() == LeftButton) 594 if (me->button() == LeftButton)
545 mLeftMouseDown = false; 595 mLeftMouseDown = false;
546 596
547 break; 597 break;
548 598
549 case QEvent::MouseMove: 599 case QEvent::MouseMove:
550 //qDebug("mm "); 600 //qDebug("mm ");
551 if ( !mLeftMouseDown ) 601 if ( !mLeftMouseDown )
552 return false; 602 return false;
553 if ( blockMoving ) { 603 if ( blockMoving ) {
554 int dX, dY; 604 int dX, dY;
555 dX = startX - viewportPos.x(); 605 dX = startX - viewportPos.x();
556 if ( dX < 0 ) 606 if ( dX < 0 )
557 dX = -dX; 607 dX = -dX;
558 dY = viewportPos.y() - startY; 608 dY = viewportPos.y() - startY;
559 if ( dY < 0 ) 609 if ( dY < 0 )
560 dY = -dY; 610 dY = -dY;
561 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 611 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
562 if ( dX > blockmoveDist || dY > blockmoveDist ) { 612 if ( dX > blockmoveDist || dY > blockmoveDist ) {
563 blockMoving = false; 613 blockMoving = false;
564 } 614 }
565 } 615 }
566 if ( ! blockMoving ) 616 if ( ! blockMoving )
567 mPopupTimer->stop(); 617 mPopupTimer->stop();
568 if (object != viewport()) { 618 if (object != viewport()) {
569 KOAgendaItem *moveItem = (KOAgendaItem *)object; 619 KOAgendaItem *moveItem = (KOAgendaItem *)object;
570 if (!moveItem->incidence()->isReadOnly() ) { 620 if (!moveItem->incidence()->isReadOnly() ) {
571 if (!mActionItem) 621 if (!mActionItem)
572 setNoActionCursor(moveItem,viewportPos); 622 setNoActionCursor(moveItem,viewportPos);
573 else { 623 else {
574 if ( !blockMoving ) 624 if ( !blockMoving )
575 performItemAction(viewportPos); 625 performItemAction(viewportPos);
576 } 626 }
577 } 627 }
578 } else { // ---------- viewport() 628 } else { // ---------- viewport()
579 mPopupPos = viewport()->mapToGlobal( me->pos() ); 629 mPopupPos = viewport()->mapToGlobal( me->pos() );
580 if ( mActionType == SELECT ) { 630 if ( mActionType == SELECT ) {
581 performSelectAction( viewportPos ); 631 performSelectAction( viewportPos );
582 } 632 }
583 } 633 }
584 break; 634 break;
585 635
586 case QEvent::MouseButtonDblClick: 636 case QEvent::MouseButtonDblClick:
587 mPopupTimer->stop(); 637 mPopupTimer->stop();
588 if (object == viewport()) { 638 if (object == viewport()) {
589 selectItem(0); 639 selectItem(0);
590 int x,y; 640 int x,y;
591 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 641 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
592 int gx,gy; 642 int gx,gy;
593 contentsToGrid(x,y,gx,gy); 643 contentsToGrid(x,y,gx,gy);
594 emit newEventSignal(gx,gy); 644 emit newEventSignal(gx,gy);
595 } else { 645 } else {
596 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 646 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
597 selectItem(doubleClickedItem); 647 selectItem(doubleClickedItem);
598 if ( KOPrefs::instance()->mEditOnDoubleClick ) 648 if ( KOPrefs::instance()->mEditOnDoubleClick )
599 emit editIncidenceSignal(doubleClickedItem->incidence()); 649 emit editIncidenceSignal(doubleClickedItem->incidence());
600 else 650 else
601 emit showIncidenceSignal(doubleClickedItem->incidence()); 651 emit showIncidenceSignal(doubleClickedItem->incidence());
602 } 652 }
603 break; 653 break;
604 654
605 default: 655 default:
606 break; 656 break;
607 } 657 }
608 return true; 658 return true;
609 659
610} 660}
611 661
612void KOAgenda::newItem( int item ) 662void KOAgenda::newItem( int item )
613{ 663{
614 if ( item == 1 ) { //new event 664 if ( item == 1 ) { //new event
615 newEventSignal(mStartCellX ,mStartCellY ); 665 newEventSignal(mStartCellX ,mStartCellY );
616 } else 666 } else
617 if ( item == 2 ) { //new event 667 if ( item == 2 ) { //new event
618 newTodoSignal(mStartCellX ,mStartCellY ); 668 newTodoSignal(mStartCellX ,mStartCellY );
619 } else 669 } else
620 { 670 {
621 emit showDateView( item, mStartCellX ); 671 emit showDateView( item, mStartCellX );
622 // 3Day view 672 // 3Day view
623 // 4Week view 673 // 4Week view
624 // 5Month view 674 // 5Month view
625 // 6Journal view 675 // 6Journal view
626 } 676 }
627} 677}
628void KOAgenda::slotClearSelection() 678void KOAgenda::slotClearSelection()
629{ 679{
630 if (mSelectionHeight) { 680 if (mSelectionHeight) {
631 int selectionX = mSelectionCellX * mGridSpacingX; 681 int selectionX = mSelectionCellX * mGridSpacingX;
632 int top = mSelectionYTop - 2 *mGridSpacingY; 682 int top = mSelectionYTop - 2 *mGridSpacingY;
633 int hei = mSelectionHeight + 4 *mGridSpacingY; 683 int hei = mSelectionHeight + 4 *mGridSpacingY;
634 clearSelection(); 684 clearSelection();
635 repaintContents( selectionX, top, 685 repaintContents( selectionX, top,
636 mGridSpacingX, hei ,false ); 686 mGridSpacingX, hei ,false );
637 } 687 }
638 688
639} 689}
640void KOAgenda::startSelectAction(QPoint viewportPos) 690void KOAgenda::startSelectAction(QPoint viewportPos)
641{ 691{
642 692
643 emit signalClearSelection(); 693 emit signalClearSelection();
644 slotClearSelection(); 694 slotClearSelection();
645 695
646 mActionType = SELECT; 696 mActionType = SELECT;
647 697
648 int x,y; 698 int x,y;
649 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 699 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
650 int gx,gy; 700 int gx,gy;
651 contentsToGrid(x,y,gx,gy); 701 contentsToGrid(x,y,gx,gy);
652 702
653 mStartCellX = gx; 703 mStartCellX = gx;
654 mStartCellY = gy; 704 mStartCellY = gy;
655 mCurrentCellX = gx; 705 mCurrentCellX = gx;
656 mCurrentCellY = gy; 706 mCurrentCellY = gy;
657 707
658 // Store new selection 708 // Store new selection
659 mSelectionCellX = gx; 709 mSelectionCellX = gx;
660 mSelectionYTop = gy * mGridSpacingY; 710 mSelectionYTop = gy * mGridSpacingY;
661 mSelectionHeight = mGridSpacingY; 711 mSelectionHeight = mGridSpacingY;
662 712