-rw-r--r-- | korganizer/koagenda.cpp | 8 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 3 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 6 |
4 files changed, 18 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index ed7a443..1a24887 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -268,384 +268,392 @@ void KOAgenda::init() | |||
268 | mCurrentCellY = 0; | 268 | mCurrentCellY = 0; |
269 | 269 | ||
270 | mSelectionCellX = 0; | 270 | mSelectionCellX = 0; |
271 | mSelectionYTop = 0; | 271 | mSelectionYTop = 0; |
272 | mSelectionHeight = 0; | 272 | mSelectionHeight = 0; |
273 | 273 | ||
274 | mOldLowerScrollValue = -1; | 274 | mOldLowerScrollValue = -1; |
275 | mOldUpperScrollValue = -1; | 275 | mOldUpperScrollValue = -1; |
276 | 276 | ||
277 | mClickedItem = 0; | 277 | mClickedItem = 0; |
278 | 278 | ||
279 | mActionItem = 0; | 279 | mActionItem = 0; |
280 | mActionType = NOP; | 280 | mActionType = NOP; |
281 | mItemMoved = false; | 281 | mItemMoved = false; |
282 | 282 | ||
283 | mSelectedItem = 0; | 283 | mSelectedItem = 0; |
284 | 284 | ||
285 | // mItems.setAutoDelete(true); | 285 | // mItems.setAutoDelete(true); |
286 | 286 | ||
287 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 287 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
288 | 288 | ||
289 | viewport()->update(); | 289 | viewport()->update(); |
290 | 290 | ||
291 | setMinimumSize(30, 1); | 291 | setMinimumSize(30, 1); |
292 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 292 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
293 | 293 | ||
294 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 294 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
295 | // controlled in a way that the contents horizontally always fits. Then it is | 295 | // controlled in a way that the contents horizontally always fits. Then it is |
296 | // not necessary to turn off the scrollbar. | 296 | // not necessary to turn off the scrollbar. |
297 | setHScrollBarMode(AlwaysOff); | 297 | setHScrollBarMode(AlwaysOff); |
298 | if ( ! mAllDayMode ) | 298 | if ( ! mAllDayMode ) |
299 | setVScrollBarMode(AlwaysOn); | 299 | setVScrollBarMode(AlwaysOn); |
300 | else | 300 | else |
301 | setVScrollBarMode(AlwaysOff); | 301 | setVScrollBarMode(AlwaysOff); |
302 | 302 | ||
303 | setStartHour(KOPrefs::instance()->mDayBegins); | 303 | setStartHour(KOPrefs::instance()->mDayBegins); |
304 | 304 | ||
305 | calculateWorkingHours(); | 305 | calculateWorkingHours(); |
306 | 306 | ||
307 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 307 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
308 | SLOT(checkScrollBoundaries(int))); | 308 | SLOT(checkScrollBoundaries(int))); |
309 | 309 | ||
310 | // Create the Marcus Bains line. | 310 | // Create the Marcus Bains line. |
311 | if(mAllDayMode) | 311 | if(mAllDayMode) |
312 | mMarcusBains = 0; | 312 | mMarcusBains = 0; |
313 | else { | 313 | else { |
314 | mMarcusBains = new MarcusBains(this); | 314 | mMarcusBains = new MarcusBains(this); |
315 | addChild(mMarcusBains); | 315 | addChild(mMarcusBains); |
316 | } | 316 | } |
317 | mPopupKind = 0; | 317 | mPopupKind = 0; |
318 | mPopupItem = 0; | 318 | mPopupItem = 0; |
319 | } | 319 | } |
320 | 320 | ||
321 | void KOAgenda::clear() | 321 | void KOAgenda::clear() |
322 | { | 322 | { |
323 | KOAgendaItem *item; | 323 | KOAgendaItem *item; |
324 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 324 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
325 | mUnusedItems.append( item ); | 325 | mUnusedItems.append( item ); |
326 | //item->hide(); | 326 | //item->hide(); |
327 | } | 327 | } |
328 | mItems.clear(); | 328 | mItems.clear(); |
329 | mSelectedItem = 0; | 329 | mSelectedItem = 0; |
330 | clearSelection(); | 330 | clearSelection(); |
331 | } | 331 | } |
332 | 332 | ||
333 | void KOAgenda::clearSelection() | 333 | void KOAgenda::clearSelection() |
334 | { | 334 | { |
335 | mSelectionCellX = 0; | 335 | mSelectionCellX = 0; |
336 | mSelectionYTop = 0; | 336 | mSelectionYTop = 0; |
337 | mSelectionHeight = 0; | 337 | mSelectionHeight = 0; |
338 | } | 338 | } |
339 | 339 | ||
340 | void KOAgenda::marcus_bains() | 340 | void KOAgenda::marcus_bains() |
341 | { | 341 | { |
342 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 342 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | void KOAgenda::changeColumns(int columns) | 346 | void KOAgenda::changeColumns(int columns) |
347 | { | 347 | { |
348 | if (columns == 0) { | 348 | if (columns == 0) { |
349 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 349 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
350 | return; | 350 | return; |
351 | } | 351 | } |
352 | clear(); | 352 | clear(); |
353 | mColumns = columns; | 353 | mColumns = columns; |
354 | computeSizes(); | 354 | computeSizes(); |
355 | } | 355 | } |
356 | 356 | ||
357 | /* | 357 | /* |
358 | This is the eventFilter function, which gets all events from the KOAgendaItems | 358 | This is the eventFilter function, which gets all events from the KOAgendaItems |
359 | contained in the agenda. It has to handle moving and resizing for all items. | 359 | contained in the agenda. It has to handle moving and resizing for all items. |
360 | */ | 360 | */ |
361 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 361 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
362 | { | 362 | { |
363 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 363 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
364 | switch(event->type()) { | 364 | switch(event->type()) { |
365 | case QEvent::MouseButtonPress: | 365 | case QEvent::MouseButtonPress: |
366 | case QEvent::MouseButtonDblClick: | 366 | case QEvent::MouseButtonDblClick: |
367 | case QEvent::MouseButtonRelease: | 367 | case QEvent::MouseButtonRelease: |
368 | case QEvent::MouseMove: | 368 | case QEvent::MouseMove: |
369 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 369 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
370 | 370 | ||
371 | case (QEvent::Leave): | 371 | case (QEvent::Leave): |
372 | if (!mActionItem) | 372 | if (!mActionItem) |
373 | setCursor(arrowCursor); | 373 | setCursor(arrowCursor); |
374 | return true; | 374 | return true; |
375 | 375 | ||
376 | default: | 376 | default: |
377 | return QScrollView::eventFilter(object,event); | 377 | return QScrollView::eventFilter(object,event); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | void KOAgenda::popupMenu() | 380 | void KOAgenda::popupMenu() |
381 | { | 381 | { |
382 | mPopupTimer->stop(); | 382 | mPopupTimer->stop(); |
383 | if ( mPopupKind == 1 ) { | 383 | if ( mPopupKind == 1 ) { |
384 | if (mActionItem ) { | 384 | if (mActionItem ) { |
385 | endItemAction(); | 385 | endItemAction(); |
386 | } | 386 | } |
387 | mLeftMouseDown = false; // no more leftMouse computation | 387 | mLeftMouseDown = false; // no more leftMouse computation |
388 | if (mPopupItem) { | 388 | if (mPopupItem) { |
389 | selectItem(mPopupItem); | 389 | selectItem(mPopupItem); |
390 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 390 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
391 | 391 | ||
392 | } | 392 | } |
393 | } else if ( mPopupKind == 2 ) { | 393 | } else if ( mPopupKind == 2 ) { |
394 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 394 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
395 | endSelectAction( false ); // do not emit new event signal | 395 | endSelectAction( false ); // do not emit new event signal |
396 | mLeftMouseDown = false; // no more leftMouse computation | 396 | mLeftMouseDown = false; // no more leftMouse computation |
397 | } | 397 | } |
398 | mNewItemPopup->popup( mPopupPos); | 398 | mNewItemPopup->popup( mPopupPos); |
399 | } | 399 | } |
400 | mLeftMouseDown = false; | 400 | mLeftMouseDown = false; |
401 | mPopupItem = 0; | 401 | mPopupItem = 0; |
402 | mPopupKind = 0; | 402 | mPopupKind = 0; |
403 | } | 403 | } |
404 | 404 | ||
405 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 405 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
406 | { | 406 | { |
407 | //qDebug("KOAgenda::eventFilter_mous "); | 407 | //qDebug("KOAgenda::eventFilter_mous "); |
408 | QPoint viewportPos; | 408 | QPoint viewportPos; |
409 | if (object != viewport()) { | 409 | if (object != viewport()) { |
410 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 410 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
411 | } else { | 411 | } else { |
412 | viewportPos = me->pos(); | 412 | viewportPos = me->pos(); |
413 | } | 413 | } |
414 | static int startX = 0; | 414 | static int startX = 0; |
415 | static int startY = 0; | 415 | static int startY = 0; |
416 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 416 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
417 | static bool blockMoving = true; | 417 | static bool blockMoving = true; |
418 | switch (me->type()) { | 418 | switch (me->type()) { |
419 | case QEvent::MouseButtonPress: | 419 | case QEvent::MouseButtonPress: |
420 | if (me->button() == LeftButton) { | 420 | if (me->button() == LeftButton) { |
421 | mPopupTimer->start( 600 ); | 421 | mPopupTimer->start( 600 ); |
422 | mLeftMouseDown = true; | 422 | mLeftMouseDown = true; |
423 | } | 423 | } |
424 | blockMoving = true; | 424 | blockMoving = true; |
425 | startX = viewportPos.x(); | 425 | startX = viewportPos.x(); |
426 | startY = viewportPos.y(); | 426 | startY = viewportPos.y(); |
427 | if (object != viewport()) { | 427 | if (object != viewport()) { |
428 | mPopupItem = (KOAgendaItem *)object; | 428 | mPopupItem = (KOAgendaItem *)object; |
429 | mPopupKind = 1; | 429 | mPopupKind = 1; |
430 | if (me->button() == RightButton) { | 430 | if (me->button() == RightButton) { |
431 | popupMenu(); | 431 | popupMenu(); |
432 | } else if (me->button() == LeftButton) { | 432 | } else if (me->button() == LeftButton) { |
433 | mActionItem = (KOAgendaItem *)object; | 433 | mActionItem = (KOAgendaItem *)object; |
434 | if (mActionItem) { | 434 | if (mActionItem) { |
435 | if ( mSelectionHeight > 0 ) { | 435 | if ( mSelectionHeight > 0 ) { |
436 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 436 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
437 | int selectionYTop = mSelectionYTop; | 437 | int selectionYTop = mSelectionYTop; |
438 | int gridSpacingX = mGridSpacingX; | 438 | int gridSpacingX = mGridSpacingX; |
439 | int selectionHeight = mSelectionHeight; | 439 | int selectionHeight = mSelectionHeight; |
440 | clearSelection(); | 440 | clearSelection(); |
441 | repaintContents( selectionCellX, selectionYTop, | 441 | repaintContents( selectionCellX, selectionYTop, |
442 | gridSpacingX, selectionHeight,false ); | 442 | gridSpacingX, selectionHeight,false ); |
443 | } | 443 | } |
444 | selectItem(mActionItem); | 444 | selectItem(mActionItem); |
445 | Incidence *incidence = mActionItem->incidence(); | 445 | Incidence *incidence = mActionItem->incidence(); |
446 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 446 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
447 | mActionItem = 0; | 447 | mActionItem = 0; |
448 | } else { | 448 | } else { |
449 | startItemAction(viewportPos); | 449 | startItemAction(viewportPos); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } else { // ---------- viewport() | 453 | } else { // ---------- viewport() |
454 | mPopupItem = 0; | 454 | mPopupItem = 0; |
455 | mPopupKind = 2; | 455 | mPopupKind = 2; |
456 | selectItem(0); | 456 | selectItem(0); |
457 | mActionItem = 0; | 457 | mActionItem = 0; |
458 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 458 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
459 | if (me->button() == RightButton) { | 459 | if (me->button() == RightButton) { |
460 | int x,y; | ||
461 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
462 | int gx,gy; | ||
463 | contentsToGrid(x,y,gx,gy); | ||
464 | mCurrentCellX = gx; | ||
465 | mCurrentCellY = gy; | ||
466 | mStartCellX = gx; | ||
467 | mStartCellY = gy; | ||
460 | popupMenu(); | 468 | popupMenu(); |
461 | } else if (me->button() == LeftButton) { | 469 | } else if (me->button() == LeftButton) { |
462 | setCursor(arrowCursor); | 470 | setCursor(arrowCursor); |
463 | startSelectAction(viewportPos); | 471 | startSelectAction(viewportPos); |
464 | } | 472 | } |
465 | } | 473 | } |
466 | break; | 474 | break; |
467 | 475 | ||
468 | case QEvent::MouseButtonRelease: | 476 | case QEvent::MouseButtonRelease: |
469 | if (me->button() == LeftButton ) { | 477 | if (me->button() == LeftButton ) { |
470 | mPopupTimer->stop(); | 478 | mPopupTimer->stop(); |
471 | } | 479 | } |
472 | if (object != viewport()) { | 480 | if (object != viewport()) { |
473 | if (me->button() == LeftButton && mLeftMouseDown) { | 481 | if (me->button() == LeftButton && mLeftMouseDown) { |
474 | if (mActionItem) { | 482 | if (mActionItem) { |
475 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 483 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
476 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 484 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
477 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 485 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
478 | mScrollUpTimer.stop(); | 486 | mScrollUpTimer.stop(); |
479 | mScrollDownTimer.stop(); | 487 | mScrollDownTimer.stop(); |
480 | mActionItem->resetMove(); | 488 | mActionItem->resetMove(); |
481 | placeSubCells( mActionItem ); | 489 | placeSubCells( mActionItem ); |
482 | // emit startDragSignal( mActionItem->incidence() ); | 490 | // emit startDragSignal( mActionItem->incidence() ); |
483 | setCursor( arrowCursor ); | 491 | setCursor( arrowCursor ); |
484 | mActionItem = 0; | 492 | mActionItem = 0; |
485 | mActionType = NOP; | 493 | mActionType = NOP; |
486 | mItemMoved = 0; | 494 | mItemMoved = 0; |
487 | mLeftMouseDown = false; | 495 | mLeftMouseDown = false; |
488 | return true; | 496 | return true; |
489 | } | 497 | } |
490 | endItemAction(); | 498 | endItemAction(); |
491 | } | 499 | } |
492 | } | 500 | } |
493 | 501 | ||
494 | } else { // ---------- viewport() | 502 | } else { // ---------- viewport() |
495 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 503 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
496 | endSelectAction( true ); // emit new event signal | 504 | endSelectAction( true ); // emit new event signal |
497 | } | 505 | } |
498 | } | 506 | } |
499 | if (me->button() == LeftButton) | 507 | if (me->button() == LeftButton) |
500 | mLeftMouseDown = false; | 508 | mLeftMouseDown = false; |
501 | 509 | ||
502 | break; | 510 | break; |
503 | 511 | ||
504 | case QEvent::MouseMove: | 512 | case QEvent::MouseMove: |
505 | if ( !mLeftMouseDown ) | 513 | if ( !mLeftMouseDown ) |
506 | return true; | 514 | return true; |
507 | if ( blockMoving ) { | 515 | if ( blockMoving ) { |
508 | int dX, dY; | 516 | int dX, dY; |
509 | dX = startX - viewportPos.x(); | 517 | dX = startX - viewportPos.x(); |
510 | if ( dX < 0 ) | 518 | if ( dX < 0 ) |
511 | dX = -dX; | 519 | dX = -dX; |
512 | dY = viewportPos.y() - startY; | 520 | dY = viewportPos.y() - startY; |
513 | if ( dY < 0 ) | 521 | if ( dY < 0 ) |
514 | dY = -dY; | 522 | dY = -dY; |
515 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 523 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
516 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 524 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
517 | blockMoving = false; | 525 | blockMoving = false; |
518 | } | 526 | } |
519 | } | 527 | } |
520 | if ( ! blockMoving ) | 528 | if ( ! blockMoving ) |
521 | mPopupTimer->stop(); | 529 | mPopupTimer->stop(); |
522 | if (object != viewport()) { | 530 | if (object != viewport()) { |
523 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 531 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
524 | if (!moveItem->incidence()->isReadOnly() ) { | 532 | if (!moveItem->incidence()->isReadOnly() ) { |
525 | if (!mActionItem) | 533 | if (!mActionItem) |
526 | setNoActionCursor(moveItem,viewportPos); | 534 | setNoActionCursor(moveItem,viewportPos); |
527 | else { | 535 | else { |
528 | if ( !blockMoving ) | 536 | if ( !blockMoving ) |
529 | performItemAction(viewportPos); | 537 | performItemAction(viewportPos); |
530 | } | 538 | } |
531 | } | 539 | } |
532 | } else { // ---------- viewport() | 540 | } else { // ---------- viewport() |
533 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 541 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
534 | if ( mActionType == SELECT ) { | 542 | if ( mActionType == SELECT ) { |
535 | performSelectAction( viewportPos ); | 543 | performSelectAction( viewportPos ); |
536 | } | 544 | } |
537 | } | 545 | } |
538 | break; | 546 | break; |
539 | 547 | ||
540 | case QEvent::MouseButtonDblClick: | 548 | case QEvent::MouseButtonDblClick: |
541 | mPopupTimer->stop(); | 549 | mPopupTimer->stop(); |
542 | if (object == viewport()) { | 550 | if (object == viewport()) { |
543 | selectItem(0); | 551 | selectItem(0); |
544 | int x,y; | 552 | int x,y; |
545 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 553 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
546 | int gx,gy; | 554 | int gx,gy; |
547 | contentsToGrid(x,y,gx,gy); | 555 | contentsToGrid(x,y,gx,gy); |
548 | emit newEventSignal(gx,gy); | 556 | emit newEventSignal(gx,gy); |
549 | } else { | 557 | } else { |
550 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 558 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
551 | selectItem(doubleClickedItem); | 559 | selectItem(doubleClickedItem); |
552 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 560 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
553 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 561 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
554 | else | 562 | else |
555 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 563 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
556 | } | 564 | } |
557 | break; | 565 | break; |
558 | 566 | ||
559 | default: | 567 | default: |
560 | break; | 568 | break; |
561 | } | 569 | } |
562 | return true; | 570 | return true; |
563 | #if 0 | 571 | #if 0 |
564 | //qDebug("KOAgenda::eventFilter_mous "); | 572 | //qDebug("KOAgenda::eventFilter_mous "); |
565 | QPoint viewportPos; | 573 | QPoint viewportPos; |
566 | if (object != viewport()) { | 574 | if (object != viewport()) { |
567 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 575 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
568 | } else { | 576 | } else { |
569 | viewportPos = me->pos(); | 577 | viewportPos = me->pos(); |
570 | } | 578 | } |
571 | static int startX = 0; | 579 | static int startX = 0; |
572 | static int startY = 0; | 580 | static int startY = 0; |
573 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 581 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
574 | static bool blockMoving = true; | 582 | static bool blockMoving = true; |
575 | static bool leftMouseDown = false; | 583 | static bool leftMouseDown = false; |
576 | bool rightButtonPressed = false; | 584 | bool rightButtonPressed = false; |
577 | switch (me->type()) { | 585 | switch (me->type()) { |
578 | case QEvent::MouseButtonPress: | 586 | case QEvent::MouseButtonPress: |
579 | if (me->button() == LeftButton) { | 587 | if (me->button() == LeftButton) { |
580 | leftMouseDown = true; | 588 | leftMouseDown = true; |
581 | } | 589 | } |
582 | else if (me->button() == RightButton) { | 590 | else if (me->button() == RightButton) { |
583 | leftMouseDown = false; | 591 | leftMouseDown = false; |
584 | } | 592 | } |
585 | blockMoving = true; | 593 | blockMoving = true; |
586 | startX = viewportPos.x(); | 594 | startX = viewportPos.x(); |
587 | startY = viewportPos.y(); | 595 | startY = viewportPos.y(); |
588 | if (object != viewport()) { // item clicked ************** | 596 | if (object != viewport()) { // item clicked ************** |
589 | if (me->button() == RightButton) { | 597 | if (me->button() == RightButton) { |
590 | leftMouseDown = false; | 598 | leftMouseDown = false; |
591 | mClickedItem = (KOAgendaItem *)object; | 599 | mClickedItem = (KOAgendaItem *)object; |
592 | if (mActionItem ) { | 600 | if (mActionItem ) { |
593 | endItemAction(); | 601 | endItemAction(); |
594 | } | 602 | } |
595 | if (mClickedItem) { | 603 | if (mClickedItem) { |
596 | selectItem(mClickedItem); | 604 | selectItem(mClickedItem); |
597 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 605 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
598 | } | 606 | } |
599 | return true; | 607 | return true; |
600 | } else if (me->button() == LeftButton) { | 608 | } else if (me->button() == LeftButton) { |
601 | mActionItem = (KOAgendaItem *)object; | 609 | mActionItem = (KOAgendaItem *)object; |
602 | if (mActionItem) { | 610 | if (mActionItem) { |
603 | if ( mSelectionHeight > 0 ) { | 611 | if ( mSelectionHeight > 0 ) { |
604 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 612 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
605 | int selectionYTop = mSelectionYTop; | 613 | int selectionYTop = mSelectionYTop; |
606 | int gridSpacingX = mGridSpacingX; | 614 | int gridSpacingX = mGridSpacingX; |
607 | int selectionHeight = mSelectionHeight; | 615 | int selectionHeight = mSelectionHeight; |
608 | clearSelection(); | 616 | clearSelection(); |
609 | repaintContents( selectionCellX, selectionYTop, | 617 | repaintContents( selectionCellX, selectionYTop, |
610 | gridSpacingX, selectionHeight,false ); | 618 | gridSpacingX, selectionHeight,false ); |
611 | } | 619 | } |
612 | selectItem(mActionItem); | 620 | selectItem(mActionItem); |
613 | Incidence *incidence = mActionItem->incidence(); | 621 | Incidence *incidence = mActionItem->incidence(); |
614 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 622 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
615 | mActionItem = 0; | 623 | mActionItem = 0; |
616 | } else { | 624 | } else { |
617 | startItemAction(viewportPos); | 625 | startItemAction(viewportPos); |
618 | } | 626 | } |
619 | } | 627 | } |
620 | } | 628 | } |
621 | } else { // ---------- viewport() | 629 | } else { // ---------- viewport() |
622 | selectItem(0); | 630 | selectItem(0); |
623 | mActionItem = 0; | 631 | mActionItem = 0; |
624 | if (me->button() == LeftButton ) { | 632 | if (me->button() == LeftButton ) { |
625 | setCursor(arrowCursor); | 633 | setCursor(arrowCursor); |
626 | startSelectAction(viewportPos); | 634 | startSelectAction(viewportPos); |
627 | } else if (me->button() == RightButton ) { | 635 | } else if (me->button() == RightButton ) { |
628 | setCursor(arrowCursor); | 636 | setCursor(arrowCursor); |
629 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action | 637 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action |
630 | endSelectAction( false ); // do not emit new event signal | 638 | endSelectAction( false ); // do not emit new event signal |
631 | leftMouseDown = false; // no more leftMouse computation | 639 | leftMouseDown = false; // no more leftMouse computation |
632 | } | 640 | } |
633 | int x,y; | 641 | int x,y; |
634 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 642 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
635 | int gx,gy; | 643 | int gx,gy; |
636 | contentsToGrid(x,y,gx,gy); | 644 | contentsToGrid(x,y,gx,gy); |
637 | mCurrentCellX = gx; | 645 | mCurrentCellX = gx; |
638 | mCurrentCellY = gy; | 646 | mCurrentCellY = gy; |
639 | mStartCellX = gx; | 647 | mStartCellX = gx; |
640 | mStartCellY = gy; | 648 | mStartCellY = gy; |
641 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | 649 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); |
642 | } | 650 | } |
643 | } | 651 | } |
644 | break; | 652 | break; |
645 | 653 | ||
646 | case QEvent::MouseButtonRelease: | 654 | case QEvent::MouseButtonRelease: |
647 | 655 | ||
648 | if (object != viewport()) { | 656 | if (object != viewport()) { |
649 | if (me->button() == LeftButton && leftMouseDown) { | 657 | if (me->button() == LeftButton && leftMouseDown) { |
650 | if (mActionItem) { | 658 | if (mActionItem) { |
651 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 659 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f6f390b..f452db0 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -543,475 +543,477 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
543 | */ | 543 | */ |
544 | // synchronize selections | 544 | // synchronize selections |
545 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 545 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
546 | mAllDayAgenda, SLOT( deselectItem() ) ); | 546 | mAllDayAgenda, SLOT( deselectItem() ) ); |
547 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 547 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
548 | mAgenda, SLOT( deselectItem() ) ); | 548 | mAgenda, SLOT( deselectItem() ) ); |
549 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 549 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
550 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 550 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
551 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 551 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
552 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 552 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
553 | connect( mAgenda, SIGNAL( resizedSignal() ), | 553 | connect( mAgenda, SIGNAL( resizedSignal() ), |
554 | SLOT( updateConfig( ) ) ); | 554 | SLOT( updateConfig( ) ) ); |
555 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 555 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
556 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 556 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
557 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 557 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
558 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 558 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
559 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 559 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
560 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 560 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
561 | 561 | ||
562 | 562 | ||
563 | } | 563 | } |
564 | 564 | ||
565 | void KOAgendaView::toggleAllDay() | 565 | void KOAgendaView::toggleAllDay() |
566 | { | 566 | { |
567 | if ( mSplitterAgenda->firstHandle() ) | 567 | if ( mSplitterAgenda->firstHandle() ) |
568 | mSplitterAgenda->firstHandle()->toggle(); | 568 | mSplitterAgenda->firstHandle()->toggle(); |
569 | } | 569 | } |
570 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 570 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
571 | { | 571 | { |
572 | calendar()->addIncidence( inc ); | 572 | calendar()->addIncidence( inc ); |
573 | 573 | ||
574 | if ( incOld ) { | 574 | if ( incOld ) { |
575 | if ( incOld->type() == "Todo" ) | 575 | if ( incOld->type() == "Todo" ) |
576 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 576 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
577 | else | 577 | else |
578 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 578 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
579 | } | 579 | } |
580 | 580 | ||
581 | } | 581 | } |
582 | 582 | ||
583 | KOAgendaView::~KOAgendaView() | 583 | KOAgendaView::~KOAgendaView() |
584 | { | 584 | { |
585 | delete mAgendaPopup; | 585 | delete mAgendaPopup; |
586 | delete mAllDayAgendaPopup; | 586 | delete mAllDayAgendaPopup; |
587 | delete KOAgendaItem::paintPix(); | 587 | delete KOAgendaItem::paintPix(); |
588 | delete KOAgendaItem::paintPixSel(); | 588 | delete KOAgendaItem::paintPixSel(); |
589 | } | 589 | } |
590 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 590 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
591 | { | 591 | { |
592 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 592 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
593 | bool uc = false; | 593 | bool uc = false; |
594 | int ow = e->oldSize().width(); | 594 | int ow = e->oldSize().width(); |
595 | int oh = e->oldSize().height(); | 595 | int oh = e->oldSize().height(); |
596 | int w = e->size().width(); | 596 | int w = e->size().width(); |
597 | int h = e->size().height(); | 597 | int h = e->size().height(); |
598 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 598 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
599 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 599 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
600 | uc = true; | 600 | uc = true; |
601 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 601 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
602 | } | 602 | } |
603 | mUpcomingWidth = e->size().width() ; | 603 | mUpcomingWidth = e->size().width() ; |
604 | if ( mBlockUpdating || uc ) { | 604 | if ( mBlockUpdating || uc ) { |
605 | mBlockUpdating = false; | 605 | mBlockUpdating = false; |
606 | //mAgenda->setMinimumSize(800 , 600 ); | 606 | //mAgenda->setMinimumSize(800 , 600 ); |
607 | //qDebug("mAgenda->resize+++++++++++++++ "); | 607 | //qDebug("mAgenda->resize+++++++++++++++ "); |
608 | updateConfig(); | 608 | updateConfig(); |
609 | //qDebug("KOAgendaView::Updating now possible "); | 609 | //qDebug("KOAgendaView::Updating now possible "); |
610 | } else | 610 | } else |
611 | createDayLabels(); | 611 | createDayLabels(); |
612 | //qDebug("resizeEvent end "); | 612 | //qDebug("resizeEvent end "); |
613 | 613 | ||
614 | } | 614 | } |
615 | void KOAgendaView::slotDaylabelClicked( int num ) | 615 | void KOAgendaView::slotDaylabelClicked( int num ) |
616 | { | 616 | { |
617 | 617 | ||
618 | QDate firstDate = mSelectedDates.first(); | 618 | QDate firstDate = mSelectedDates.first(); |
619 | if ( num == -1 ) | 619 | if ( num == -1 ) |
620 | emit showDateView( 6, firstDate ); | 620 | emit showDateView( 6, firstDate ); |
621 | else if (num >= 0 ) { | 621 | else if (num >= 0 ) { |
622 | if ( mSelectedDates.count() == 1) | 622 | if ( mSelectedDates.count() == 1) |
623 | emit showDateView( 9, firstDate.addDays( num ) ); | 623 | emit showDateView( 9, firstDate.addDays( num ) ); |
624 | else | 624 | else |
625 | emit showDateView( 3, firstDate.addDays( num ) ); | 625 | emit showDateView( 3, firstDate.addDays( num ) ); |
626 | } | 626 | } |
627 | else | 627 | else |
628 | showDateView( 10, firstDate.addDays(1) ); | 628 | showDateView( 10, firstDate.addDays(1) ); |
629 | } | 629 | } |
630 | 630 | ||
631 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 631 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
632 | { | 632 | { |
633 | 633 | ||
634 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 634 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
635 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 635 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
636 | mDayLabelsList.append( dayLabel ); | 636 | mDayLabelsList.append( dayLabel ); |
637 | mLayoutDayLabels->addWidget(dayLabel); | 637 | mLayoutDayLabels->addWidget(dayLabel); |
638 | return dayLabel ; | 638 | return dayLabel ; |
639 | } | 639 | } |
640 | 640 | ||
641 | void KOAgendaView::createDayLabels() | 641 | void KOAgendaView::createDayLabels() |
642 | { | 642 | { |
643 | 643 | ||
644 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 644 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
645 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 645 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
646 | return; | 646 | return; |
647 | 647 | ||
648 | } | 648 | } |
649 | int newHight; | 649 | int newHight; |
650 | 650 | ||
651 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 651 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
652 | // It would remove some flickering and gain speed (since this is called by | 652 | // It would remove some flickering and gain speed (since this is called by |
653 | // each updateView() call) | 653 | // each updateView() call) |
654 | 654 | ||
655 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 655 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
656 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 656 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
657 | if ( maxWid < 0 ) | 657 | if ( maxWid < 0 ) |
658 | maxWid = 20; | 658 | maxWid = 20; |
659 | 659 | ||
660 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 660 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
661 | QFontMetrics fm ( dlf ); | 661 | QFontMetrics fm ( dlf ); |
662 | int selCount = mSelectedDates.count(); | 662 | int selCount = mSelectedDates.count(); |
663 | QString dayTest = "Mon 20"; | 663 | QString dayTest = "Mon 20"; |
664 | //QString dayTest = "Mon 20"; | 664 | //QString dayTest = "Mon 20"; |
665 | int wid = fm.width( dayTest ); | 665 | int wid = fm.width( dayTest ); |
666 | //maxWid -= ( selCount * 3 ); //working for QLabels | 666 | //maxWid -= ( selCount * 3 ); //working for QLabels |
667 | maxWid -= ( selCount * 3 ); //working for QPushButton | 667 | maxWid -= ( selCount * 3 ); //working for QPushButton |
668 | if ( maxWid < 0 ) | 668 | if ( maxWid < 0 ) |
669 | maxWid = 20; | 669 | maxWid = 20; |
670 | int needWid = wid * selCount; | 670 | int needWid = wid * selCount; |
671 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 671 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
672 | //if ( needWid > maxWid ) | 672 | //if ( needWid > maxWid ) |
673 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 673 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
674 | while ( needWid > maxWid ) { | 674 | while ( needWid > maxWid ) { |
675 | dayTest = dayTest.left( dayTest.length() - 1 ); | 675 | dayTest = dayTest.left( dayTest.length() - 1 ); |
676 | wid = fm.width( dayTest ); | 676 | wid = fm.width( dayTest ); |
677 | needWid = wid * selCount; | 677 | needWid = wid * selCount; |
678 | } | 678 | } |
679 | int maxLen = dayTest.length(); | 679 | int maxLen = dayTest.length(); |
680 | int fontPoint = dlf.pointSize(); | 680 | int fontPoint = dlf.pointSize(); |
681 | if ( maxLen < 2 ) { | 681 | if ( maxLen < 2 ) { |
682 | int fontPoint = dlf.pointSize(); | 682 | int fontPoint = dlf.pointSize(); |
683 | while ( fontPoint > 4 ) { | 683 | while ( fontPoint > 4 ) { |
684 | --fontPoint; | 684 | --fontPoint; |
685 | dlf.setPointSize( fontPoint ); | 685 | dlf.setPointSize( fontPoint ); |
686 | QFontMetrics f( dlf ); | 686 | QFontMetrics f( dlf ); |
687 | wid = f.width( "30" ); | 687 | wid = f.width( "30" ); |
688 | needWid = wid * selCount; | 688 | needWid = wid * selCount; |
689 | if ( needWid < maxWid ) | 689 | if ( needWid < maxWid ) |
690 | break; | 690 | break; |
691 | } | 691 | } |
692 | maxLen = 2; | 692 | maxLen = 2; |
693 | } | 693 | } |
694 | //qDebug("Max len %d ", dayTest.length() ); | 694 | //qDebug("Max len %d ", dayTest.length() ); |
695 | 695 | ||
696 | QFontMetrics tempF( dlf ); | 696 | QFontMetrics tempF( dlf ); |
697 | newHight = tempF.height(); | 697 | newHight = tempF.height(); |
698 | mDayLabels->setFont( dlf ); | 698 | mDayLabels->setFont( dlf ); |
699 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 699 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
700 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 700 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
701 | //mLayoutDayLabels->addSpacing( 2 ); | 701 | //mLayoutDayLabels->addSpacing( 2 ); |
702 | // QFont lFont = dlf; | 702 | // QFont lFont = dlf; |
703 | bool appendLabels = false; | 703 | bool appendLabels = false; |
704 | KOAgendaButton *dayLabel; | 704 | KOAgendaButton *dayLabel; |
705 | dayLabel = mDayLabelsList.first(); | 705 | dayLabel = mDayLabelsList.first(); |
706 | if ( !dayLabel ) { | 706 | if ( !dayLabel ) { |
707 | appendLabels = true; | 707 | appendLabels = true; |
708 | dayLabel = getNewDaylabel(); | 708 | dayLabel = getNewDaylabel(); |
709 | } | 709 | } |
710 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 710 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
711 | dayLabel->setFont( dlf ); | 711 | dayLabel->setFont( dlf ); |
712 | dayLabel->setNum( -1 ); | 712 | dayLabel->setNum( -1 ); |
713 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 713 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
714 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 714 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
715 | dayLabel->show(); | 715 | dayLabel->show(); |
716 | DateList::ConstIterator dit; | 716 | DateList::ConstIterator dit; |
717 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 717 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
718 | int counter = -1; | 718 | int counter = -1; |
719 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 719 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
720 | ++counter; | 720 | ++counter; |
721 | QDate date = *dit; | 721 | QDate date = *dit; |
722 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 722 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
723 | if ( ! appendLabels ) { | 723 | if ( ! appendLabels ) { |
724 | dayLabel = mDayLabelsList.next(); | 724 | dayLabel = mDayLabelsList.next(); |
725 | if ( !dayLabel ) | 725 | if ( !dayLabel ) |
726 | appendLabels = true; | 726 | appendLabels = true; |
727 | } | 727 | } |
728 | if ( appendLabels ) { | 728 | if ( appendLabels ) { |
729 | dayLabel = getNewDaylabel(); | 729 | dayLabel = getNewDaylabel(); |
730 | } | 730 | } |
731 | dayLabel->setMinimumWidth( 1 ); | 731 | dayLabel->setMinimumWidth( 1 ); |
732 | dayLabel->setMaximumWidth( 10240 ); | 732 | dayLabel->setMaximumWidth( 10240 ); |
733 | dayLabel->setFont( dlf ); | 733 | dayLabel->setFont( dlf ); |
734 | dayLabel->show(); | 734 | dayLabel->show(); |
735 | dayLabel->setAutoRepeat( false ); | ||
735 | dayLabel->setNum( counter ); | 736 | dayLabel->setNum( counter ); |
736 | QString str; | 737 | QString str; |
737 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 738 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
738 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 739 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
739 | switch ( maxLen ) { | 740 | switch ( maxLen ) { |
740 | case 2: | 741 | case 2: |
741 | str = QString::number( date.day() ); | 742 | str = QString::number( date.day() ); |
742 | break; | 743 | break; |
743 | 744 | ||
744 | case 3: | 745 | case 3: |
745 | str = dayName.left( 1 ) +QString::number( date.day()); | 746 | str = dayName.left( 1 ) +QString::number( date.day()); |
746 | 747 | ||
747 | break; | 748 | break; |
748 | case 4: | 749 | case 4: |
749 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 750 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
750 | 751 | ||
751 | break; | 752 | break; |
752 | case 5: | 753 | case 5: |
753 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 754 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
754 | 755 | ||
755 | break; | 756 | break; |
756 | case 6: | 757 | case 6: |
757 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 758 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
758 | break; | 759 | break; |
759 | 760 | ||
760 | default: | 761 | default: |
761 | break; | 762 | break; |
762 | } | 763 | } |
763 | if ( oneday ) { | 764 | if ( oneday ) { |
764 | QString addString; | 765 | QString addString; |
765 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 766 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
766 | addString = i18n("Today"); | 767 | addString = i18n("Today"); |
767 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
768 | addString = i18n("Tomorrow"); | 769 | addString = i18n("Tomorrow"); |
769 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 770 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
770 | addString = i18n("Yesterday"); | 771 | addString = i18n("Yesterday"); |
771 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 772 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
772 | addString = i18n("Day before yesterday"); | 773 | addString = i18n("Day before yesterday"); |
773 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 774 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
774 | addString = i18n("Day after tomorrow"); | 775 | addString = i18n("Day after tomorrow"); |
775 | if ( !addString.isEmpty() ) { | 776 | if ( !addString.isEmpty() ) { |
776 | str = addString+", " + str; | 777 | str = addString+", " + str; |
777 | } else { | 778 | } else { |
778 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 779 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
779 | } | 780 | } |
780 | } | 781 | } |
781 | dayLabel->setText(str); | 782 | dayLabel->setText(str); |
782 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 783 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
783 | if (date == QDate::currentDate()) { | 784 | if (date == QDate::currentDate()) { |
784 | QFont bFont = dlf; | 785 | QFont bFont = dlf; |
785 | bFont.setBold( true ); | 786 | bFont.setBold( true ); |
786 | dayLabel->setFont(bFont); | 787 | dayLabel->setFont(bFont); |
787 | } | 788 | } |
788 | //dayLayout->addWidget(dayLabel); | 789 | //dayLayout->addWidget(dayLabel); |
789 | 790 | ||
790 | #ifndef KORG_NOPLUGINS | 791 | #ifndef KORG_NOPLUGINS |
791 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 792 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
792 | CalendarDecoration *it; | 793 | CalendarDecoration *it; |
793 | for(it = cds.first(); it; it = cds.next()) { | 794 | for(it = cds.first(); it; it = cds.next()) { |
794 | QString text = it->shortText( date ); | 795 | QString text = it->shortText( date ); |
795 | if ( !text.isEmpty() ) { | 796 | if ( !text.isEmpty() ) { |
796 | QLabel *label = new QLabel(text,mDayLabels); | 797 | QLabel *label = new QLabel(text,mDayLabels); |
797 | label->setAlignment(AlignCenter); | 798 | label->setAlignment(AlignCenter); |
798 | dayLayout->addWidget(label); | 799 | dayLayout->addWidget(label); |
799 | } | 800 | } |
800 | } | 801 | } |
801 | 802 | ||
802 | for(it = cds.first(); it; it = cds.next()) { | 803 | for(it = cds.first(); it; it = cds.next()) { |
803 | QWidget *wid = it->smallWidget(mDayLabels,date); | 804 | QWidget *wid = it->smallWidget(mDayLabels,date); |
804 | if ( wid ) { | 805 | if ( wid ) { |
805 | // wid->setHeight(20); | 806 | // wid->setHeight(20); |
806 | dayLayout->addWidget(wid); | 807 | dayLayout->addWidget(wid); |
807 | } | 808 | } |
808 | } | 809 | } |
809 | #endif | 810 | #endif |
810 | } | 811 | } |
811 | if ( ! appendLabels ) { | 812 | if ( ! appendLabels ) { |
812 | dayLabel = mDayLabelsList.next(); | 813 | dayLabel = mDayLabelsList.next(); |
813 | if ( !dayLabel ) | 814 | if ( !dayLabel ) |
814 | appendLabels = true; | 815 | appendLabels = true; |
815 | } | 816 | } |
816 | if ( appendLabels ) { | 817 | if ( appendLabels ) { |
817 | dayLabel = getNewDaylabel(); | 818 | dayLabel = getNewDaylabel(); |
818 | } | 819 | } |
819 | //dayLabel->hide();//test only | 820 | //dayLabel->hide();//test only |
820 | 821 | ||
821 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 822 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
822 | if ( offset < 0 ) offset = 0; | 823 | if ( offset < 0 ) offset = 0; |
823 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 824 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
824 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 825 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
825 | dayLabel->setFont( dlf ); | 826 | dayLabel->setFont( dlf ); |
827 | dayLabel->setAutoRepeat( true ); | ||
826 | dayLabel->show(); | 828 | dayLabel->show(); |
827 | dayLabel->setNum( -2 ); | 829 | dayLabel->setNum( -2 ); |
828 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 830 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
829 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 831 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
830 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 832 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
831 | if ( !appendLabels ) { | 833 | if ( !appendLabels ) { |
832 | dayLabel = mDayLabelsList.next(); | 834 | dayLabel = mDayLabelsList.next(); |
833 | while ( dayLabel ) { | 835 | while ( dayLabel ) { |
834 | //qDebug("!dayLabel %d",dayLabel ); | 836 | //qDebug("!dayLabel %d",dayLabel ); |
835 | dayLabel->hide(); | 837 | dayLabel->hide(); |
836 | dayLabel = mDayLabelsList.next(); | 838 | dayLabel = mDayLabelsList.next(); |
837 | } | 839 | } |
838 | } | 840 | } |
839 | 841 | ||
840 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 842 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
841 | } | 843 | } |
842 | 844 | ||
843 | int KOAgendaView::maxDatesHint() | 845 | int KOAgendaView::maxDatesHint() |
844 | { | 846 | { |
845 | // Not sure about the max number of events, so return 0 for now. | 847 | // Not sure about the max number of events, so return 0 for now. |
846 | return 0; | 848 | return 0; |
847 | } | 849 | } |
848 | 850 | ||
849 | int KOAgendaView::currentDateCount() | 851 | int KOAgendaView::currentDateCount() |
850 | { | 852 | { |
851 | return mSelectedDates.count(); | 853 | return mSelectedDates.count(); |
852 | } | 854 | } |
853 | 855 | ||
854 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 856 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
855 | { | 857 | { |
856 | QPtrList<Incidence> selected; | 858 | QPtrList<Incidence> selected; |
857 | Incidence *incidence; | 859 | Incidence *incidence; |
858 | 860 | ||
859 | incidence = mAgenda->selectedIncidence(); | 861 | incidence = mAgenda->selectedIncidence(); |
860 | if (incidence) selected.append(incidence); | 862 | if (incidence) selected.append(incidence); |
861 | 863 | ||
862 | incidence = mAllDayAgenda->selectedIncidence(); | 864 | incidence = mAllDayAgenda->selectedIncidence(); |
863 | if (incidence) selected.append(incidence); | 865 | if (incidence) selected.append(incidence); |
864 | 866 | ||
865 | return selected; | 867 | return selected; |
866 | } | 868 | } |
867 | 869 | ||
868 | DateList KOAgendaView::selectedDates() | 870 | DateList KOAgendaView::selectedDates() |
869 | { | 871 | { |
870 | DateList selected; | 872 | DateList selected; |
871 | QDate qd; | 873 | QDate qd; |
872 | 874 | ||
873 | qd = mAgenda->selectedIncidenceDate(); | 875 | qd = mAgenda->selectedIncidenceDate(); |
874 | if (qd.isValid()) selected.append(qd); | 876 | if (qd.isValid()) selected.append(qd); |
875 | 877 | ||
876 | qd = mAllDayAgenda->selectedIncidenceDate(); | 878 | qd = mAllDayAgenda->selectedIncidenceDate(); |
877 | if (qd.isValid()) selected.append(qd); | 879 | if (qd.isValid()) selected.append(qd); |
878 | 880 | ||
879 | return selected; | 881 | return selected; |
880 | } | 882 | } |
881 | 883 | ||
882 | 884 | ||
883 | void KOAgendaView::updateView() | 885 | void KOAgendaView::updateView() |
884 | { | 886 | { |
885 | if ( mBlockUpdating ) | 887 | if ( mBlockUpdating ) |
886 | return; | 888 | return; |
887 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 889 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
888 | fillAgenda(); | 890 | fillAgenda(); |
889 | 891 | ||
890 | } | 892 | } |
891 | 893 | ||
892 | 894 | ||
893 | /* | 895 | /* |
894 | Update configuration settings for the agenda view. This method is not | 896 | Update configuration settings for the agenda view. This method is not |
895 | complete. | 897 | complete. |
896 | */ | 898 | */ |
897 | void KOAgendaView::updateConfig() | 899 | void KOAgendaView::updateConfig() |
898 | { | 900 | { |
899 | if ( mBlockUpdating ) | 901 | if ( mBlockUpdating ) |
900 | return; | 902 | return; |
901 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 903 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
902 | int old = KOPrefs::instance()->mHourSize; | 904 | int old = KOPrefs::instance()->mHourSize; |
903 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 905 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
904 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 906 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
905 | } | 907 | } |
906 | 908 | ||
907 | 909 | ||
908 | // update config for children | 910 | // update config for children |
909 | mTimeLabels->updateConfig(); | 911 | mTimeLabels->updateConfig(); |
910 | mAgenda->storePosition(); | 912 | mAgenda->storePosition(); |
911 | mAgenda->updateConfig(); | 913 | mAgenda->updateConfig(); |
912 | mAllDayAgenda->updateConfig(); | 914 | mAllDayAgenda->updateConfig(); |
913 | // widget synchronization | 915 | // widget synchronization |
914 | //TODO: find a better way, maybe signal/slot | 916 | //TODO: find a better way, maybe signal/slot |
915 | mTimeLabels->positionChanged(); | 917 | mTimeLabels->positionChanged(); |
916 | 918 | ||
917 | // for some reason, this needs to be called explicitly | 919 | // for some reason, this needs to be called explicitly |
918 | mTimeLabels->repaint(); | 920 | mTimeLabels->repaint(); |
919 | 921 | ||
920 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 922 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
921 | 923 | ||
922 | // ToolTips displaying summary of events | 924 | // ToolTips displaying summary of events |
923 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 925 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
924 | ->mEnableToolTips); | 926 | ->mEnableToolTips); |
925 | 927 | ||
926 | //setHolidayMasks(); | 928 | //setHolidayMasks(); |
927 | 929 | ||
928 | //createDayLabels(); called by via updateView(); | 930 | //createDayLabels(); called by via updateView(); |
929 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 931 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
930 | updateView(); | 932 | updateView(); |
931 | mAgenda->restorePosition(); | 933 | mAgenda->restorePosition(); |
932 | } | 934 | } |
933 | 935 | ||
934 | 936 | ||
935 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 937 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
936 | { | 938 | { |
937 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 939 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
938 | //qDebug("KOAgendaView::updateEventDates "); | 940 | //qDebug("KOAgendaView::updateEventDates "); |
939 | QDateTime startDt,endDt; | 941 | QDateTime startDt,endDt; |
940 | QDate startDate; | 942 | QDate startDate; |
941 | int lenInSecs; | 943 | int lenInSecs; |
942 | // if ( type == KOAgenda::RESIZETOP ) | 944 | // if ( type == KOAgenda::RESIZETOP ) |
943 | // qDebug("RESIZETOP "); | 945 | // qDebug("RESIZETOP "); |
944 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 946 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
945 | // qDebug("RESIZEBOTTOM "); | 947 | // qDebug("RESIZEBOTTOM "); |
946 | // if ( type == KOAgenda::MOVE ) | 948 | // if ( type == KOAgenda::MOVE ) |
947 | // qDebug("MOVE "); | 949 | // qDebug("MOVE "); |
948 | if ( item->incidence()->type() == "Event" ) { | 950 | if ( item->incidence()->type() == "Event" ) { |
949 | startDt =item->incidence()->dtStart(); | 951 | startDt =item->incidence()->dtStart(); |
950 | endDt = item->incidence()->dtEnd(); | 952 | endDt = item->incidence()->dtEnd(); |
951 | lenInSecs = startDt.secsTo( endDt ); | 953 | lenInSecs = startDt.secsTo( endDt ); |
952 | } | 954 | } |
953 | 955 | ||
954 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 956 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
955 | 957 | ||
956 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 958 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
957 | startDate = mSelectedDates[item->mLastMoveXPos]; | 959 | startDate = mSelectedDates[item->mLastMoveXPos]; |
958 | } else { | 960 | } else { |
959 | if (item->cellX() < 0) { | 961 | if (item->cellX() < 0) { |
960 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 962 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
961 | } else { | 963 | } else { |
962 | startDate = mSelectedDates[item->cellX()]; | 964 | startDate = mSelectedDates[item->cellX()]; |
963 | } | 965 | } |
964 | } | 966 | } |
965 | startDt.setDate(startDate); | 967 | startDt.setDate(startDate); |
966 | 968 | ||
967 | if (item->incidence()->doesFloat()) { | 969 | if (item->incidence()->doesFloat()) { |
968 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 970 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
969 | } else { | 971 | } else { |
970 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 972 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
971 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 973 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
972 | if ( item->incidence()->type() == "Event" ) { | 974 | if ( item->incidence()->type() == "Event" ) { |
973 | if ( type == KOAgenda::MOVE ) { | 975 | if ( type == KOAgenda::MOVE ) { |
974 | endDt = startDt.addSecs(lenInSecs); | 976 | endDt = startDt.addSecs(lenInSecs); |
975 | 977 | ||
976 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 978 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
977 | if (item->lastMultiItem()) { | 979 | if (item->lastMultiItem()) { |
978 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 980 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
979 | endDt.setDate(startDate. | 981 | endDt.setDate(startDate. |
980 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 982 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
981 | } else { | 983 | } else { |
982 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 984 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
983 | endDt.setDate(startDate); | 985 | endDt.setDate(startDate); |
984 | } | 986 | } |
985 | } | 987 | } |
986 | } else { | 988 | } else { |
987 | // todo | 989 | // todo |
988 | if (item->lastMultiItem()) { | 990 | if (item->lastMultiItem()) { |
989 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 991 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
990 | endDt.setDate(startDate. | 992 | endDt.setDate(startDate. |
991 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 993 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
992 | } else { | 994 | } else { |
993 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 995 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
994 | if ( item->cellYBottom() > 0 ) | 996 | if ( item->cellYBottom() > 0 ) |
995 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 997 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
996 | else | 998 | else |
997 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 999 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
998 | endDt.setDate(startDate); | 1000 | endDt.setDate(startDate); |
999 | } | 1001 | } |
1000 | } | 1002 | } |
1001 | } | 1003 | } |
1002 | if ( item->incidence()->type() == "Event" ) { | 1004 | if ( item->incidence()->type() == "Event" ) { |
1003 | item->incidence()->setDtStart(startDt); | 1005 | item->incidence()->setDtStart(startDt); |
1004 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1006 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1005 | } else if ( item->incidence()->type() == "Todo" ) { | 1007 | } else if ( item->incidence()->type() == "Todo" ) { |
1006 | Todo* to = static_cast<Todo*>(item->incidence()); | 1008 | Todo* to = static_cast<Todo*>(item->incidence()); |
1007 | 1009 | ||
1008 | to->setDtDue(endDt); | 1010 | to->setDtDue(endDt); |
1009 | if ( to->hasStartDate() ) { | 1011 | if ( to->hasStartDate() ) { |
1010 | if (to->dtStart() >= to->dtDue() ) | 1012 | if (to->dtStart() >= to->dtDue() ) |
1011 | to->setDtStart(to->dtDue().addDays( -2 )); | 1013 | to->setDtStart(to->dtDue().addDays( -2 )); |
1012 | } | 1014 | } |
1013 | 1015 | ||
1014 | } | 1016 | } |
1015 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1017 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1016 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1018 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1017 | item->setItemDate(startDt.date()); | 1019 | item->setItemDate(startDt.date()); |
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index a9d1ed3..a03ec52 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -26,391 +26,392 @@ | |||
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
37 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <krestrictedline.h> | 39 | #include <krestrictedline.h> |
40 | #include <kstandarddirs.h> | 40 | #include <kstandarddirs.h> |
41 | #include <kfiledialog.h> | 41 | #include <kfiledialog.h> |
42 | 42 | ||
43 | #include <libkcal/todo.h> | 43 | #include <libkcal/todo.h> |
44 | 44 | ||
45 | #include <libkdepim/kdateedit.h> | 45 | #include <libkdepim/kdateedit.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "ktimeedit.h" | 48 | #include "ktimeedit.h" |
49 | 49 | ||
50 | #include "koeditorgeneraltodo.h" | 50 | #include "koeditorgeneraltodo.h" |
51 | #include "kolocationbox.h" | 51 | #include "kolocationbox.h" |
52 | 52 | ||
53 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, | 53 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, |
54 | const char* name) | 54 | const char* name) |
55 | : KOEditorGeneral( parent, name) | 55 | : KOEditorGeneral( parent, name) |
56 | { | 56 | { |
57 | } | 57 | } |
58 | 58 | ||
59 | KOEditorGeneralTodo::~KOEditorGeneralTodo() | 59 | KOEditorGeneralTodo::~KOEditorGeneralTodo() |
60 | { | 60 | { |
61 | } | 61 | } |
62 | 62 | ||
63 | void KOEditorGeneralTodo::finishSetup() | 63 | void KOEditorGeneralTodo::finishSetup() |
64 | { | 64 | { |
65 | 65 | ||
66 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); | 66 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); |
67 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); | 67 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); |
68 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); | 68 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); |
69 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); | 69 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); |
70 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); | 70 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); |
71 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); | 71 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); |
72 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); | 72 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); |
73 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); | 73 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); |
74 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); | 74 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); |
75 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); | 75 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); |
76 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); | 76 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); |
77 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); | 77 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); |
78 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); | 78 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); |
79 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); | 79 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); |
80 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 80 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
81 | mSummaryEdit->setFocus(); | 81 | mSummaryEdit->setFocus(); |
82 | } | 82 | } |
83 | 83 | ||
84 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) | 84 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) |
85 | { | 85 | { |
86 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); | 86 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); |
87 | 87 | ||
88 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, | 88 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, |
89 | i18n("Date && Time"),parent); | 89 | i18n("Date && Time"),parent); |
90 | timeLayout->addWidget(timeGroupBox); | 90 | timeLayout->addWidget(timeGroupBox); |
91 | timeGroupBox->layout()->setSpacing( 0 ); | 91 | timeGroupBox->layout()->setSpacing( 0 ); |
92 | timeGroupBox->layout()->setMargin( 5 ); | 92 | timeGroupBox->layout()->setMargin( 5 ); |
93 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); | 93 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); |
94 | 94 | ||
95 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); | 95 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); |
96 | layoutTimeBox->setSpacing(topLayout->spacing()); | 96 | layoutTimeBox->setSpacing(topLayout->spacing()); |
97 | layoutTimeBox->setColStretch( 1, 1 ); | 97 | layoutTimeBox->setColStretch( 1, 1 ); |
98 | 98 | ||
99 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); | 99 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); |
100 | layoutTimeBox->addWidget(mDueCheck,0,0); | 100 | layoutTimeBox->addWidget(mDueCheck,0,0); |
101 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); | 101 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); |
102 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); | 102 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); |
103 | 103 | ||
104 | 104 | ||
105 | mDueDateEdit = new KDateEdit(timeBoxFrame); | 105 | mDueDateEdit = new KDateEdit(timeBoxFrame); |
106 | layoutTimeBox->addWidget(mDueDateEdit,0,1); | 106 | layoutTimeBox->addWidget(mDueDateEdit,0,1); |
107 | 107 | ||
108 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); | 108 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); |
109 | layoutTimeBox->addWidget(mDueTimeEdit,0,2); | 109 | layoutTimeBox->addWidget(mDueTimeEdit,0,2); |
110 | 110 | ||
111 | 111 | ||
112 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); | 112 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); |
113 | layoutTimeBox->addWidget(mStartCheck,1,0); | 113 | layoutTimeBox->addWidget(mStartCheck,1,0); |
114 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); | 114 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); |
115 | 115 | ||
116 | mStartDateEdit = new KDateEdit(timeBoxFrame); | 116 | mStartDateEdit = new KDateEdit(timeBoxFrame); |
117 | layoutTimeBox->addWidget(mStartDateEdit,1,1); | 117 | layoutTimeBox->addWidget(mStartDateEdit,1,1); |
118 | 118 | ||
119 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); | 119 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); |
120 | layoutTimeBox->addWidget(mStartTimeEdit,1,2); | 120 | layoutTimeBox->addWidget(mStartTimeEdit,1,2); |
121 | 121 | ||
122 | 122 | ||
123 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); | 123 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); |
124 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); | 124 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); |
125 | 125 | ||
126 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); | 126 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); |
127 | 127 | ||
128 | // some more layouting | 128 | // some more layouting |
129 | //layoutTimeBox->setColStretch(3,1); | 129 | //layoutTimeBox->setColStretch(3,1); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) | 133 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) |
134 | { | 134 | { |
135 | mCompletedCombo = new QComboBox(parent); | 135 | mCompletedCombo = new QComboBox(parent); |
136 | // xgettext:no-c-format | 136 | // xgettext:no-c-format |
137 | mCompletedCombo->insertItem(i18n(" 0 %")); | 137 | mCompletedCombo->insertItem(i18n(" 0 %")); |
138 | // xgettext:no-c-format | 138 | // xgettext:no-c-format |
139 | mCompletedCombo->insertItem(i18n(" 20 %")); | 139 | mCompletedCombo->insertItem(i18n(" 20 %")); |
140 | // xgettext:no-c-format | 140 | // xgettext:no-c-format |
141 | mCompletedCombo->insertItem(i18n(" 40 %")); | 141 | mCompletedCombo->insertItem(i18n(" 40 %")); |
142 | // xgettext:no-c-format | 142 | // xgettext:no-c-format |
143 | mCompletedCombo->insertItem(i18n(" 60 %")); | 143 | mCompletedCombo->insertItem(i18n(" 60 %")); |
144 | // xgettext:no-c-format | 144 | // xgettext:no-c-format |
145 | mCompletedCombo->insertItem(i18n(" 80 %")); | 145 | mCompletedCombo->insertItem(i18n(" 80 %")); |
146 | // xgettext:no-c-format | 146 | // xgettext:no-c-format |
147 | mCompletedCombo->insertItem(i18n("100 %")); | 147 | mCompletedCombo->insertItem(i18n("100 %")); |
148 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); | 148 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); |
149 | topLayout->addWidget(mCompletedCombo); | 149 | topLayout->addWidget(mCompletedCombo); |
150 | 150 | ||
151 | mCompletedLabel = new QLabel(i18n("completed"),parent); | 151 | mCompletedLabel = new QLabel(i18n("completed"),parent); |
152 | topLayout->addWidget(mCompletedLabel); | 152 | topLayout->addWidget(mCompletedLabel); |
153 | 153 | ||
154 | mCompleteDateEdit = new KDateEdit(parent); | 154 | mCompleteDateEdit = new KDateEdit(parent); |
155 | topLayout->addWidget(mCompleteDateEdit ); | 155 | topLayout->addWidget(mCompleteDateEdit ); |
156 | 156 | ||
157 | mCompleteTimeEdit = new KOTimeEdit(parent); | 157 | mCompleteTimeEdit = new KOTimeEdit(parent); |
158 | topLayout->addWidget( mCompleteTimeEdit); | 158 | topLayout->addWidget( mCompleteTimeEdit); |
159 | 159 | ||
160 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); | 160 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); |
161 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); | 161 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); |
162 | 162 | ||
163 | if ( QApplication::desktop()->width() <= 480 ) { | 163 | if ( QApplication::desktop()->width() <= 480 ) { |
164 | if ( QApplication::desktop()->width() < 320 ) | 164 | if ( QApplication::desktop()->width() < 320 ) |
165 | mCompleteDateEdit->setMaximumWidth( 85 ); | 165 | mCompleteDateEdit->setMaximumWidth( 85 ); |
166 | else | 166 | else |
167 | mCompleteDateEdit->setMaximumWidth( 140 ); | 167 | mCompleteDateEdit->setMaximumWidth( 140 ); |
168 | topLayout->setSpacing( 0 ); | 168 | topLayout->setSpacing( 0 ); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) | 172 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) |
173 | { | 173 | { |
174 | 174 | ||
175 | QHBox* h = new QHBox ( parent ); | 175 | QHBox* h = new QHBox ( parent ); |
176 | topLayout->addWidget( h ); | 176 | topLayout->addWidget( h ); |
177 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); | 177 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); |
178 | // topLayout->addWidget(priorityLabel); | 178 | // topLayout->addWidget(priorityLabel); |
179 | mPriorityCombo = new QComboBox( h ); | 179 | mPriorityCombo = new QComboBox( h ); |
180 | mPriorityCombo->insertItem(i18n("1 (high)")); | 180 | mPriorityCombo->insertItem(i18n("1 (high)")); |
181 | mPriorityCombo->insertItem(i18n("2")); | 181 | mPriorityCombo->insertItem(i18n("2")); |
182 | mPriorityCombo->insertItem(i18n("3")); | 182 | mPriorityCombo->insertItem(i18n("3")); |
183 | mPriorityCombo->insertItem(i18n("4")); | 183 | mPriorityCombo->insertItem(i18n("4")); |
184 | mPriorityCombo->insertItem(i18n("5 (low)")); | 184 | mPriorityCombo->insertItem(i18n("5 (low)")); |
185 | //topLayout->addWidget(mPriorityCombo); | 185 | //topLayout->addWidget(mPriorityCombo); |
186 | } | 186 | } |
187 | 187 | ||
188 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) | 188 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) |
189 | { | 189 | { |
190 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); | 190 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); |
191 | 191 | ||
192 | initCompletion( parent, statusLayout ); | 192 | initCompletion( parent, statusLayout ); |
193 | 193 | ||
194 | statusLayout->addStretch( 1 ); | 194 | statusLayout->addStretch( 1 ); |
195 | 195 | ||
196 | initPriority( parent, statusLayout ); | 196 | initPriority( parent, statusLayout ); |
197 | } | 197 | } |
198 | 198 | ||
199 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) | 199 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) |
200 | { | 200 | { |
201 | 201 | ||
202 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 202 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
203 | mLocationEdit->load(KOLocationBox::LOCATION); | 203 | mLocationEdit->load(KOLocationBox::LOCATION); |
204 | KOEditorGeneral::setDefaults(allDay); | 204 | KOEditorGeneral::setDefaults(allDay); |
205 | 205 | ||
206 | mTimeButton->setChecked( !allDay ); | 206 | mTimeButton->setChecked( !allDay ); |
207 | if(mTimeButton->isChecked()) { | 207 | if(mTimeButton->isChecked()) { |
208 | mTimeButton->setEnabled(true); | 208 | mTimeButton->setEnabled(true); |
209 | } | 209 | } |
210 | else { | 210 | else { |
211 | mTimeButton->setEnabled(false); | 211 | mTimeButton->setEnabled(false); |
212 | } | 212 | } |
213 | 213 | ||
214 | enableTimeEdits( !allDay ); | 214 | enableTimeEdits( !allDay ); |
215 | if ( due.isValid() ) { | 215 | if ( due.isValid() ) { |
216 | mDueCheck->setChecked(true); | 216 | mDueCheck->setChecked(true); |
217 | enableDueEdit(true); | 217 | enableDueEdit(true); |
218 | alarmDisable(false); | ||
218 | } else { | 219 | } else { |
219 | mDueCheck->setChecked(false); | 220 | mDueCheck->setChecked(false); |
220 | enableDueEdit(false); | 221 | enableDueEdit(false); |
221 | due = QDateTime::currentDateTime().addDays(7); | 222 | due = QDateTime::currentDateTime().addDays(7); |
223 | alarmDisable(true); | ||
222 | } | 224 | } |
223 | 225 | ||
224 | alarmDisable(true); | ||
225 | 226 | ||
226 | mStartCheck->setChecked(false); | 227 | mStartCheck->setChecked(false); |
227 | enableStartEdit(false); | 228 | enableStartEdit(false); |
228 | 229 | ||
229 | mDueDateEdit->setDate(due.date()); | 230 | mDueDateEdit->setDate(due.date()); |
230 | mDueTimeEdit->setTime(due.time()); | 231 | mDueTimeEdit->setTime(due.time()); |
231 | due = due.addDays(-7); | 232 | due = due.addDays(-7); |
232 | mStartDateEdit->setDate(due.date()); | 233 | mStartDateEdit->setDate(due.date()); |
233 | mStartTimeEdit->setTime(due.time()); | 234 | mStartTimeEdit->setTime(due.time()); |
234 | 235 | ||
235 | mPriorityCombo->setCurrentItem(2); | 236 | mPriorityCombo->setCurrentItem(2); |
236 | mCompletedLabel->setText(i18n(" completed"));; | 237 | mCompletedLabel->setText(i18n(" completed"));; |
237 | mCompletedCombo->setCurrentItem(0); | 238 | mCompletedCombo->setCurrentItem(0); |
238 | mCompleteDateEdit->hide(); | 239 | mCompleteDateEdit->hide(); |
239 | mCompleteTimeEdit->hide(); | 240 | mCompleteTimeEdit->hide(); |
240 | } | 241 | } |
241 | 242 | ||
242 | void KOEditorGeneralTodo::readTodo(Todo *todo) | 243 | void KOEditorGeneralTodo::readTodo(Todo *todo) |
243 | { | 244 | { |
244 | 245 | ||
245 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 246 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
246 | mLocationEdit->load(KOLocationBox::LOCATION); | 247 | mLocationEdit->load(KOLocationBox::LOCATION); |
247 | KOEditorGeneral::readIncidence(todo); | 248 | KOEditorGeneral::readIncidence(todo); |
248 | 249 | ||
249 | QDateTime dueDT; | 250 | QDateTime dueDT; |
250 | 251 | ||
251 | if (todo->hasDueDate()) { | 252 | if (todo->hasDueDate()) { |
252 | enableAlarmEdit(true); | 253 | enableAlarmEdit(true); |
253 | dueDT = todo->dtDue(); | 254 | dueDT = todo->dtDue(); |
254 | mDueDateEdit->setDate(todo->dtDue().date()); | 255 | mDueDateEdit->setDate(todo->dtDue().date()); |
255 | mDueTimeEdit->setTime(todo->dtDue().time()); | 256 | mDueTimeEdit->setTime(todo->dtDue().time()); |
256 | mDueCheck->setChecked(true); | 257 | mDueCheck->setChecked(true); |
257 | } else { | 258 | } else { |
258 | alarmDisable(true); | 259 | alarmDisable(true); |
259 | mDueDateEdit->setEnabled(false); | 260 | mDueDateEdit->setEnabled(false); |
260 | mDueTimeEdit->setEnabled(false); | 261 | mDueTimeEdit->setEnabled(false); |
261 | mDueDateEdit->setDate(QDate::currentDate()); | 262 | mDueDateEdit->setDate(QDate::currentDate()); |
262 | mDueTimeEdit->setTime(QTime::currentTime()); | 263 | mDueTimeEdit->setTime(QTime::currentTime()); |
263 | mDueCheck->setChecked(false); | 264 | mDueCheck->setChecked(false); |
264 | } | 265 | } |
265 | 266 | ||
266 | if (todo->hasStartDate()) { | 267 | if (todo->hasStartDate()) { |
267 | mStartDateEdit->setDate(todo->dtStart().date()); | 268 | mStartDateEdit->setDate(todo->dtStart().date()); |
268 | mStartTimeEdit->setTime(todo->dtStart().time()); | 269 | mStartTimeEdit->setTime(todo->dtStart().time()); |
269 | mStartCheck->setChecked(true); | 270 | mStartCheck->setChecked(true); |
270 | } else { | 271 | } else { |
271 | mStartDateEdit->setEnabled(false); | 272 | mStartDateEdit->setEnabled(false); |
272 | mStartTimeEdit->setEnabled(false); | 273 | mStartTimeEdit->setEnabled(false); |
273 | mStartDateEdit->setDate(QDate::currentDate()); | 274 | mStartDateEdit->setDate(QDate::currentDate()); |
274 | mStartTimeEdit->setTime(QTime::currentTime()); | 275 | mStartTimeEdit->setTime(QTime::currentTime()); |
275 | mStartCheck->setChecked(false); | 276 | mStartCheck->setChecked(false); |
276 | } | 277 | } |
277 | 278 | ||
278 | mTimeButton->setChecked( !todo->doesFloat() ); | 279 | mTimeButton->setChecked( !todo->doesFloat() ); |
279 | 280 | ||
280 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 281 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
281 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 282 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
282 | mCompleted = todo->completed(); | 283 | mCompleted = todo->completed(); |
283 | } | 284 | } |
284 | setCompletedDate(); | 285 | setCompletedDate(); |
285 | 286 | ||
286 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 287 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
287 | } | 288 | } |
288 | 289 | ||
289 | void KOEditorGeneralTodo::writeTodo(Todo *todo) | 290 | void KOEditorGeneralTodo::writeTodo(Todo *todo) |
290 | { | 291 | { |
291 | KOEditorGeneral::writeIncidence(todo); | 292 | KOEditorGeneral::writeIncidence(todo); |
292 | 293 | ||
293 | // temp. until something better happens. | 294 | // temp. until something better happens. |
294 | QString tmpStr; | 295 | QString tmpStr; |
295 | 296 | ||
296 | todo->setHasDueDate(mDueCheck->isChecked()); | 297 | todo->setHasDueDate(mDueCheck->isChecked()); |
297 | todo->setHasStartDate(mStartCheck->isChecked()); | 298 | todo->setHasStartDate(mStartCheck->isChecked()); |
298 | 299 | ||
299 | QDate tmpDate; | 300 | QDate tmpDate; |
300 | QTime tmpTime; | 301 | QTime tmpTime; |
301 | QDateTime tmpDT; | 302 | QDateTime tmpDT; |
302 | if ( mTimeButton->isChecked() ) { | 303 | if ( mTimeButton->isChecked() ) { |
303 | todo->setFloats(false); | 304 | todo->setFloats(false); |
304 | 305 | ||
305 | // set due date/time | 306 | // set due date/time |
306 | tmpDate = mDueDateEdit->date(); | 307 | tmpDate = mDueDateEdit->date(); |
307 | tmpTime = mDueTimeEdit->getTime(); | 308 | tmpTime = mDueTimeEdit->getTime(); |
308 | tmpDT.setDate(tmpDate); | 309 | tmpDT.setDate(tmpDate); |
309 | tmpDT.setTime(tmpTime); | 310 | tmpDT.setTime(tmpTime); |
310 | todo->setDtDue(tmpDT); | 311 | todo->setDtDue(tmpDT); |
311 | 312 | ||
312 | // set start date/time | 313 | // set start date/time |
313 | tmpDate = mStartDateEdit->date(); | 314 | tmpDate = mStartDateEdit->date(); |
314 | tmpTime = mStartTimeEdit->getTime(); | 315 | tmpTime = mStartTimeEdit->getTime(); |
315 | tmpDT.setDate(tmpDate); | 316 | tmpDT.setDate(tmpDate); |
316 | tmpDT.setTime(tmpTime); | 317 | tmpDT.setTime(tmpTime); |
317 | todo->setDtStart(tmpDT); | 318 | todo->setDtStart(tmpDT); |
318 | } else { | 319 | } else { |
319 | todo->setFloats(true); | 320 | todo->setFloats(true); |
320 | 321 | ||
321 | // need to change this. | 322 | // need to change this. |
322 | tmpDate = mDueDateEdit->date(); | 323 | tmpDate = mDueDateEdit->date(); |
323 | tmpTime.setHMS(0,0,0); | 324 | tmpTime.setHMS(0,0,0); |
324 | tmpDT.setDate(tmpDate); | 325 | tmpDT.setDate(tmpDate); |
325 | tmpDT.setTime(tmpTime); | 326 | tmpDT.setTime(tmpTime); |
326 | todo->setDtDue(tmpDT); | 327 | todo->setDtDue(tmpDT); |
327 | 328 | ||
328 | tmpDate = mStartDateEdit->date(); | 329 | tmpDate = mStartDateEdit->date(); |
329 | tmpTime.setHMS(0,0,0); | 330 | tmpTime.setHMS(0,0,0); |
330 | tmpDT.setDate(tmpDate); | 331 | tmpDT.setDate(tmpDate); |
331 | tmpDT.setTime(tmpTime); | 332 | tmpDT.setTime(tmpTime); |
332 | todo->setDtStart(tmpDT); | 333 | todo->setDtStart(tmpDT); |
333 | } | 334 | } |
334 | todo->setPriority(mPriorityCombo->currentItem()+1); | 335 | todo->setPriority(mPriorityCombo->currentItem()+1); |
335 | 336 | ||
336 | // set completion state | 337 | // set completion state |
337 | if ( mCompletedCombo->currentItem() == 5 ) { | 338 | if ( mCompletedCombo->currentItem() == 5 ) { |
338 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); | 339 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); |
339 | if ( comp.isValid () ) { | 340 | if ( comp.isValid () ) { |
340 | todo->setPercentComplete(0); | 341 | todo->setPercentComplete(0); |
341 | todo->setPercentComplete(100); | 342 | todo->setPercentComplete(100); |
342 | todo->setCompleted(comp); | 343 | todo->setCompleted(comp); |
343 | } else { | 344 | } else { |
344 | todo->setPercentComplete( 100 ); | 345 | todo->setPercentComplete( 100 ); |
345 | if ( mCompleted.isValid() ) | 346 | if ( mCompleted.isValid() ) |
346 | todo->setCompleted(mCompleted); | 347 | todo->setCompleted(mCompleted); |
347 | } | 348 | } |
348 | } else { | 349 | } else { |
349 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | 350 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); |
350 | } | 351 | } |
351 | 352 | ||
352 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); | 353 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); |
353 | } | 354 | } |
354 | 355 | ||
355 | void KOEditorGeneralTodo::enableDueEdit(bool enable) | 356 | void KOEditorGeneralTodo::enableDueEdit(bool enable) |
356 | { | 357 | { |
357 | mDueDateEdit->setEnabled( enable ); | 358 | mDueDateEdit->setEnabled( enable ); |
358 | 359 | ||
359 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 360 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
360 | mTimeButton->setEnabled(true); | 361 | mTimeButton->setEnabled(true); |
361 | } | 362 | } |
362 | else { | 363 | else { |
363 | mTimeButton->setEnabled(false); | 364 | mTimeButton->setEnabled(false); |
364 | mTimeButton->setChecked(false); | 365 | mTimeButton->setChecked(false); |
365 | } | 366 | } |
366 | 367 | ||
367 | if (enable) { | 368 | if (enable) { |
368 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); | 369 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); |
369 | } else { | 370 | } else { |
370 | mDueTimeEdit->setEnabled( false ); | 371 | mDueTimeEdit->setEnabled( false ); |
371 | } | 372 | } |
372 | emit datesChecked(); | 373 | emit datesChecked(); |
373 | } | 374 | } |
374 | 375 | ||
375 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) | 376 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) |
376 | { | 377 | { |
377 | mStartDateEdit->setEnabled( enable ); | 378 | mStartDateEdit->setEnabled( enable ); |
378 | 379 | ||
379 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 380 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
380 | mTimeButton->setEnabled(true); | 381 | mTimeButton->setEnabled(true); |
381 | } | 382 | } |
382 | else { | 383 | else { |
383 | mTimeButton->setEnabled(false); | 384 | mTimeButton->setEnabled(false); |
384 | mTimeButton->setChecked(false); | 385 | mTimeButton->setChecked(false); |
385 | } | 386 | } |
386 | 387 | ||
387 | if (enable) { | 388 | if (enable) { |
388 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); | 389 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); |
389 | } else { | 390 | } else { |
390 | mStartTimeEdit->setEnabled( false ); | 391 | mStartTimeEdit->setEnabled( false ); |
391 | } | 392 | } |
392 | emit datesChecked(); | 393 | emit datesChecked(); |
393 | } | 394 | } |
394 | 395 | ||
395 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) | 396 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) |
396 | { | 397 | { |
397 | if(mStartCheck->isChecked()) { | 398 | if(mStartCheck->isChecked()) { |
398 | mStartTimeEdit->setEnabled( enable ); | 399 | mStartTimeEdit->setEnabled( enable ); |
399 | } | 400 | } |
400 | if(mDueCheck->isChecked()) { | 401 | if(mDueCheck->isChecked()) { |
401 | mDueTimeEdit->setEnabled( enable ); | 402 | mDueTimeEdit->setEnabled( enable ); |
402 | } | 403 | } |
403 | } | 404 | } |
404 | 405 | ||
405 | void KOEditorGeneralTodo::showAlarm() | 406 | void KOEditorGeneralTodo::showAlarm() |
406 | { | 407 | { |
407 | if ( mDueCheck->isChecked() ) { | 408 | if ( mDueCheck->isChecked() ) { |
408 | alarmDisable(false); | 409 | alarmDisable(false); |
409 | } | 410 | } |
410 | else { | 411 | else { |
411 | alarmDisable(true); | 412 | alarmDisable(true); |
412 | } | 413 | } |
413 | } | 414 | } |
414 | 415 | ||
415 | bool KOEditorGeneralTodo::validateInput() | 416 | bool KOEditorGeneralTodo::validateInput() |
416 | { | 417 | { |
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index eca7c14..49149f2 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -1,272 +1,278 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kglobal.h> | 36 | #include <kglobal.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include "libkdepim/kdatepicker.h" | 38 | #include "libkdepim/kdatepicker.h" |
39 | #include <knotifyclient.h> | 39 | #include <knotifyclient.h> |
40 | #include "kdatetbl.h" | 40 | #include "kdatetbl.h" |
41 | 41 | ||
42 | #include "koglobals.h" | 42 | #include "koglobals.h" |
43 | #include <kglobalsettings.h> | 43 | #include <kglobalsettings.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #ifndef KORG_NOPLUGINS | 45 | #ifndef KORG_NOPLUGINS |
46 | #include "kocore.h" | 46 | #include "kocore.h" |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <kcalendarsystem.h> | 49 | #include <kcalendarsystem.h> |
50 | 50 | ||
51 | #include "navigatorbar.h" | 51 | #include "navigatorbar.h" |
52 | 52 | ||
53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) | 53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) |
54 | : QWidget( parent, name ) | 54 | : QWidget( parent, name ) |
55 | { | 55 | { |
56 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 56 | QBoxLayout *topLayout = new QHBoxLayout( this ); |
57 | 57 | ||
58 | // Set up the control buttons and date label | 58 | // Set up the control buttons and date label |
59 | mCtrlFrame = new QFrame( this ); | 59 | mCtrlFrame = new QFrame( this ); |
60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); | 60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); |
61 | mCtrlFrame->setLineWidth(1); | 61 | mCtrlFrame->setLineWidth(1); |
62 | 62 | ||
63 | topLayout->addWidget( mCtrlFrame ); | 63 | topLayout->addWidget( mCtrlFrame ); |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | bool isRTL = KOGlobals::self()->reverseLayout(); | 67 | bool isRTL = KOGlobals::self()->reverseLayout(); |
68 | #ifndef DESKTOP_VERSION | 68 | #ifndef DESKTOP_VERSION |
69 | bool isDesktop = false; | 69 | bool isDesktop = false; |
70 | #else | 70 | #else |
71 | bool isDesktop = true; | 71 | bool isDesktop = true; |
72 | #endif | 72 | #endif |
73 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 73 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) |
74 | isDesktop = true; | 74 | isDesktop = true; |
75 | // Create backward navigation buttons | 75 | // Create backward navigation buttons |
76 | mPrevYear = new QPushButton( mCtrlFrame ); | 76 | mPrevYear = new QPushButton( mCtrlFrame ); |
77 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) ); | 77 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) ); |
78 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 78 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
79 | 79 | ||
80 | mPrevMonth = new QPushButton( mCtrlFrame ); | 80 | mPrevMonth = new QPushButton( mCtrlFrame ); |
81 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") ); | 81 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") ); |
82 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 82 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
83 | 83 | ||
84 | // Create forward navigation buttons | 84 | // Create forward navigation buttons |
85 | mNextMonth = new QPushButton( mCtrlFrame ); | 85 | mNextMonth = new QPushButton( mCtrlFrame ); |
86 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") ); | 86 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") ); |
87 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 87 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
88 | 88 | ||
89 | mPrevWeek = new QPushButton( mCtrlFrame ); | 89 | mPrevWeek = new QPushButton( mCtrlFrame ); |
90 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 90 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
91 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); | 91 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); |
92 | 92 | ||
93 | // Create forward navigation buttons | 93 | // Create forward navigation buttons |
94 | mNextWeek = new QPushButton( mCtrlFrame ); | 94 | mNextWeek = new QPushButton( mCtrlFrame ); |
95 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 95 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
96 | QToolTip::add( mNextWeek, i18n("Next Week") ); | 96 | QToolTip::add( mNextWeek, i18n("Next Week") ); |
97 | 97 | ||
98 | mNextYear = new QPushButton( mCtrlFrame ); | 98 | mNextYear = new QPushButton( mCtrlFrame ); |
99 | mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") ); | 99 | mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") ); |
100 | QToolTip::add( mNextYear, i18n("Next Year") ); | 100 | QToolTip::add( mNextYear, i18n("Next Year") ); |
101 | mSelectMonth = new QPushButton( mCtrlFrame ); | 101 | mSelectMonth = new QPushButton( mCtrlFrame ); |
102 | // Create month name label | 102 | // Create month name label |
103 | //selectMonth->setFont( tfont ); | 103 | //selectMonth->setFont( tfont ); |
104 | // selectMonth->setAlignment( AlignCenter ); | 104 | // selectMonth->setAlignment( AlignCenter ); |
105 | //mDateLabel = new QLabel( selectMonth ); | 105 | //mDateLabel = new QLabel( selectMonth ); |
106 | //mDateLabel->setFont( tfont ); | 106 | //mDateLabel->setFont( tfont ); |
107 | //mDateLabel->setAlignment( AlignCenter ); | 107 | //mDateLabel->setAlignment( AlignCenter ); |
108 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 108 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
109 | mNextMonth->setFlat( true); | 109 | mNextMonth->setFlat( true); |
110 | mNextWeek->setFlat( true); | 110 | mNextWeek->setFlat( true); |
111 | mNextYear->setFlat( true); | 111 | mNextYear->setFlat( true); |
112 | mSelectMonth->setFlat( true); | 112 | mSelectMonth->setFlat( true); |
113 | mPrevYear->setFlat( true); | 113 | mPrevYear->setFlat( true); |
114 | mPrevMonth->setFlat( true); | 114 | mPrevMonth->setFlat( true); |
115 | mPrevWeek->setFlat( true); | 115 | mPrevWeek->setFlat( true); |
116 | } else { | 116 | } else { |
117 | mPrevWeek->hide(); | 117 | mPrevWeek->hide(); |
118 | mNextWeek->hide(); | 118 | mNextWeek->hide(); |
119 | } | 119 | } |
120 | 120 | ||
121 | resetFont( font() ); | 121 | resetFont( font() ); |
122 | 122 | ||
123 | 123 | ||
124 | // set up control frame layout | 124 | // set up control frame layout |
125 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 125 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
126 | ctrlLayout->addWidget( mPrevYear, 3 ); | 126 | ctrlLayout->addWidget( mPrevYear, 3 ); |
127 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 127 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
128 | ctrlLayout->addWidget( mPrevWeek, 3 ); | 128 | ctrlLayout->addWidget( mPrevWeek, 3 ); |
129 | //ctrlLayout->addStretch( 1 ); | 129 | //ctrlLayout->addStretch( 1 ); |
130 | // ctrlLayout->addSpacing( 1 ); | 130 | // ctrlLayout->addSpacing( 1 ); |
131 | // ctrlLayout->addWidget( mDateLabel ); | 131 | // ctrlLayout->addWidget( mDateLabel ); |
132 | ctrlLayout->addWidget( mSelectMonth ); | 132 | ctrlLayout->addWidget( mSelectMonth ); |
133 | // ctrlLayout->addSpacing( 1 ); | 133 | // ctrlLayout->addSpacing( 1 ); |
134 | // ctrlLayout->addStretch( 1 ); | 134 | // ctrlLayout->addStretch( 1 ); |
135 | ctrlLayout->addWidget( mNextWeek, 3 ); | 135 | ctrlLayout->addWidget( mNextWeek, 3 ); |
136 | ctrlLayout->addWidget( mNextMonth, 3 ); | 136 | ctrlLayout->addWidget( mNextMonth, 3 ); |
137 | ctrlLayout->addWidget( mNextYear, 3 ); | 137 | ctrlLayout->addWidget( mNextYear, 3 ); |
138 | 138 | ||
139 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 139 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
140 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 140 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
141 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 141 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
142 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); | 142 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); |
143 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); | 143 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); |
144 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 144 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
145 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 145 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
146 | mPrevYear->setFocusPolicy(NoFocus); | 146 | mPrevYear->setFocusPolicy(NoFocus); |
147 | mPrevMonth->setFocusPolicy(NoFocus); | 147 | mPrevMonth->setFocusPolicy(NoFocus); |
148 | mNextMonth->setFocusPolicy(NoFocus); | 148 | mNextMonth->setFocusPolicy(NoFocus); |
149 | mPrevWeek->setFocusPolicy(NoFocus); | 149 | mPrevWeek->setFocusPolicy(NoFocus); |
150 | mNextWeek->setFocusPolicy(NoFocus); | 150 | mNextWeek->setFocusPolicy(NoFocus); |
151 | mNextYear->setFocusPolicy(NoFocus); | 151 | mNextYear->setFocusPolicy(NoFocus); |
152 | mSelectMonth->setFocusPolicy(NoFocus); | 152 | mSelectMonth->setFocusPolicy(NoFocus); |
153 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 153 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
154 | mPrevYear->setAutoRepeat( true ); | ||
155 | mPrevMonth->setAutoRepeat( true ); | ||
156 | mNextMonth->setAutoRepeat( true ); | ||
157 | mPrevWeek->setAutoRepeat( true ); | ||
158 | mNextWeek->setAutoRepeat( true ); | ||
159 | mNextYear->setAutoRepeat( true ); | ||
154 | 160 | ||
155 | } | 161 | } |
156 | 162 | ||
157 | NavigatorBar::~NavigatorBar() | 163 | NavigatorBar::~NavigatorBar() |
158 | { | 164 | { |
159 | } | 165 | } |
160 | QSize NavigatorBar::sizeHint() const | 166 | QSize NavigatorBar::sizeHint() const |
161 | { | 167 | { |
162 | int wid = mCurrentMinWid ; | 168 | int wid = mCurrentMinWid ; |
163 | if ( mPrevYear->isVisible() ) | 169 | if ( mPrevYear->isVisible() ) |
164 | wid += mCurrentButtonMinWid; | 170 | wid += mCurrentButtonMinWid; |
165 | if ( mPrevMonth->isVisible() ) | 171 | if ( mPrevMonth->isVisible() ) |
166 | wid += mCurrentButtonMinWid; | 172 | wid += mCurrentButtonMinWid; |
167 | if ( mPrevWeek->isVisible() ) | 173 | if ( mPrevWeek->isVisible() ) |
168 | wid += mCurrentButtonMinWid; | 174 | wid += mCurrentButtonMinWid; |
169 | if ( mNextMonth->isVisible() ) | 175 | if ( mNextMonth->isVisible() ) |
170 | wid += mCurrentButtonMinWid; | 176 | wid += mCurrentButtonMinWid; |
171 | if ( mNextWeek->isVisible() ) | 177 | if ( mNextWeek->isVisible() ) |
172 | wid += mCurrentButtonMinWid; | 178 | wid += mCurrentButtonMinWid; |
173 | if ( mNextYear->isVisible() ) | 179 | if ( mNextYear->isVisible() ) |
174 | wid += mCurrentButtonMinWid; | 180 | wid += mCurrentButtonMinWid; |
175 | //qDebug("ret %d %d ", wid, mCurrentHei); | 181 | //qDebug("ret %d %d ", wid, mCurrentHei); |
176 | return QSize ( wid, mCurrentHei ); | 182 | return QSize ( wid, mCurrentHei ); |
177 | } | 183 | } |
178 | QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const | 184 | QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const |
179 | { | 185 | { |
180 | return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei ); | 186 | return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei ); |
181 | } | 187 | } |
182 | void NavigatorBar::resetFont ( QFont fo ) | 188 | void NavigatorBar::resetFont ( QFont fo ) |
183 | { | 189 | { |
184 | 190 | ||
185 | QFont tfont = fo; | 191 | QFont tfont = fo; |
186 | if ( QApplication::desktop()->width() >= 480 ) | 192 | if ( QApplication::desktop()->width() >= 480 ) |
187 | tfont.setPointSize(tfont.pointSize()+2); | 193 | tfont.setPointSize(tfont.pointSize()+2); |
188 | tfont.setBold(true); | 194 | tfont.setBold(true); |
189 | 195 | ||
190 | mSelectMonth->setFont( tfont ); | 196 | mSelectMonth->setFont( tfont ); |
191 | // Set minimum width to width of widest month name label | 197 | // Set minimum width to width of widest month name label |
192 | int i; | 198 | int i; |
193 | int maxwidth = 0; | 199 | int maxwidth = 0; |
194 | QFontMetrics fm ( mSelectMonth->font() ); | 200 | QFontMetrics fm ( mSelectMonth->font() ); |
195 | int width = fm.width("September '00" ); | 201 | int width = fm.width("September '00" ); |
196 | maxwidth = width+2; | 202 | maxwidth = width+2; |
197 | int size = fm.height()+2; | 203 | int size = fm.height()+2; |
198 | if ( QApplication::desktop()->width() >= 480 ) { | 204 | if ( QApplication::desktop()->width() >= 480 ) { |
199 | size += 6; | 205 | size += 6; |
200 | maxwidth+= 6; | 206 | maxwidth+= 6; |
201 | } | 207 | } |
202 | mSelectMonth->setMinimumWidth( maxwidth ); | 208 | mSelectMonth->setMinimumWidth( maxwidth ); |
203 | mSelectMonth->setFixedHeight( size ); | 209 | mSelectMonth->setFixedHeight( size ); |
204 | mPrevYear->setFixedHeight( size ); | 210 | mPrevYear->setFixedHeight( size ); |
205 | mPrevMonth->setFixedHeight( size ); | 211 | mPrevMonth->setFixedHeight( size ); |
206 | mPrevWeek->setFixedHeight( size ); | 212 | mPrevWeek->setFixedHeight( size ); |
207 | mNextMonth->setFixedHeight( size ); | 213 | mNextMonth->setFixedHeight( size ); |
208 | mNextWeek->setFixedHeight( size ); | 214 | mNextWeek->setFixedHeight( size ); |
209 | mNextYear->setFixedHeight ( size ); | 215 | mNextYear->setFixedHeight ( size ); |
210 | mCurrentHei = size +2; | 216 | mCurrentHei = size +2; |
211 | mCurrentMinWid = maxwidth+2; | 217 | mCurrentMinWid = maxwidth+2; |
212 | mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2; | 218 | mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2; |
213 | } | 219 | } |
214 | 220 | ||
215 | void NavigatorBar::showButtons( bool left, bool right ) | 221 | void NavigatorBar::showButtons( bool left, bool right ) |
216 | { | 222 | { |
217 | if ( left ) { | 223 | if ( left ) { |
218 | mPrevYear->show(); | 224 | mPrevYear->show(); |
219 | mPrevMonth->show(); | 225 | mPrevMonth->show(); |
220 | } else { | 226 | } else { |
221 | mPrevYear->hide(); | 227 | mPrevYear->hide(); |
222 | mPrevMonth->hide(); | 228 | mPrevMonth->hide(); |
223 | } | 229 | } |
224 | 230 | ||
225 | if ( right ) { | 231 | if ( right ) { |
226 | mNextYear->show(); | 232 | mNextYear->show(); |
227 | mNextMonth->show(); | 233 | mNextMonth->show(); |
228 | } else { | 234 | } else { |
229 | mNextYear->hide(); | 235 | mNextYear->hide(); |
230 | mNextMonth->hide(); | 236 | mNextMonth->hide(); |
231 | } | 237 | } |
232 | if ( !left && !right ) { | 238 | if ( !left && !right ) { |
233 | //mSelectMonth->setMaximumWidth( 1024 ); | 239 | //mSelectMonth->setMaximumWidth( 1024 ); |
234 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 240 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
235 | } | 241 | } |
236 | } | 242 | } |
237 | 243 | ||
238 | void NavigatorBar::selectMonth() | 244 | void NavigatorBar::selectMonth() |
239 | { | 245 | { |
240 | 246 | ||
241 | int month; | 247 | int month; |
242 | KPopupFrame* popup = new KPopupFrame(this); | 248 | KPopupFrame* popup = new KPopupFrame(this); |
243 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 249 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
244 | // ----- | 250 | // ----- |
245 | picker->resize(picker->sizeHint()); | 251 | picker->resize(picker->sizeHint()); |
246 | popup->setMainWidget(picker); | 252 | popup->setMainWidget(picker); |
247 | picker->setFocus(); | 253 | picker->setFocus(); |
248 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 254 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
249 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 255 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
250 | { | 256 | { |
251 | month = picker->getResult(); | 257 | month = picker->getResult(); |
252 | emit monthSelected ( month ); | 258 | emit monthSelected ( month ); |
253 | } else { | 259 | } else { |
254 | KNotifyClient::beep(); | 260 | KNotifyClient::beep(); |
255 | } | 261 | } |
256 | delete popup; | 262 | delete popup; |
257 | } | 263 | } |
258 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 264 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
259 | { | 265 | { |
260 | if (dateList.count() > 0) { | 266 | if (dateList.count() > 0) { |
261 | QDate date = dateList.first(); | 267 | QDate date = dateList.first(); |
262 | 268 | ||
263 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | 269 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); |
264 | 270 | ||
265 | // compute the label at the top of the navigator | 271 | // compute the label at the top of the navigator |
266 | QString dtstr = i18n(calSys->monthName( date )) + " '" + | 272 | QString dtstr = i18n(calSys->monthName( date )) + " '" + |
267 | QString::number( calSys->year( date ) ).right(2); | 273 | QString::number( calSys->year( date ) ).right(2); |
268 | 274 | ||
269 | mSelectMonth->setText( dtstr ); | 275 | mSelectMonth->setText( dtstr ); |
270 | } | 276 | } |
271 | } | 277 | } |
272 | 278 | ||