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
@@ -198,384 +198,385 @@ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 199#endif
200 mHolidayMask = 0; 200 mHolidayMask = 0;
201 init(); 201 init();
202} 202}
203 203
204 204
205KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
206{ 206{
207 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
208 208
209} 209}
210 210
211Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
212{ 212{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 214}
215 215
216 216
217QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
218{ 218{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 220}
221 221
222 222
223void KOAgenda::init() 223void KOAgenda::init()
224{ 224{
225 mPopupTimer = new QTimer(this); 225 mPopupTimer = new QTimer(this);
226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
227 227
228 mNewItemPopup = new QPopupMenu( this ); 228 mNewItemPopup = new QPopupMenu( this );
229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
230 QString pathString = ""; 230 QString pathString = "";
231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
232 if ( QApplication::desktop()->width() < 480 ) 232 if ( QApplication::desktop()->width() < 480 )
233 pathString += "icons16/"; 233 pathString += "icons16/";
234 } else 234 } else
235 pathString += "iconsmini/"; 235 pathString += "iconsmini/";
236 236
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
239 mNewItemPopup->insertSeparator ( ); 239 mNewItemPopup->insertSeparator ( );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
246#ifndef _WIN32_ 246#ifndef _WIN32_
247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
248 viewport()->setWFlags ( wflags); 248 viewport()->setWFlags ( wflags);
249#endif 249#endif
250 mGridSpacingX = 80; 250 mGridSpacingX = 80;
251 mResizeBorderWidth = 8; 251 mResizeBorderWidth = 8;
252 mScrollBorderWidth = 8; 252 mScrollBorderWidth = 8;
253 mScrollDelay = 30; 253 mScrollDelay = 30;
254 mScrollOffset = 10; 254 mScrollOffset = 10;
255 mPaintPixmap.resize( 20,20); 255 mPaintPixmap.resize( 20,20);
256 //enableClipper(true); 256 //enableClipper(true);
257 257
258 // Grab key strokes for keyboard navigation of agenda. Seems to have no 258 // Grab key strokes for keyboard navigation of agenda. Seems to have no
259 // effect. Has to be fixed. 259 // effect. Has to be fixed.
260 setFocusPolicy(WheelFocus); 260 setFocusPolicy(WheelFocus);
261 261
262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
265 265
266 mStartCellX = 0; 266 mStartCellX = 0;
267 mStartCellY = 0; 267 mStartCellY = 0;
268 mCurrentCellX = 0; 268 mCurrentCellX = 0;
269 mCurrentCellY = 0; 269 mCurrentCellY = 0;
270 270
271 mSelectionCellX = 0; 271 mSelectionCellX = 0;
272 mSelectionYTop = 0; 272 mSelectionYTop = 0;
273 mSelectionHeight = 0; 273 mSelectionHeight = 0;
274 274
275 mOldLowerScrollValue = -1; 275 mOldLowerScrollValue = -1;
276 mOldUpperScrollValue = -1; 276 mOldUpperScrollValue = -1;
277 277
278 mClickedItem = 0; 278 mClickedItem = 0;
279 279
280 mActionItem = 0; 280 mActionItem = 0;
281 mActionType = NOP; 281 mActionType = NOP;
282 mItemMoved = false; 282 mItemMoved = false;
283 283
284 mSelectedItem = 0; 284 mSelectedItem = 0;
285 285
286 // mItems.setAutoDelete(true); 286 // mItems.setAutoDelete(true);
287 287
288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
289 289
290 viewport()->update(); 290 viewport()->update();
291 291
292 setMinimumSize(30, 1); 292 setMinimumSize(30, 1);
293// setMaximumHeight(mGridSpacingY * mRows + 5); 293// setMaximumHeight(mGridSpacingY * mRows + 5);
294 294
295 // Disable horizontal scrollbar. This is a hack. The geometry should be 295 // Disable horizontal scrollbar. This is a hack. The geometry should be
296 // controlled in a way that the contents horizontally always fits. Then it is 296 // controlled in a way that the contents horizontally always fits. Then it is
297 // not necessary to turn off the scrollbar. 297 // not necessary to turn off the scrollbar.
298 setHScrollBarMode(AlwaysOff); 298 setHScrollBarMode(AlwaysOff);
299 if ( ! mAllDayMode ) 299 if ( ! mAllDayMode )
300 setVScrollBarMode(AlwaysOn); 300 setVScrollBarMode(AlwaysOn);
301 else 301 else
302 setVScrollBarMode(AlwaysOff); 302 setVScrollBarMode(AlwaysOff);
303 303
304 setStartHour(KOPrefs::instance()->mDayBegins); 304 setStartHour(KOPrefs::instance()->mDayBegins);
305 305
306 calculateWorkingHours(); 306 calculateWorkingHours();
307 307
308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
309 SLOT(checkScrollBoundaries(int))); 309 SLOT(checkScrollBoundaries(int)));
310 310
311 // Create the Marcus Bains line. 311 // Create the Marcus Bains line.
312 if(mAllDayMode) 312 if(mAllDayMode)
313 mMarcusBains = 0; 313 mMarcusBains = 0;
314 else { 314 else {
315 mMarcusBains = new MarcusBains(this); 315 mMarcusBains = new MarcusBains(this);
316 addChild(mMarcusBains); 316 addChild(mMarcusBains);
317 } 317 }
318 mPopupKind = 0; 318 mPopupKind = 0;
319 mPopupItem = 0; 319 mPopupItem = 0;
320} 320}
321 321
322void KOAgenda::clear() 322void KOAgenda::clear()
323{ 323{
324 KOAgendaItem *item; 324 KOAgendaItem *item;
325 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 325 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
326 mUnusedItems.append( item ); 326 mUnusedItems.append( item );
327 //item->hide(); 327 //item->hide();
328 } 328 }
329 mItems.clear(); 329 mItems.clear();
330 mSelectedItem = 0; 330 mSelectedItem = 0;
331 clearSelection(); 331 clearSelection();
332} 332}
333 333
334void KOAgenda::clearSelection() 334void KOAgenda::clearSelection()
335{ 335{
336 mSelectionCellX = 0; 336 mSelectionCellX = 0;
337 mSelectionYTop = 0; 337 mSelectionYTop = 0;
338 mSelectionHeight = 0; 338 mSelectionHeight = 0;
339} 339}
340 340
341void KOAgenda::marcus_bains() 341void KOAgenda::marcus_bains()
342{ 342{
343 if(mMarcusBains) mMarcusBains->updateLocation(true); 343 if(mMarcusBains) mMarcusBains->updateLocation(true);
344} 344}
345 345
346 346
347void KOAgenda::changeColumns(int columns) 347void KOAgenda::changeColumns(int columns)
348{ 348{
349 if (columns == 0) { 349 if (columns == 0) {
350 qDebug("KOAgenda::changeColumns() called with argument 0 "); 350 qDebug("KOAgenda::changeColumns() called with argument 0 ");
351 return; 351 return;
352 } 352 }
353 clear(); 353 clear();
354 mColumns = columns; 354 mColumns = columns;
355 computeSizes(); 355 computeSizes();
356} 356}
357 357
358/* 358/*
359 This is the eventFilter function, which gets all events from the KOAgendaItems 359 This is the eventFilter function, which gets all events from the KOAgendaItems
360 contained in the agenda. It has to handle moving and resizing for all items. 360 contained in the agenda. It has to handle moving and resizing for all items.
361*/ 361*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
363{ 363{
364 // kdDebug() << "KOAgenda::eventFilter" << endl; 364 // kdDebug() << "KOAgenda::eventFilter" << endl;
365 switch(event->type()) { 365 switch(event->type()) {
366 case QEvent::MouseButtonPress: 366 case QEvent::MouseButtonPress:
367 case QEvent::MouseButtonDblClick: 367 case QEvent::MouseButtonDblClick:
368 case QEvent::MouseButtonRelease: 368 case QEvent::MouseButtonRelease:
369 case QEvent::MouseMove: 369 case QEvent::MouseMove:
370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
371 371
372 case (QEvent::Leave): 372 case (QEvent::Leave):
373 if (!mActionItem) 373 if (!mActionItem)
374 setCursor(arrowCursor); 374 setCursor(arrowCursor);
375 return true; 375 return true;
376 376
377 default: 377 default:
378 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
379 } 379 }
380} 380}
381void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
382{ 382{
383 mPopupTimer->stop(); 383 mPopupTimer->stop();
384 if ( mPopupKind == 1 ) { 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 {
454 viewportPos = me->pos(); 455 viewportPos = me->pos();
455 } 456 }
456 457
457 switch (me->type()) { 458 switch (me->type()) {
458 case QEvent::MouseButtonPress: 459 case QEvent::MouseButtonPress:
459 if (me->button() == LeftButton) { 460 if (me->button() == LeftButton) {
460 mPopupTimer->start( 600 ); 461 mPopupTimer->start( 600 );
461 mLeftMouseDown = true; 462 mLeftMouseDown = true;
462 } 463 }
463 blockMoving = true; 464 blockMoving = true;
464 startX = viewportPos.x(); 465 startX = viewportPos.x();
465 startY = viewportPos.y(); 466 startY = viewportPos.y();
466 mPopupPos = me->globalPos(); 467 mPopupPos = me->globalPos();
467 if (object != viewport()) { 468 if (object != viewport()) {
468 mPopupItem = (KOAgendaItem *)object; 469 mPopupItem = (KOAgendaItem *)object;
469 mPopupKind = 1; 470 mPopupKind = 1;
470 if (me->button() == RightButton) { 471 if (me->button() == RightButton) {
471 popupMenu(); 472 popupMenu();
472 } else if (me->button() == LeftButton) { 473 } else if (me->button() == LeftButton) {
473 mActionItem = (KOAgendaItem *)object; 474 mActionItem = (KOAgendaItem *)object;
474 if (mActionItem) { 475 if (mActionItem) {
475 if ( mSelectionHeight > 0 ) { 476 if ( mSelectionHeight > 0 ) {
476 int selectionCellX = mSelectionCellX * mGridSpacingX; 477 int selectionCellX = mSelectionCellX * mGridSpacingX;
477 int selectionYTop = mSelectionYTop; 478 int selectionYTop = mSelectionYTop;
478 int gridSpacingX = mGridSpacingX; 479 int gridSpacingX = mGridSpacingX;
479 int selectionHeight = mSelectionHeight; 480 int selectionHeight = mSelectionHeight;
480 clearSelection(); 481 clearSelection();
481 repaintContents( selectionCellX, selectionYTop, 482 repaintContents( selectionCellX, selectionYTop,
482 gridSpacingX, selectionHeight,false ); 483 gridSpacingX, selectionHeight,false );
483 } 484 }
484 selectItem(mActionItem); 485 selectItem(mActionItem);
485 Incidence *incidence = mActionItem->incidence(); 486 Incidence *incidence = mActionItem->incidence();
486 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 487 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
487 mActionItem = 0; 488 mActionItem = 0;
488 } else { 489 } else {
489 startItemAction(viewportPos); 490 startItemAction(viewportPos);
490 } 491 }
491 } 492 }
492 } 493 }
493 } else { // ---------- viewport() 494 } else { // ---------- viewport()
494 mPopupItem = 0; 495 mPopupItem = 0;
495 mPopupKind = 2; 496 mPopupKind = 2;
496 selectItem(0); 497 selectItem(0);
497 mActionItem = 0; 498 mActionItem = 0;
498 if (me->button() == RightButton) { 499 if (me->button() == RightButton) {
499 int x,y; 500 int x,y;
500 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 501 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
501 int gx,gy; 502 int gx,gy;
502 contentsToGrid(x,y,gx,gy); 503 contentsToGrid(x,y,gx,gy);
503 mCurrentCellX = gx; 504 mCurrentCellX = gx;
504 mCurrentCellY = gy; 505 mCurrentCellY = gy;
505 mStartCellX = gx; 506 mStartCellX = gx;
506 mStartCellY = gy; 507 mStartCellY = gy;
507 popupMenu(); 508 popupMenu();
508 } else if (me->button() == LeftButton) { 509 } else if (me->button() == LeftButton) {
509 setCursor(arrowCursor); 510 setCursor(arrowCursor);
510 startSelectAction(viewportPos); 511 startSelectAction(viewportPos);
511 } 512 }
512 } 513 }
513 break; 514 break;
514 515
515 case QEvent::MouseButtonRelease: 516 case QEvent::MouseButtonRelease:
516 if (me->button() == LeftButton ) { 517 if (me->button() == LeftButton ) {
517 mPopupTimer->stop(); 518 mPopupTimer->stop();
518 } 519 }
519 if (object != viewport()) { 520 if (object != viewport()) {
520 if (me->button() == LeftButton && mLeftMouseDown) { 521 if (me->button() == LeftButton && mLeftMouseDown) {
521 if (mActionItem) { 522 if (mActionItem) {
522 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 523 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
523 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 524 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
524 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 525 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
525 mScrollUpTimer.stop(); 526 mScrollUpTimer.stop();
526 mScrollDownTimer.stop(); 527 mScrollDownTimer.stop();
527 mActionItem->resetMove(); 528 mActionItem->resetMove();
528 placeSubCells( mActionItem ); 529 placeSubCells( mActionItem );
529 // emit startDragSignal( mActionItem->incidence() ); 530 // emit startDragSignal( mActionItem->incidence() );
530 setCursor( arrowCursor ); 531 setCursor( arrowCursor );
531 mActionItem = 0; 532 mActionItem = 0;
532 mActionType = NOP; 533 mActionType = NOP;
533 mItemMoved = 0; 534 mItemMoved = 0;
534 mLeftMouseDown = false; 535 mLeftMouseDown = false;
535 return true; 536 return true;
536 } 537 }
537 endItemAction(); 538 endItemAction();
538 } 539 }
539 } 540 }
540 541
541 } else { // ---------- viewport() 542 } else { // ---------- viewport()
542 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 543 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
543 endSelectAction( true ); // emit new event signal 544 endSelectAction( true ); // emit new event signal
544 } 545 }
545 } 546 }
546 if (me->button() == LeftButton) 547 if (me->button() == LeftButton)
547 mLeftMouseDown = false; 548 mLeftMouseDown = false;
548 549
549 break; 550 break;
550 551
551 case QEvent::MouseMove: 552 case QEvent::MouseMove:
552 //qDebug("mm "); 553 //qDebug("mm ");
553 if ( !mLeftMouseDown ) 554 if ( !mLeftMouseDown )
554 return false; 555 return false;
555 if ( blockMoving ) { 556 if ( blockMoving ) {
556 int dX, dY; 557 int dX, dY;
557 dX = startX - viewportPos.x(); 558 dX = startX - viewportPos.x();
558 if ( dX < 0 ) 559 if ( dX < 0 )
559 dX = -dX; 560 dX = -dX;
560 dY = viewportPos.y() - startY; 561 dY = viewportPos.y() - startY;
561 if ( dY < 0 ) 562 if ( dY < 0 )
562 dY = -dY; 563 dY = -dY;
563 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 564 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
564 if ( dX > blockmoveDist || dY > blockmoveDist ) { 565 if ( dX > blockmoveDist || dY > blockmoveDist ) {
565 blockMoving = false; 566 blockMoving = false;
566 } 567 }
567 } 568 }
568 if ( ! blockMoving ) 569 if ( ! blockMoving )
569 mPopupTimer->stop(); 570 mPopupTimer->stop();
570 if (object != viewport()) { 571 if (object != viewport()) {
571 KOAgendaItem *moveItem = (KOAgendaItem *)object; 572 KOAgendaItem *moveItem = (KOAgendaItem *)object;
572 if (!moveItem->incidence()->isReadOnly() ) { 573 if (!moveItem->incidence()->isReadOnly() ) {
573 if (!mActionItem) 574 if (!mActionItem)
574 setNoActionCursor(moveItem,viewportPos); 575 setNoActionCursor(moveItem,viewportPos);
575 else { 576 else {
576 if ( !blockMoving ) 577 if ( !blockMoving )
577 performItemAction(viewportPos); 578 performItemAction(viewportPos);
578 } 579 }
579 } 580 }
580 } else { // ---------- viewport() 581 } else { // ---------- viewport()
581 mPopupPos = viewport()->mapToGlobal( me->pos() ); 582 mPopupPos = viewport()->mapToGlobal( me->pos() );
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 6d1e6d5..20a5b74 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -275,389 +275,390 @@ void TimeLabels::paintEvent(QPaintEvent*)
275 275
276 // kdDebug() << "paintevent..." << endl; 276 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 277 // this is another hack!
278 // QPainter painter(this); 278 // QPainter painter(this);
279 //QString c 279 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 281}
282 282
283//////////////////////////////////////////////////////////////////////////// 283////////////////////////////////////////////////////////////////////////////
284 284
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 286 : QFrame(parent,name)
287{ 287{
288 mColumns = 1; 288 mColumns = 1;
289 mTopBox = 0; 289 mTopBox = 0;
290 mLocation = loc; 290 mLocation = loc;
291 mTopLayout = 0; 291 mTopLayout = 0;
292 mPaintWidget = 0; 292 mPaintWidget = 0;
293 mXOffset = 0; 293 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 295 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 297 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 298 setMinimumHeight(mPixmap.height());
299} 299}
300 300
301EventIndicator::~EventIndicator() 301EventIndicator::~EventIndicator()
302{ 302{
303} 303}
304 304
305void EventIndicator::drawContents(QPainter *p) 305void EventIndicator::drawContents(QPainter *p)
306{ 306{
307 307
308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
309 KDGanttSplitterHandle* han = 0; 309 KDGanttSplitterHandle* han = 0;
310 if ( mPaintWidget ) 310 if ( mPaintWidget )
311 han = mPaintWidget->firstHandle(); 311 han = mPaintWidget->firstHandle();
312 if ( ! han ) { 312 if ( ! han ) {
313 int i; 313 int i;
314 for(i=0;i<mColumns;++i) { 314 for(i=0;i<mColumns;++i) {
315 if (mEnabled[i]) { 315 if (mEnabled[i]) {
316 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
319 i*cellWidth + (cellWidth -mPixmap.width()) /2; 319 i*cellWidth + (cellWidth -mPixmap.width()) /2;
320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
321 } 321 }
322 } 322 }
323 } else { 323 } else {
324 han->repaint(); 324 han->repaint();
325 //mPaintWidget->setBackgroundColor( red ); 325 //mPaintWidget->setBackgroundColor( red );
326 326
327 QPainter pa( han ); 327 QPainter pa( han );
328 int i; 328 int i;
329 bool setColor = false; 329 bool setColor = false;
330 for(i=0;i<mColumns;++i) { 330 for(i=0;i<mColumns;++i) {
331 if (mEnabled[i]) { 331 if (mEnabled[i]) {
332 setColor = true; 332 setColor = true;
333 333
334 int cellWidth = contentsRect().right()/mColumns; 334 int cellWidth = contentsRect().right()/mColumns;
335 int xOffset = KOGlobals::self()->reverseLayout() ? 335 int xOffset = KOGlobals::self()->reverseLayout() ?
336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
337 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 337 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
339 //qDebug("222draw pix %d ",xOffset ); 339 //qDebug("222draw pix %d ",xOffset );
340 340
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
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 )));
536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 537 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
537 SLOT(updateEventDates(KOAgendaItem *, int))); 538 SLOT(updateEventDates(KOAgendaItem *, int)));
538 539
539 // event indicator update 540 // event indicator update
540 connect(mAgenda,SIGNAL(lowerYChanged(int)), 541 connect(mAgenda,SIGNAL(lowerYChanged(int)),
541 SLOT(updateEventIndicatorTop(int))); 542 SLOT(updateEventIndicatorTop(int)));
542 connect(mAgenda,SIGNAL(upperYChanged(int)), 543 connect(mAgenda,SIGNAL(upperYChanged(int)),
543 SLOT(updateEventIndicatorBottom(int))); 544 SLOT(updateEventIndicatorBottom(int)));
544 // drag signals 545 // drag signals
545 /* 546 /*
546 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 547 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
547 SLOT(startDrag(Event *))); 548 SLOT(startDrag(Event *)));
548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 549 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
549 SLOT(startDrag(Event *))); 550 SLOT(startDrag(Event *)));
550 */ 551 */
551 // synchronize selections 552 // synchronize selections
552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 553 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
553 mAllDayAgenda, SLOT( deselectItem() ) ); 554 mAllDayAgenda, SLOT( deselectItem() ) );
554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 555 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
555 mAgenda, SLOT( deselectItem() ) ); 556 mAgenda, SLOT( deselectItem() ) );
556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
557 SIGNAL( incidenceSelected( Incidence * ) ) ); 558 SIGNAL( incidenceSelected( Incidence * ) ) );
558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 SIGNAL( incidenceSelected( Incidence * ) ) ); 560 SIGNAL( incidenceSelected( Incidence * ) ) );
560 connect( mAgenda, SIGNAL( resizedSignal() ), 561 connect( mAgenda, SIGNAL( resizedSignal() ),
561 SLOT( updateConfig( ) ) ); 562 SLOT( updateConfig( ) ) );
562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 563 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 564 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 565 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
565 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 566 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 568 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 569
569 570
570} 571}
571 572
572void KOAgendaView::toggleAllDay() 573void KOAgendaView::toggleAllDay()
573{ 574{
574 if ( mSplitterAgenda->firstHandle() ) 575 if ( mSplitterAgenda->firstHandle() )
575 mSplitterAgenda->firstHandle()->toggle(); 576 mSplitterAgenda->firstHandle()->toggle();
576} 577}
577void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 578void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
578{ 579{
579 calendar()->addIncidence( inc ); 580 calendar()->addIncidence( inc );
580 581
581 if ( incOld ) { 582 if ( incOld ) {
582 if ( incOld->type() == "Todo" ) 583 if ( incOld->type() == "Todo" )
583 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 584 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
584 else 585 else
585 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 586 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
586 } 587 }
587 588
588} 589}
589 590
590KOAgendaView::~KOAgendaView() 591KOAgendaView::~KOAgendaView()
591{ 592{
592 delete mAllAgendaPopup; 593 delete mAllAgendaPopup;
593 //delete mAllDayAgendaPopup; 594 //delete mAllDayAgendaPopup;
594 delete KOAgendaItem::paintPix(); 595 delete KOAgendaItem::paintPix();
595 delete KOAgendaItem::paintPixSel(); 596 delete KOAgendaItem::paintPixSel();
596} 597}
597void KOAgendaView::resizeEvent( QResizeEvent* e ) 598void KOAgendaView::resizeEvent( QResizeEvent* e )
598{ 599{
599 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 600 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
600 bool uc = false; 601 bool uc = false;
601 int ow = e->oldSize().width(); 602 int ow = e->oldSize().width();
602 int oh = e->oldSize().height(); 603 int oh = e->oldSize().height();
603 int w = e->size().width(); 604 int w = e->size().width();
604 int h = e->size().height(); 605 int h = e->size().height();
605 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 606 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
606 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 607 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
607 uc = true; 608 uc = true;
608 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 609 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
609 } 610 }
610 mUpcomingWidth = e->size().width() ; 611 mUpcomingWidth = e->size().width() ;
611 if ( mBlockUpdating || uc ) { 612 if ( mBlockUpdating || uc ) {
612 mBlockUpdating = false; 613 mBlockUpdating = false;
613 //mAgenda->setMinimumSize(800 , 600 ); 614 //mAgenda->setMinimumSize(800 , 600 );
614 //qDebug("mAgenda->resize+++++++++++++++ "); 615 //qDebug("mAgenda->resize+++++++++++++++ ");
615 updateConfig(); 616 updateConfig();
616 //qDebug("KOAgendaView::Updating now possible "); 617 //qDebug("KOAgendaView::Updating now possible ");
617 } else 618 } else
618 createDayLabels(); 619 createDayLabels();
619 //qDebug("resizeEvent end "); 620 //qDebug("resizeEvent end ");
620 621
621} 622}
622void KOAgendaView::slotDaylabelClicked( int num ) 623void KOAgendaView::slotDaylabelClicked( int num )
623{ 624{
624 625
625 QDate firstDate = mSelectedDates.first(); 626 QDate firstDate = mSelectedDates.first();
626 if ( num == -1 ) 627 if ( num == -1 )
627 emit showDateView( 6, firstDate ); 628 emit showDateView( 6, firstDate );
628 else if (num >= 0 ) { 629 else if (num >= 0 ) {
629 if ( mSelectedDates.count() == 1) 630 if ( mSelectedDates.count() == 1)
630 emit showDateView( 9, firstDate.addDays( num ) ); 631 emit showDateView( 9, firstDate.addDays( num ) );
631 else 632 else
632 emit showDateView( 3, firstDate.addDays( num ) ); 633 emit showDateView( 3, firstDate.addDays( num ) );
633 } 634 }
634 else 635 else
635 showDateView( 10, firstDate.addDays(1) ); 636 showDateView( 10, firstDate.addDays(1) );
636} 637}
637 638
638KOAgendaButton* KOAgendaView::getNewDaylabel() 639KOAgendaButton* KOAgendaView::getNewDaylabel()
639{ 640{
640 641
641 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 642 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
642 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 643 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
643 mDayLabelsList.append( dayLabel ); 644 mDayLabelsList.append( dayLabel );
644 mLayoutDayLabels->addWidget(dayLabel); 645 mLayoutDayLabels->addWidget(dayLabel);
645 return dayLabel ; 646 return dayLabel ;
646} 647}
647 648
648void KOAgendaView::createDayLabels() 649void KOAgendaView::createDayLabels()
649{ 650{
650 651
651 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 652 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
652 // qDebug(" KOAgendaView::createDayLabels() blocked "); 653 // qDebug(" KOAgendaView::createDayLabels() blocked ");
653 return; 654 return;
654 655
655 } 656 }
656 int newHight; 657 int newHight;
657 if ( !mSelectedDates.count()) 658 if ( !mSelectedDates.count())
658 return; 659 return;
659 660
660 // ### Before deleting and recreating we could check if mSelectedDates changed... 661 // ### Before deleting and recreating we could check if mSelectedDates changed...
661 // It would remove some flickering and gain speed (since this is called by 662 // It would remove some flickering and gain speed (since this is called by
662 // each updateView() call) 663 // each updateView() call)
663 664
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 5c889c3..00a43e5 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -109,460 +109,460 @@ bool CalendarLocal::addAnniversaryNoDup( Event *event )
109 cat = i18n( "Birthday" ); 109 cat = i18n( "Birthday" );
110 } else { 110 } else {
111 qDebug("addAnniversaryNoDup called without fitting category! "); 111 qDebug("addAnniversaryNoDup called without fitting category! ");
112 return false; 112 return false;
113 } 113 }
114 Event * eve; 114 Event * eve;
115 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 115 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
116 if ( !(eve->categories().contains( cat ) )) 116 if ( !(eve->categories().contains( cat ) ))
117 continue; 117 continue;
118 // now we have an event with fitting category 118 // now we have an event with fitting category
119 if ( eve->dtStart().date() != event->dtStart().date() ) 119 if ( eve->dtStart().date() != event->dtStart().date() )
120 continue; 120 continue;
121 // now we have an event with fitting category+date 121 // now we have an event with fitting category+date
122 if ( eve->summary() != event->summary() ) 122 if ( eve->summary() != event->summary() )
123 continue; 123 continue;
124 // now we have an event with fitting category+date+summary 124 // now we have an event with fitting category+date+summary
125 return false; 125 return false;
126 } 126 }
127 return addEvent( event ); 127 return addEvent( event );
128 128
129} 129}
130bool CalendarLocal::addEventNoDup( Event *event ) 130bool CalendarLocal::addEventNoDup( Event *event )
131{ 131{
132 Event * eve; 132 Event * eve;
133 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 133 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
134 if ( *eve == *event ) { 134 if ( *eve == *event ) {
135 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 135 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
136 return false; 136 return false;
137 } 137 }
138 } 138 }
139 return addEvent( event ); 139 return addEvent( event );
140} 140}
141 141
142bool CalendarLocal::addEvent( Event *event ) 142bool CalendarLocal::addEvent( Event *event )
143{ 143{
144 insertEvent( event ); 144 insertEvent( event );
145 145
146 event->registerObserver( this ); 146 event->registerObserver( this );
147 147
148 setModified( true ); 148 setModified( true );
149 149
150 return true; 150 return true;
151} 151}
152 152
153void CalendarLocal::deleteEvent( Event *event ) 153void CalendarLocal::deleteEvent( Event *event )
154{ 154{
155 if ( mUndoIncidence ) delete mUndoIncidence; 155 if ( mUndoIncidence ) delete mUndoIncidence;
156 mUndoIncidence = event->clone(); 156 mUndoIncidence = event->clone();
157 if ( mEventList.removeRef( event ) ) { 157 if ( mEventList.removeRef( event ) ) {
158 setModified( true ); 158 setModified( true );
159 } 159 }
160} 160}
161 161
162 162
163Event *CalendarLocal::event( const QString &uid ) 163Event *CalendarLocal::event( const QString &uid )
164{ 164{
165 165
166 Event *event; 166 Event *event;
167 167
168 for ( event = mEventList.first(); event; event = mEventList.next() ) { 168 for ( event = mEventList.first(); event; event = mEventList.next() ) {
169 if ( event->uid() == uid ) { 169 if ( event->uid() == uid ) {
170 return event; 170 return event;
171 } 171 }
172 } 172 }
173 173
174 return 0; 174 return 0;
175} 175}
176bool CalendarLocal::addTodoNoDup( Todo *todo ) 176bool CalendarLocal::addTodoNoDup( Todo *todo )
177{ 177{
178 Todo * eve; 178 Todo * eve;
179 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 179 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
180 if ( *eve == *todo ) { 180 if ( *eve == *todo ) {
181 //qDebug("duplicate todo found! not inserted! "); 181 //qDebug("duplicate todo found! not inserted! ");
182 return false; 182 return false;
183 } 183 }
184 } 184 }
185 return addTodo( todo ); 185 return addTodo( todo );
186} 186}
187bool CalendarLocal::addTodo( Todo *todo ) 187bool CalendarLocal::addTodo( Todo *todo )
188{ 188{
189 mTodoList.append( todo ); 189 mTodoList.append( todo );
190 190
191 todo->registerObserver( this ); 191 todo->registerObserver( this );
192 192
193 // Set up subtask relations 193 // Set up subtask relations
194 setupRelations( todo ); 194 setupRelations( todo );
195 195
196 setModified( true ); 196 setModified( true );
197 197
198 return true; 198 return true;
199} 199}
200 200
201void CalendarLocal::deleteTodo( Todo *todo ) 201void CalendarLocal::deleteTodo( Todo *todo )
202{ 202{
203 // Handle orphaned children 203 // Handle orphaned children
204 if ( mUndoIncidence ) delete mUndoIncidence; 204 if ( mUndoIncidence ) delete mUndoIncidence;
205 removeRelations( todo ); 205 removeRelations( todo );
206 mUndoIncidence = todo->clone(); 206 mUndoIncidence = todo->clone();
207 207
208 if ( mTodoList.removeRef( todo ) ) { 208 if ( mTodoList.removeRef( todo ) ) {
209 setModified( true ); 209 setModified( true );
210 } 210 }
211} 211}
212 212
213QPtrList<Todo> CalendarLocal::rawTodos() 213QPtrList<Todo> CalendarLocal::rawTodos()
214{ 214{
215 return mTodoList; 215 return mTodoList;
216} 216}
217Todo *CalendarLocal::todo( QString syncProf, QString id ) 217Todo *CalendarLocal::todo( QString syncProf, QString id )
218{ 218{
219 Todo *todo; 219 Todo *todo;
220 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 220 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
221 if ( todo->getID( syncProf ) == id ) return todo; 221 if ( todo->getID( syncProf ) == id ) return todo;
222 } 222 }
223 223
224 return 0; 224 return 0;
225} 225}
226void CalendarLocal::removeSyncInfo( QString syncProfile) 226void CalendarLocal::removeSyncInfo( QString syncProfile)
227{ 227{
228 QPtrList<Incidence> all = rawIncidences() ; 228 QPtrList<Incidence> all = rawIncidences() ;
229 Incidence *inc; 229 Incidence *inc;
230 for ( inc = all.first(); inc; inc = all.next() ) { 230 for ( inc = all.first(); inc; inc = all.next() ) {
231 inc->removeID( syncProfile ); 231 inc->removeID( syncProfile );
232 } 232 }
233 if ( syncProfile.isEmpty() ) { 233 if ( syncProfile.isEmpty() ) {
234 QPtrList<Event> el; 234 QPtrList<Event> el;
235 Event *todo; 235 Event *todo;
236 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 236 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
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;
441 } 441 }
442 } 442 }
443 } 443 }
444 if ( mNextAlarmIncidence ) { 444 if ( mNextAlarmIncidence ) {
445 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 445 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
446 mNextAlarmDateTime = nextA; 446 mNextAlarmDateTime = nextA;
447 } 447 }
448 return nextA; 448 return nextA;
449} 449}
450Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) 450Alarm::List CalendarLocal::alarmsTo( const QDateTime &to )
451{ 451{
452 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); 452 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to );
453} 453}
454 454
455Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) 455Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
456{ 456{
457 kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " 457 kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - "
458 << to.toString() << ")\n"; 458 << to.toString() << ")\n";
459 459
460 Alarm::List alarms; 460 Alarm::List alarms;
461 461
462 Event *e; 462 Event *e;
463 463
464 for( e = mEventList.first(); e; e = mEventList.next() ) { 464 for( e = mEventList.first(); e; e = mEventList.next() ) {
465 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); 465 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
466 else appendAlarms( alarms, e, from, to ); 466 else appendAlarms( alarms, e, from, to );
467 } 467 }
468 468
469 Todo *t; 469 Todo *t;
470 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 470 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
471 appendAlarms( alarms, t, from, to ); 471 appendAlarms( alarms, t, from, to );
472 } 472 }
473 473
474 return alarms; 474 return alarms;
475} 475}
476 476
477void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, 477void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
478 const QDateTime &from, const QDateTime &to ) 478 const QDateTime &from, const QDateTime &to )
479{ 479{
480 QPtrList<Alarm> alarmList = incidence->alarms(); 480 QPtrList<Alarm> alarmList = incidence->alarms();
481 Alarm *alarm; 481 Alarm *alarm;
482 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 482 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
483// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() 483// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text()
484// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; 484// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl;
485 if ( alarm->enabled() ) { 485 if ( alarm->enabled() ) {
486 if ( alarm->time() >= from && alarm->time() <= to ) { 486 if ( alarm->time() >= from && alarm->time() <= to ) {
487 kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary() 487 kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary()
488 << "': " << alarm->time().toString() << endl; 488 << "': " << alarm->time().toString() << endl;
489 alarms.append( alarm ); 489 alarms.append( alarm );
490 } 490 }
491 } 491 }
492 } 492 }
493} 493}
494 494
495void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, 495void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms,
496 Incidence *incidence, 496 Incidence *incidence,
497 const QDateTime &from, 497 const QDateTime &from,
498 const QDateTime &to ) 498 const QDateTime &to )
499{ 499{
500 500
501 QPtrList<Alarm> alarmList = incidence->alarms(); 501 QPtrList<Alarm> alarmList = incidence->alarms();
502 Alarm *alarm; 502 Alarm *alarm;
503 QDateTime qdt; 503 QDateTime qdt;
504 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 504 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
505 if (incidence->recursOn(from.date())) { 505 if (incidence->recursOn(from.date())) {
506 qdt.setTime(alarm->time().time()); 506 qdt.setTime(alarm->time().time());
507 qdt.setDate(from.date()); 507 qdt.setDate(from.date());
508 } 508 }
509 else qdt = alarm->time(); 509 else qdt = alarm->time();
510 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); 510 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1());
511 if ( alarm->enabled() ) { 511 if ( alarm->enabled() ) {
512 if ( qdt >= from && qdt <= to ) { 512 if ( qdt >= from && qdt <= to ) {
513 alarms.append( alarm ); 513 alarms.append( alarm );
514 } 514 }
515 } 515 }
516 } 516 }
517} 517}
518 518
519 519
520/****************************** PROTECTED METHODS ****************************/ 520/****************************** PROTECTED METHODS ****************************/
521 521
522// after changes are made to an event, this should be called. 522// after changes are made to an event, this should be called.
523void CalendarLocal::update( IncidenceBase *incidence ) 523void CalendarLocal::update( IncidenceBase *incidence )
524{ 524{
525 incidence->setSyncStatus( Event::SYNCMOD ); 525 incidence->setSyncStatus( Event::SYNCMOD );
526 incidence->setLastModified( QDateTime::currentDateTime() ); 526 incidence->setLastModified( QDateTime::currentDateTime() );
527 // we should probably update the revision number here, 527 // we should probably update the revision number here,
528 // or internally in the Event itself when certain things change. 528 // or internally in the Event itself when certain things change.
529 // need to verify with ical documentation. 529 // need to verify with ical documentation.
530 530
531 setModified( true ); 531 setModified( true );
532} 532}
533 533
534void CalendarLocal::insertEvent( Event *event ) 534void CalendarLocal::insertEvent( Event *event )
535{ 535{
536 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); 536 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event );
537} 537}
538 538
539 539
540QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 540QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
541{ 541{
542 QPtrList<Event> eventList; 542 QPtrList<Event> eventList;
543 543
544 Event *event; 544 Event *event;
545 for( event = mEventList.first(); event; event = mEventList.next() ) { 545 for( event = mEventList.first(); event; event = mEventList.next() ) {
546 if ( event->doesRecur() ) { 546 if ( event->doesRecur() ) {
547 if ( event->isMultiDay() ) { 547 if ( event->isMultiDay() ) {
548 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 548 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
549 int i; 549 int i;
550 for ( i = 0; i <= extraDays; i++ ) { 550 for ( i = 0; i <= extraDays; i++ ) {
551 if ( event->recursOn( qd.addDays( -i ) ) ) { 551 if ( event->recursOn( qd.addDays( -i ) ) ) {
552 eventList.append( event ); 552 eventList.append( event );
553 break; 553 break;
554 } 554 }
555 } 555 }
556 } else { 556 } else {
557 if ( event->recursOn( qd ) ) 557 if ( event->recursOn( qd ) )
558 eventList.append( event ); 558 eventList.append( event );
559 } 559 }
560 } else { 560 } else {
561 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 561 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
562 eventList.append( event ); 562 eventList.append( event );
563 } 563 }
564 } 564 }
565 } 565 }
566 566
567 if ( !sorted ) { 567 if ( !sorted ) {
568 return eventList; 568 return eventList;