author | zautrix <zautrix> | 2005-01-30 20:31:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-30 20:31:35 (UTC) |
commit | 15c5772f8a54750115f82aea34fea47e5842ff4f (patch) (unidiff) | |
tree | 13c31b5fd3d41058b65a392acf17ee3efd230f33 /korganizer | |
parent | 23d345c877ae9de6a077af3705026d15bb04d1e3 (diff) | |
download | kdepimpi-15c5772f8a54750115f82aea34fea47e5842ff4f.zip kdepimpi-15c5772f8a54750115f82aea34fea47e5842ff4f.tar.gz kdepimpi-15c5772f8a54750115f82aea34fea47e5842ff4f.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagenda.cpp | 35 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 7 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 4 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 1 |
5 files changed, 29 insertions, 22 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0aef929..ffa2678 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -345,246 +345,251 @@ void KOAgenda::changeColumns(int columns) | |||
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 | */ |
366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 366 | bool 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 | ||
387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 387 | bool 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 | 405 | ||
406 | mClickedItem = (KOAgendaItem *)object; | 406 | mClickedItem = (KOAgendaItem *)object; |
407 | if (mClickedItem) { | 407 | if (mClickedItem) { |
408 | selectItem(mClickedItem); | 408 | selectItem(mClickedItem); |
409 | // emit showIncidencePopupSignal(mClickedItem->incidence()); | 409 | // emit showIncidencePopupSignal(mClickedItem->incidence()); |
410 | } | 410 | } |
411 | //mItemPopup->popup(QCursor::pos()); | 411 | //mItemPopup->popup(QCursor::pos()); |
412 | } else { | 412 | } else { |
413 | mActionItem = (KOAgendaItem *)object; | 413 | mActionItem = (KOAgendaItem *)object; |
414 | if (mActionItem) { | 414 | if (mActionItem) { |
415 | if ( mSelectionHeight > 0 ) { | 415 | if ( mSelectionHeight > 0 ) { |
416 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 416 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
417 | int selectionYTop = mSelectionYTop; | 417 | int selectionYTop = mSelectionYTop; |
418 | int gridSpacingX = mGridSpacingX; | 418 | int gridSpacingX = mGridSpacingX; |
419 | int selectionHeight = mSelectionHeight; | 419 | int selectionHeight = mSelectionHeight; |
420 | clearSelection(); | 420 | clearSelection(); |
421 | repaintContents( selectionCellX, selectionYTop, | 421 | repaintContents( selectionCellX, selectionYTop, |
422 | gridSpacingX, selectionHeight,false ); | 422 | gridSpacingX, selectionHeight,false ); |
423 | } | 423 | } |
424 | selectItem(mActionItem); | 424 | selectItem(mActionItem); |
425 | Incidence *incidence = mActionItem->incidence(); | 425 | Incidence *incidence = mActionItem->incidence(); |
426 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 426 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
427 | mActionItem = 0; | 427 | mActionItem = 0; |
428 | } else { | 428 | } else { |
429 | startItemAction(viewportPos); | 429 | startItemAction(viewportPos); |
430 | startX = viewportPos.x(); | 430 | startX = viewportPos.x(); |
431 | startY = viewportPos.y(); | 431 | startY = viewportPos.y(); |
432 | block = true; | 432 | block = true; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | } | 435 | } |
436 | } else { | 436 | } else { |
437 | selectItem(0); | 437 | selectItem(0); |
438 | mActionItem = 0; | 438 | mActionItem = 0; |
439 | if (me->button() == RightButton ) { | 439 | if (me->button() == RightButton ) { |
440 | blockNewEvent = true; | 440 | blockNewEvent = true; |
441 | //qDebug("right "); | 441 | block = false; |
442 | int x,y; | ||
443 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
444 | int gx,gy; | ||
445 | contentsToGrid(x,y,gx,gy); | ||
446 | mStartCellX = gx; | ||
447 | mStartCellY = gy; | ||
448 | mCurrentCellX = gx; | ||
449 | mCurrentCellY = gy; | ||
450 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | ||
451 | |||
452 | } else { | 442 | } else { |
453 | blockNewEvent = false; | 443 | blockNewEvent = false; |
454 | setCursor(arrowCursor); | 444 | setCursor(arrowCursor); |
455 | startSelectAction(viewportPos); | 445 | startSelectAction(viewportPos); |
456 | } | 446 | } |
457 | } | 447 | } |
458 | break; | 448 | break; |
459 | 449 | ||
460 | case QEvent::MouseButtonRelease: | 450 | case QEvent::MouseButtonRelease: |
461 | //qDebug("QEvent::MouseButtonRelease: "); | 451 | //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); |
462 | if (me->button() == RightButton && block ) { | 452 | if (me->button() == RightButton && blockNewEvent && !block) { |
453 | int x,y; | ||
454 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
455 | int gx,gy; | ||
456 | contentsToGrid(x,y,gx,gy); | ||
457 | if ( mCurrentCellY < mStartCellY +1 ) { | ||
458 | //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); | ||
459 | mCurrentCellX = gx; | ||
460 | mCurrentCellY = gy; | ||
461 | mStartCellX = gx; | ||
462 | mStartCellY = gy; | ||
463 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | ||
464 | break; | ||
465 | } else { | ||
466 | blockNewEvent = false; | ||
467 | } | ||
468 | } else if (me->button() == RightButton && block ) { | ||
463 | if (object != viewport()) { | 469 | if (object != viewport()) { |
464 | mClickedItem = (KOAgendaItem *)object; | 470 | mClickedItem = (KOAgendaItem *)object; |
465 | if (mActionItem ) { | 471 | if (mActionItem ) { |
466 | endItemAction(); | 472 | endItemAction(); |
467 | } | 473 | } |
468 | if (mClickedItem) { | 474 | if (mClickedItem) { |
469 | selectItem(mClickedItem); | 475 | selectItem(mClickedItem); |
470 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 476 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
471 | } | 477 | } |
472 | } | 478 | } |
473 | break; | 479 | break; |
474 | } | 480 | } |
475 | block = true; | 481 | block = true; |
476 | if (mActionItem) { | 482 | if (mActionItem) { |
477 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 483 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
478 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 484 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
479 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 485 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
480 | mScrollUpTimer.stop(); | 486 | mScrollUpTimer.stop(); |
481 | mScrollDownTimer.stop(); | 487 | mScrollDownTimer.stop(); |
482 | mActionItem->resetMove(); | 488 | mActionItem->resetMove(); |
483 | placeSubCells( mActionItem ); | 489 | placeSubCells( mActionItem ); |
484 | // emit startDragSignal( mActionItem->incidence() ); | 490 | // emit startDragSignal( mActionItem->incidence() ); |
485 | setCursor( arrowCursor ); | 491 | setCursor( arrowCursor ); |
486 | mActionItem = 0; | 492 | mActionItem = 0; |
487 | mActionType = NOP; | 493 | mActionType = NOP; |
488 | mItemMoved = 0; | 494 | mItemMoved = 0; |
489 | return true; | 495 | return true; |
490 | } | 496 | } |
491 | endItemAction(); | 497 | endItemAction(); |
492 | } else if ( mActionType == SELECT ) { | 498 | } else if ( mActionType == SELECT ) { |
493 | if (me->button() == RightButton ) { | 499 | if (me->button() == RightButton ) { |
494 | |||
495 | } else { | 500 | } else { |
496 | endSelectAction( !blockNewEvent ); | 501 | endSelectAction( !blockNewEvent ); |
497 | } | 502 | } |
498 | } | 503 | } |
499 | break; | 504 | break; |
500 | 505 | ||
501 | case QEvent::MouseMove: | 506 | case QEvent::MouseMove: |
502 | if (object != viewport()) { | 507 | if (object != viewport()) { |
503 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 508 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
504 | //qDebug("moveItem %d ",moveItem ); | 509 | //qDebug("moveItem %d ",moveItem ); |
505 | if (!moveItem->incidence()->isReadOnly() /*&& | 510 | if (!moveItem->incidence()->isReadOnly() /*&& |
506 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) | 511 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) |
507 | if (!mActionItem) | 512 | if (!mActionItem) |
508 | setNoActionCursor(moveItem,viewportPos); | 513 | setNoActionCursor(moveItem,viewportPos); |
509 | else { | 514 | else { |
510 | if ( block ) { | 515 | if ( block ) { |
511 | int dX, dY; | 516 | int dX, dY; |
512 | dX = startX - viewportPos.x(); | 517 | dX = startX - viewportPos.x(); |
513 | if ( dX < 0 ) | 518 | if ( dX < 0 ) |
514 | dX = -dX; | 519 | dX = -dX; |
515 | dY = viewportPos.y() - startY; | 520 | dY = viewportPos.y() - startY; |
516 | if ( dY < 0 ) | 521 | if ( dY < 0 ) |
517 | dY = -dY; | 522 | dY = -dY; |
518 | int diff = 30; | 523 | int diff = 30; |
519 | if ( QApplication::desktop()->width() < 480 ) | 524 | if ( QApplication::desktop()->width() < 480 ) |
520 | diff = 15; | 525 | diff = 15; |
521 | // qDebug(" %d %d ",dX, dY ); | 526 | // qDebug(" %d %d ",dX, dY ); |
522 | if ( dX > diff || dY > diff ) { | 527 | if ( dX > diff || dY > diff ) { |
523 | block = false; | 528 | block = false; |
524 | } | 529 | } |
525 | } | 530 | } |
526 | if ( !block ) | 531 | if ( !block ) |
527 | performItemAction(viewportPos); | 532 | performItemAction(viewportPos); |
528 | } | 533 | } |
529 | } else { | 534 | } else { |
530 | if ( mActionType == SELECT ) { | 535 | if ( mActionType == SELECT ) { |
531 | performSelectAction( viewportPos ); | 536 | performSelectAction( viewportPos ); |
532 | } | 537 | } |
533 | } | 538 | } |
534 | break; | 539 | break; |
535 | 540 | ||
536 | case QEvent::MouseButtonDblClick: | 541 | case QEvent::MouseButtonDblClick: |
537 | if (object == viewport()) { | 542 | if (object == viewport()) { |
538 | selectItem(0); | 543 | selectItem(0); |
539 | int x,y; | 544 | int x,y; |
540 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 545 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
541 | int gx,gy; | 546 | int gx,gy; |
542 | contentsToGrid(x,y,gx,gy); | 547 | contentsToGrid(x,y,gx,gy); |
543 | emit newEventSignal(gx,gy); | 548 | emit newEventSignal(gx,gy); |
544 | } else { | 549 | } else { |
545 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 550 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
546 | selectItem(doubleClickedItem); | 551 | selectItem(doubleClickedItem); |
547 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 552 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
548 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 553 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
549 | else | 554 | else |
550 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 555 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
551 | } | 556 | } |
552 | break; | 557 | break; |
553 | 558 | ||
554 | default: | 559 | default: |
555 | break; | 560 | break; |
556 | } | 561 | } |
557 | 562 | ||
558 | return true; | 563 | return true; |
559 | } | 564 | } |
560 | 565 | ||
561 | void KOAgenda::newItem( int item ) | 566 | void KOAgenda::newItem( int item ) |
562 | { | 567 | { |
563 | if ( item == 1 ) { //new event | 568 | if ( item == 1 ) { //new event |
564 | newEventSignal(mStartCellX ,mStartCellY ); | 569 | newEventSignal(mStartCellX ,mStartCellY ); |
565 | } else | 570 | } else |
566 | if ( item == 2 ) { //new event | 571 | if ( item == 2 ) { //new event |
567 | newTodoSignal(mStartCellX ,mStartCellY ); | 572 | newTodoSignal(mStartCellX ,mStartCellY ); |
568 | } else | 573 | } else |
569 | { | 574 | { |
570 | QDate day = mSelectedDates[mStartCellX]; | 575 | QDate day = mSelectedDates[mStartCellX]; |
571 | emit showDateView( item, day ); | 576 | emit showDateView( item, day ); |
572 | // 3Day view | 577 | // 3Day view |
573 | // 4Week view | 578 | // 4Week view |
574 | // 5Month view | 579 | // 5Month view |
575 | // 6Journal view | 580 | // 6Journal view |
576 | } | 581 | } |
577 | } | 582 | } |
578 | void KOAgenda::startSelectAction(QPoint viewportPos) | 583 | void KOAgenda::startSelectAction(QPoint viewportPos) |
579 | { | 584 | { |
580 | //emit newStartSelectSignal(); | 585 | //emit newStartSelectSignal(); |
581 | 586 | ||
582 | mActionType = SELECT; | 587 | mActionType = SELECT; |
583 | 588 | ||
584 | int x,y; | 589 | int x,y; |
585 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 590 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
586 | int gx,gy; | 591 | int gx,gy; |
587 | contentsToGrid(x,y,gx,gy); | 592 | contentsToGrid(x,y,gx,gy); |
588 | 593 | ||
589 | mStartCellX = gx; | 594 | mStartCellX = gx; |
590 | mStartCellY = gy; | 595 | mStartCellY = gy; |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 060b4c4..faa2c21 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -55,336 +55,335 @@ DynamicTip::DynamicTip( QWidget * parent ) | |||
55 | : QToolTip( parent ) | 55 | : QToolTip( parent ) |
56 | { | 56 | { |
57 | matrix = (KODayMatrix*)parent; | 57 | matrix = (KODayMatrix*)parent; |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | void DynamicTip::maybeTip( const QPoint &pos ) | 61 | void DynamicTip::maybeTip( const QPoint &pos ) |
62 | { | 62 | { |
63 | //calculate which cell of the matrix the mouse is in | 63 | //calculate which cell of the matrix the mouse is in |
64 | QRect sz = matrix->frameRect(); | 64 | QRect sz = matrix->frameRect(); |
65 | int dheight = sz.height()*7 / 42; | 65 | int dheight = sz.height()*7 / 42; |
66 | int dwidth = sz.width() / 7; | 66 | int dwidth = sz.width() / 7; |
67 | int row = pos.y()/dheight; | 67 | int row = pos.y()/dheight; |
68 | int col = pos.x()/dwidth; | 68 | int col = pos.x()/dwidth; |
69 | 69 | ||
70 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 70 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
71 | 71 | ||
72 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 72 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
73 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 73 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
74 | 74 | ||
75 | //show holiday names only | 75 | //show holiday names only |
76 | QString str = matrix->getHolidayLabel(col+row*7); | 76 | QString str = matrix->getHolidayLabel(col+row*7); |
77 | if (str.isEmpty()) return; | 77 | if (str.isEmpty()) return; |
78 | tip(rct, str); | 78 | tip(rct, str); |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | // ============================================================================ | 82 | // ============================================================================ |
83 | // K O D A Y M A T R I X | 83 | // K O D A Y M A T R I X |
84 | // ============================================================================ | 84 | // ============================================================================ |
85 | 85 | ||
86 | const int KODayMatrix::NOSELECTION = -1000; | 86 | const int KODayMatrix::NOSELECTION = -1000; |
87 | const int KODayMatrix::NUMDAYS = 42; | 87 | const int KODayMatrix::NUMDAYS = 42; |
88 | 88 | ||
89 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 89 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
90 | QFrame(parent, name) | 90 | QFrame(parent, name) |
91 | { | 91 | { |
92 | mCalendar = calendar; | 92 | mCalendar = calendar; |
93 | 93 | ||
94 | // initialize dynamic arrays | 94 | // initialize dynamic arrays |
95 | days = new QDate[NUMDAYS]; | 95 | days = new QDate[NUMDAYS]; |
96 | daylbls = new QString[NUMDAYS]; | 96 | daylbls = new QString[NUMDAYS]; |
97 | events = new int[NUMDAYS]; | 97 | events = new int[NUMDAYS]; |
98 | mToolTip = new DynamicTip(this); | 98 | mToolTip = new DynamicTip(this); |
99 | 99 | ||
100 | // set default values used for drawing the matrix | 100 | // set default values used for drawing the matrix |
101 | mDefaultBackColor = palette().active().base(); | 101 | mDefaultBackColor = palette().active().base(); |
102 | mDefaultTextColor = palette().active().foreground(); | 102 | mDefaultTextColor = palette().active().foreground(); |
103 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 103 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
104 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 104 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
105 | mSelectedDaysColor = QColor("white"); | 105 | mSelectedDaysColor = QColor("white"); |
106 | mTodayMarginWidth = 2; | 106 | mTodayMarginWidth = 2; |
107 | mSelEnd = mSelStart = NOSELECTION; | 107 | mSelEnd = mSelStart = NOSELECTION; |
108 | 108 | ||
109 | setAcceptDrops(true); | 109 | setAcceptDrops(true); |
110 | //setFont( QFont("Arial", 10) ); | 110 | //setFont( QFont("Arial", 10) ); |
111 | 111 | ||
112 | mUpdateTimer = new QTimer( this ); | 112 | mUpdateTimer = new QTimer( this ); |
113 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 113 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
114 | mRepaintTimer = new QTimer( this ); | 114 | mRepaintTimer = new QTimer( this ); |
115 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 115 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
116 | mDayChanged = false; | 116 | mDayChanged = false; |
117 | updateView(); | 117 | updateView(); |
118 | } | 118 | } |
119 | 119 | ||
120 | QColor KODayMatrix::getShadedColor(QColor color) | 120 | QColor KODayMatrix::getShadedColor(QColor color) |
121 | { | 121 | { |
122 | QColor shaded; | 122 | QColor shaded; |
123 | int h=0; | 123 | int h=0; |
124 | int s=0; | 124 | int s=0; |
125 | int v=0; | 125 | int v=0; |
126 | color.hsv(&h,&s,&v); | 126 | color.hsv(&h,&s,&v); |
127 | s = s/4; | 127 | s = s/4; |
128 | v = 192+v/4; | 128 | v = 192+v/4; |
129 | shaded.setHsv(h,s,v); | 129 | shaded.setHsv(h,s,v); |
130 | 130 | ||
131 | return shaded; | 131 | return shaded; |
132 | } | 132 | } |
133 | 133 | ||
134 | KODayMatrix::~KODayMatrix() | 134 | KODayMatrix::~KODayMatrix() |
135 | { | 135 | { |
136 | delete [] days; | 136 | delete [] days; |
137 | delete [] daylbls; | 137 | delete [] daylbls; |
138 | delete [] events; | 138 | delete [] events; |
139 | delete mToolTip; | 139 | delete mToolTip; |
140 | } | 140 | } |
141 | 141 | ||
142 | /* | 142 | /* |
143 | void KODayMatrix::setStartDate(QDate start) | 143 | void KODayMatrix::setStartDate(QDate start) |
144 | { | 144 | { |
145 | updateView(start); | 145 | updateView(start); |
146 | } | 146 | } |
147 | */ | 147 | */ |
148 | 148 | ||
149 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 149 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
150 | { | 150 | { |
151 | kdDebug() << "KODayMatrix::addSelectedDaysTo() - " << "mSelStart:" << mSelStart << endl; | 151 | |
152 | |||
153 | if (mSelStart == NOSELECTION) { | 152 | if (mSelStart == NOSELECTION) { |
154 | return; | 153 | return; |
155 | } | 154 | } |
156 | 155 | ||
157 | //cope with selection being out of matrix limits at top (< 0) | 156 | //cope with selection being out of matrix limits at top (< 0) |
158 | int i0 = mSelStart; | 157 | int i0 = mSelStart; |
159 | if (i0 < 0) { | 158 | if (i0 < 0) { |
160 | for (int i = i0; i < 0; i++) { | 159 | for (int i = i0; i < 0; i++) { |
161 | selDays.append(days[0].addDays(i)); | 160 | selDays.append(days[0].addDays(i)); |
162 | } | 161 | } |
163 | i0 = 0; | 162 | i0 = 0; |
164 | } | 163 | } |
165 | 164 | ||
166 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 165 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
167 | if (mSelEnd > NUMDAYS-1) { | 166 | if (mSelEnd > NUMDAYS-1) { |
168 | for (int i = i0; i <= NUMDAYS-1; i++) { | 167 | for (int i = i0; i <= NUMDAYS-1; i++) { |
169 | selDays.append(days[i]); | 168 | selDays.append(days[i]); |
170 | } | 169 | } |
171 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 170 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
172 | selDays.append(days[0].addDays(i)); | 171 | selDays.append(days[0].addDays(i)); |
173 | } | 172 | } |
174 | 173 | ||
175 | // apply normal routine to selection being entirely within matrix limits | 174 | // apply normal routine to selection being entirely within matrix limits |
176 | } else { | 175 | } else { |
177 | for (int i = i0; i <= mSelEnd; i++) { | 176 | for (int i = i0; i <= mSelEnd; i++) { |
178 | selDays.append(days[i]); | 177 | selDays.append(days[i]); |
179 | } | 178 | } |
180 | } | 179 | } |
181 | } | 180 | } |
182 | 181 | ||
183 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 182 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
184 | { | 183 | { |
185 | mSelStart = startdate.daysTo(start); | 184 | mSelStart = startdate.daysTo(start); |
186 | mSelEnd = startdate.daysTo(end); | 185 | mSelEnd = startdate.daysTo(end); |
187 | } | 186 | } |
188 | 187 | ||
189 | 188 | ||
190 | void KODayMatrix::recalculateToday() | 189 | void KODayMatrix::recalculateToday() |
191 | { | 190 | { |
192 | today = -1; | 191 | today = -1; |
193 | for (int i=0; i<NUMDAYS; i++) { | 192 | for (int i=0; i<NUMDAYS; i++) { |
194 | days[i] = startdate.addDays(i); | 193 | days[i] = startdate.addDays(i); |
195 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 194 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
196 | 195 | ||
197 | // if today is in the currently displayed month, hilight today | 196 | // if today is in the currently displayed month, hilight today |
198 | if (days[i].year() == QDate::currentDate().year() && | 197 | if (days[i].year() == QDate::currentDate().year() && |
199 | days[i].month() == QDate::currentDate().month() && | 198 | days[i].month() == QDate::currentDate().month() && |
200 | days[i].day() == QDate::currentDate().day()) { | 199 | days[i].day() == QDate::currentDate().day()) { |
201 | today = i; | 200 | today = i; |
202 | } | 201 | } |
203 | } | 202 | } |
204 | // qDebug(QString("Today is visible at %1.").arg(today)); | 203 | // qDebug(QString("Today is visible at %1.").arg(today)); |
205 | } | 204 | } |
206 | 205 | ||
207 | void KODayMatrix::updateView() | 206 | void KODayMatrix::updateView() |
208 | { | 207 | { |
209 | updateView(startdate); | 208 | updateView(startdate); |
210 | } | 209 | } |
211 | void KODayMatrix::repaintViewTimed() | 210 | void KODayMatrix::repaintViewTimed() |
212 | { | 211 | { |
213 | qDebug("KODayMatrix::repaintViewTimed "); | 212 | qDebug("KODayMatrix::repaintViewTimed "); |
214 | mRepaintTimer->stop(); | 213 | mRepaintTimer->stop(); |
215 | repaint(false); | 214 | repaint(false); |
216 | } | 215 | } |
217 | void KODayMatrix::updateViewTimed() | 216 | void KODayMatrix::updateViewTimed() |
218 | { | 217 | { |
219 | 218 | ||
220 | mUpdateTimer->stop(); | 219 | mUpdateTimer->stop(); |
221 | //QDate actdate = mPendingNewDate; | 220 | //QDate actdate = mPendingNewDate; |
222 | 221 | ||
223 | static int iii = 0; | 222 | static int iii = 0; |
224 | qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); | 223 | qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); |
225 | 224 | ||
226 | if (mDayChanged) { | 225 | if (mDayChanged) { |
227 | recalculateToday(); | 226 | recalculateToday(); |
228 | mDayChanged = false; | 227 | mDayChanged = false; |
229 | } | 228 | } |
230 | 229 | ||
231 | for(int i = 0; i < NUMDAYS; i++) { | 230 | for(int i = 0; i < NUMDAYS; i++) { |
232 | 231 | ||
233 | // if events are set for the day then remember to draw it bold | 232 | // if events are set for the day then remember to draw it bold |
234 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 233 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
235 | Event *event; | 234 | Event *event; |
236 | int numEvents = eventlist.count(); | 235 | int numEvents = eventlist.count(); |
237 | 236 | ||
238 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 237 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
239 | ushort recurType = event->recurrence()->doesRecur(); | 238 | ushort recurType = event->recurrence()->doesRecur(); |
240 | 239 | ||
241 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 240 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
242 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 241 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
243 | numEvents--; | 242 | numEvents--; |
244 | } | 243 | } |
245 | } | 244 | } |
246 | events[i] = numEvents; | 245 | events[i] = numEvents; |
247 | 246 | ||
248 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 247 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
249 | #ifndef KORG_NOPLUGINS | 248 | #ifndef KORG_NOPLUGINS |
250 | QString holiStr = KOCore::self()->holiday(days[i]); | 249 | QString holiStr = KOCore::self()->holiday(days[i]); |
251 | #else | 250 | #else |
252 | QString holiStr = QString::null; | 251 | QString holiStr = QString::null; |
253 | #endif | 252 | #endif |
254 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 253 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
255 | !holiStr.isEmpty()) { | 254 | !holiStr.isEmpty()) { |
256 | if (holiStr.isNull()) holiStr = ""; | 255 | if (holiStr.isNull()) holiStr = ""; |
257 | mHolidays[i] = holiStr; | 256 | mHolidays[i] = holiStr; |
258 | 257 | ||
259 | } else { | 258 | } else { |
260 | mHolidays[i] = QString::null; | 259 | mHolidays[i] = QString::null; |
261 | } | 260 | } |
262 | } | 261 | } |
263 | repaint(false); | 262 | repaint(false); |
264 | } | 263 | } |
265 | void KODayMatrix::updateView(QDate actdate) | 264 | void KODayMatrix::updateView(QDate actdate) |
266 | { | 265 | { |
267 | 266 | ||
268 | //flag to indicate if the starting day of the matrix has changed by this call | 267 | //flag to indicate if the starting day of the matrix has changed by this call |
269 | //mDayChanged = false; | 268 | //mDayChanged = false; |
270 | // if a new startdate is to be set then apply Cornelius's calculation | 269 | // if a new startdate is to be set then apply Cornelius's calculation |
271 | // of the first day to be shown | 270 | // of the first day to be shown |
272 | if (actdate != startdate) { | 271 | if (actdate != startdate) { |
273 | // reset index of selection according to shift of starting date from startdate to actdate | 272 | // reset index of selection according to shift of starting date from startdate to actdate |
274 | if (mSelStart != NOSELECTION) { | 273 | if (mSelStart != NOSELECTION) { |
275 | int tmp = actdate.daysTo(startdate); | 274 | int tmp = actdate.daysTo(startdate); |
276 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 275 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
277 | // shift selection if new one would be visible at least partly ! | 276 | // shift selection if new one would be visible at least partly ! |
278 | 277 | ||
279 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 278 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
280 | // nested if is required for next X display pushed from a different month - correction required | 279 | // nested if is required for next X display pushed from a different month - correction required |
281 | // otherwise, for month forward and backward, it must be avoided | 280 | // otherwise, for month forward and backward, it must be avoided |
282 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 281 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
283 | mSelStart = mSelStart + tmp; | 282 | mSelStart = mSelStart + tmp; |
284 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 283 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
285 | mSelEnd = mSelEnd + tmp; | 284 | mSelEnd = mSelEnd + tmp; |
286 | } | 285 | } |
287 | } | 286 | } |
288 | 287 | ||
289 | startdate = actdate; | 288 | startdate = actdate; |
290 | mDayChanged = true; | 289 | mDayChanged = true; |
291 | } | 290 | } |
292 | qDebug("restart Timer %d", mDayChanged ); | 291 | qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
293 | static int iii = 0; | 292 | static int iii = 0; |
294 | if ( iii < 5 ) { | 293 | if ( iii < 2 ) { |
295 | ++iii; | 294 | ++iii; |
296 | updateViewTimed(); | 295 | updateViewTimed(); |
297 | } else { | 296 | } else { |
298 | if ( !isVisible() ) { | 297 | if ( !isVisible() ) { |
299 | mUpdateTimer->start( 2000 ); | 298 | mUpdateTimer->start( 2000 ); |
300 | } else { | 299 | } else { |
301 | if ( mDayChanged ) { | 300 | if ( mDayChanged ) { |
302 | mUpdateTimer->start( 250 ); | 301 | mUpdateTimer->start( 250 ); |
303 | } else { | 302 | } else { |
304 | mRepaintTimer->start( 250 ); | 303 | mRepaintTimer->start( 250 ); |
305 | mUpdateTimer->start( 2000 ); | 304 | mUpdateTimer->start( 2000 ); |
306 | } | 305 | } |
307 | } | 306 | } |
308 | } | 307 | } |
309 | 308 | ||
310 | } | 309 | } |
311 | 310 | ||
312 | const QDate& KODayMatrix::getDate(int offset) | 311 | const QDate& KODayMatrix::getDate(int offset) |
313 | { | 312 | { |
314 | if (offset < 0 || offset > NUMDAYS-1) { | 313 | if (offset < 0 || offset > NUMDAYS-1) { |
315 | qDebug("Wrong offset2 "); | 314 | qDebug("Wrong offset2 "); |
316 | return days[0]; | 315 | return days[0]; |
317 | } | 316 | } |
318 | return days[offset]; | 317 | return days[offset]; |
319 | } | 318 | } |
320 | 319 | ||
321 | QString KODayMatrix::getHolidayLabel(int offset) | 320 | QString KODayMatrix::getHolidayLabel(int offset) |
322 | { | 321 | { |
323 | if (offset < 0 || offset > NUMDAYS-1) { | 322 | if (offset < 0 || offset > NUMDAYS-1) { |
324 | qDebug("Wrong offset1 "); | 323 | qDebug("Wrong offset1 "); |
325 | return 0; | 324 | return 0; |
326 | } | 325 | } |
327 | return mHolidays[offset]; | 326 | return mHolidays[offset]; |
328 | } | 327 | } |
329 | 328 | ||
330 | int KODayMatrix::getDayIndexFrom(int x, int y) | 329 | int KODayMatrix::getDayIndexFrom(int x, int y) |
331 | { | 330 | { |
332 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 331 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
333 | 6 - x/daysize.width() : x/daysize.width()); | 332 | 6 - x/daysize.width() : x/daysize.width()); |
334 | } | 333 | } |
335 | 334 | ||
336 | // ---------------------------------------------------------------------------- | 335 | // ---------------------------------------------------------------------------- |
337 | // M O U S E E V E N T H A N D L I N G | 336 | // M O U S E E V E N T H A N D L I N G |
338 | // ---------------------------------------------------------------------------- | 337 | // ---------------------------------------------------------------------------- |
339 | 338 | ||
340 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 339 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
341 | { | 340 | { |
342 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 341 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
343 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 342 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
344 | mSelInit = mSelStart; | 343 | mSelInit = mSelStart; |
345 | } | 344 | } |
346 | 345 | ||
347 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 346 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
348 | { | 347 | { |
349 | 348 | ||
350 | int tmp = getDayIndexFrom(e->x(), e->y()); | 349 | int tmp = getDayIndexFrom(e->x(), e->y()); |
351 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 350 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
352 | 351 | ||
353 | if (mSelInit > tmp) { | 352 | if (mSelInit > tmp) { |
354 | mSelEnd = mSelInit; | 353 | mSelEnd = mSelInit; |
355 | if (tmp != mSelStart) { | 354 | if (tmp != mSelStart) { |
356 | mSelStart = tmp; | 355 | mSelStart = tmp; |
357 | repaint(); | 356 | repaint(); |
358 | } | 357 | } |
359 | } else { | 358 | } else { |
360 | mSelStart = mSelInit; | 359 | mSelStart = mSelInit; |
361 | 360 | ||
362 | //repaint only if selection has changed | 361 | //repaint only if selection has changed |
363 | if (tmp != mSelEnd) { | 362 | if (tmp != mSelEnd) { |
364 | mSelEnd = tmp; | 363 | mSelEnd = tmp; |
365 | repaint(); | 364 | repaint(); |
366 | } | 365 | } |
367 | } | 366 | } |
368 | 367 | ||
369 | DateList daylist; | 368 | DateList daylist; |
370 | if ( mSelStart < 0 ) | 369 | if ( mSelStart < 0 ) |
371 | mSelStart = 0; | 370 | mSelStart = 0; |
372 | for (int i = mSelStart; i <= mSelEnd; i++) { | 371 | for (int i = mSelStart; i <= mSelEnd; i++) { |
373 | daylist.append(days[i]); | 372 | daylist.append(days[i]); |
374 | } | 373 | } |
375 | emit selected((const DateList)daylist); | 374 | emit selected((const DateList)daylist); |
376 | 375 | ||
377 | } | 376 | } |
378 | 377 | ||
379 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 378 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
380 | { | 379 | { |
381 | int tmp = getDayIndexFrom(e->x(), e->y()); | 380 | int tmp = getDayIndexFrom(e->x(), e->y()); |
382 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 381 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
383 | 382 | ||
384 | if (mSelInit > tmp) { | 383 | if (mSelInit > tmp) { |
385 | mSelEnd = mSelInit; | 384 | mSelEnd = mSelInit; |
386 | if (tmp != mSelStart) { | 385 | if (tmp != mSelStart) { |
387 | mSelStart = tmp; | 386 | mSelStart = tmp; |
388 | repaint(); | 387 | repaint(); |
389 | } | 388 | } |
390 | } else { | 389 | } else { |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 2f5259f..8d8fc2a 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -660,209 +660,209 @@ void KOTodoView::restoreItemState( QListViewItem *item ) | |||
660 | } | 660 | } |
661 | 661 | ||
662 | 662 | ||
663 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 663 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
664 | KOTodoView::insertTodoItem(Todo *todo) | 664 | KOTodoView::insertTodoItem(Todo *todo) |
665 | { | 665 | { |
666 | 666 | ||
667 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 667 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
668 | // TODO: Check, if dynmaic cast is necessary | 668 | // TODO: Check, if dynmaic cast is necessary |
669 | 669 | ||
670 | pendingSubtodo = 0; | 670 | pendingSubtodo = 0; |
671 | Incidence *incidence = todo->relatedTo(); | 671 | Incidence *incidence = todo->relatedTo(); |
672 | if (incidence && incidence->type() == "Todo") { | 672 | if (incidence && incidence->type() == "Todo") { |
673 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 673 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
674 | 674 | ||
675 | // kdDebug() << " has Related" << endl; | 675 | // kdDebug() << " has Related" << endl; |
676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
677 | itemIterator = mTodoMap.find(relatedTodo); | 677 | itemIterator = mTodoMap.find(relatedTodo); |
678 | if (itemIterator == mTodoMap.end()) { | 678 | if (itemIterator == mTodoMap.end()) { |
679 | // kdDebug() << " related not yet in list" << endl; | 679 | // kdDebug() << " related not yet in list" << endl; |
680 | itemIterator = insertTodoItem (relatedTodo); | 680 | itemIterator = insertTodoItem (relatedTodo); |
681 | } | 681 | } |
682 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 682 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
683 | // and one into the map. Sure finding is more easy but why? -zecke | 683 | // and one into the map. Sure finding is more easy but why? -zecke |
684 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 684 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
685 | return mTodoMap.insert(todo,todoItem); | 685 | return mTodoMap.insert(todo,todoItem); |
686 | } else { | 686 | } else { |
687 | // kdDebug() << " no Related" << endl; | 687 | // kdDebug() << " no Related" << endl; |
688 | // see above -zecke | 688 | // see above -zecke |
689 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 689 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
690 | return mTodoMap.insert(todo,todoItem); | 690 | return mTodoMap.insert(todo,todoItem); |
691 | } | 691 | } |
692 | } | 692 | } |
693 | 693 | ||
694 | 694 | ||
695 | void KOTodoView::updateConfig() | 695 | void KOTodoView::updateConfig() |
696 | { | 696 | { |
697 | updateView(); | 697 | updateView(); |
698 | mTodoListView->repaintContents(); | 698 | mTodoListView->repaintContents(); |
699 | } | 699 | } |
700 | 700 | ||
701 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 701 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
702 | { | 702 | { |
703 | QPtrList<Incidence> selected; | 703 | QPtrList<Incidence> selected; |
704 | 704 | ||
705 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 705 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
706 | // if (!item) item = mActiveItem; | 706 | // if (!item) item = mActiveItem; |
707 | if (item) selected.append(item->todo()); | 707 | if (item) selected.append(item->todo()); |
708 | 708 | ||
709 | return selected; | 709 | return selected; |
710 | } | 710 | } |
711 | 711 | ||
712 | QPtrList<Todo> KOTodoView::selectedTodos() | 712 | QPtrList<Todo> KOTodoView::selectedTodos() |
713 | { | 713 | { |
714 | QPtrList<Todo> selected; | 714 | QPtrList<Todo> selected; |
715 | 715 | ||
716 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 716 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
717 | // if (!item) item = mActiveItem; | 717 | // if (!item) item = mActiveItem; |
718 | if (item) selected.append(item->todo()); | 718 | if (item) selected.append(item->todo()); |
719 | 719 | ||
720 | return selected; | 720 | return selected; |
721 | } | 721 | } |
722 | 722 | ||
723 | void KOTodoView::changeEventDisplay(Event *, int) | 723 | void KOTodoView::changeEventDisplay(Event *, int) |
724 | { | 724 | { |
725 | updateView(); | 725 | updateView(); |
726 | } | 726 | } |
727 | 727 | ||
728 | void KOTodoView::showDates(const QDate &, const QDate &) | 728 | void KOTodoView::showDates(const QDate &, const QDate &) |
729 | { | 729 | { |
730 | } | 730 | } |
731 | 731 | ||
732 | void KOTodoView::showEvents(QPtrList<Event>) | 732 | void KOTodoView::showEvents(QPtrList<Event>) |
733 | { | 733 | { |
734 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 734 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
735 | } | 735 | } |
736 | 736 | ||
737 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 737 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
738 | const QDate &td) | 738 | const QDate &td) |
739 | { | 739 | { |
740 | #ifndef KORG_NOPRINTER | 740 | #ifndef KORG_NOPRINTER |
741 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 741 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
742 | #endif | 742 | #endif |
743 | } | 743 | } |
744 | 744 | ||
745 | void KOTodoView::editItem(QListViewItem *item ) | 745 | void KOTodoView::editItem(QListViewItem *item ) |
746 | { | 746 | { |
747 | // qDebug("editItem(QListViewItem *item ) "); | 747 | // qDebug("editItem(QListViewItem *item ) "); |
748 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 748 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
749 | } | 749 | } |
750 | 750 | ||
751 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 751 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
752 | { | 752 | { |
753 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 753 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
754 | } | 754 | } |
755 | 755 | ||
756 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | 756 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
757 | { | 757 | { |
758 | pendingSubtodo = 0; | 758 | pendingSubtodo = 0; |
759 | mActiveItem = (KOTodoViewItem *)item; | 759 | mActiveItem = (KOTodoViewItem *)item; |
760 | if (item) { | 760 | if (item) { |
761 | switch (column){ | 761 | switch (column){ |
762 | case 1: | 762 | case 1: |
763 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 763 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
764 | case 2: | 764 | case 2: |
765 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 765 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
766 | case 3: | 766 | case 3: |
767 | moveTodo(); | 767 | moveTodo(); |
768 | break; | 768 | break; |
769 | case 8: | 769 | case 8: |
770 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 770 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
771 | default: | 771 | default: |
772 | mItemPopupMenu->popup(QCursor::pos()); | 772 | mItemPopupMenu->popup(QCursor::pos()); |
773 | } | 773 | } |
774 | } else mPopupMenu->popup(QCursor::pos()); | 774 | } else mPopupMenu->popup(QCursor::pos()); |
775 | } | 775 | } |
776 | void KOTodoView::newTodo() | 776 | void KOTodoView::newTodo() |
777 | { | 777 | { |
778 | emit newTodoSignal(); | 778 | emit newTodoSignal(); |
779 | } | 779 | } |
780 | 780 | ||
781 | void KOTodoView::newSubTodo() | 781 | void KOTodoView::newSubTodo() |
782 | { | 782 | { |
783 | if (mActiveItem) { | 783 | if (mActiveItem) { |
784 | emit newSubTodoSignal(mActiveItem->todo()); | 784 | emit newSubTodoSignal(mActiveItem->todo()); |
785 | } | 785 | } |
786 | } | 786 | } |
787 | void KOTodoView::unparentTodo() | 787 | void KOTodoView::unparentTodo() |
788 | { | 788 | { |
789 | if (mActiveItem) { | 789 | if (mActiveItem) { |
790 | emit unparentTodoSignal(mActiveItem->todo()); | 790 | emit unparentTodoSignal(mActiveItem->todo()); |
791 | } | 791 | } |
792 | } | 792 | } |
793 | 793 | ||
794 | void KOTodoView::reparentTodo() | 794 | void KOTodoView::reparentTodo() |
795 | { | 795 | { |
796 | if (mActiveItem) { | 796 | if (mActiveItem) { |
797 | qDebug("KOTodoView::reparentTodo() "); | 797 | qDebug("KOTodoView::reparentTodo() "); |
798 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 798 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
799 | pendingSubtodo = mActiveItem; | 799 | pendingSubtodo = mActiveItem; |
800 | } | 800 | } |
801 | } | 801 | } |
802 | void KOTodoView::editTodo() | 802 | void KOTodoView::editTodo() |
803 | { | 803 | { |
804 | if (mActiveItem) { | 804 | if (mActiveItem) { |
805 | emit editTodoSignal(mActiveItem->todo()); | 805 | emit editTodoSignal(mActiveItem->todo()); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | void KOTodoView::cloneTodo() | 808 | void KOTodoView::cloneTodo() |
809 | { | 809 | { |
810 | if (mActiveItem) { | 810 | if (mActiveItem) { |
811 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 811 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
812 | } | 812 | } |
813 | } | 813 | } |
814 | void KOTodoView::cancelTodo() | 814 | void KOTodoView::cancelTodo() |
815 | { | 815 | { |
816 | if (mActiveItem) { | 816 | if (mActiveItem) { |
817 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 817 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | void KOTodoView::moveTodo() | 820 | void KOTodoView::moveTodo() |
821 | { | 821 | { |
822 | if (mActiveItem) { | 822 | if (mActiveItem) { |
823 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 823 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | void KOTodoView::beamTodo() | 826 | void KOTodoView::beamTodo() |
827 | { | 827 | { |
828 | if (mActiveItem) { | 828 | if (mActiveItem) { |
829 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 829 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
830 | } | 830 | } |
831 | } | 831 | } |
832 | 832 | ||
833 | 833 | ||
834 | void KOTodoView::showTodo() | 834 | void KOTodoView::showTodo() |
835 | { | 835 | { |
836 | if (mActiveItem) { | 836 | if (mActiveItem) { |
837 | emit showTodoSignal(mActiveItem->todo()); | 837 | emit showTodoSignal(mActiveItem->todo()); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | 840 | ||
841 | void KOTodoView::deleteTodo() | 841 | void KOTodoView::deleteTodo() |
842 | { | 842 | { |
843 | if (mActiveItem) { | 843 | if (mActiveItem) { |
844 | emit deleteTodoSignal(mActiveItem->todo()); | 844 | emit deleteTodoSignal(mActiveItem->todo()); |
845 | } | 845 | } |
846 | } | 846 | } |
847 | 847 | ||
848 | void KOTodoView::setNewPriority(int index) | 848 | void KOTodoView::setNewPriority(int index) |
849 | { | 849 | { |
850 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 850 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
851 | mActiveItem->todo()->setPriority(mPriority[index]); | 851 | mActiveItem->todo()->setPriority(mPriority[index]); |
852 | mActiveItem->construct(); | 852 | mActiveItem->construct(); |
853 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 853 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
854 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 854 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
855 | } | 855 | } |
856 | } | 856 | } |
857 | 857 | ||
858 | void KOTodoView::setNewPercentage(int index) | 858 | void KOTodoView::setNewPercentage(int index) |
859 | { | 859 | { |
860 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 860 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
861 | 861 | ||
862 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 862 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
863 | mActiveItem->setOn( true ); | 863 | mActiveItem->setOn( true ); |
864 | return; | 864 | return; |
865 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 865 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
866 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 866 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
867 | if ( par && par->isOn() ) | 867 | if ( par && par->isOn() ) |
868 | par->setOn( false ); | 868 | par->setOn( false ); |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 4c03f9a..35774d6 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -24,195 +24,197 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void KOViewManager::showDateView( int view, QDate date) | 102 | void KOViewManager::showDateView( int view, QDate date) |
103 | { | 103 | { |
104 | 104 | ||
105 | //qDebug("date %d %s", view, date.toString().latin1()); | 105 | //qDebug("date %d %s", view, date.toString().latin1()); |
106 | #if 0 | 106 | #if 0 |
107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); | 108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); |
109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); | 109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); |
110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); | 110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); |
111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
112 | #endif | 112 | #endif |
113 | if ( view == 3 ) { | 113 | if ( view == 3 ) { |
114 | mMainView->showDay( date ); | 114 | mMainView->showDay( date ); |
115 | } else if (view == 4 ) { | 115 | } else if (view == 4 ) { |
116 | mMainView->dateNavigator()->selectDates( date, 7 ); | 116 | mMainView->dateNavigator()->selectDates( date, 7 ); |
117 | } else if (view == 5 ) { | 117 | } else if (view == 5 ) { |
118 | mMainView->dateNavigator()->selectDates( date, 14); | 118 | mMainView->dateNavigator()->selectDates( date, 14); |
119 | } else if (view == 6 ) { | 119 | } else if (view == 6 ) { |
120 | showMonthView(); | 120 | mMainView->dateNavigator()->blockSignals( true ); |
121 | mMainView->dateNavigator()->selectMonthByDate( date ); | 121 | mMainView->dateNavigator()->selectMonthByDate( date ); |
122 | mMainView->dateNavigator()->selectDate( date ); | 122 | mMainView->dateNavigator()->selectDate( date ); |
123 | mMainView->dateNavigator()->blockSignals( false ); | ||
124 | showMonthView(); | ||
123 | } else if (view == 7 ) { | 125 | } else if (view == 7 ) { |
124 | mMainView->dateNavigator()->selectDate( date ); | 126 | mMainView->dateNavigator()->selectDate( date ); |
125 | showJournalView(); | 127 | showJournalView(); |
126 | } else if (view == 8 ) { | 128 | } else if (view == 8 ) { |
127 | globalFlagBlockAgenda = 1; | 129 | globalFlagBlockAgenda = 1; |
128 | if ( mCurrentAgendaView != 3 ) | 130 | if ( mCurrentAgendaView != 3 ) |
129 | mCurrentAgendaView = -1; | 131 | mCurrentAgendaView = -1; |
130 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 132 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
131 | globalFlagBlockAgenda = 2; | 133 | globalFlagBlockAgenda = 2; |
132 | mMainView->dateNavigator()->selectDates( date , | 134 | mMainView->dateNavigator()->selectDates( date , |
133 | KOPrefs::instance()->mNextXDays ); | 135 | KOPrefs::instance()->mNextXDays ); |
134 | mFlagShowNextxDays = true; | 136 | mFlagShowNextxDays = true; |
135 | mCurrentAgendaView = 3 ; | 137 | mCurrentAgendaView = 3 ; |
136 | } | 138 | } |
137 | 139 | ||
138 | #if 0 | 140 | #if 0 |
139 | dateNavigator()->blockSignals( true ); | 141 | dateNavigator()->blockSignals( true ); |
140 | dateNavigator()->selectDate( d ); | 142 | dateNavigator()->selectDate( d ); |
141 | dateNavigator()->blockSignals( false ); | 143 | dateNavigator()->blockSignals( false ); |
142 | mViewManager->showDayView(); | 144 | mViewManager->showDayView(); |
143 | #endif | 145 | #endif |
144 | 146 | ||
145 | } | 147 | } |
146 | 148 | ||
147 | 149 | ||
148 | 150 | ||
149 | void KOViewManager::writeSettings(KConfig *config) | 151 | void KOViewManager::writeSettings(KConfig *config) |
150 | { | 152 | { |
151 | config->setGroup("General"); | 153 | config->setGroup("General"); |
152 | 154 | ||
153 | QString view; | 155 | QString view; |
154 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 156 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
155 | else if (mCurrentView == mMonthView) view = "Month"; | 157 | else if (mCurrentView == mMonthView) view = "Month"; |
156 | else if (mCurrentView == mListView) view = "List"; | 158 | else if (mCurrentView == mListView) view = "List"; |
157 | else if (mCurrentView == mJournalView) view = "Journal"; | 159 | else if (mCurrentView == mJournalView) view = "Journal"; |
158 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 160 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
159 | else if (mCurrentView == mTodoView) view = "Todo"; | 161 | else if (mCurrentView == mTodoView) view = "Todo"; |
160 | else view = "Agenda"; | 162 | else view = "Agenda"; |
161 | 163 | ||
162 | config->writeEntry("Current View",view); | 164 | config->writeEntry("Current View",view); |
163 | 165 | ||
164 | if (mAgendaView) { | 166 | if (mAgendaView) { |
165 | mAgendaView->writeSettings(config); | 167 | mAgendaView->writeSettings(config); |
166 | } | 168 | } |
167 | if (mTimeSpanView) { | 169 | if (mTimeSpanView) { |
168 | mTimeSpanView->writeSettings(config); | 170 | mTimeSpanView->writeSettings(config); |
169 | } | 171 | } |
170 | if (mListView) { | 172 | if (mListView) { |
171 | mListView->writeSettings(config); | 173 | mListView->writeSettings(config); |
172 | } | 174 | } |
173 | if (mTodoView) { | 175 | if (mTodoView) { |
174 | mTodoView->saveLayout(config,"Todo View"); | 176 | mTodoView->saveLayout(config,"Todo View"); |
175 | } | 177 | } |
176 | } | 178 | } |
177 | 179 | ||
178 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 180 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
179 | { | 181 | { |
180 | 182 | ||
181 | //mFlagShowNextxDays = false; | 183 | //mFlagShowNextxDays = false; |
182 | //if(view == mCurrentView) return; | 184 | //if(view == mCurrentView) return; |
183 | if ( view == 0 ) { | 185 | if ( view == 0 ) { |
184 | view = mCurrentView; | 186 | view = mCurrentView; |
185 | if ( view == 0 ) | 187 | if ( view == 0 ) |
186 | return; | 188 | return; |
187 | } | 189 | } |
188 | bool full = fullScreen; | 190 | bool full = fullScreen; |
189 | if(view == mCurrentView && view != mWhatsNextView ) { | 191 | if(view == mCurrentView && view != mWhatsNextView ) { |
190 | if ( mCurrentAgendaView < 0 ) | 192 | if ( mCurrentAgendaView < 0 ) |
191 | return; | 193 | return; |
192 | full = mMainView->leftFrame()->isVisible(); | 194 | full = mMainView->leftFrame()->isVisible(); |
193 | } else { | 195 | } else { |
194 | mCurrentView = view; | 196 | mCurrentView = view; |
195 | // bool full = fullScreen; | 197 | // bool full = fullScreen; |
196 | bool isFull = !mMainView->leftFrame()->isVisible(); | 198 | bool isFull = !mMainView->leftFrame()->isVisible(); |
197 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 199 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
198 | full = true; | 200 | full = true; |
199 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 201 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
200 | full = false; | 202 | full = false; |
201 | } | 203 | } |
202 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 204 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
203 | //raiseCurrentView( full ); | 205 | //raiseCurrentView( full ); |
204 | mMainView->processIncidenceSelection( 0 ); | 206 | mMainView->processIncidenceSelection( 0 ); |
205 | mMainView->updateView(); | 207 | mMainView->updateView(); |
206 | raiseCurrentView( full ); | 208 | raiseCurrentView( full ); |
207 | mMainView->adaptNavigationUnits(); | 209 | mMainView->adaptNavigationUnits(); |
208 | } | 210 | } |
209 | 211 | ||
210 | void KOViewManager::raiseCurrentView( bool fullScreen ) | 212 | void KOViewManager::raiseCurrentView( bool fullScreen ) |
211 | { | 213 | { |
212 | mCurrentAgendaView = 0; | 214 | mCurrentAgendaView = 0; |
213 | int wid = mMainView->width() ; | 215 | int wid = mMainView->width() ; |
214 | int hei = mMainView->height(); | 216 | int hei = mMainView->height(); |
215 | if ( mCurrentView == mMonthView ) { | 217 | if ( mCurrentView == mMonthView ) { |
216 | mMainView->navigatorBar()->show(); | 218 | mMainView->navigatorBar()->show(); |
217 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 219 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
218 | //mMainView->navigatorBar()->hide(); | 220 | //mMainView->navigatorBar()->hide(); |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index d7ff9f2..10665f4 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -84,192 +84,193 @@ void WhatsNextTextBrowser::printMe() | |||
84 | #endif | 84 | #endif |
85 | } | 85 | } |
86 | 86 | ||
87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
88 | const char *name) | 88 | const char *name) |
89 | : KOrg::BaseView(calendar, parent, name) | 89 | : KOrg::BaseView(calendar, parent, name) |
90 | { | 90 | { |
91 | // mDateLabel = | 91 | // mDateLabel = |
92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
93 | // mDateLabel->setMargin(2); | 93 | // mDateLabel->setMargin(2); |
94 | // mDateLabel->setAlignment(AlignCenter); | 94 | // mDateLabel->setAlignment(AlignCenter); |
95 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 95 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
96 | mView = new WhatsNextTextBrowser(this); | 96 | mView = new WhatsNextTextBrowser(this); |
97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
98 | QStyleSheet* stsh = mView->styleSheet(); | 98 | QStyleSheet* stsh = mView->styleSheet(); |
99 | QStyleSheetItem * style ; | 99 | QStyleSheetItem * style ; |
100 | style = stsh->item ("h2" ); | 100 | style = stsh->item ("h2" ); |
101 | if ( style ) { | 101 | if ( style ) { |
102 | style->setMargin(QStyleSheetItem::MarginAll,0); | 102 | style->setMargin(QStyleSheetItem::MarginAll,0); |
103 | } | 103 | } |
104 | style = stsh->item ("h3" ); | 104 | style = stsh->item ("h3" ); |
105 | if ( style ) { | 105 | if ( style ) { |
106 | style->setMargin(QStyleSheetItem::MarginAll,0); | 106 | style->setMargin(QStyleSheetItem::MarginAll,0); |
107 | } | 107 | } |
108 | mEventViewer = 0; | 108 | mEventViewer = 0; |
109 | 109 | ||
110 | QBoxLayout *topLayout = new QVBoxLayout(this); | 110 | QBoxLayout *topLayout = new QVBoxLayout(this); |
111 | // topLayout->addWidget(mDateLabel); | 111 | // topLayout->addWidget(mDateLabel); |
112 | topLayout->addWidget(mView); | 112 | topLayout->addWidget(mView); |
113 | mTimer = new QTimer( this ); | 113 | mTimer = new QTimer( this ); |
114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
115 | 115 | ||
116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
118 | } | 118 | } |
119 | 119 | ||
120 | KOWhatsNextView::~KOWhatsNextView() | 120 | KOWhatsNextView::~KOWhatsNextView() |
121 | { | 121 | { |
122 | } | 122 | } |
123 | 123 | ||
124 | int KOWhatsNextView::maxDatesHint() | 124 | int KOWhatsNextView::maxDatesHint() |
125 | { | 125 | { |
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
128 | 128 | ||
129 | int KOWhatsNextView::currentDateCount() | 129 | int KOWhatsNextView::currentDateCount() |
130 | { | 130 | { |
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | 133 | ||
134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
135 | { | 135 | { |
136 | QPtrList<Incidence> eventList; | 136 | QPtrList<Incidence> eventList; |
137 | 137 | ||
138 | return eventList; | 138 | return eventList; |
139 | } | 139 | } |
140 | 140 | ||
141 | void KOWhatsNextView::printMe() | 141 | void KOWhatsNextView::printMe() |
142 | { | 142 | { |
143 | #ifdef DESKTOP_VERSION | 143 | #ifdef DESKTOP_VERSION |
144 | mView->printMe(); | 144 | mView->printMe(); |
145 | #endif | 145 | #endif |
146 | } | 146 | } |
147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
148 | const QDate &td) | 148 | const QDate &td) |
149 | { | 149 | { |
150 | #ifndef KORG_NOPRINTER | 150 | #ifndef KORG_NOPRINTER |
151 | calPrinter->preview(CalPrinter::Day, fd, td); | 151 | calPrinter->preview(CalPrinter::Day, fd, td); |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | void KOWhatsNextView::updateConfig() | 154 | void KOWhatsNextView::updateConfig() |
155 | { | 155 | { |
156 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 156 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
157 | updateView(); | 157 | updateView(); |
158 | 158 | ||
159 | } | 159 | } |
160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
161 | { | 161 | { |
162 | //qDebug("KOWhatsNextView::showEvent "); | 162 | //qDebug("KOWhatsNextView::showEvent "); |
163 | restartTimer(); | 163 | restartTimer(); |
164 | QWidget::showEvent ( e ); | 164 | QWidget::showEvent ( e ); |
165 | } | 165 | } |
166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
167 | { | 167 | { |
168 | //qDebug(" KOWhatsNextView::hideEvent"); | 168 | //qDebug(" KOWhatsNextView::hideEvent"); |
169 | mTimer->stop(); | 169 | mTimer->stop(); |
170 | QWidget::hideEvent ( e ); | 170 | QWidget::hideEvent ( e ); |
171 | } | 171 | } |
172 | void KOWhatsNextView::restartTimer() | 172 | void KOWhatsNextView::restartTimer() |
173 | { | 173 | { |
174 | //qDebug("KOWhatsNextView::restartTimer() "); | 174 | //qDebug("KOWhatsNextView::restartTimer() "); |
175 | mTimer->start( 300000 ); | 175 | mTimer->start( 300000 ); |
176 | //mTimer->start( 5000 ); | 176 | //mTimer->start( 5000 ); |
177 | } | 177 | } |
178 | void KOWhatsNextView::updateView() | 178 | void KOWhatsNextView::updateView() |
179 | { | 179 | { |
180 | //qDebug("KOWhatsNextView::updateView() "); | ||
180 | if ( mTimer->isActive() ) | 181 | if ( mTimer->isActive() ) |
181 | restartTimer(); | 182 | restartTimer(); |
182 | //qDebug("KOWhatsNextView::updateView() "); | 183 | //qDebug("KOWhatsNextView::updateView() "); |
183 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 184 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
184 | KIconLoader kil("korganizer"); | 185 | KIconLoader kil("korganizer"); |
185 | QString ipath;// = new QString(); | 186 | QString ipath;// = new QString(); |
186 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 187 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
187 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 188 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
188 | mText = "<table width=\"100%\">\n"; | 189 | mText = "<table width=\"100%\">\n"; |
189 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 190 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
190 | #ifdef DESKTOP_VERSION | 191 | #ifdef DESKTOP_VERSION |
191 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 192 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
192 | #else | 193 | #else |
193 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 194 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
194 | #endif | 195 | #endif |
195 | // mText += "<img src=\""; | 196 | // mText += "<img src=\""; |
196 | // mText += ipath; | 197 | // mText += ipath; |
197 | // mText += "\">"; | 198 | // mText += "\">"; |
198 | mEventDate = QDate::currentDate(); | 199 | mEventDate = QDate::currentDate(); |
199 | #ifdef DESKTOP_VERSION | 200 | #ifdef DESKTOP_VERSION |
200 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 201 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
201 | #else | 202 | #else |
202 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 203 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
203 | #endif | 204 | #endif |
204 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 205 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
205 | int iii; | 206 | int iii; |
206 | mTodos.clear(); | 207 | mTodos.clear(); |
207 | QPtrList<Event> events; | 208 | QPtrList<Event> events; |
208 | QPtrList<Todo> todos = calendar()->todos(); | 209 | QPtrList<Todo> todos = calendar()->todos(); |
209 | Todo * todo; | 210 | Todo * todo; |
210 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 211 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
211 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 212 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
212 | bool itemAdded = false; | 213 | bool itemAdded = false; |
213 | for ( iii = 0; iii < daysToShow; ++iii ) { | 214 | for ( iii = 0; iii < daysToShow; ++iii ) { |
214 | QString date; | 215 | QString date; |
215 | itemAdded = false; | 216 | itemAdded = false; |
216 | events = calendar()->events( mEventDate, true ); | 217 | events = calendar()->events( mEventDate, true ); |
217 | 218 | ||
218 | if ( iii == 0 ) { // today !!! | 219 | if ( iii == 0 ) { // today !!! |
219 | todo = todos.first(); | 220 | todo = todos.first(); |
220 | while(todo) { | 221 | while(todo) { |
221 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 222 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
222 | if ( ! itemAdded ) { | 223 | if ( ! itemAdded ) { |
223 | appendDay ( iii, mEventDate ); | 224 | appendDay ( iii, mEventDate ); |
224 | //itemAdded = true; | 225 | //itemAdded = true; |
225 | 226 | ||
226 | } //bool reply=false, bool notRed = true, bool appendTable = false); | 227 | } //bool reply=false, bool notRed = true, bool appendTable = false); |
227 | appendEvent(todo, false, false, !itemAdded ); | 228 | appendEvent(todo, false, false, !itemAdded ); |
228 | itemAdded = true; | 229 | itemAdded = true; |
229 | } | 230 | } |
230 | todo = todos.next(); | 231 | todo = todos.next(); |
231 | } | 232 | } |
232 | } | 233 | } |
233 | 234 | ||
234 | 235 | ||
235 | if (events.count() > 0) { | 236 | if (events.count() > 0) { |
236 | // mText += "<p></p>"; | 237 | // mText += "<p></p>"; |
237 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 238 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
238 | // mText += "<h2>"; | 239 | // mText += "<h2>"; |
239 | //mText += " <img src=\""; | 240 | //mText += " <img src=\""; |
240 | //mText += ipath; | 241 | //mText += ipath; |
241 | //mText += "\">"; | 242 | //mText += "\">"; |
242 | if ( ! itemAdded ) { | 243 | if ( ! itemAdded ) { |
243 | appendDay ( iii, mEventDate ); | 244 | appendDay ( iii, mEventDate ); |
244 | 245 | ||
245 | } | 246 | } |
246 | // for first day (iii == 0) | 247 | // for first day (iii == 0) |
247 | // we may have syncevents, or events in the past, which maybe should not be diaplayed | 248 | // we may have syncevents, or events in the past, which maybe should not be diaplayed |
248 | // for that reason we cannot append <table> in appendDay () for iii == 0 | 249 | // for that reason we cannot append <table> in appendDay () for iii == 0 |
249 | // we must append it in the first successful call of appendEvent() | 250 | // we must append it in the first successful call of appendEvent() |
250 | Event *ev = events.first(); | 251 | Event *ev = events.first(); |
251 | while(ev) { | 252 | while(ev) { |
252 | //qDebug("+++++event append %s", ev->summary().latin1()); | 253 | //qDebug("+++++event append %s", ev->summary().latin1()); |
253 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 254 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
254 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) | 255 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) |
255 | itemAdded = true; | 256 | itemAdded = true; |
256 | } | 257 | } |
257 | ev = events.next(); | 258 | ev = events.next(); |
258 | } | 259 | } |
259 | 260 | ||
260 | //mText += "</table>\n"; | 261 | //mText += "</table>\n"; |
261 | } | 262 | } |
262 | 263 | ||
263 | todo = todos.first(); | 264 | todo = todos.first(); |
264 | while(todo) { | 265 | while(todo) { |
265 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 266 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
266 | if ( ! itemAdded ) { | 267 | if ( ! itemAdded ) { |
267 | appendDay ( iii, mEventDate ); | 268 | appendDay ( iii, mEventDate ); |
268 | //itemAdded = true; | 269 | //itemAdded = true; |
269 | } | 270 | } |
270 | appendEvent(todo, false , iii!= 0,!itemAdded); | 271 | appendEvent(todo, false , iii!= 0,!itemAdded); |
271 | itemAdded = true; | 272 | itemAdded = true; |
272 | } | 273 | } |
273 | todo = todos.next(); | 274 | todo = todos.next(); |
274 | } | 275 | } |
275 | if ( !itemAdded && iii == 0 ) { | 276 | if ( !itemAdded && iii == 0 ) { |