summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-04 18:24:25 (UTC)
committer zautrix <zautrix>2005-04-04 18:24:25 (UTC)
commitff205358654ed8741f0008eabd64a0e8b0476b61 (patch) (unidiff)
tree52844c5c14286c463fc11b132b6d92cd6d72c96c
parent13fa1e5e1d5e4663bbbc79e0c68caf725ad2e31b (diff)
downloadkdepimpi-ff205358654ed8741f0008eabd64a0e8b0476b61.zip
kdepimpi-ff205358654ed8741f0008eabd64a0e8b0476b61.tar.gz
kdepimpi-ff205358654ed8741f0008eabd64a0e8b0476b61.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp1
-rw-r--r--korganizer/koagendaview.cpp3
-rw-r--r--libkcal/calendarlocal.cpp2
3 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index de964da..b5d52d2 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -326,128 +326,129 @@ void KOAgenda::clear()
326 mUnusedItems.append( item ); 326 mUnusedItems.append( item );
327 //item->hide(); 327 //item->hide();
328 } 328 }
329 mItems.clear(); 329 mItems.clear();
330 mSelectedItem = 0; 330 mSelectedItem = 0;
331 clearSelection(); 331 clearSelection();
332} 332}
333 333
334void KOAgenda::clearSelection() 334void KOAgenda::clearSelection()
335{ 335{
336 mSelectionCellX = 0; 336 mSelectionCellX = 0;
337 mSelectionYTop = 0; 337 mSelectionYTop = 0;
338 mSelectionHeight = 0; 338 mSelectionHeight = 0;
339} 339}
340 340
341void KOAgenda::marcus_bains() 341void KOAgenda::marcus_bains()
342{ 342{
343 if(mMarcusBains) mMarcusBains->updateLocation(true); 343 if(mMarcusBains) mMarcusBains->updateLocation(true);
344} 344}
345 345
346 346
347void KOAgenda::changeColumns(int columns) 347void KOAgenda::changeColumns(int columns)
348{ 348{
349 if (columns == 0) { 349 if (columns == 0) {
350 qDebug("KOAgenda::changeColumns() called with argument 0 "); 350 qDebug("KOAgenda::changeColumns() called with argument 0 ");
351 return; 351 return;
352 } 352 }
353 clear(); 353 clear();
354 mColumns = columns; 354 mColumns = columns;
355 computeSizes(); 355 computeSizes();
356} 356}
357 357
358/* 358/*
359 This is the eventFilter function, which gets all events from the KOAgendaItems 359 This is the eventFilter function, which gets all events from the KOAgendaItems
360 contained in the agenda. It has to handle moving and resizing for all items. 360 contained in the agenda. It has to handle moving and resizing for all items.
361*/ 361*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
363{ 363{
364 // kdDebug() << "KOAgenda::eventFilter" << endl; 364 // kdDebug() << "KOAgenda::eventFilter" << endl;
365 switch(event->type()) { 365 switch(event->type()) {
366 case QEvent::MouseButtonPress: 366 case QEvent::MouseButtonPress:
367 case QEvent::MouseButtonDblClick: 367 case QEvent::MouseButtonDblClick:
368 case QEvent::MouseButtonRelease: 368 case QEvent::MouseButtonRelease:
369 case QEvent::MouseMove: 369 case QEvent::MouseMove:
370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
371 371
372 case (QEvent::Leave): 372 case (QEvent::Leave):
373 if (!mActionItem) 373 if (!mActionItem)
374 setCursor(arrowCursor); 374 setCursor(arrowCursor);
375 return true; 375 return true;
376 376
377 default: 377 default:
378 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
379 } 379 }
380} 380}
381void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
382{ 382{
383 mPopupTimer->stop(); 383 mPopupTimer->stop();
384 if ( mPopupKind == 1 ) { 384 if ( mPopupKind == 1 ) {
385 if (mActionItem ) { 385 if (mActionItem ) {
386 endItemAction(); 386 endItemAction();
387 } 387 }
388 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 389 if (mPopupItem) {
390 //mClickedItem = mPopupItem;
390 selectItem(mPopupItem); 391 selectItem(mPopupItem);
391 if ( mAllAgendaPopup ) 392 if ( mAllAgendaPopup )
392 mAllAgendaPopup->installEventFilter( this ); 393 mAllAgendaPopup->installEventFilter( this );
393 emit showIncidencePopupSignal(mPopupItem->incidence()); 394 emit showIncidencePopupSignal(mPopupItem->incidence());
394 395
395 } 396 }
396 } else if ( mPopupKind == 2 ) { 397 } else if ( mPopupKind == 2 ) {
397 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
398 endSelectAction( false ); // do not emit new event signal 399 endSelectAction( false ); // do not emit new event signal
399 mLeftMouseDown = false; // no more leftMouse computation 400 mLeftMouseDown = false; // no more leftMouse computation
400 } 401 }
401 mNewItemPopup->installEventFilter( this ); 402 mNewItemPopup->installEventFilter( this );
402 mNewItemPopup->popup( mPopupPos); 403 mNewItemPopup->popup( mPopupPos);
403 404
404 } 405 }
405 mLeftMouseDown = false; 406 mLeftMouseDown = false;
406 mPopupItem = 0; 407 mPopupItem = 0;
407 mPopupKind = 0; 408 mPopupKind = 0;
408} 409}
409 410
410bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 411bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
411{ 412{
412 static int startX = 0; 413 static int startX = 0;
413 static int startY = 0; 414 static int startY = 0;
414 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 415 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
415 static bool blockMoving = true; 416 static bool blockMoving = true;
416 417
417 //qDebug("KOAgenda::eventFilter_mous "); 418 //qDebug("KOAgenda::eventFilter_mous ");
418 if ( object == mNewItemPopup ) { 419 if ( object == mNewItemPopup ) {
419 //qDebug("mNewItemPopup "); 420 //qDebug("mNewItemPopup ");
420 if ( me->type() == QEvent::MouseButtonRelease ) { 421 if ( me->type() == QEvent::MouseButtonRelease ) {
421 mNewItemPopup->removeEventFilter( this ); 422 mNewItemPopup->removeEventFilter( this );
422 int dX = me->globalPos().x() - mPopupPos.x();; 423 int dX = me->globalPos().x() - mPopupPos.x();;
423 if ( dX < 0 ) 424 if ( dX < 0 )
424 dX = -dX; 425 dX = -dX;
425 int dY = me->globalPos().y() - mPopupPos.y(); 426 int dY = me->globalPos().y() - mPopupPos.y();
426 if ( dY < 0 ) 427 if ( dY < 0 )
427 dY = -dY; 428 dY = -dY;
428 if ( dX > blockmoveDist || dY > blockmoveDist ) { 429 if ( dX > blockmoveDist || dY > blockmoveDist ) {
429 mNewItemPopup->hide(); 430 mNewItemPopup->hide();
430 } 431 }
431 } 432 }
432 return true; 433 return true;
433 } 434 }
434 if ( object == mAllAgendaPopup ) { 435 if ( object == mAllAgendaPopup ) {
435 //qDebug(" mAllAgendaPopup "); 436 //qDebug(" mAllAgendaPopup ");
436 if ( me->type() == QEvent::MouseButtonRelease ) { 437 if ( me->type() == QEvent::MouseButtonRelease ) {
437 mAllAgendaPopup->removeEventFilter( this ); 438 mAllAgendaPopup->removeEventFilter( this );
438 int dX = me->globalPos().x() - mPopupPos.x();; 439 int dX = me->globalPos().x() - mPopupPos.x();;
439 if ( dX < 0 ) 440 if ( dX < 0 )
440 dX = -dX; 441 dX = -dX;
441 int dY = me->globalPos().y() - mPopupPos.y(); 442 int dY = me->globalPos().y() - mPopupPos.y();
442 if ( dY < 0 ) 443 if ( dY < 0 )
443 dY = -dY; 444 dY = -dY;
444 if ( dX > blockmoveDist || dY > blockmoveDist ) { 445 if ( dX > blockmoveDist || dY > blockmoveDist ) {
445 mAllAgendaPopup->hide(); 446 mAllAgendaPopup->hide();
446 } 447 }
447 } 448 }
448 return true; 449 return true;
449 } 450 }
450 QPoint viewportPos; 451 QPoint viewportPos;
451 if (object != viewport()) { 452 if (object != viewport()) {
452 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 453 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
453 } else { 454 } else {
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 6d1e6d5..20a5b74 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -403,133 +403,134 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 // FIX 437 // FIX
438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
439#endif 439#endif
440 mDayLabelsFrame = new QHBox(agendaFrame); 440 mDayLabelsFrame = new QHBox(agendaFrame);
441 //topLayout->addWidget(mDayLabelsFrame); 441 //topLayout->addWidget(mDayLabelsFrame);
442 mDayLabels = new QFrame (mDayLabelsFrame); 442 mDayLabels = new QFrame (mDayLabelsFrame);
443 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 443 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
445 agendaLayout->addWidget(mEventIndicatorTop,1,1); 445 agendaLayout->addWidget(mEventIndicatorTop,1,1);
446 446
447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
448 agendaFrame); 448 agendaFrame);
449 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 449 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
450 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 450 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
451 agendaLayout->addWidget(dummyAgendaRight,1,2); 451 agendaLayout->addWidget(dummyAgendaRight,1,2);
452 452
453 // Create time labels 453 // Create time labels
454 mTimeLabels = new TimeLabels(24,agendaFrame); 454 mTimeLabels = new TimeLabels(24,agendaFrame);
455 agendaLayout->addWidget(mTimeLabels,2,0); 455 agendaLayout->addWidget(mTimeLabels,2,0);
456 connect(mTimeLabels,SIGNAL( scaleChanged()), 456 connect(mTimeLabels,SIGNAL( scaleChanged()),
457 this,SLOT(updateConfig())); 457 this,SLOT(updateConfig()));
458 458
459 // Create agenda 459 // Create agenda
460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
462 agendaLayout->setColStretch(1,1); 462 agendaLayout->setColStretch(1,1);
463 mAgenda->setFocusPolicy(NoFocus); 463 mAgenda->setFocusPolicy(NoFocus);
464 // Create event context menu for agenda 464 // Create event context menu for agenda
465 mAllAgendaPopup = eventPopup(); 465 mAllAgendaPopup = eventPopup();
466 466
467#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 468 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 469 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 470 SLOT(popupAlarm()),true);
470 471
471 472#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 473 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 474 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 475
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 476 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 477 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 mAgenda->setPopup( mAllAgendaPopup ); 478 mAgenda->setPopup( mAllAgendaPopup );
478 mAllDayAgenda->setPopup( mAllAgendaPopup ); 479 mAllDayAgenda->setPopup( mAllAgendaPopup );
479 // make connections between dependent widgets 480 // make connections between dependent widgets
480 mTimeLabels->setAgenda(mAgenda); 481 mTimeLabels->setAgenda(mAgenda);
481 482
482 // Update widgets to reflect user preferences 483 // Update widgets to reflect user preferences
483 // updateConfig(); 484 // updateConfig();
484 485
485 // createDayLabels(); 486 // createDayLabels();
486 487
487 // these blank widgets make the All Day Event box line up with the agenda 488 // these blank widgets make the All Day Event box line up with the agenda
488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 490 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 491 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
491 492
492 // Scrolling 493 // Scrolling
493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 494 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
494 mTimeLabels, SLOT(positionChanged())); 495 mTimeLabels, SLOT(positionChanged()));
495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 496 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
496 SLOT(setContentsPos(int))); 497 SLOT(setContentsPos(int)));
497 498
498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 499 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 500 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
500 501
501 // Create/Show/Edit/Delete Event 502 // Create/Show/Edit/Delete Event
502 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 503 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
503 SLOT(newEvent(int,int))); 504 SLOT(newEvent(int,int)));
504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 505 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
505 SLOT(newTodo(int,int))); 506 SLOT(newTodo(int,int)));
506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
507 SLOT(newEvent(int,int,int,int))); 508 SLOT(newEvent(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 509 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEventAllDay(int,int))); 510 SLOT(newEventAllDay(int,int)));
510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 511 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodoAllDay(int,int))); 512 SLOT(newTodoAllDay(int,int)));
512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 515 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
515 SLOT(newTimeSpanSelected(int,int,int,int))); 516 SLOT(newTimeSpanSelected(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 518 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 520 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 521
521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 522 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
522 SIGNAL(editIncidenceSignal(Incidence *))); 523 SIGNAL(editIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 524 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
524 SIGNAL(editIncidenceSignal(Incidence *))); 525 SIGNAL(editIncidenceSignal(Incidence *)));
525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
526 SIGNAL(showIncidenceSignal(Incidence *))); 527 SIGNAL(showIncidenceSignal(Incidence *)));
527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
528 SIGNAL(showIncidenceSignal(Incidence *))); 529 SIGNAL(showIncidenceSignal(Incidence *)));
529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
530 SIGNAL(deleteIncidenceSignal(Incidence *))); 531 SIGNAL(deleteIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
532 SIGNAL(deleteIncidenceSignal(Incidence *))); 533 SIGNAL(deleteIncidenceSignal(Incidence *)));
533 534
534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 535 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
535 SLOT(updateEventDates(KOAgendaItem *, int ))); 536 SLOT(updateEventDates(KOAgendaItem *, int )));
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 5c889c3..00a43e5 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -237,204 +237,204 @@ void CalendarLocal::removeSyncInfo( QString syncProfile)
237 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 237 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
238 el.append( todo ); 238 el.append( todo );
239 } 239 }
240 for ( todo = el.first(); todo; todo = el.next() ) { 240 for ( todo = el.first(); todo; todo = el.next() ) {
241 deleteIncidence ( todo ); 241 deleteIncidence ( todo );
242 } 242 }
243 } else { 243 } else {
244 Event *lse = event( "last-syncEvent-"+ syncProfile); 244 Event *lse = event( "last-syncEvent-"+ syncProfile);
245 if ( lse ) 245 if ( lse )
246 deleteIncidence ( lse ); 246 deleteIncidence ( lse );
247 } 247 }
248} 248}
249QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 249QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
250{ 250{
251 QPtrList<Event> el; 251 QPtrList<Event> el;
252 Event *todo; 252 Event *todo;
253 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 253 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
254 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 254 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
255 if ( todo->summary().left(3) == "E: " ) 255 if ( todo->summary().left(3) == "E: " )
256 el.append( todo ); 256 el.append( todo );
257 } 257 }
258 258
259 return el; 259 return el;
260 260
261} 261}
262Event *CalendarLocal::event( QString syncProf, QString id ) 262Event *CalendarLocal::event( QString syncProf, QString id )
263{ 263{
264 Event *todo; 264 Event *todo;
265 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 265 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
266 if ( todo->getID( syncProf ) == id ) return todo; 266 if ( todo->getID( syncProf ) == id ) return todo;
267 } 267 }
268 268
269 return 0; 269 return 0;
270} 270}
271Todo *CalendarLocal::todo( const QString &uid ) 271Todo *CalendarLocal::todo( const QString &uid )
272{ 272{
273 Todo *todo; 273 Todo *todo;
274 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 274 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
275 if ( todo->uid() == uid ) return todo; 275 if ( todo->uid() == uid ) return todo;
276 } 276 }
277 277
278 return 0; 278 return 0;
279} 279}
280QString CalendarLocal::nextSummary() const 280QString CalendarLocal::nextSummary() const
281{ 281{
282 return mNextSummary; 282 return mNextSummary;
283} 283}
284QDateTime CalendarLocal::nextAlarmEventDateTime() const 284QDateTime CalendarLocal::nextAlarmEventDateTime() const
285{ 285{
286 return mNextAlarmEventDateTime; 286 return mNextAlarmEventDateTime;
287} 287}
288void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 288void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
289{ 289{
290 //mNextAlarmIncidence 290 //mNextAlarmIncidence
291 //mNextAlarmDateTime 291 //mNextAlarmDateTime
292 //return mNextSummary; 292 //return mNextSummary;
293 //return mNextAlarmEventDateTime; 293 //return mNextAlarmEventDateTime;
294 bool newNextAlarm = false; 294 bool newNextAlarm = false;
295 bool computeNextAlarm = false; 295 bool computeNextAlarm = false;
296 bool ok; 296 bool ok;
297 int offset; 297 int offset;
298 QDateTime nextA; 298 QDateTime nextA;
299 // QString nextSum; 299 // QString nextSum;
300 //QDateTime nextEvent; 300 //QDateTime nextEvent;
301 mNextAlarmEventDateTime = QDateTime();
302 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 301 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
303 computeNextAlarm = true; 302 computeNextAlarm = true;
304 } else { 303 } else {
305 if ( ! deleted ) { 304 if ( ! deleted ) {
306 nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; 305 nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ;
307 if ( ok ) { 306 if ( ok ) {
308 if ( nextA < mNextAlarmDateTime ) { 307 if ( nextA < mNextAlarmDateTime ) {
309 deRegisterAlarm(); 308 deRegisterAlarm();
310 mNextAlarmDateTime = nextA; 309 mNextAlarmDateTime = nextA;
311 mNextSummary = incidence->summary(); 310 mNextSummary = incidence->summary();
312 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 311 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
313 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 312 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
314 newNextAlarm = true; 313 newNextAlarm = true;
315 mNextAlarmIncidence = incidence; 314 mNextAlarmIncidence = incidence;
316 } else { 315 } else {
317 if ( incidence == mNextAlarmIncidence ) { 316 if ( incidence == mNextAlarmIncidence ) {
318 computeNextAlarm = true; 317 computeNextAlarm = true;
319 } 318 }
320 } 319 }
321 } else { 320 } else {
322 if ( mNextAlarmIncidence == incidence ) { 321 if ( mNextAlarmIncidence == incidence ) {
323 computeNextAlarm = true; 322 computeNextAlarm = true;
324 } 323 }
325 } 324 }
326 } else { // deleted 325 } else { // deleted
327 if ( incidence == mNextAlarmIncidence ) { 326 if ( incidence == mNextAlarmIncidence ) {
328 computeNextAlarm = true; 327 computeNextAlarm = true;
329 } 328 }
330 } 329 }
331 } 330 }
332 if ( computeNextAlarm ) { 331 if ( computeNextAlarm ) {
333 deRegisterAlarm(); 332 deRegisterAlarm();
334 nextA = nextAlarm( 1000 ); 333 nextA = nextAlarm( 1000 );
335 if (! mNextAlarmIncidence ) { 334 if (! mNextAlarmIncidence ) {
336 return; 335 return;
337 } 336 }
338 newNextAlarm = true; 337 newNextAlarm = true;
339 } 338 }
340 if ( newNextAlarm ) 339 if ( newNextAlarm )
341 registerAlarm(); 340 registerAlarm();
342} 341}
343QString CalendarLocal:: getAlarmNotification() 342QString CalendarLocal:: getAlarmNotification()
344{ 343{
345 QString ret; 344 QString ret;
346 // this should not happen 345 // this should not happen
347 if (! mNextAlarmIncidence ) 346 if (! mNextAlarmIncidence )
348 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; 347 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString;
349 Alarm* alarm = mNextAlarmIncidence->alarms().first(); 348 Alarm* alarm = mNextAlarmIncidence->alarms().first();
350 if ( alarm->type() == Alarm::Procedure ) { 349 if ( alarm->type() == Alarm::Procedure ) {
351 ret = "proc_alarm" + alarm->programFile()+"+++"; 350 ret = "proc_alarm" + alarm->programFile()+"+++";
352 } else { 351 } else {
353 ret = "audio_alarm" +alarm->audioFile() +"+++"; 352 ret = "audio_alarm" +alarm->audioFile() +"+++";
354 } 353 }
355 ret += "cal_alarm"+ mNextSummary.left( 25 ); 354 ret += "cal_alarm"+ mNextSummary.left( 25 );
356 if ( mNextSummary.length() > 25 ) 355 if ( mNextSummary.length() > 25 )
357 ret += "\n" + mNextSummary.mid(25, 25 ); 356 ret += "\n" + mNextSummary.mid(25, 25 );
358 ret+= "\n"+mNextAlarmEventDateTimeString; 357 ret+= "\n"+mNextAlarmEventDateTimeString;
359 return ret; 358 return ret;
360} 359}
361void CalendarLocal::registerAlarm() 360void CalendarLocal::registerAlarm()
362{ 361{
363 mLastAlarmNotificationString = getAlarmNotification(); 362 mLastAlarmNotificationString = getAlarmNotification();
364 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); 363 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() );
365 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 364 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
366// #ifndef DESKTOP_VERSION 365// #ifndef DESKTOP_VERSION
367// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); 366// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() );
368// #endif 367// #endif
369} 368}
370void CalendarLocal::deRegisterAlarm() 369void CalendarLocal::deRegisterAlarm()
371{ 370{
372 if ( mLastAlarmNotificationString.isNull() ) 371 if ( mLastAlarmNotificationString.isNull() )
373 return; 372 return;
374 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 373 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
375 374
376 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 375 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
376 mNextAlarmEventDateTime = QDateTime();
377// #ifndef DESKTOP_VERSION 377// #ifndef DESKTOP_VERSION
378// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); 378// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() );
379// #endif 379// #endif
380} 380}
381 381
382QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 382QPtrList<Todo> CalendarLocal::todos( const QDate &date )
383{ 383{
384 QPtrList<Todo> todos; 384 QPtrList<Todo> todos;
385 385
386 Todo *todo; 386 Todo *todo;
387 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 387 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
388 if ( todo->hasDueDate() && todo->dtDue().date() == date ) { 388 if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
389 todos.append( todo ); 389 todos.append( todo );
390 } 390 }
391 } 391 }
392 392
393 filter()->apply( &todos ); 393 filter()->apply( &todos );
394 return todos; 394 return todos;
395} 395}
396void CalendarLocal::reInitAlarmSettings() 396void CalendarLocal::reInitAlarmSettings()
397{ 397{
398 if ( !mNextAlarmIncidence ) { 398 if ( !mNextAlarmIncidence ) {
399 nextAlarm( 1000 ); 399 nextAlarm( 1000 );
400 } 400 }
401 deRegisterAlarm(); 401 deRegisterAlarm();
402 mNextAlarmIncidence = 0; 402 mNextAlarmIncidence = 0;
403 checkAlarmForIncidence( 0, false ); 403 checkAlarmForIncidence( 0, false );
404 404
405} 405}
406 406
407 407
408 408
409QDateTime CalendarLocal::nextAlarm( int daysTo ) 409QDateTime CalendarLocal::nextAlarm( int daysTo )
410{ 410{
411 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); 411 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo );
412 QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); 412 QDateTime start = QDateTime::currentDateTime().addSecs( 30 );
413 QDateTime next; 413 QDateTime next;
414 Event *e; 414 Event *e;
415 bool ok; 415 bool ok;
416 bool found = false; 416 bool found = false;
417 int offset; 417 int offset;
418 mNextAlarmIncidence = 0; 418 mNextAlarmIncidence = 0;
419 for( e = mEventList.first(); e; e = mEventList.next() ) { 419 for( e = mEventList.first(); e; e = mEventList.next() ) {
420 next = e->getNextAlarmDateTime(& ok, &offset ) ; 420 next = e->getNextAlarmDateTime(& ok, &offset ) ;
421 if ( ok ) { 421 if ( ok ) {
422 if ( next < nextA ) { 422 if ( next < nextA ) {
423 nextA = next; 423 nextA = next;
424 found = true; 424 found = true;
425 mNextSummary = e->summary(); 425 mNextSummary = e->summary();
426 mNextAlarmEventDateTime = next.addSecs(offset ) ; 426 mNextAlarmEventDateTime = next.addSecs(offset ) ;
427 mNextAlarmIncidence = (Incidence *) e; 427 mNextAlarmIncidence = (Incidence *) e;
428 } 428 }
429 } 429 }
430 } 430 }
431 Todo *t; 431 Todo *t;
432 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 432 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
433 next = t->getNextAlarmDateTime(& ok, &offset ) ; 433 next = t->getNextAlarmDateTime(& ok, &offset ) ;
434 if ( ok ) { 434 if ( ok ) {
435 if ( next < nextA ) { 435 if ( next < nextA ) {
436 nextA = next; 436 nextA = next;
437 found = true; 437 found = true;
438 mNextSummary = t->summary(); 438 mNextSummary = t->summary();
439 mNextAlarmEventDateTime = next.addSecs(offset ); 439 mNextAlarmEventDateTime = next.addSecs(offset );
440 mNextAlarmIncidence = (Incidence *) t; 440 mNextAlarmIncidence = (Incidence *) t;