summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-01 06:04:54 (UTC)
committer zautrix <zautrix>2005-07-01 06:04:54 (UTC)
commita7924287e231b461585c4121f6ee2ce32f955089 (patch) (unidiff)
tree992d503b50212e72d69d845bd8d27cb8f8518c30
parent7da83cbf37b406a523e36a948039941840d48fb1 (diff)
downloadkdepimpi-a7924287e231b461585c4121f6ee2ce32f955089.zip
kdepimpi-a7924287e231b461585c4121f6ee2ce32f955089.tar.gz
kdepimpi-a7924287e231b461585c4121f6ee2ce32f955089.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp11
-rw-r--r--korganizer/koagenda.h1
-rw-r--r--korganizer/koagendaitem.cpp34
-rw-r--r--korganizer/koagendaitem.h1
-rw-r--r--korganizer/koagendaview.cpp11
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/koeventpopupmenu.cpp44
-rw-r--r--korganizer/koeventpopupmenu.h4
-rw-r--r--korganizer/koeventview.cpp1
-rw-r--r--korganizer/kolistview.cpp8
10 files changed, 89 insertions, 27 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ce73168..f860f7d 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -219,385 +219,394 @@ QDate KOAgenda::selectedIncidenceDate() const
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 || mPopupKind == 3 ) { 384 if ( mPopupKind == 1 || mPopupKind == 3 ) {
385 if (mActionItem ) { 385 if (mActionItem ) {
386 endItemAction(); 386 endItemAction();
387 } 387 }
388 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 389 if (mPopupItem) {
390 //mClickedItem = mPopupItem; 390 //mClickedItem = mPopupItem;
391 selectItem(mPopupItem); 391 selectItem(mPopupItem);
392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
393 mAllAgendaPopup->installEventFilter( this ); 393 mAllAgendaPopup->installEventFilter( this );
394 emit showIncidencePopupSignal(mPopupItem->incidence()); 394 emit showIncidencePopupSignal(mPopupItem->incidence());
395 395
396 } 396 }
397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
399 endSelectAction( false ); // do not emit new event signal 399 endSelectAction( false ); // do not emit new event signal
400 mLeftMouseDown = false; // no more leftMouse computation 400 mLeftMouseDown = false; // no more leftMouse computation
401 } 401 }
402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
403 mNewItemPopup->installEventFilter( this ); 403 mNewItemPopup->installEventFilter( this );
404 mNewItemPopup->popup( mPopupPos); 404 mNewItemPopup->popup( mPopupPos);
405 405
406 } 406 }
407 mLeftMouseDown = false; 407 mLeftMouseDown = false;
408 mPopupItem = 0; 408 mPopupItem = 0;
409 mPopupKind = 0; 409 mPopupKind = 0;
410} 410}
411 411void KOAgenda::categoryChanged(Incidence * inc)
412{
413 KOAgendaItem *item;
414 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
415 if ( item->incidence() == inc ) {
416 item->initColor ();
417 item->updateItem();
418 }
419 }
420}
412bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 421bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
413{ 422{
414 static int startX = 0; 423 static int startX = 0;
415 static int startY = 0; 424 static int startY = 0;
416 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 425 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
417 static bool blockMoving = true; 426 static bool blockMoving = true;
418 427
419 //qDebug("KOAgenda::eventFilter_mous "); 428 //qDebug("KOAgenda::eventFilter_mous ");
420 if ( object == mNewItemPopup ) { 429 if ( object == mNewItemPopup ) {
421 //qDebug("mNewItemPopup "); 430 //qDebug("mNewItemPopup ");
422 if ( me->type() == QEvent::MouseButtonRelease ) { 431 if ( me->type() == QEvent::MouseButtonRelease ) {
423 mNewItemPopup->removeEventFilter( this ); 432 mNewItemPopup->removeEventFilter( this );
424 int dX = me->globalPos().x() - mPopupPos.x();; 433 int dX = me->globalPos().x() - mPopupPos.x();;
425 if ( dX < 0 ) 434 if ( dX < 0 )
426 dX = -dX; 435 dX = -dX;
427 int dY = me->globalPos().y() - mPopupPos.y(); 436 int dY = me->globalPos().y() - mPopupPos.y();
428 if ( dY < 0 ) 437 if ( dY < 0 )
429 dY = -dY; 438 dY = -dY;
430 if ( dX > blockmoveDist || dY > blockmoveDist ) { 439 if ( dX > blockmoveDist || dY > blockmoveDist ) {
431 mNewItemPopup->hide(); 440 mNewItemPopup->hide();
432 } 441 }
433 } 442 }
434 return true; 443 return true;
435 } 444 }
436 if ( object == mAllAgendaPopup ) { 445 if ( object == mAllAgendaPopup ) {
437 //qDebug(" mAllAgendaPopup "); 446 //qDebug(" mAllAgendaPopup ");
438 if ( me->type() == QEvent::MouseButtonRelease ) { 447 if ( me->type() == QEvent::MouseButtonRelease ) {
439 mAllAgendaPopup->removeEventFilter( this ); 448 mAllAgendaPopup->removeEventFilter( this );
440 int dX = me->globalPos().x() - mPopupPos.x();; 449 int dX = me->globalPos().x() - mPopupPos.x();;
441 if ( dX < 0 ) 450 if ( dX < 0 )
442 dX = -dX; 451 dX = -dX;
443 int dY = me->globalPos().y() - mPopupPos.y(); 452 int dY = me->globalPos().y() - mPopupPos.y();
444 if ( dY < 0 ) 453 if ( dY < 0 )
445 dY = -dY; 454 dY = -dY;
446 if ( dX > blockmoveDist || dY > blockmoveDist ) { 455 if ( dX > blockmoveDist || dY > blockmoveDist ) {
447 mAllAgendaPopup->hide(); 456 mAllAgendaPopup->hide();
448 } 457 }
449 } 458 }
450 return true; 459 return true;
451 } 460 }
452 QPoint viewportPos; 461 QPoint viewportPos;
453 if (object != viewport()) { 462 if (object != viewport()) {
454 blockmoveDist = blockmoveDist*2; 463 blockmoveDist = blockmoveDist*2;
455 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 464 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
456 } else { 465 } else {
457 viewportPos = me->pos(); 466 viewportPos = me->pos();
458 } 467 }
459 bool objIsNotViewport = (object != viewport()); 468 bool objIsNotViewport = (object != viewport());
460 bool leftButt = false; 469 bool leftButt = false;
461#ifdef DESKTOP_VERSION 470#ifdef DESKTOP_VERSION
462 leftButt = (me->button() == LeftButton); 471 leftButt = (me->button() == LeftButton);
463#endif 472#endif
464 switch (me->type()) { 473 switch (me->type()) {
465 case QEvent::MouseButtonPress: 474 case QEvent::MouseButtonPress:
466 if (me->button() == LeftButton) { 475 if (me->button() == LeftButton) {
467 mPopupTimer->start( 600 ); 476 mPopupTimer->start( 600 );
468 mLeftMouseDown = true; 477 mLeftMouseDown = true;
469 } 478 }
470 blockMoving = true; 479 blockMoving = true;
471 startX = viewportPos.x(); 480 startX = viewportPos.x();
472 startY = viewportPos.y(); 481 startY = viewportPos.y();
473 mPopupPos = me->globalPos(); 482 mPopupPos = me->globalPos();
474 if ( objIsNotViewport && !leftButt ) { 483 if ( objIsNotViewport && !leftButt ) {
475 KOAgendaItem * tempItem = (KOAgendaItem *)object; 484 KOAgendaItem * tempItem = (KOAgendaItem *)object;
476 if (mAllDayMode) { 485 if (mAllDayMode) {
477 if ( tempItem->height() > 10 ) { 486 if ( tempItem->height() > 10 ) {
478 int minV = tempItem->height()/4; 487 int minV = tempItem->height()/4;
479 if ( minV > (blockmoveDist/2)-2 ) { 488 if ( minV > (blockmoveDist/2)-2 ) {
480 if ( minV > blockmoveDist ) 489 if ( minV > blockmoveDist )
481 minV = blockmoveDist; 490 minV = blockmoveDist;
482 else 491 else
483 minV = (blockmoveDist/2); 492 minV = (blockmoveDist/2);
484 } 493 }
485 bool border = false; 494 bool border = false;
486 int diff = tempItem->y() - viewportPos.y(); 495 int diff = tempItem->y() - viewportPos.y();
487 if ( diff < 0 ) 496 if ( diff < 0 )
488 diff *= -1; 497 diff *= -1;
489 if ( diff < minV ) { 498 if ( diff < minV ) {
490 border = true; 499 border = true;
491 objIsNotViewport = false; 500 objIsNotViewport = false;
492 } 501 }
493 if ( ! border ) { 502 if ( ! border ) {
494 diff = tempItem->y() + tempItem->height()- viewportPos.y(); 503 diff = tempItem->y() + tempItem->height()- viewportPos.y();
495 if ( diff < 0 ) 504 if ( diff < 0 )
496 diff *= -1; 505 diff *= -1;
497 if ( diff < minV ) { 506 if ( diff < minV ) {
498 border = true; 507 border = true;
499 objIsNotViewport = false; 508 objIsNotViewport = false;
500 } 509 }
501 } 510 }
502 } 511 }
503 } else { // not allday 512 } else { // not allday
504 if ( tempItem->width() > 10 ) { 513 if ( tempItem->width() > 10 ) {
505 int minH = tempItem->width()/4; 514 int minH = tempItem->width()/4;
506 if ( minH > (blockmoveDist/2)-2 ) { 515 if ( minH > (blockmoveDist/2)-2 ) {
507 if ( minH > blockmoveDist ) 516 if ( minH > blockmoveDist )
508 minH = blockmoveDist; 517 minH = blockmoveDist;
509 else 518 else
510 minH = (blockmoveDist/2); 519 minH = (blockmoveDist/2);
511 } 520 }
512 bool border = false; 521 bool border = false;
513 int diff = tempItem->x() - viewportPos.x(); 522 int diff = tempItem->x() - viewportPos.x();
514 if ( diff < 0 ) 523 if ( diff < 0 )
515 diff *= -1; 524 diff *= -1;
516 if ( diff < minH ) { 525 if ( diff < minH ) {
517 border = true; 526 border = true;
518 objIsNotViewport = false; 527 objIsNotViewport = false;
519 } 528 }
520 if ( ! border ) { 529 if ( ! border ) {
521 diff = tempItem->x() + tempItem->width() - viewportPos.x(); 530 diff = tempItem->x() + tempItem->width() - viewportPos.x();
522 if ( diff < 0 ) 531 if ( diff < 0 )
523 diff *= -1; 532 diff *= -1;
524 if ( diff < minH ) { 533 if ( diff < minH ) {
525 border = true; 534 border = true;
526 objIsNotViewport = false; 535 objIsNotViewport = false;
527 } 536 }
528 } 537 }
529 } 538 }
530 } 539 }
531 } 540 }
532 if ( objIsNotViewport ) { 541 if ( objIsNotViewport ) {
533 mPopupItem = (KOAgendaItem *)object; 542 mPopupItem = (KOAgendaItem *)object;
534 mPopupKind = 1; 543 mPopupKind = 1;
535 if (me->button() == RightButton) { 544 if (me->button() == RightButton) {
536 mPopupKind = 3; 545 mPopupKind = 3;
537 popupMenu(); 546 popupMenu();
538 } else if (me->button() == LeftButton) { 547 } else if (me->button() == LeftButton) {
539 mActionItem = (KOAgendaItem *)object; 548 mActionItem = (KOAgendaItem *)object;
540 if (mActionItem) { 549 if (mActionItem) {
541 emit signalClearSelection(); 550 emit signalClearSelection();
542 slotClearSelection(); 551 slotClearSelection();
543 selectItem(mActionItem); 552 selectItem(mActionItem);
544 Incidence *incidence = mActionItem->incidence(); 553 Incidence *incidence = mActionItem->incidence();
545 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 554 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
546 mActionItem = 0; 555 mActionItem = 0;
547 } else { 556 } else {
548 startItemAction(viewportPos); 557 startItemAction(viewportPos);
549 } 558 }
550 } 559 }
551 } 560 }
552 } else { // ---------- viewport() 561 } else { // ---------- viewport()
553 mPopupItem = 0; 562 mPopupItem = 0;
554 mPopupKind = 2; 563 mPopupKind = 2;
555 selectItem(0); 564 selectItem(0);
556 mActionItem = 0; 565 mActionItem = 0;
557 if (me->button() == RightButton) { 566 if (me->button() == RightButton) {
558 int x,y; 567 int x,y;
559 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 568 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
560 int gx,gy; 569 int gx,gy;
561 contentsToGrid(x,y,gx,gy); 570 contentsToGrid(x,y,gx,gy);
562 mCurrentCellX = gx; 571 mCurrentCellX = gx;
563 mCurrentCellY = gy; 572 mCurrentCellY = gy;
564 mStartCellX = gx; 573 mStartCellX = gx;
565 mStartCellY = gy; 574 mStartCellY = gy;
566 mPopupKind = 4; 575 mPopupKind = 4;
567 popupMenu(); 576 popupMenu();
568 } else if (me->button() == LeftButton) { 577 } else if (me->button() == LeftButton) {
569 setCursor(arrowCursor); 578 setCursor(arrowCursor);
570 startSelectAction(viewportPos); 579 startSelectAction(viewportPos);
571 } 580 }
572 } 581 }
573 break; 582 break;
574 583
575 case QEvent::MouseButtonRelease: 584 case QEvent::MouseButtonRelease:
576 if (me->button() == LeftButton ) { 585 if (me->button() == LeftButton ) {
577 mPopupTimer->stop(); 586 mPopupTimer->stop();
578 } 587 }
579 if (object != viewport()) { 588 if (object != viewport()) {
580 if (me->button() == LeftButton && mLeftMouseDown) { 589 if (me->button() == LeftButton && mLeftMouseDown) {
581 if (mActionItem) { 590 if (mActionItem) {
582 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 591 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
583 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 592 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
584 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 593 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
585 mScrollUpTimer.stop(); 594 mScrollUpTimer.stop();
586 mScrollDownTimer.stop(); 595 mScrollDownTimer.stop();
587 mActionItem->resetMove(); 596 mActionItem->resetMove();
588 placeSubCells( mActionItem ); 597 placeSubCells( mActionItem );
589 // emit startDragSignal( mActionItem->incidence() ); 598 // emit startDragSignal( mActionItem->incidence() );
590 setCursor( arrowCursor ); 599 setCursor( arrowCursor );
591 mActionItem = 0; 600 mActionItem = 0;
592 mActionType = NOP; 601 mActionType = NOP;
593 mItemMoved = 0; 602 mItemMoved = 0;
594 mLeftMouseDown = false; 603 mLeftMouseDown = false;
595 return true; 604 return true;
596 } 605 }
597 endItemAction(); 606 endItemAction();
598 } 607 }
599 } 608 }
600 609
601 } else { // ---------- viewport() 610 } else { // ---------- viewport()
602 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 611 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
603 endSelectAction( true ); // emit new event signal 612 endSelectAction( true ); // emit new event signal
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index fb9983e..de6acac 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,300 +1,301 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34#include "koeventview.h" 34#include "koeventview.h"
35 35
36class QPopupMenu; 36class QPopupMenu;
37class QTime; 37class QTime;
38class KConfig; 38class KConfig;
39class QFrame; 39class QFrame;
40class KOAgenda; 40class KOAgenda;
41class KCal::Event; 41class KCal::Event;
42class KCal::Todo; 42class KCal::Todo;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46class MarcusBains : public QFrame { 46class MarcusBains : public QFrame {
47 Q_OBJECT 47 Q_OBJECT
48 public: 48 public:
49 MarcusBains(KOAgenda *agenda=0,const char *name=0); 49 MarcusBains(KOAgenda *agenda=0,const char *name=0);
50 virtual ~MarcusBains(); 50 virtual ~MarcusBains();
51 51
52 public slots: 52 public slots:
53 void updateLocation(bool recalculate=false); 53 void updateLocation(bool recalculate=false);
54 void updateLoc(); 54 void updateLoc();
55 55
56 private: 56 private:
57 int todayColumn(); 57 int todayColumn();
58 QTimer *minutes; 58 QTimer *minutes;
59 QLabel *mTimeBox; 59 QLabel *mTimeBox;
60 KOAgenda *agenda; 60 KOAgenda *agenda;
61 QTime oldTime; 61 QTime oldTime;
62 int oldToday; 62 int oldToday;
63}; 63};
64 64
65 65
66class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 public: 69 public:
70 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
72 72
73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
74 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
75 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
76 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
77 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
78 78
79 Incidence *selectedIncidence() const; 79 Incidence *selectedIncidence() const;
80 QDate selectedIncidenceDate() const; 80 QDate selectedIncidenceDate() const;
81 81
82 virtual bool eventFilter ( QObject *, QEvent * ); 82 virtual bool eventFilter ( QObject *, QEvent * );
83 83
84 void contentsToGrid (int x, int y, int& gx, int& gy); 84 void contentsToGrid (int x, int y, int& gx, int& gy);
85 void gridToContents (int gx, int gy, int& x, int& y); 85 void gridToContents (int gx, int gy, int& x, int& y);
86 86
87 int timeToY (const QTime &time); 87 int timeToY (const QTime &time);
88 QTime gyToTime (int y); 88 QTime gyToTime (int y);
89 89
90 void setStartHour(int startHour); 90 void setStartHour(int startHour);
91 91
92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
95 int YTop,int YBottom); 95 int YTop,int YBottom);
96 96
97 void changeColumns(int columns); 97 void changeColumns(int columns);
98 98
99 int columns() { return mColumns; } 99 int columns() { return mColumns; }
100 int rows() { return mRows; } 100 int rows() { return mRows; }
101 101
102 int gridSpacingX() const { return mGridSpacingX; } 102 int gridSpacingX() const { return mGridSpacingX; }
103 int gridSpacingY() const { return mGridSpacingY; } 103 int gridSpacingY() const { return mGridSpacingY; }
104 104
105// virtual QSizePolicy sizePolicy() const; 105// virtual QSizePolicy sizePolicy() const;
106 106
107 void clear(); 107 void clear();
108 108
109 void clearSelection(); 109 void clearSelection();
110 void hideUnused(); 110 void hideUnused();
111 111
112 /** Calculates the minimum width */ 112 /** Calculates the minimum width */
113 virtual int minimumWidth() const; 113 virtual int minimumWidth() const;
114 /** Update configuration from preference settings */ 114 /** Update configuration from preference settings */
115 void updateConfig(); 115 void updateConfig();
116 116
117 void checkScrollBoundaries(); 117 void checkScrollBoundaries();
118 118
119 void setHolidayMask(QMemArray<bool> *); 119 void setHolidayMask(QMemArray<bool> *);
120 void setDateList(const DateList &selectedDates); 120 void setDateList(const DateList &selectedDates);
121 DateList dateList() const; 121 DateList dateList() const;
122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
123 void finishUpdate(); 123 void finishUpdate();
124 void printSelection(); 124 void printSelection();
125 void storePosition(); 125 void storePosition();
126 void restorePosition(); 126 void restorePosition();
127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } 127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
128 128
129 public slots: 129 public slots:
130 void categoryChanged(Incidence * inc);
130 void slotClearSelection(); 131 void slotClearSelection();
131 void popupMenu(); 132 void popupMenu();
132 void newItem( int ); 133 void newItem( int );
133 void moveChild( QWidget *, int, int ); 134 void moveChild( QWidget *, int, int );
134 void scrollUp(); 135 void scrollUp();
135 void scrollDown(); 136 void scrollDown();
136 void updateTodo( Todo * t, int , bool ); 137 void updateTodo( Todo * t, int , bool );
137 void popupAlarm(); 138 void popupAlarm();
138 139
139 void checkScrollBoundaries(int); 140 void checkScrollBoundaries(int);
140 141
141 /** Deselect selected items. This function does not emit any signals. */ 142 /** Deselect selected items. This function does not emit any signals. */
142 void deselectItem(); 143 void deselectItem();
143 /** Select item. If the argument is 0, the currently selected item gets 144 /** Select item. If the argument is 0, the currently selected item gets
144 deselected. This function emits the itemSelected(bool) signal to inform 145 deselected. This function emits the itemSelected(bool) signal to inform
145 about selection/deseelction of events. */ 146 about selection/deseelction of events. */
146 void selectItem(KOAgendaItem *); 147 void selectItem(KOAgendaItem *);
147 void finishResize(); 148 void finishResize();
148 149
149 signals: 150 signals:
150 void signalClearSelection(); 151 void signalClearSelection();
151 void showDateView( int, int); 152 void showDateView( int, int);
152 void newEventSignal(); 153 void newEventSignal();
153 void newEventSignal(int gx,int gy); 154 void newEventSignal(int gx,int gy);
154 void newTodoSignal(int gx,int gy); 155 void newTodoSignal(int gx,int gy);
155 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 156 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
156 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 157 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
157 void newStartSelectSignal(); 158 void newStartSelectSignal();
158 void showIncidenceSignal(Incidence *); 159 void showIncidenceSignal(Incidence *);
159 void editIncidenceSignal(Incidence *); 160 void editIncidenceSignal(Incidence *);
160 void deleteIncidenceSignal(Incidence *); 161 void deleteIncidenceSignal(Incidence *);
161 void showIncidencePopupSignal(Incidence *); 162 void showIncidencePopupSignal(Incidence *);
162 163
163 void itemModified(KOAgendaItem *item, int ); 164 void itemModified(KOAgendaItem *item, int );
164 void incidenceSelected(Incidence *); 165 void incidenceSelected(Incidence *);
165 166
166 void lowerYChanged(int); 167 void lowerYChanged(int);
167 void upperYChanged(int); 168 void upperYChanged(int);
168 169
169 void startDragSignal(Incidence *); 170 void startDragSignal(Incidence *);
170 void addToCalSignal(Incidence *, Incidence *); 171 void addToCalSignal(Incidence *, Incidence *);
171 void resizedSignal(); 172 void resizedSignal();
172 173
173 protected: 174 protected:
174 KOEventPopupMenu * mAllAgendaPopup; 175 KOEventPopupMenu * mAllAgendaPopup;
175 QPainter mPixPainter; 176 QPainter mPixPainter;
176 QPixmap mPaintPixmap; 177 QPixmap mPaintPixmap;
177 QPixmap mHighlightPixmap; 178 QPixmap mHighlightPixmap;
178 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 179 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
179 virtual void resizeEvent ( QResizeEvent * ); 180 virtual void resizeEvent ( QResizeEvent * );
180 181
181 /** Handles mouse events. Called from eventFilter */ 182 /** Handles mouse events. Called from eventFilter */
182 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 183 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
183 184
184 /** Start selecting time span. */ 185 /** Start selecting time span. */
185 void startSelectAction(QPoint viewportPos); 186 void startSelectAction(QPoint viewportPos);
186 187
187 /** Select time span. */ 188 /** Select time span. */
188 void performSelectAction(QPoint viewportPos); 189 void performSelectAction(QPoint viewportPos);
189 190
190 /** Emd selecting time span. */ 191 /** Emd selecting time span. */
191 void endSelectAction( bool emitNewEvent = false ); 192 void endSelectAction( bool emitNewEvent = false );
192 193
193 /** Start moving/resizing agenda item */ 194 /** Start moving/resizing agenda item */
194 void startItemAction(QPoint viewportPos); 195 void startItemAction(QPoint viewportPos);
195 196
196 /** Move/resize agenda item */ 197 /** Move/resize agenda item */
197 void performItemAction(QPoint viewportPos); 198 void performItemAction(QPoint viewportPos);
198 199
199 /** End moving/resizing agenda item */ 200 /** End moving/resizing agenda item */
200 void endItemAction(); 201 void endItemAction();
201 202
202 /** Set cursor, when no item action is in progress */ 203 /** Set cursor, when no item action is in progress */
203 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 204 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
204 205
205 /** Place agenda item in agenda and adjust other cells if necessary */ 206 /** Place agenda item in agenda and adjust other cells if necessary */
206 void placeSubCells(KOAgendaItem *placeItem); 207 void placeSubCells(KOAgendaItem *placeItem);
207 208
208 /** Process the keyevent, including the ignored keyevents of eventwidgets. 209 /** Process the keyevent, including the ignored keyevents of eventwidgets.
209 * Implements pgup/pgdn and cursor key navigation in the view. 210 * Implements pgup/pgdn and cursor key navigation in the view.
210 */ 211 */
211 void keyPressEvent( QKeyEvent * ); 212 void keyPressEvent( QKeyEvent * );
212 213
213 void calculateWorkingHours(); 214 void calculateWorkingHours();
214 215
215 virtual void contentsMousePressEvent ( QMouseEvent * ); 216 virtual void contentsMousePressEvent ( QMouseEvent * );
216 217
217 private: 218 private:
218 void init(); 219 void init();
219 void marcus_bains(); 220 void marcus_bains();
220 bool mAllDayMode; 221 bool mAllDayMode;
221 bool blockResize; 222 bool blockResize;
222 bool mLeftMouseDown; 223 bool mLeftMouseDown;
223 KOAgendaItem *mPopupItem; 224 KOAgendaItem *mPopupItem;
224 QTimer* mPopupTimer; 225 QTimer* mPopupTimer;
225 int mPopupKind; 226 int mPopupKind;
226 QPoint mPopupPos; 227 QPoint mPopupPos;
227 QTimer mResizeTimer; 228 QTimer mResizeTimer;
228 double mContentPosition; 229 double mContentPosition;
229 230
230 // Width and height of agenda cells 231 // Width and height of agenda cells
231 int mGridSpacingX; 232 int mGridSpacingX;
232 int mGridSpacingY; 233 int mGridSpacingY;
233 234
234 // size of border, where mouse action will resize the KOAgendaItem 235 // size of border, where mouse action will resize the KOAgendaItem
235 int mResizeBorderWidth; 236 int mResizeBorderWidth;
236 237
237 // size of border, where mouse mve will cause a scroll of the agenda 238 // size of border, where mouse mve will cause a scroll of the agenda
238 int mScrollBorderWidth; 239 int mScrollBorderWidth;
239 int mScrollDelay; 240 int mScrollDelay;
240 int mScrollOffset; 241 int mScrollOffset;
241 242
242 QTimer mScrollUpTimer; 243 QTimer mScrollUpTimer;
243 QTimer mScrollDownTimer; 244 QTimer mScrollDownTimer;
244 245
245 // Number of Columns/Rows of agenda grid 246 // Number of Columns/Rows of agenda grid
246 int mColumns; 247 int mColumns;
247 int mRows; 248 int mRows;
248 249
249 // Cells to store Move and Resize coordiantes 250 // Cells to store Move and Resize coordiantes
250 int mStartCellX; 251 int mStartCellX;
251 int mStartCellY; 252 int mStartCellY;
252 int mCurrentCellX; 253 int mCurrentCellX;
253 int mCurrentCellY; 254 int mCurrentCellY;
254 255
255 // Working Hour coordiantes 256 // Working Hour coordiantes
256 bool mWorkingHoursEnable; 257 bool mWorkingHoursEnable;
257 int mWorkingHoursYTop; 258 int mWorkingHoursYTop;
258 int mWorkingHoursYBottom; 259 int mWorkingHoursYBottom;
259 260
260 // Selection 261 // Selection
261 int mSelectionCellX; 262 int mSelectionCellX;
262 int mSelectionYTop; 263 int mSelectionYTop;
263 int mSelectionHeight; 264 int mSelectionHeight;
264 265
265 // List of dates to be displayed 266 // List of dates to be displayed
266 DateList mSelectedDates; 267 DateList mSelectedDates;
267 268
268 // The KOAgendaItem, which has been right-clicked last 269 // The KOAgendaItem, which has been right-clicked last
269 KOAgendaItem *mClickedItem; 270 KOAgendaItem *mClickedItem;
270 271
271 // The KOAgendaItem, which is being moved/resized 272 // The KOAgendaItem, which is being moved/resized
272 QGuardedPtr<KOAgendaItem> mActionItem; 273 QGuardedPtr<KOAgendaItem> mActionItem;
273 274
274 // Currently selected item 275 // Currently selected item
275 QGuardedPtr<KOAgendaItem> mSelectedItem; 276 QGuardedPtr<KOAgendaItem> mSelectedItem;
276 277
277 // The Marcus Bains Line widget. 278 // The Marcus Bains Line widget.
278 MarcusBains *mMarcusBains; 279 MarcusBains *mMarcusBains;
279 void computeSizes(); 280 void computeSizes();
280 281
281 MouseActionType mActionType; 282 MouseActionType mActionType;
282 283
283 bool mItemMoved; 284 bool mItemMoved;
284 285
285 // List of all Items contained in agenda 286 // List of all Items contained in agenda
286 QPtrList<KOAgendaItem> mItems; 287 QPtrList<KOAgendaItem> mItems;
287 QPtrList<KOAgendaItem> mUnusedItems; 288 QPtrList<KOAgendaItem> mUnusedItems;
288 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 289 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
289 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 290 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
290 QPopupMenu *mNewItemPopup; 291 QPopupMenu *mNewItemPopup;
291 292
292 int mOldLowerScrollValue; 293 int mOldLowerScrollValue;
293 int mOldUpperScrollValue; 294 int mOldUpperScrollValue;
294 KOAgendaItem * getItemForTodo ( Todo * todo ); 295 KOAgendaItem * getItemForTodo ( Todo * todo );
295 QMemArray<bool> *mHolidayMask; 296 QMemArray<bool> *mHolidayMask;
296 int mCurPixWid; 297 int mCurPixWid;
297 int mCurPixHei; 298 int mCurPixHei;
298}; 299};
299 300
300#endif // KOAGENDA_H 301#endif // KOAGENDA_H
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index a8e0678..a42d07b 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,335 +1,339 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#include <qapplication.h> 38#include <qapplication.h>
39#define AGENDA_ICON_SIZE 7 39#define AGENDA_ICON_SIZE 7
40#endif 40#endif
41#include <libkcal/icaldrag.h> 41#include <libkcal/icaldrag.h>
42#include <libkcal/vcaldrag.h> 42#include <libkcal/vcaldrag.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44extern int globalFlagBlockAgenda; 44extern int globalFlagBlockAgenda;
45extern int globalFlagBlockAgendaItemPaint; 45extern int globalFlagBlockAgendaItemPaint;
46extern int globalFlagBlockAgendaItemUpdate; 46extern int globalFlagBlockAgendaItemUpdate;
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49 49
50#include "koagendaitem.h" 50#include "koagendaitem.h"
51//#include "koagendaitem.moc" 51//#include "koagendaitem.moc"
52 52
53 53
54//-------------------------------------------------------------------------- 54//--------------------------------------------------------------------------
55 55
56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
57 57
58//-------------------------------------------------------------------------- 58//--------------------------------------------------------------------------
59 59
60class KOAgendaItemWhatsThis :public QWhatsThis 60class KOAgendaItemWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& ) 66 virtual QString text( const QPoint& )
67 { 67 {
68 return _view->getWhatsThisText() ; 68 return _view->getWhatsThisText() ;
69 } 69 }
70private: 70private:
71 KOAgendaItem * _view; 71 KOAgendaItem * _view;
72}; 72};
73 73
74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
75 const char *name,WFlags) : 75 const char *name,WFlags) :
76 QWidget(parent, name), mIncidence(incidence), mDate(qd) 76 QWidget(parent, name), mIncidence(incidence), mDate(qd)
77{ 77{
78#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
80#endif 80#endif
81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
83 setWFlags ( wflags); 83 setWFlags ( wflags);
84 mAllDay = allday; 84 mAllDay = allday;
85 init ( incidence, qd ); 85 init ( incidence, qd );
86 //setMouseTracking(true); 86 //setMouseTracking(true);
87 //setAcceptDrops(true); 87 //setAcceptDrops(true);
88 xPaintCoord = -1; 88 xPaintCoord = -1;
89 yPaintCoord = -1; 89 yPaintCoord = -1;
90} 90}
91QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
92{ 92{
93 if ( mIncidence ) 93 if ( mIncidence )
94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
95 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
96 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
97 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
98 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
99} 99}
100void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 100
101void KOAgendaItem::initColor ()
101{ 102{
102 mIncidence = incidence; 103 if ( (mIncidence->typeID() == todoID ) &&
103 mDate = qd; 104 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) &&
104 mFirstMultiItem = 0; 105 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) {
105 mNextMultiItem = 0; 106 if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date())
106 mLastMultiItem = 0;
107 computeText();
108
109 if ( (incidence->typeID() == todoID ) &&
110 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 107 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
114 else 108 else
115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 109 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
116 } 110 }
117 else { 111 else {
118 QStringList categories = mIncidence->categories(); 112 QStringList categories = mIncidence->categories();
119 QString cat = categories.first(); 113 QString cat = categories.first();
120 if (cat.isEmpty()) { 114 if (cat.isEmpty()) {
121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) 115 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) )
122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 116 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
123 else 117 else
124 mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() ); 118 mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() );
125 } else { 119 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 120 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 121 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) {
128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 122 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
129 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; 123 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor;
130 } 124 }
131 } 125 }
132 126
133 } 127 }
134 128
135 QColor BackgroundColor ( mBackgroundColor ); 129 QColor BackgroundColor ( mBackgroundColor );
136 if ( mIncidence->calID() > 1 ) { 130 if ( mIncidence->calID() > 1 ) {
137 BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); 131 BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() );
138 } 132 }
139 mColorGroup = QColorGroup( BackgroundColor.light(), 133 mColorGroup = QColorGroup( BackgroundColor.light(),
140 BackgroundColor.dark(),BackgroundColor.light(), 134 BackgroundColor.dark(),BackgroundColor.light(),
141 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; 135 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ;
142 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
143 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); 137 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250);
138}
139void KOAgendaItem::init ( Incidence *incidence, QDate qd )
140{
141 mIncidence = incidence;
142 mDate = qd;
143 mFirstMultiItem = 0;
144 mNextMultiItem = 0;
145 mLastMultiItem = 0;
146 computeText();
147 initColor();
144 mConflictItems.clear(); 148 mConflictItems.clear();
145 setCellXY(0,0,1); 149 setCellXY(0,0,1);
146 setCellXWidth(0); 150 setCellXWidth(0);
147 setSubCell(0); 151 setSubCell(0);
148 setSubCells(1); 152 setSubCells(1);
149 setMultiItem(0,0,0); 153 setMultiItem(0,0,0);
150 startMove(); 154 startMove();
151 mSelected = true; 155 mSelected = true;
152 select(false); 156 select(false);
153 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
154 mFontPixelSize = fontinf.height();; 158 mFontPixelSize = fontinf.height();;
155 hide(); 159 hide();
156 xPaintCoord = -1; 160 xPaintCoord = -1;
157 yPaintCoord = -1; 161 yPaintCoord = -1;
158} 162}
159 163
160 164
161KOAgendaItem::~KOAgendaItem() 165KOAgendaItem::~KOAgendaItem()
162{ 166{
163#if QT_VERSION >= 0x030000 167#if QT_VERSION >= 0x030000
164 168
165#else 169#else
166 delete mKOAgendaItemWhatsThis; 170 delete mKOAgendaItemWhatsThis;
167#endif 171#endif
168 172
169} 173}
170 174
171void KOAgendaItem::recreateIncidence() 175void KOAgendaItem::recreateIncidence()
172{ 176{
173#if 0 177#if 0
174 Incidence* newInc = mIncidence->clone(); 178 Incidence* newInc = mIncidence->clone();
175 newInc->recreate(); 179 newInc->recreate();
176 if ( mIncidence->doesRecur() ) { 180 if ( mIncidence->doesRecur() ) {
177 mIncidence->addExDate( mDate ); 181 mIncidence->addExDate( mDate );
178 newInc->recurrence()->unsetRecurs(); 182 newInc->recurrence()->unsetRecurs();
179 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
180 QTime tim = mIncidence->dtStart().time(); 184 QTime tim = mIncidence->dtStart().time();
181 newInc->setDtStart( QDateTime(mDate, tim) ); 185 newInc->setDtStart( QDateTime(mDate, tim) );
182 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
183 } 187 }
184#endif 188#endif
185 mIncidence = mIncidence->recreateCloneException( mDate ); 189 mIncidence = mIncidence->recreateCloneException( mDate );
186} 190}
187bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
188{ 192{
189 int size = AGENDA_ICON_SIZE; 193 int size = AGENDA_ICON_SIZE;
190 194
191 int yOff = 0; 195 int yOff = 0;
192 int xOff = 0; 196 int xOff = 0;
193 int x = pos().x() +3; 197 int x = pos().x() +3;
194 int y; 198 int y;
195 if ( mAllDay ) 199 if ( mAllDay )
196 y = pos().y()+3; 200 y = pos().y()+3;
197 else 201 else
198 y = mCellYTop * ( height() / cellHeight() ) +3; 202 y = mCellYTop * ( height() / cellHeight() ) +3;
199 if (mIncidence->cancelled()) { 203 if (mIncidence->cancelled()) {
200 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 204 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
201 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 205 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
202 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 206 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
203 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 207 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
204 if ( horLayout ) 208 if ( horLayout )
205 ++xOff; 209 ++xOff;
206 else 210 else
207 ++yOff; 211 ++yOff;
208 } 212 }
209 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { 213 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) {
210 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
211 if ( horLayout ) 215 if ( horLayout )
212 ++xOff; 216 ++xOff;
213 else 217 else
214 ++yOff; 218 ++yOff;
215 } 219 }
216 if (mIncidence->recurrence()->doesRecur()) { 220 if (mIncidence->recurrence()->doesRecur()) {
217 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
218 if ( horLayout ) 222 if ( horLayout )
219 ++xOff; 223 ++xOff;
220 else 224 else
221 ++yOff; 225 ++yOff;
222 } 226 }
223 if (mIncidence->description().length() > 0) { 227 if (mIncidence->description().length() > 0) {
224 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 228 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
225 if ( horLayout ) 229 if ( horLayout )
226 ++xOff; 230 ++xOff;
227 else 231 else
228 ++yOff; 232 ++yOff;
229 } 233 }
230 if (mIncidence->isReadOnly()) { 234 if (mIncidence->isReadOnly()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 235 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
232 if ( horLayout ) 236 if ( horLayout )
233 ++xOff; 237 ++xOff;
234 else 238 else
235 ++yOff; 239 ++yOff;
236 } 240 }
237 241
238 if (mIncidence->attendeeCount()>0) { 242 if (mIncidence->attendeeCount()>0) {
239 243
240 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 244 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
241 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
242 if ( horLayout ) 246 if ( horLayout )
243 ++xOff; 247 ++xOff;
244 else 248 else
245 ++yOff; 249 ++yOff;
246 } else { 250 } else {
247 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 251 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
248 if (me!=0) { 252 if (me!=0) {
249 253
250 254
251 } else { 255 } else {
252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 256 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
253 if ( horLayout ) 257 if ( horLayout )
254 ++xOff; 258 ++xOff;
255 else 259 else
256 ++yOff; 260 ++yOff;
257 261
258 } 262 }
259 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 263 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
260 if ( horLayout ) 264 if ( horLayout )
261 ++xOff; 265 ++xOff;
262 else 266 else
263 ++yOff; 267 ++yOff;
264 268
265 } 269 }
266 270
267 } 271 }
268 return ( yOff || xOff ); 272 return ( yOff || xOff );
269} 273}
270 274
271 275
272void KOAgendaItem::select(bool selected) 276void KOAgendaItem::select(bool selected)
273{ 277{
274 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 278 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
275 if (mSelected == selected) return; 279 if (mSelected == selected) return;
276 mSelected = selected; 280 mSelected = selected;
277 if ( ! isVisible() ) 281 if ( ! isVisible() )
278 return; 282 return;
279 if ( firstMultiItem() ) 283 if ( firstMultiItem() )
280 firstMultiItem()->select( selected ); 284 firstMultiItem()->select( selected );
281 if ( !firstMultiItem() && nextMultiItem() ) { 285 if ( !firstMultiItem() && nextMultiItem() ) {
282 KOAgendaItem * placeItem = nextMultiItem(); 286 KOAgendaItem * placeItem = nextMultiItem();
283 while ( placeItem ) { 287 while ( placeItem ) {
284 placeItem->select( selected ); 288 placeItem->select( selected );
285 placeItem = placeItem->nextMultiItem(); 289 placeItem = placeItem->nextMultiItem();
286 } 290 }
287 } 291 }
288 globalFlagBlockAgendaItemUpdate = 0; 292 globalFlagBlockAgendaItemUpdate = 0;
289 paintMe( selected ); 293 paintMe( selected );
290 globalFlagBlockAgendaItemUpdate = 1; 294 globalFlagBlockAgendaItemUpdate = 1;
291 repaint( false ); 295 repaint( false );
292} 296}
293 297
294 298
295/* 299/*
296 The eventFilter has to filter the mouse events of the agenda item childs. The 300 The eventFilter has to filter the mouse events of the agenda item childs. The
297 events are fed into the event handling method of KOAgendaItem. This allows the 301 events are fed into the event handling method of KOAgendaItem. This allows the
298 KOAgenda to handle the KOAgendaItems by using an eventFilter. 302 KOAgenda to handle the KOAgendaItems by using an eventFilter.
299*/ 303*/
300bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 304bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
301{ 305{
302 if (e->type() == QEvent::MouseButtonPress || 306 if (e->type() == QEvent::MouseButtonPress ||
303 e->type() == QEvent::MouseButtonDblClick || 307 e->type() == QEvent::MouseButtonDblClick ||
304 e->type() == QEvent::MouseButtonRelease || 308 e->type() == QEvent::MouseButtonRelease ||
305 e->type() == QEvent::MouseMove) { 309 e->type() == QEvent::MouseMove) {
306 QMouseEvent *me = (QMouseEvent *)e; 310 QMouseEvent *me = (QMouseEvent *)e;
307 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 311 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
308 mapToGlobal(me->pos())); 312 mapToGlobal(me->pos()));
309 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 313 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
310 return event(&returnEvent); 314 return event(&returnEvent);
311 } else { 315 } else {
312 return false; 316 return false;
313 } 317 }
314} 318}
315void KOAgendaItem::repaintMe( ) 319void KOAgendaItem::repaintMe( )
316{ 320{
317 paintMe ( mSelected ); 321 paintMe ( mSelected );
318} 322}
319void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 323void KOAgendaItem::paintMe( bool selected, QPainter* paint )
320{ 324{
321 if ( globalFlagBlockAgendaItemUpdate && ! selected) 325 if ( globalFlagBlockAgendaItemUpdate && ! selected)
322 return; 326 return;
323 QPainter pa; 327 QPainter pa;
324 328
325 if ( mSelected ) { 329 if ( mSelected ) {
326 pa.begin( paintPixSel() ); 330 pa.begin( paintPixSel() );
327 } else { 331 } else {
328 if ( mAllDay ) 332 if ( mAllDay )
329 pa.begin( paintPixAllday() ); 333 pa.begin( paintPixAllday() );
330 else 334 else
331 pa.begin( paintPix() ); 335 pa.begin( paintPix() );
332 } 336 }
333 int x, yy, w, h; 337 int x, yy, w, h;
334 float nfh = 7.0; 338 float nfh = 7.0;
335 x = pos().x(); w = width(); h = height (); 339 x = pos().x(); w = width(); h = height ();
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index d1b1940..dc2316a 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,165 +1,166 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class KOAgendaItemWhatsThis; 30class KOAgendaItemWhatsThis;
31class QToolTipGroup; 31class QToolTipGroup;
32class QDragEnterEvent; 32class QDragEnterEvent;
33class QDropEvent; 33class QDropEvent;
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37/* 37/*
38 The KOAgendaItem has to make sure that it receives all mouse events, which are 38 The KOAgendaItem has to make sure that it receives all mouse events, which are
39 to be used for dragging and resizing. That means it has to be installed as 39 to be used for dragging and resizing. That means it has to be installed as
40 eventfiler for its children, if it has children, and it has to pass mouse 40 eventfiler for its children, if it has children, and it has to pass mouse
41 events from the cildren to itself. See eventFilter(). 41 events from the cildren to itself. See eventFilter().
42*/ 42*/
43class KOAgendaItem : public QWidget 43class KOAgendaItem : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
48 WFlags f=0 ); 48 WFlags f=0 );
49 ~KOAgendaItem(); 49 ~KOAgendaItem();
50 QString getWhatsThisText(); 50 QString getWhatsThisText();
51 void init ( Incidence *incidence, QDate qd ); 51 void init ( Incidence *incidence, QDate qd );
52 int cellX() { return mCellX; } 52 int cellX() { return mCellX; }
53 int cellXWidth() { return mCellXWidth; } 53 int cellXWidth() { return mCellXWidth; }
54 int cellYTop() { return mCellYTop; } 54 int cellYTop() { return mCellYTop; }
55 int cellYBottom() { return mCellYBottom; } 55 int cellYBottom() { return mCellYBottom; }
56 int cellHeight(); 56 int cellHeight();
57 int cellWidth(); 57 int cellWidth();
58 int subCell() { return mSubCell; } 58 int subCell() { return mSubCell; }
59 int subCells() { return mSubCells; } 59 int subCells() { return mSubCells; }
60 60
61 void setCellXY(int X, int YTop, int YBottom); 61 void setCellXY(int X, int YTop, int YBottom);
62 void setCellY(int YTop, int YBottom); 62 void setCellY(int YTop, int YBottom);
63 void setCellX(int XLeft, int XRight); 63 void setCellX(int XLeft, int XRight);
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static void resizePixmap( int, int ); 104 static void resizePixmap( int, int );
105 static QPixmap * paintPix(); 105 static QPixmap * paintPix();
106 static QPixmap * paintPixSel(); 106 static QPixmap * paintPixSel();
107 static QPixmap * paintPixAllday(); 107 static QPixmap * paintPixAllday();
108 void updateItem(); 108 void updateItem();
109 void computeText(); 109 void computeText();
110 void recreateIncidence(); 110 void recreateIncidence();
111 bool checkLayout(); 111 bool checkLayout();
112 void initColor ();
112 public slots: 113 public slots:
113 bool updateIcons( QPainter *, bool ); 114 bool updateIcons( QPainter *, bool );
114 void select(bool=true); 115 void select(bool=true);
115 116
116 protected: 117 protected:
117 void dragEnterEvent(QDragEnterEvent *e); 118 void dragEnterEvent(QDragEnterEvent *e);
118 void dropEvent(QDropEvent *e); 119 void dropEvent(QDropEvent *e);
119 void paintEvent ( QPaintEvent * ); 120 void paintEvent ( QPaintEvent * );
120 void resizeEvent ( QResizeEvent *ev ); 121 void resizeEvent ( QResizeEvent *ev );
121 122
122 private: 123 private:
123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 124 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
124 bool mAllDay; 125 bool mAllDay;
125 bool mWhiteText; 126 bool mWhiteText;
126 int mCellX; 127 int mCellX;
127 int mCellXWidth; 128 int mCellXWidth;
128 int mCellYTop,mCellYBottom; 129 int mCellYTop,mCellYBottom;
129 int mSubCell; // subcell number of this item 130 int mSubCell; // subcell number of this item
130 int mSubCells; // Total number of subcells in cell of this item 131 int mSubCells; // Total number of subcells in cell of this item
131 int xPaintCoord; 132 int xPaintCoord;
132 int yPaintCoord; 133 int yPaintCoord;
133 int wPaintCoord; 134 int wPaintCoord;
134 int hPaintCoord; 135 int hPaintCoord;
135 // Variables to remember start position 136 // Variables to remember start position
136 int mStartCellX; 137 int mStartCellX;
137 int mStartCellXWidth; 138 int mStartCellXWidth;
138 int mStartCellYTop,mStartCellYBottom; 139 int mStartCellYTop,mStartCellYBottom;
139 int mLastMovePos; 140 int mLastMovePos;
140 141
141 // Multi item pointers 142 // Multi item pointers
142 KOAgendaItem *mFirstMultiItem; 143 KOAgendaItem *mFirstMultiItem;
143 KOAgendaItem *mNextMultiItem; 144 KOAgendaItem *mNextMultiItem;
144 KOAgendaItem *mLastMultiItem; 145 KOAgendaItem *mLastMultiItem;
145 146
146 int mFontPixelSize; 147 int mFontPixelSize;
147 Incidence *mIncidence; // corresponding event or todo 148 Incidence *mIncidence; // corresponding event or todo
148 QDate mDate; //date this events occurs (for recurrence) 149 QDate mDate; //date this events occurs (for recurrence)
149 //void showIcon( QLabel*, int ); 150 //void showIcon( QLabel*, int );
150 //QLabel *mTodoIconLabel; 151 //QLabel *mTodoIconLabel;
151 //QLabel *mItemLabel; 152 //QLabel *mItemLabel;
152 //QWidget *mIconBox; 153 //QWidget *mIconBox;
153 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 154 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
154 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 155 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
155 //QLabel *mIconMoreInfo; 156 //QLabel *mIconMoreInfo;
156 static QToolTipGroup *mToolTipGroup; 157 static QToolTipGroup *mToolTipGroup;
157 158
158 QColor mBackgroundColor; 159 QColor mBackgroundColor;
159 QColorGroup mColorGroup; 160 QColorGroup mColorGroup;
160 QString mDisplayedText; 161 QString mDisplayedText;
161 bool mSelected; 162 bool mSelected;
162 QPtrList<KOAgendaItem> mConflictItems; 163 QPtrList<KOAgendaItem> mConflictItems;
163}; 164};
164 165
165#endif // KOAGENDAITEM_H 166#endif // KOAGENDAITEM_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index c851ab5..a42227c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -285,499 +285,508 @@ void TimeLabels::paintEvent(QPaintEvent*)
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 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *)));
480
481
477 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
478 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
479 // make connections between dependent widgets 484 // make connections between dependent widgets
480 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
481 486
482 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
483 // updateConfig(); 488 // updateConfig();
484 489
485 // createDayLabels(); 490 // createDayLabels();
486 491
487 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
491 496
492 // Scrolling 497 // Scrolling
493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
494 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
496 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
497 502
498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
500 505
501 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
502 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
503 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
505 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
507 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
515 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 525
521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
522 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
524 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
526 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
528 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
530 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
532 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
533 538
534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
535 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
537 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
538 543
539 // event indicator update 544 // event indicator update
540 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
541 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
542 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
543 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
544 // drag signals 549 // drag signals
545 /* 550 /*
546 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
547 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
549 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
550 */ 555 */
551 // synchronize selections 556 // synchronize selections
552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
553 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
555 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
557 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
560 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
561 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
565 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 573
569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
571 576
572} 577}
573 578
574void KOAgendaView::toggleAllDay() 579void KOAgendaView::toggleAllDay()
575{ 580{
576 if ( mSplitterAgenda->firstHandle() ) 581 if ( mSplitterAgenda->firstHandle() )
577 mSplitterAgenda->firstHandle()->toggle(); 582 mSplitterAgenda->firstHandle()->toggle();
578} 583}
579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
580{ 585{
581 calendar()->addIncidence( inc ); 586 calendar()->addIncidence( inc );
582 587
583 if ( incOld ) { 588 if ( incOld ) {
584 if ( incOld->typeID() == todoID ) 589 if ( incOld->typeID() == todoID )
585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
586 else 591 else
587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
588 } 593 }
589 594
590} 595}
591 596void KOAgendaView::categoryChanged(Incidence * inc)
597{
598 mAgenda->categoryChanged( inc );
599 mAllDayAgenda->categoryChanged( inc );
600}
592KOAgendaView::~KOAgendaView() 601KOAgendaView::~KOAgendaView()
593{ 602{
594 delete mAllAgendaPopup; 603 delete mAllAgendaPopup;
595 //delete mAllDayAgendaPopup; 604 //delete mAllDayAgendaPopup;
596 delete KOAgendaItem::paintPix(); 605 delete KOAgendaItem::paintPix();
597 delete KOAgendaItem::paintPixSel(); 606 delete KOAgendaItem::paintPixSel();
598} 607}
599void KOAgendaView::resizeEvent( QResizeEvent* e ) 608void KOAgendaView::resizeEvent( QResizeEvent* e )
600{ 609{
601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
602 bool uc = false; 611 bool uc = false;
603 int ow = e->oldSize().width(); 612 int ow = e->oldSize().width();
604 int oh = e->oldSize().height(); 613 int oh = e->oldSize().height();
605 int w = e->size().width(); 614 int w = e->size().width();
606 int h = e->size().height(); 615 int h = e->size().height();
607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
609 uc = true; 618 uc = true;
610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
611 } 620 }
612 mUpcomingWidth = e->size().width() ; 621 mUpcomingWidth = e->size().width() ;
613 if ( mBlockUpdating || uc ) { 622 if ( mBlockUpdating || uc ) {
614 mBlockUpdating = false; 623 mBlockUpdating = false;
615 //mAgenda->setMinimumSize(800 , 600 ); 624 //mAgenda->setMinimumSize(800 , 600 );
616 //qDebug("mAgenda->resize+++++++++++++++ "); 625 //qDebug("mAgenda->resize+++++++++++++++ ");
617 updateConfig(); 626 updateConfig();
618 //qDebug("KOAgendaView::Updating now possible "); 627 //qDebug("KOAgendaView::Updating now possible ");
619 } else 628 } else
620 createDayLabels(); 629 createDayLabels();
621 //qDebug("resizeEvent end "); 630 //qDebug("resizeEvent end ");
622 631
623} 632}
624void KOAgendaView::slotDaylabelClicked( int num ) 633void KOAgendaView::slotDaylabelClicked( int num )
625{ 634{
626 635
627 QDate firstDate = mSelectedDates.first(); 636 QDate firstDate = mSelectedDates.first();
628 if ( num == -1 ) 637 if ( num == -1 )
629 emit showDateView( 6, firstDate ); 638 emit showDateView( 6, firstDate );
630 else if (num >= 0 ) { 639 else if (num >= 0 ) {
631 if ( mSelectedDates.count() == 1) 640 if ( mSelectedDates.count() == 1)
632 emit showDateView( 9, firstDate.addDays( num ) ); 641 emit showDateView( 9, firstDate.addDays( num ) );
633 else 642 else
634 emit showDateView( 3, firstDate.addDays( num ) ); 643 emit showDateView( 3, firstDate.addDays( num ) );
635 } 644 }
636 else 645 else
637 showDateView( 10, firstDate.addDays(1) ); 646 showDateView( 10, firstDate.addDays(1) );
638} 647}
639 648
640KOAgendaButton* KOAgendaView::getNewDaylabel() 649KOAgendaButton* KOAgendaView::getNewDaylabel()
641{ 650{
642 651
643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
645 mDayLabelsList.append( dayLabel ); 654 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel); 655 mLayoutDayLabels->addWidget(dayLabel);
647 return dayLabel ; 656 return dayLabel ;
648} 657}
649 658
650void KOAgendaView::createDayLabels() 659void KOAgendaView::createDayLabels()
651{ 660{
652 661
653 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 662 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
654 // qDebug(" KOAgendaView::createDayLabels() blocked "); 663 // qDebug(" KOAgendaView::createDayLabels() blocked ");
655 return; 664 return;
656 665
657 } 666 }
658 int newHight; 667 int newHight;
659 if ( !mSelectedDates.count()) 668 if ( !mSelectedDates.count())
660 return; 669 return;
661 670
662 // ### Before deleting and recreating we could check if mSelectedDates changed... 671 // ### Before deleting and recreating we could check if mSelectedDates changed...
663 // It would remove some flickering and gain speed (since this is called by 672 // It would remove some flickering and gain speed (since this is called by
664 // each updateView() call) 673 // each updateView() call)
665 674
666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
668 if ( maxWid < 20 ) 677 if ( maxWid < 20 )
669 maxWid = 20; 678 maxWid = 20;
670 679
671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
672 QFontMetrics fm ( dlf ); 681 QFontMetrics fm ( dlf );
673 dlf.setBold( true ); 682 dlf.setBold( true );
674 int selCount = mSelectedDates.count(); 683 int selCount = mSelectedDates.count();
675 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
676 QString dayTest = "Mon 20"; 685 QString dayTest = "Mon 20";
677 //QString dayTest = "Mon 20"; 686 //QString dayTest = "Mon 20";
678 int wid = fm.width( dayTest ); 687 int wid = fm.width( dayTest );
679 //maxWid -= ( selCount * 3 ); //working for QLabels 688 //maxWid -= ( selCount * 3 ); //working for QLabels
680 if ( QApplication::desktop()->width() <= 320 ) 689 if ( QApplication::desktop()->width() <= 320 )
681 maxWid -= ( selCount * 3 ); //working for QPushButton 690 maxWid -= ( selCount * 3 ); //working for QPushButton
682 else 691 else
683 maxWid -= ( selCount * 4 ); //working for QPushButton 692 maxWid -= ( selCount * 4 ); //working for QPushButton
684 if ( maxWid < 0 ) 693 if ( maxWid < 0 )
685 maxWid = 20; 694 maxWid = 20;
686 int needWid = wid * selCount; 695 int needWid = wid * selCount;
687 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
688 //if ( needWid > maxWid ) 697 //if ( needWid > maxWid )
689 // qDebug("DAYLABELS TOOOOOOO BIG "); 698 // qDebug("DAYLABELS TOOOOOOO BIG ");
690 while ( needWid > maxWid ) { 699 while ( needWid > maxWid ) {
691 dayTest = dayTest.left( dayTest.length() - 1 ); 700 dayTest = dayTest.left( dayTest.length() - 1 );
692 wid = fm.width( dayTest ); 701 wid = fm.width( dayTest );
693 needWid = wid * selCount; 702 needWid = wid * selCount;
694 } 703 }
695 int maxLen = dayTest.length(); 704 int maxLen = dayTest.length();
696 int fontPoint = dlf.pointSize(); 705 int fontPoint = dlf.pointSize();
697 if ( maxLen < 2 ) { 706 if ( maxLen < 2 ) {
698 int fontPoint = dlf.pointSize(); 707 int fontPoint = dlf.pointSize();
699 while ( fontPoint > 4 ) { 708 while ( fontPoint > 4 ) {
700 --fontPoint; 709 --fontPoint;
701 dlf.setPointSize( fontPoint ); 710 dlf.setPointSize( fontPoint );
702 QFontMetrics f( dlf ); 711 QFontMetrics f( dlf );
703 wid = f.width( "30" ); 712 wid = f.width( "30" );
704 needWid = wid * selCount; 713 needWid = wid * selCount;
705 if ( needWid < maxWid ) 714 if ( needWid < maxWid )
706 break; 715 break;
707 } 716 }
708 maxLen = 2; 717 maxLen = 2;
709 } 718 }
710 //qDebug("Max len %d ", dayTest.length() ); 719 //qDebug("Max len %d ", dayTest.length() );
711 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
712 dlf.setBold( false ); 721 dlf.setBold( false );
713 QFontMetrics tempF( dlf ); 722 QFontMetrics tempF( dlf );
714 newHight = tempF.height(); 723 newHight = tempF.height();
715 mDayLabels->setFont( dlf ); 724 mDayLabels->setFont( dlf );
716 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
717 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 726 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
718 //mLayoutDayLabels->addSpacing( 2 ); 727 //mLayoutDayLabels->addSpacing( 2 );
719 // QFont lFont = dlf; 728 // QFont lFont = dlf;
720 bool appendLabels = false; 729 bool appendLabels = false;
721 KOAgendaButton *dayLabel; 730 KOAgendaButton *dayLabel;
722 dayLabel = mDayLabelsList.first(); 731 dayLabel = mDayLabelsList.first();
723 if ( !dayLabel ) { 732 if ( !dayLabel ) {
724 appendLabels = true; 733 appendLabels = true;
725 dayLabel = getNewDaylabel(); 734 dayLabel = getNewDaylabel();
726 } 735 }
727 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
728 dayLabel->setFont( dlf ); 737 dayLabel->setFont( dlf );
729 dayLabel->setNum( -1 ); 738 dayLabel->setNum( -1 );
730 //dayLabel->setAlignment(QLabel::AlignHCenter); 739 //dayLabel->setAlignment(QLabel::AlignHCenter);
731 740
732 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
733 dayLabel->show(); 742 dayLabel->show();
734 DateList::ConstIterator dit; 743 DateList::ConstIterator dit;
735 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
736 int counter = -1; 745 int counter = -1;
737 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
738 ++counter; 747 ++counter;
739 QDate date = *dit; 748 QDate date = *dit;
740 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
741 if ( ! appendLabels ) { 750 if ( ! appendLabels ) {
742 dayLabel = mDayLabelsList.next(); 751 dayLabel = mDayLabelsList.next();
743 if ( !dayLabel ) 752 if ( !dayLabel )
744 appendLabels = true; 753 appendLabels = true;
745 } 754 }
746 if ( appendLabels ) { 755 if ( appendLabels ) {
747 dayLabel = getNewDaylabel(); 756 dayLabel = getNewDaylabel();
748 } 757 }
749 dayLabel->setMinimumWidth( 1 ); 758 dayLabel->setMinimumWidth( 1 );
750 dayLabel->setMaximumWidth( 10240 ); 759 dayLabel->setMaximumWidth( 10240 );
751 dayLabel->setFont( dlf ); 760 dayLabel->setFont( dlf );
752 dayLabel->show(); 761 dayLabel->show();
753 dayLabel->setAutoRepeat( false ); 762 dayLabel->setAutoRepeat( false );
754 dayLabel->setNum( counter ); 763 dayLabel->setNum( counter );
755 QString str; 764 QString str;
756 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
757 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
758 switch ( maxLen ) { 767 switch ( maxLen ) {
759 case 2: 768 case 2:
760 str = QString::number( date.day() ); 769 str = QString::number( date.day() );
761 break; 770 break;
762 771
763 case 3: 772 case 3:
764 str = dayName.left( 1 ) +QString::number( date.day()); 773 str = dayName.left( 1 ) +QString::number( date.day());
765 774
766 break; 775 break;
767 case 4: 776 case 4:
768 str = dayName.left( 1 ) + " " +QString::number( date.day()); 777 str = dayName.left( 1 ) + " " +QString::number( date.day());
769 778
770 break; 779 break;
771 case 5: 780 case 5:
772 str = dayName.left( 2 ) + " " +QString::number( date.day()); 781 str = dayName.left( 2 ) + " " +QString::number( date.day());
773 782
774 break; 783 break;
775 case 6: 784 case 6:
776 str = dayName.left( 3 ) + " " +QString::number( date.day()); 785 str = dayName.left( 3 ) + " " +QString::number( date.day());
777 break; 786 break;
778 787
779 default: 788 default:
780 break; 789 break;
781 } 790 }
782 if ( oneday ) { 791 if ( oneday ) {
783 QString addString; 792 QString addString;
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index cc953fc..a1cf308 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -50,244 +50,245 @@ class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix; 104 QPixmap myPix;
105 bool mRedrawNeeded; 105 bool mRedrawNeeded;
106 int mMiniWidth; 106 int mMiniWidth;
107 int mMouseDownY; 107 int mMouseDownY;
108 QString mOrgCap; 108 QString mOrgCap;
109 int mRows; 109 int mRows;
110 int mCellHeight; 110 int mCellHeight;
111 111
112 /** */ 112 /** */
113 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
114}; 114};
115 115
116class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 void clearList(); 169 void clearList();
170 KOAgenda *agenda() { return mAgenda;} 170 KOAgenda *agenda() { return mAgenda;}
171 virtual void printPreview(CalPrinter *calPrinter, 171 virtual void printPreview(CalPrinter *calPrinter,
172 const QDate &, const QDate &); 172 const QDate &, const QDate &);
173 173
174 /** start-datetime of selection */ 174 /** start-datetime of selection */
175 QDateTime selectionStart() {return mTimeSpanBegin;} 175 QDateTime selectionStart() {return mTimeSpanBegin;}
176 /** end-datetime of selection */ 176 /** end-datetime of selection */
177 QDateTime selectionEnd() {return mTimeSpanEnd;} 177 QDateTime selectionEnd() {return mTimeSpanEnd;}
178 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
179 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
180 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
181 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
182 void repaintAgenda(); 182 void repaintAgenda();
183 public slots: 183 public slots:
184 void setInitStartHour(); 184 void setInitStartHour();
185 virtual void updateView(); 185 virtual void updateView();
186 virtual void updateConfig(); 186 virtual void updateConfig();
187 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
188 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
189 189
190 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
191 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
192 192
193 void clearSelection(); 193 void clearSelection();
194 194
195 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
196 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
198 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
199 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
200 200
201 void startDrag(Event *); 201 void startDrag(Event *);
202 202
203 void readSettings(); 203 void readSettings();
204 void readSettings(KConfig *); 204 void readSettings(KConfig *);
205 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
206 206
207 void setContentsPos(int y); 207 void setContentsPos(int y);
208 208
209 void scrollOneHourUp(); 209 void scrollOneHourUp();
210 void scrollOneHourDown(); 210 void scrollOneHourDown();
211 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
212 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
213 213
214 signals: 214 signals:
215 void showDateView( int, QDate ); 215 void showDateView( int, QDate );
216 void newTodoSignal( QDateTime ,bool ); 216 void newTodoSignal( QDateTime ,bool );
217 void toggleExpand(); 217 void toggleExpand();
218 void selectWeekNum( int ); 218 void selectWeekNum( int );
219 void todoMoved( Todo *, int ); 219 void todoMoved( Todo *, int );
220 void incidenceChanged(Incidence * , int ); 220 void incidenceChanged(Incidence * , int );
221 // void cloneIncidenceSignal(Incidence *); 221 // void cloneIncidenceSignal(Incidence *);
222 222
223 protected: 223 protected:
224 KOAgendaButton* getNewDaylabel(); 224 KOAgendaButton* getNewDaylabel();
225 bool mBlockUpdating; 225 bool mBlockUpdating;
226 int mUpcomingWidth; 226 int mUpcomingWidth;
227 /** Fill agenda beginning with date startDate */ 227 /** Fill agenda beginning with date startDate */
228 void fillAgenda(const QDate &startDate); 228 void fillAgenda(const QDate &startDate);
229 void resizeEvent( QResizeEvent* e ); 229 void resizeEvent( QResizeEvent* e );
230 /** Fill agenda using the current set value for the start date */ 230 /** Fill agenda using the current set value for the start date */
231 void fillAgenda(); 231 void fillAgenda();
232 232
233 /** Create labels for the selected dates. */ 233 /** Create labels for the selected dates. */
234 void createDayLabels(); 234 void createDayLabels();
235 235
236 /** 236 /**
237 Set the masks on the agenda widgets indicating, which days are holidays. 237 Set the masks on the agenda widgets indicating, which days are holidays.
238 */ 238 */
239 void setHolidayMasks(); 239 void setHolidayMasks();
240 240
241 protected slots: 241 protected slots:
242 void categoryChanged( Incidence * );
242 void slotDaylabelClicked( int ); 243 void slotDaylabelClicked( int );
243 /** Update event belonging to agenda item */ 244 /** Update event belonging to agenda item */
244 void updateEventDates(KOAgendaItem *item, int mode = -1); 245 void updateEventDates(KOAgendaItem *item, int mode = -1);
245 //void updateMovedTodo(); 246 //void updateMovedTodo();
246 247
247 void updateEventIndicatorTop(int newY); 248 void updateEventIndicatorTop(int newY);
248 void updateEventIndicatorBottom(int newY); 249 void updateEventIndicatorBottom(int newY);
249 250
250 /** Updates data for selected timespan */ 251 /** Updates data for selected timespan */
251 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 252 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
252 /** Updates data for selected timespan for all day event*/ 253 /** Updates data for selected timespan for all day event*/
253 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 254 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
254 255
255 private: 256 private:
256 // view widgets 257 // view widgets
257 QFrame *mDayLabels; 258 QFrame *mDayLabels;
258 QHBox *mDayLabelsFrame; 259 QHBox *mDayLabelsFrame;
259 QBoxLayout *mLayoutDayLabels; 260 QBoxLayout *mLayoutDayLabels;
260 QFrame *mAllDayFrame; 261 QFrame *mAllDayFrame;
261 KOAgenda *mAllDayAgenda; 262 KOAgenda *mAllDayAgenda;
262 KOAgenda *mAgenda; 263 KOAgenda *mAgenda;
263 TimeLabels *mTimeLabels; 264 TimeLabels *mTimeLabels;
264 QWidget *mDummyAllDayLeft; 265 QWidget *mDummyAllDayLeft;
265 266
266 KDGanttMinimizeSplitter* mSplitterAgenda; 267 KDGanttMinimizeSplitter* mSplitterAgenda;
267 QPushButton *mExpandButton; 268 QPushButton *mExpandButton;
268 269
269 DateList mSelectedDates; // List of dates to be displayed 270 DateList mSelectedDates; // List of dates to be displayed
270 int mViewType; 271 int mViewType;
271 272
272 bool mWeekStartsMonday; 273 bool mWeekStartsMonday;
273 int mStartHour; 274 int mStartHour;
274 275
275 KOEventPopupMenu *mAllAgendaPopup; 276 KOEventPopupMenu *mAllAgendaPopup;
276 //KOEventPopupMenu *mAllDayAgendaPopup; 277 //KOEventPopupMenu *mAllDayAgendaPopup;
277 278
278 EventIndicator *mEventIndicatorTop; 279 EventIndicator *mEventIndicatorTop;
279 EventIndicator *mEventIndicatorBottom; 280 EventIndicator *mEventIndicatorBottom;
280 281
281 QMemArray<int> mMinY; 282 QMemArray<int> mMinY;
282 QMemArray<int> mMaxY; 283 QMemArray<int> mMaxY;
283 284
284 QMemArray<bool> mHolidayMask; 285 QMemArray<bool> mHolidayMask;
285 286
286 QPtrList<KOAgendaButton> mDayLabelsList; 287 QPtrList<KOAgendaButton> mDayLabelsList;
287 QDateTime mTimeSpanBegin; 288 QDateTime mTimeSpanBegin;
288 QDateTime mTimeSpanEnd; 289 QDateTime mTimeSpanEnd;
289 bool mTimeSpanInAllDay; 290 bool mTimeSpanInAllDay;
290 void keyPressEvent ( QKeyEvent * e ); 291 void keyPressEvent ( QKeyEvent * e );
291}; 292};
292 293
293#endif // KOAGENDAVIEW_H 294#endif // KOAGENDAVIEW_H
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 17ef81e..90caaf4 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -1,130 +1,168 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcursor.h> 24#include <qcursor.h>
25 25
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kiconloader.h> 28#include <kiconloader.h>
29 29
30#include <libkcal/event.h> 30#include <libkcal/event.h>
31 31
32#include "koeventpopupmenu.h" 32#include "koeventpopupmenu.h"
33#include "koprefs.h"
33 34
34KOEventPopupMenu::KOEventPopupMenu() 35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
35{ 36{
36 mCurrentIncidence = 0; 37 mCurrentIncidence = 0;
37 mHasAdditionalItems = false; 38 mHasAdditionalItems = false;
38 39
39 40
40 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); 41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
41 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
42 mEditOnlyItems.append(insertItem (i18n("&Delete"), 43 mEditOnlyItems.append(insertItem (i18n("&Delete"),
43 this,SLOT(popupDelete()))); 44 this,SLOT(popupDelete())));
44 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 45 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
45 this,SLOT(popupClone()))); 46 this,SLOT(popupClone())));
46 mEditOnlyItems.append(insertItem (i18n("&Move..."), 47 mEditOnlyItems.append(insertItem (i18n("&Move..."),
47 this,SLOT(popupMove()))); 48 this,SLOT(popupMove())));
48#ifndef DESKTOP_VERSION 49#ifndef DESKTOP_VERSION
49 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 50 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
50 this,SLOT(popupBeam()))); 51 this,SLOT(popupBeam())));
51#endif 52#endif
52 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), 53 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
53 this,SLOT(popupCancel()))); 54 this,SLOT(popupCancel())));
54 isDisabled = false; 55 isDisabled = false;
56 mCatPopup = new QPopupMenu ( this );
57 mCatPopup->setCheckable (true);
58 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup()));
59 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int )));
60 mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
55 QValueList<int>::Iterator it; 61 QValueList<int>::Iterator it;
56 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 62 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
57 mSingleOnlyItems.append(*it); 63 mSingleOnlyItems.append(*it);
58 } 64 }
65
59} 66}
60void KOEventPopupMenu::enableDefault( bool enable ) 67void KOEventPopupMenu::enableDefault( bool enable )
61{ 68{
62 isDisabled = !enable; 69 isDisabled = !enable;
63 QValueList<int>::Iterator it; 70 QValueList<int>::Iterator it;
64 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { 71 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
65 setItemEnabled(*it,enable); 72 setItemEnabled(*it,enable);
66 } 73 }
67 74
68} 75}
69 76
77void KOEventPopupMenu::fillCatPopup()
78{
79 mCatPopup->clear();
80 QStringList checkedCategories = mCurrentIncidence->categories();
81 int index = 0;
82 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
83 it != KOPrefs::instance()->mCustomCategories.end ();
84 ++it) {
85 mCatPopup->insertItem (*it, index );
86 if (checkedCategories.find (*it) != checkedCategories.end ()) {
87 mCatPopup->setItemChecked (index, true);
88 }
89 ++index;
90 }
91}
92void KOEventPopupMenu::computeCatPopup( int index )
93{
94 QStringList categories = mCurrentIncidence->categories();
95 QString colcat = categories.first();
96 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
97 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
98 else
99 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
100 categories.sort ();
101 if ( !colcat.isEmpty() ) {
102 if ( categories.find ( colcat ) != categories.end () ) {
103 categories.remove( colcat );
104 categories.prepend( colcat );
105 }
106 }
107 mCurrentIncidence->setCategories( categories );
108 emit categoryChanged( mCurrentIncidence );
109}
70void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 110void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
71{ 111{
72 mCurrentIncidence = incidence; 112 mCurrentIncidence = incidence;
73 113
74 if (mCurrentIncidence) { 114 if (mCurrentIncidence) {
75 // Enable/Disabled menu items only valid for editable events. 115 // Enable/Disabled menu items only valid for editable events.
76 if ( !isDisabled ) { 116 if ( !isDisabled ) {
77 QValueList<int>::Iterator it; 117 QValueList<int>::Iterator it;
78 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 118 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
79 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 119 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
80 } 120 }
81 } 121 }
82 popup(QCursor::pos()); 122 popup(QCursor::pos());
83 } else {
84 kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
85 } 123 }
86} 124}
87 125
88void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 126void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
89 const QObject *receiver, const char *member, 127 const QObject *receiver, const char *member,
90 bool editOnly) 128 bool editOnly)
91{ 129{
92 if (!mHasAdditionalItems) { 130 if (!mHasAdditionalItems) {
93 mHasAdditionalItems = true; 131 mHasAdditionalItems = true;
94 insertSeparator(); 132 insertSeparator();
95 } 133 }
96 int id = insertItem(icon,text,receiver,member); 134 int id = insertItem(icon,text,receiver,member);
97 if (editOnly) mEditOnlyItems.append(id); 135 if (editOnly) mEditOnlyItems.append(id);
98} 136}
99 137
100void KOEventPopupMenu::popupShow() 138void KOEventPopupMenu::popupShow()
101{ 139{
102 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); 140 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
103} 141}
104 142
105void KOEventPopupMenu::popupEdit() 143void KOEventPopupMenu::popupEdit()
106{ 144{
107 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); 145 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
108} 146}
109 147
110void KOEventPopupMenu::popupDelete() 148void KOEventPopupMenu::popupDelete()
111{ 149{
112 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); 150 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
113} 151}
114void KOEventPopupMenu::popupClone() 152void KOEventPopupMenu::popupClone()
115{ 153{
116 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); 154 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence);
117} 155}
118void KOEventPopupMenu::popupCancel() 156void KOEventPopupMenu::popupCancel()
119{ 157{
120 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); 158 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence);
121} 159}
122void KOEventPopupMenu::popupMove() 160void KOEventPopupMenu::popupMove()
123{ 161{
124 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); 162 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence);
125} 163}
126 164
127void KOEventPopupMenu::popupBeam() 165void KOEventPopupMenu::popupBeam()
128{ 166{
129 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); 167 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence);
130} 168}
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h
index 8fb51fa..3d8b595 100644
--- a/korganizer/koeventpopupmenu.h
+++ b/korganizer/koeventpopupmenu.h
@@ -1,76 +1,80 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOEVENTPOPUPMENU_H 23#ifndef KOEVENTPOPUPMENU_H
24#define KOEVENTPOPUPMENU_H 24#define KOEVENTPOPUPMENU_H
25// 25//
26// Context menu for event views with standard event actions 26// Context menu for event views with standard event actions
27// 27//
28 28
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30 30
31#include <libkcal/incidence.h> 31#include <libkcal/incidence.h>
32 32
33using namespace KCal; 33using namespace KCal;
34 34
35class KOEventPopupMenu : public QPopupMenu { 35class KOEventPopupMenu : public QPopupMenu {
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 KOEventPopupMenu(); 38 KOEventPopupMenu();
39 39
40 void addAdditionalItem(const QIconSet &icon,const QString &text, 40 void addAdditionalItem(const QIconSet &icon,const QString &text,
41 const QObject *receiver, const char *member, 41 const QObject *receiver, const char *member,
42 bool editOnly=false); 42 bool editOnly=false);
43 43
44 44
45 public slots: 45 public slots:
46 void showIncidencePopup(Incidence *); 46 void showIncidencePopup(Incidence *);
47 void enableDefault( bool ); 47 void enableDefault( bool );
48 48
49 protected slots: 49 protected slots:
50 void popupShow(); 50 void popupShow();
51 void popupEdit(); 51 void popupEdit();
52 void popupDelete(); 52 void popupDelete();
53 void popupClone(); 53 void popupClone();
54 void popupCancel(); 54 void popupCancel();
55 void popupMove(); 55 void popupMove();
56 void popupBeam(); 56 void popupBeam();
57 void fillCatPopup();
58 void computeCatPopup( int );
57 59
58 signals: 60 signals:
59 void editIncidenceSignal(Incidence *); 61 void editIncidenceSignal(Incidence *);
60 void showIncidenceSignal(Incidence *); 62 void showIncidenceSignal(Incidence *);
61 void deleteIncidenceSignal(Incidence *); 63 void deleteIncidenceSignal(Incidence *);
62 void cloneIncidenceSignal(Incidence *); 64 void cloneIncidenceSignal(Incidence *);
63 void cancelIncidenceSignal(Incidence *); 65 void cancelIncidenceSignal(Incidence *);
64 void moveIncidenceSignal(Incidence *); 66 void moveIncidenceSignal(Incidence *);
65 void beamIncidenceSignal(Incidence *); 67 void beamIncidenceSignal(Incidence *);
68 void categoryChanged( Incidence * );
66 69
67 private: 70 private:
68 Incidence *mCurrentIncidence; 71 Incidence *mCurrentIncidence;
69 72
70 bool mHasAdditionalItems; 73 bool mHasAdditionalItems;
71 QValueList<int> mEditOnlyItems; 74 QValueList<int> mEditOnlyItems;
72 QValueList<int> mSingleOnlyItems; 75 QValueList<int> mSingleOnlyItems;
73 bool isDisabled; 76 bool isDisabled;
77 QPopupMenu *mCatPopup;
74}; 78};
75 79
76#endif 80#endif
diff --git a/korganizer/koeventview.cpp b/korganizer/koeventview.cpp
index bce2626..1d26930 100644
--- a/korganizer/koeventview.cpp
+++ b/korganizer/koeventview.cpp
@@ -1,130 +1,129 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25#include <qcursor.h> 25#include <qcursor.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kdebug.h> 28#include <kdebug.h>
29#include <kiconloader.h> 29#include <kiconloader.h>
30#include <kmessagebox.h> 30#include <kmessagebox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33#include "koprefs.h" 33#include "koprefs.h"
34#include "koeventview.h" 34#include "koeventview.h"
35using namespace KOrg; 35using namespace KOrg;
36 36
37//--------------------------------------------------------------------------- 37//---------------------------------------------------------------------------
38 38
39KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name) 39KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name)
40 : KOrg::BaseView(cal,parent,name) 40 : KOrg::BaseView(cal,parent,name)
41{ 41{
42} 42}
43 43
44//--------------------------------------------------------------------------- 44//---------------------------------------------------------------------------
45 45
46KOEventView::~KOEventView() 46KOEventView::~KOEventView()
47{ 47{
48} 48}
49 49
50//--------------------------------------------------------------------------- 50//---------------------------------------------------------------------------
51 51
52KOEventPopupMenu *KOEventView::eventPopup() 52KOEventPopupMenu *KOEventView::eventPopup()
53{ 53{
54 KOEventPopupMenu *eventPopup = new KOEventPopupMenu; 54 KOEventPopupMenu *eventPopup = new KOEventPopupMenu;
55 55
56 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)), 56 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)),
57 SIGNAL(editIncidenceSignal(Incidence *))); 57 SIGNAL(editIncidenceSignal(Incidence *)));
58 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)), 58 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)),
59 SIGNAL(showIncidenceSignal(Incidence *))); 59 SIGNAL(showIncidenceSignal(Incidence *)));
60 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)), 60 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)),
61 SIGNAL(deleteIncidenceSignal(Incidence *))); 61 SIGNAL(deleteIncidenceSignal(Incidence *)));
62 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)), 62 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)),
63 SIGNAL(cancelIncidenceSignal(Incidence *))); 63 SIGNAL(cancelIncidenceSignal(Incidence *)));
64 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)), 64 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)),
65 SIGNAL(cloneIncidenceSignal(Incidence *))); 65 SIGNAL(cloneIncidenceSignal(Incidence *)));
66 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)), 66 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)),
67 SIGNAL(beamIncidenceSignal(Incidence *))); 67 SIGNAL(beamIncidenceSignal(Incidence *)));
68 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)), 68 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)),
69 SIGNAL(moveIncidenceSignal(Incidence *))); 69 SIGNAL(moveIncidenceSignal(Incidence *)));
70 70
71 return eventPopup; 71 return eventPopup;
72} 72}
73 73
74//--------------------------------------------------------------------------- 74//---------------------------------------------------------------------------
75 75
76void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event) 76void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event)
77{ 77{
78 mCurrentIncidence = event; 78 mCurrentIncidence = event;
79 if (event) popup->popup(QCursor::pos()); 79 if (event) popup->popup(QCursor::pos());
80 else kdDebug() << "KOEventView::showEventPopup(): No event selected" << endl;
81} 80}
82 81
83//--------------------------------------------------------------------------- 82//---------------------------------------------------------------------------
84 83
85void KOEventView::popupShow() 84void KOEventView::popupShow()
86{ 85{
87 emit showIncidenceSignal(mCurrentIncidence); 86 emit showIncidenceSignal(mCurrentIncidence);
88} 87}
89 88
90//--------------------------------------------------------------------------- 89//---------------------------------------------------------------------------
91 90
92void KOEventView::popupEdit() 91void KOEventView::popupEdit()
93{ 92{
94 emit editIncidenceSignal(mCurrentIncidence); 93 emit editIncidenceSignal(mCurrentIncidence);
95} 94}
96 95
97//--------------------------------------------------------------------------- 96//---------------------------------------------------------------------------
98 97
99void KOEventView::popupDelete() 98void KOEventView::popupDelete()
100{ 99{
101 emit deleteIncidenceSignal(mCurrentIncidence); 100 emit deleteIncidenceSignal(mCurrentIncidence);
102} 101}
103void KOEventView::popupClone() 102void KOEventView::popupClone()
104{ 103{
105 emit cloneIncidenceSignal(mCurrentIncidence); 104 emit cloneIncidenceSignal(mCurrentIncidence);
106} 105}
107void KOEventView::popupCancel() 106void KOEventView::popupCancel()
108{ 107{
109 emit cancelIncidenceSignal(mCurrentIncidence); 108 emit cancelIncidenceSignal(mCurrentIncidence);
110} 109}
111 110
112//--------------------------------------------------------------------------- 111//---------------------------------------------------------------------------
113 112
114void KOEventView::defaultAction( Incidence *incidence ) 113void KOEventView::defaultAction( Incidence *incidence )
115{ 114{
116 115
117 if ( !incidence ) return; 116 if ( !incidence ) return;
118 117
119 if ( incidence->isReadOnly() ) 118 if ( incidence->isReadOnly() )
120 emit showIncidenceSignal(incidence); 119 emit showIncidenceSignal(incidence);
121 else { 120 else {
122 if ( KOPrefs::instance()->mEditOnDoubleClick ) 121 if ( KOPrefs::instance()->mEditOnDoubleClick )
123 emit editIncidenceSignal(incidence); 122 emit editIncidenceSignal(incidence);
124 else 123 else
125 emit showIncidenceSignal(incidence); 124 emit showIncidenceSignal(incidence);
126 } 125 }
127} 126}
128 127
129//--------------------------------------------------------------------------- 128//---------------------------------------------------------------------------
130 129
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 8f17e6e..43e1113 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -46,385 +46,385 @@
46#include <libkcal/calendar.h> 46#include <libkcal/calendar.h>
47#include <libkcal/calendarlocal.h> 47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 49#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 50#include <libkcal/recurrence.h>
51#include <libkcal/filestorage.h> 51#include <libkcal/filestorage.h>
52#include <libkdepim/categoryselectdialog.h> 52#include <libkdepim/categoryselectdialog.h>
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60#ifndef KORG_NOPRINTER 60#ifndef KORG_NOPRINTER
61#include "calprinter.h" 61#include "calprinter.h"
62#endif 62#endif
63#include "koglobals.h" 63#include "koglobals.h"
64#include "koprefs.h" 64#include "koprefs.h"
65#include "kfiledialog.h" 65#include "kfiledialog.h"
66 66
67#include "kolistview.h" 67#include "kolistview.h"
68#include "koeventviewer.h" 68#include "koeventviewer.h"
69 69
70extern QPixmap* sgListViewCompletedPix[6]; 70extern QPixmap* sgListViewCompletedPix[6];
71 71
72class KOListViewWhatsThis :public QWhatsThis 72class KOListViewWhatsThis :public QWhatsThis
73{ 73{
74public: 74public:
75 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 75 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
76 76
77protected: 77protected:
78 virtual QString text( const QPoint& p) 78 virtual QString text( const QPoint& p)
79 { 79 {
80 return _view->getWhatsThisText(p) ; 80 return _view->getWhatsThisText(p) ;
81 } 81 }
82private: 82private:
83 QWidget* _wid; 83 QWidget* _wid;
84 KOListView * _view; 84 KOListView * _view;
85}; 85};
86 86
87 87
88ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 88ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
89{ 89{
90 mItem = item; 90 mItem = item;
91 mDate = date; 91 mDate = date;
92} 92}
93 93
94ListItemVisitor::~ListItemVisitor() 94ListItemVisitor::~ListItemVisitor()
95{ 95{
96} 96}
97 97
98bool ListItemVisitor::visit(Event *e) 98bool ListItemVisitor::visit(Event *e)
99{ 99{
100 bool ok = false; 100 bool ok = false;
101 QString start, end; 101 QString start, end;
102 QDate ds, de; 102 QDate ds, de;
103 if ( e->doesRecur() ) { 103 if ( e->doesRecur() ) {
104 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 104 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
105 if ( ok ) { 105 if ( ok ) {
106 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 106 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
107 start = KGlobal::locale()->formatDate(ds,true); 107 start = KGlobal::locale()->formatDate(ds,true);
108 de = ds.addDays( days); 108 de = ds.addDays( days);
109 end = KGlobal::locale()->formatDate(de,true); 109 end = KGlobal::locale()->formatDate(de,true);
110 } 110 }
111 111
112 } 112 }
113 if ( ! ok ) { 113 if ( ! ok ) {
114 start =e->dtStartDateStr(); 114 start =e->dtStartDateStr();
115 end = e->dtEndDateStr(); 115 end = e->dtEndDateStr();
116 ds = e->dtStart().date(); 116 ds = e->dtStart().date();
117 de = e->dtEnd().date(); 117 de = e->dtEnd().date();
118 } 118 }
119 mItem->setText(0,e->summary()); 119 mItem->setText(0,e->summary());
120 mItem->setText(1,start); 120 mItem->setText(1,start);
121 if ( e->doesFloat() ) 121 if ( e->doesFloat() )
122 mItem->setText(2,"---"); 122 mItem->setText(2,"---");
123 else 123 else
124 mItem->setText(2,e->dtStartTimeStr()); 124 mItem->setText(2,e->dtStartTimeStr());
125 mItem->setText(3,end); 125 mItem->setText(3,end);
126 if ( e->doesFloat() ) 126 if ( e->doesFloat() )
127 mItem->setText(4,"---"); 127 mItem->setText(4,"---");
128 else 128 else
129 mItem->setText(4,e->dtEndTimeStr()); 129 mItem->setText(4,e->dtEndTimeStr());
130 if ( e->isAlarmEnabled() ) { 130 if ( e->isAlarmEnabled() ) {
131 mItem->setText(5,e->alarms().first()->offsetText() ); 131 mItem->setText(5,e->alarms().first()->offsetText() );
132 } else { 132 } else {
133 mItem->setText(5, i18n("No")); 133 mItem->setText(5, i18n("No"));
134 } 134 }
135 mItem->setText(6, e->recurrence()->recurrenceText()); 135 mItem->setText(6, e->recurrence()->recurrenceText());
136 if( ! e->doesRecur() ) 136 if( ! e->doesRecur() )
137 mItem->setSortKey( 6, "-" ); 137 mItem->setSortKey( 6, "-" );
138 mItem->setText(7,"---"); 138 mItem->setText(7,"---");
139 mItem->setText(8,"---"); 139 mItem->setText(8,"---");
140 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 140 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
141 mItem->setText(10,e->categoriesStr()); 141 mItem->setText(10,e->categoriesStr());
142 mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); 142 mItem->setText(11, KOPrefs::instance()->calName( e->calID() ));
143 143
144 QString key; 144 QString key;
145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
147 mItem->setSortKey(1,key); 147 mItem->setSortKey(1,key);
148 148
149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
151 mItem->setSortKey(3,key); 151 mItem->setSortKey(3,key);
152 return true; 152 return true;
153} 153}
154 154
155bool ListItemVisitor::visit(Todo *t) 155bool ListItemVisitor::visit(Todo *t)
156{ 156{
157 mItem->setText(0,t->summary()); 157 mItem->setText(0,t->summary());
158 if ( t->isCompleted() ) { 158 if ( t->isCompleted() ) {
159 mItem->setSortKey(0,"99"+ t->summary().left(10)); 159 mItem->setSortKey(0,"99"+ t->summary().left(10));
160 } else 160 } else
161 mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); 161 mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10));
162 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); 162 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20]));
163 if (t->hasStartDate()) { 163 if (t->hasStartDate()) {
164 mItem->setText(1,t->dtStartDateStr()); 164 mItem->setText(1,t->dtStartDateStr());
165 if (t->doesFloat()) { 165 if (t->doesFloat()) {
166 mItem->setText(2,"---"); 166 mItem->setText(2,"---");
167 } else { 167 } else {
168 mItem->setText(2,t->dtStartTimeStr()); 168 mItem->setText(2,t->dtStartTimeStr());
169 } 169 }
170 } else { 170 } else {
171 mItem->setText(1,"---"); 171 mItem->setText(1,"---");
172 mItem->setText(2,"---"); 172 mItem->setText(2,"---");
173 } 173 }
174 mItem->setText(3,"---"); 174 mItem->setText(3,"---");
175 mItem->setText(4,"---"); 175 mItem->setText(4,"---");
176 if ( t->isAlarmEnabled() ) { 176 if ( t->isAlarmEnabled() ) {
177 mItem->setText(5,t->alarms().first()->offsetText() ); 177 mItem->setText(5,t->alarms().first()->offsetText() );
178 } else { 178 } else {
179 mItem->setText(5, i18n("No")); 179 mItem->setText(5, i18n("No"));
180 } 180 }
181 mItem->setText(6, t->recurrence()->recurrenceText()); 181 mItem->setText(6, t->recurrence()->recurrenceText());
182 if( ! t->doesRecur() ) 182 if( ! t->doesRecur() )
183 mItem->setSortKey( 6, "-" ); 183 mItem->setSortKey( 6, "-" );
184 if (t->hasDueDate()) { 184 if (t->hasDueDate()) {
185 mItem->setText(7,t->dtDueDateStr()); 185 mItem->setText(7,t->dtDueDateStr());
186 if (t->doesFloat()) { 186 if (t->doesFloat()) {
187 mItem->setText(8,"---"); 187 mItem->setText(8,"---");
188 } else { 188 } else {
189 mItem->setText(8,t->dtDueTimeStr()); 189 mItem->setText(8,t->dtDueTimeStr());
190 } 190 }
191 } else { 191 } else {
192 mItem->setText(7,"---"); 192 mItem->setText(7,"---");
193 mItem->setText(8,"---"); 193 mItem->setText(8,"---");
194 } 194 }
195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
196 mItem->setText(10,t->categoriesStr()); 196 mItem->setText(10,t->categoriesStr());
197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); 197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
198 198
199 QString key; 199 QString key;
200 QDate d; 200 QDate d;
201 if (t->hasDueDate()) { 201 if (t->hasDueDate()) {
202 d = t->dtDue().date(); 202 d = t->dtDue().date();
203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
205 mItem->setSortKey(7,key); 205 mItem->setSortKey(7,key);
206 } 206 }
207 if ( t->hasStartDate() ) { 207 if ( t->hasStartDate() ) {
208 d = t->dtStart().date(); 208 d = t->dtStart().date();
209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
211 mItem->setSortKey(1,key); 211 mItem->setSortKey(1,key);
212 } 212 }
213 return true; 213 return true;
214} 214}
215 215
216bool ListItemVisitor::visit(Journal * j) 216bool ListItemVisitor::visit(Journal * j)
217{ 217{
218 218
219 QString des; 219 QString des;
220 if ( !j->summary().isEmpty() ) { 220 if ( !j->summary().isEmpty() ) {
221 des = j->summary(); 221 des = j->summary();
222 } else { 222 } else {
223 des = j->description().left(30); 223 des = j->description().left(30);
224 des = des.simplifyWhiteSpace (); 224 des = des.simplifyWhiteSpace ();
225 des.replace (QRegExp ("\\n"),"" ); 225 des.replace (QRegExp ("\\n"),"" );
226 des.replace (QRegExp ("\\r"),"" ); 226 des.replace (QRegExp ("\\r"),"" );
227 } 227 }
228 mItem->setText(0,i18n("Journal: ")+des.left(25)); 228 mItem->setText(0,i18n("Journal: ")+des.left(25));
229 mItem->setText(1,j->dtStartDateStr()); 229 mItem->setText(1,j->dtStartDateStr());
230 mItem->setText(2,"---"); 230 mItem->setText(2,"---");
231 mItem->setText(3,"---"); 231 mItem->setText(3,"---");
232 mItem->setText(4,"---"); 232 mItem->setText(4,"---");
233 mItem->setText(5,"---"); 233 mItem->setText(5,"---");
234 mItem->setText(6,"---"); 234 mItem->setText(6,"---");
235 mItem->setText(7,j->dtStartDateStr()); 235 mItem->setText(7,j->dtStartDateStr());
236 mItem->setText(8,"---"); 236 mItem->setText(8,"---");
237 mItem->setText(9,"---"); 237 mItem->setText(9,"---");
238 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 238 mItem->setText(10,j->categoriesStr());
239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); 239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
240 240
241 QString key; 241 QString key;
242 QDate d = j->dtStart().date(); 242 QDate d = j->dtStart().date();
243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
244 mItem->setSortKey(1,key); 244 mItem->setSortKey(1,key);
245 mItem->setSortKey(7,key); 245 mItem->setSortKey(7,key);
246 246
247 return true; 247 return true;
248} 248}
249 249
250KOListView::KOListView(Calendar *calendar, QWidget *parent, 250KOListView::KOListView(Calendar *calendar, QWidget *parent,
251 const char *name) 251 const char *name)
252 : KOEventView(calendar, parent, name) 252 : KOEventView(calendar, parent, name)
253{ 253{
254 254
255 mActiveItem = 0; 255 mActiveItem = 0;
256 mForceShowCompletedTodos = false; 256 mForceShowCompletedTodos = false;
257 mListView = new KOListViewListView(this); 257 mListView = new KOListViewListView(this);
258 mListView->addColumn(i18n("Summary")); 258 mListView->addColumn(i18n("Summary"));
259 mListView->addColumn(i18n("Start Date")); 259 mListView->addColumn(i18n("Start Date"));
260 mListView->addColumn(i18n("Start Time")); 260 mListView->addColumn(i18n("Start Time"));
261 mListView->addColumn(i18n("End Date")); 261 mListView->addColumn(i18n("End Date"));
262 mListView->addColumn(i18n("End Time")); 262 mListView->addColumn(i18n("End Time"));
263 mListView->addColumn(i18n("Alarm")); // alarm set? 263 mListView->addColumn(i18n("Alarm")); // alarm set?
264 mListView->addColumn(i18n("Recurs")); // recurs? 264 mListView->addColumn(i18n("Recurs")); // recurs?
265 mListView->addColumn(i18n("Due Date")); 265 mListView->addColumn(i18n("Due Date"));
266 mListView->addColumn(i18n("Due Time")); 266 mListView->addColumn(i18n("Due Time"));
267 mListView->addColumn(i18n("Cancelled")); 267 mListView->addColumn(i18n("Cancelled"));
268 mListView->addColumn(i18n("Categories")); 268 mListView->addColumn(i18n("Categories"));
269 mListView->addColumn(i18n("Calendar")); 269 mListView->addColumn(i18n("Calendar"));
270 270
271 mListView->setColumnAlignment(0,AlignLeft); 271 mListView->setColumnAlignment(0,AlignLeft);
272 mListView->setColumnAlignment(1,AlignLeft); 272 mListView->setColumnAlignment(1,AlignLeft);
273 mListView->setColumnAlignment(2,AlignHCenter); 273 mListView->setColumnAlignment(2,AlignHCenter);
274 mListView->setColumnAlignment(3,AlignLeft); 274 mListView->setColumnAlignment(3,AlignLeft);
275 mListView->setColumnAlignment(4,AlignHCenter); 275 mListView->setColumnAlignment(4,AlignHCenter);
276 mListView->setColumnAlignment(5,AlignLeft); 276 mListView->setColumnAlignment(5,AlignLeft);
277 mListView->setColumnAlignment(6,AlignLeft); 277 mListView->setColumnAlignment(6,AlignLeft);
278 mListView->setColumnAlignment(7,AlignLeft); 278 mListView->setColumnAlignment(7,AlignLeft);
279 mListView->setColumnAlignment(8,AlignLeft); 279 mListView->setColumnAlignment(8,AlignLeft);
280 mListView->setColumnAlignment(9,AlignLeft); 280 mListView->setColumnAlignment(9,AlignLeft);
281 mListView->setColumnAlignment(10,AlignLeft); 281 mListView->setColumnAlignment(10,AlignLeft);
282 mListView->setColumnAlignment(11,AlignLeft); 282 mListView->setColumnAlignment(11,AlignLeft);
283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
284 284
285 int iii = 0; 285 int iii = 0;
286 for ( iii = 0; iii< 12 ; ++iii ) 286 for ( iii = 0; iii< 12 ; ++iii )
287 mListView->setColumnWidthMode( iii, QListView::Manual ); 287 mListView->setColumnWidthMode( iii, QListView::Manual );
288 288
289 QBoxLayout *layoutTop = new QVBoxLayout(this); 289 QBoxLayout *layoutTop = new QVBoxLayout(this);
290 layoutTop->addWidget(mListView); 290 layoutTop->addWidget(mListView);
291 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 291 mListView->setFont ( KOPrefs::instance()->mListViewFont );
292 mPopupMenu = eventPopup(); 292 mPopupMenu = eventPopup();
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Select all"),this, 294 i18n("Select all"),this,
295 SLOT(allSelection()),true); 295 SLOT(allSelection()),true);
296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
297 i18n("Deselect all"),this, 297 i18n("Deselect all"),this,
298 SLOT(clearSelection()),true); 298 SLOT(clearSelection()),true);
299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
300 i18n("Delete all selected"),this, 300 i18n("Delete all selected"),this,
301 SLOT(deleteAll()),true); 301 SLOT(deleteAll()),true);
302 302
303 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 303 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
304 i18n("Hide all selected"),this, 304 i18n("Hide all selected"),this,
305 SLOT(hideAll()),true); 305 SLOT(hideAll()),true);
306 306
307 mPopupMenu->insertSeparator(); 307 mPopupMenu->insertSeparator();
308#ifdef DESKTOP_VERSION 308#ifdef DESKTOP_VERSION
309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
310 i18n("Print complete list"),this, 310 i18n("Print complete list"),this,
311 SLOT(printList()),true); 311 SLOT(printList()),true);
312 mPopupMenu->insertSeparator(); 312 mPopupMenu->insertSeparator();
313#endif 313#endif
314 mCalPopup = new QPopupMenu ( this ); 314 mCalPopup = new QPopupMenu ( this );
315 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup ); 315 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup );
316 316
317 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, 317 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
318 SLOT( populateCalPopup() )); 318 SLOT( populateCalPopup() ));
319 QObject::connect(mCalPopup,SIGNAL(activated( int )),this, 319 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
320 SLOT( setCalendar( int ) )); 320 SLOT( setCalendar( int ) ));
321 QPopupMenu * exportPO = new QPopupMenu ( this ); 321 QPopupMenu * exportPO = new QPopupMenu ( this );
322 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 322 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
323 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 323 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
324 SLOT(saveToFile())); 324 SLOT(saveToFile()));
325 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 325 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
326 SLOT(saveToFileVCS())); 326 SLOT(saveToFileVCS()));
327 exportPO->insertItem( i18n("Journal/Details..."),this, 327 exportPO->insertItem( i18n("Journal/Details..."),this,
328 SLOT(saveDescriptionToFile())); 328 SLOT(saveDescriptionToFile()));
329 // mPopupMenu->insertSeparator(); 329 // mPopupMenu->insertSeparator();
330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
331 i18n("Add Categ. to selected..."),this, 331 i18n("Add Categ. to selected..."),this,
332 SLOT(addCat()),true); 332 SLOT(addCat()),true);
333 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 333 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
334 i18n("Set Categ. for selected..."),this, 334 i18n("Set Categ. for selected..."),this,
335 SLOT(setCat()),true); 335 SLOT(setCat()),true);
336 //mPopupMenu->insertSeparator(); 336 //mPopupMenu->insertSeparator();
337 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 337 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
338 i18n("Set alarm for selected..."),this, 338 i18n("Set alarm for selected..."),this,
339 SLOT(setAlarm()),true); 339 SLOT(setAlarm()),true);
340 340
341 341
342 342
343#ifndef DESKTOP_VERSION 343#ifndef DESKTOP_VERSION
344 mPopupMenu->insertSeparator(); 344 mPopupMenu->insertSeparator();
345 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 345 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
346 i18n("Beam selected via IR"),this, 346 i18n("Beam selected via IR"),this,
347 SLOT(beamSelected()),true); 347 SLOT(beamSelected()),true);
348#endif 348#endif
349 /* 349 /*
350 mPopupMenu = new QPopupMenu; 350 mPopupMenu = new QPopupMenu;
351 mPopupMenu->insertItem(i18n("Edit Event"), this, 351 mPopupMenu->insertItem(i18n("Edit Event"), this,
352 SLOT (editEvent())); 352 SLOT (editEvent()));
353 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 353 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
354 SLOT (deleteEvent())); 354 SLOT (deleteEvent()));
355 mPopupMenu->insertSeparator(); 355 mPopupMenu->insertSeparator();
356 mPopupMenu->insertItem(i18n("Show Dates"), this, 356 mPopupMenu->insertItem(i18n("Show Dates"), this,
357 SLOT(showDates())); 357 SLOT(showDates()));
358 mPopupMenu->insertItem(i18n("Hide Dates"), this, 358 mPopupMenu->insertItem(i18n("Hide Dates"), this,
359 SLOT(hideDates())); 359 SLOT(hideDates()));
360 */ 360 */
361 QObject::connect(mListView,SIGNAL( newEvent()), 361 QObject::connect(mListView,SIGNAL( newEvent()),
362 this,SIGNAL(signalNewEvent())); 362 this,SIGNAL(signalNewEvent()));
363 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 363 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
364 this,SLOT(defaultItemAction(QListViewItem *))); 364 this,SLOT(defaultItemAction(QListViewItem *)));
365 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 365 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
366 const QPoint &, int )), 366 const QPoint &, int )),
367 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 367 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
368 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 368 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
369 SLOT(processSelectionChange(QListViewItem *))); 369 SLOT(processSelectionChange(QListViewItem *)));
370 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 370 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
371 SIGNAL(showIncidenceSignal(Incidence *)) ); 371 SIGNAL(showIncidenceSignal(Incidence *)) );
372 372
373 readSettings(KOGlobals::config(),"KOListView Layout"); 373 readSettings(KOGlobals::config(),"KOListView Layout");
374} 374}
375 375
376KOListView::~KOListView() 376KOListView::~KOListView()
377{ 377{
378 delete mPopupMenu; 378 delete mPopupMenu;
379#if QT_VERSION >= 0x030000 379#if QT_VERSION >= 0x030000
380 380
381#else 381#else
382 delete mKOListViewWhatsThis; 382 delete mKOListViewWhatsThis;
383#endif 383#endif
384} 384}
385 385
386QString KOListView::getWhatsThisText(QPoint p) 386QString KOListView::getWhatsThisText(QPoint p)
387{ 387{
388 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 388 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
389 if ( item ) 389 if ( item )
390 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 390 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
391 KOPrefs::instance()->mWTshowDetails, 391 KOPrefs::instance()->mWTshowDetails,
392 KOPrefs::instance()->mWTshowCreated, 392 KOPrefs::instance()->mWTshowCreated,
393 KOPrefs::instance()->mWTshowChanged); 393 KOPrefs::instance()->mWTshowChanged);
394 return i18n("That is the list view" ); 394 return i18n("That is the list view" );
395 395
396} 396}
397 397
398void KOListView::setCalendar( int c ) 398void KOListView::setCalendar( int c )
399{ 399{
400 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 400 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
401 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), 401 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
402 i18n("Continue"), i18n("Cancel"), 0, 402 i18n("Continue"), i18n("Cancel"), 0,
403 0, 1 ); 403 0, 1 );
404 if ( result != 0 ) { 404 if ( result != 0 ) {
405 return; 405 return;
406 } 406 }
407 407
408 QPtrList<Incidence> delSel = getSelectedIncidences() ; 408 QPtrList<Incidence> delSel = getSelectedIncidences() ;
409 int icount = delSel.count(); 409 int icount = delSel.count();
410 if ( icount ) { 410 if ( icount ) {
411 Incidence *incidence = delSel.first(); 411 Incidence *incidence = delSel.first();
412 while ( incidence ) { 412 while ( incidence ) {
413 incidence->setCalID( c ); 413 incidence->setCalID( c );
414 KOListViewItem * item = getItemForEvent( incidence ); 414 KOListViewItem * item = getItemForEvent( incidence );
415 if ( item ) { 415 if ( item ) {
416 ListItemVisitor v(item, mStartDate ); 416 ListItemVisitor v(item, mStartDate );
417 incidence->accept(v); 417 incidence->accept(v);
418 } 418 }
419 incidence = delSel.next(); 419 incidence = delSel.next();
420 } 420 }
421 } 421 }
422 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 422 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
423 KopiCalendarFile * cal = calendars.first(); 423 KopiCalendarFile * cal = calendars.first();
424 while ( cal ) { 424 while ( cal ) {
425 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 425 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
426 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 426 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
427 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 427 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
428 if ( cal->isStandard ) 428 if ( cal->isStandard )
429 mCalendar->setDefaultCalendar( cal->mCalNumber ); 429 mCalendar->setDefaultCalendar( cal->mCalNumber );
430 cal = calendars.next(); 430 cal = calendars.next();
@@ -822,394 +822,390 @@ void KOListView::writeToFile( bool iCal )
822 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 822 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
823 Incidence *incidence = delSel.first(); 823 Incidence *incidence = delSel.first();
824 while ( incidence ) { 824 while ( incidence ) {
825 cal.addIncidence( incidence->clone() ); 825 cal.addIncidence( incidence->clone() );
826 incidence = delSel.next(); 826 incidence = delSel.next();
827 } 827 }
828 if ( iCal ) { 828 if ( iCal ) {
829 ICalFormat format; 829 ICalFormat format;
830 format.save( &cal, fn ); 830 format.save( &cal, fn );
831 } else { 831 } else {
832 832
833 VCalFormat format; 833 VCalFormat format;
834 format.save( &cal, fn ); 834 format.save( &cal, fn );
835 } 835 }
836 mes = i18n("KO/Pi:Saved %1").arg(fn ); 836 mes = i18n("KO/Pi:Saved %1").arg(fn );
837 KOPrefs::instance()->mLastSaveFile = fn; 837 KOPrefs::instance()->mLastSaveFile = fn;
838 topLevelWidget()->setCaption(mes); 838 topLevelWidget()->setCaption(mes);
839 } 839 }
840 } 840 }
841 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 841 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
842} 842}
843void KOListView::hideAll() 843void KOListView::hideAll()
844{ 844{
845 QPtrList<QListViewItem> delSel ; 845 QPtrList<QListViewItem> delSel ;
846 QListViewItem *item = mListView->firstChild (); 846 QListViewItem *item = mListView->firstChild ();
847 while ( item ) { 847 while ( item ) {
848 if ( item->isSelected() ) { 848 if ( item->isSelected() ) {
849 delSel.append(item); 849 delSel.append(item);
850 } 850 }
851 item = item->nextSibling(); 851 item = item->nextSibling();
852 } 852 }
853 item = delSel.first() ; 853 item = delSel.first() ;
854 while ( item ) { 854 while ( item ) {
855 QListViewItem * del = item; 855 QListViewItem * del = item;
856 item = delSel.next(); 856 item = delSel.next();
857 delete del; 857 delete del;
858 } 858 }
859} 859}
860void KOListView::printList() 860void KOListView::printList()
861{ 861{
862 mListView->printList(); 862 mListView->printList();
863} 863}
864void KOListView::deleteAll() 864void KOListView::deleteAll()
865{ 865{
866 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; 866 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
867 if ( delSel.count() ) { 867 if ( delSel.count() ) {
868 int icount = delSel.count(); 868 int icount = delSel.count();
869 Incidence *incidence = delSel.first(); 869 Incidence *incidence = delSel.first();
870 Incidence *toDelete; 870 Incidence *toDelete;
871 KOPrefs *p = KOPrefs::instance(); 871 KOPrefs *p = KOPrefs::instance();
872 bool confirm = p->mConfirm; 872 bool confirm = p->mConfirm;
873 QString mess; 873 QString mess;
874 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 874 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
875 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 875 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
876 p->mConfirm = false; 876 p->mConfirm = false;
877 int delCounter = 0; 877 int delCounter = 0;
878 QDialog dia ( this, "p-dialog", true ); 878 QDialog dia ( this, "p-dialog", true );
879 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 879 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
880 QVBoxLayout lay( &dia ); 880 QVBoxLayout lay( &dia );
881 lay.setMargin(7); 881 lay.setMargin(7);
882 lay.setSpacing(7); 882 lay.setSpacing(7);
883 lay.addWidget( &lab); 883 lay.addWidget( &lab);
884 QProgressBar bar( icount, &dia ); 884 QProgressBar bar( icount, &dia );
885 lay.addWidget( &bar); 885 lay.addWidget( &bar);
886 int w = 220; 886 int w = 220;
887 int h = 50; 887 int h = 50;
888 int dw = QApplication::desktop()->width(); 888 int dw = QApplication::desktop()->width();
889 int dh = QApplication::desktop()->height(); 889 int dh = QApplication::desktop()->height();
890 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 890 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
891 //dia.resize( 240,50 ); 891 //dia.resize( 240,50 );
892 dia.show(); 892 dia.show();
893 893
894 while ( incidence ) { 894 while ( incidence ) {
895 bar.setProgress( delCounter ); 895 bar.setProgress( delCounter );
896 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 896 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
897 dia.setCaption( mess ); 897 dia.setCaption( mess );
898 qApp->processEvents(); 898 qApp->processEvents();
899 toDelete = (incidence); 899 toDelete = (incidence);
900 incidence = delSel.next(); 900 incidence = delSel.next();
901 emit deleteIncidenceSignal(toDelete ); 901 emit deleteIncidenceSignal(toDelete );
902 if ( dia.result() != 0 ) 902 if ( dia.result() != 0 )
903 break; 903 break;
904 904
905 } 905 }
906 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 906 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
907 topLevelWidget ()->setCaption( mess ); 907 topLevelWidget ()->setCaption( mess );
908 p->mConfirm = confirm; 908 p->mConfirm = confirm;
909 } 909 }
910 } 910 }
911 911
912 912
913} 913}
914int KOListView::maxDatesHint() 914int KOListView::maxDatesHint()
915{ 915{
916 return 0; 916 return 0;
917} 917}
918 918
919int KOListView::currentDateCount() 919int KOListView::currentDateCount()
920{ 920{
921 return 0; 921 return 0;
922} 922}
923 923
924QPtrList<Incidence> KOListView::selectedIncidences() 924QPtrList<Incidence> KOListView::selectedIncidences()
925{ 925{
926 QPtrList<Incidence> eventList; 926 QPtrList<Incidence> eventList;
927 QListViewItem *item = mListView->firstChild (); 927 QListViewItem *item = mListView->firstChild ();
928 while ( item ) { 928 while ( item ) {
929 if ( item->isSelected() ) { 929 if ( item->isSelected() ) {
930 eventList.append(((KOListViewItem *)item)->data()); 930 eventList.append(((KOListViewItem *)item)->data());
931 } 931 }
932 932
933 item = item->nextSibling(); 933 item = item->nextSibling();
934 } 934 }
935 935
936 // // QListViewItem *item = mListView->selectedItem(); 936 // // QListViewItem *item = mListView->selectedItem();
937 //if (item) eventList.append(((KOListViewItem *)item)->data()); 937 //if (item) eventList.append(((KOListViewItem *)item)->data());
938 938
939 return eventList; 939 return eventList;
940} 940}
941 941
942DateList KOListView::selectedDates() 942DateList KOListView::selectedDates()
943{ 943{
944 DateList eventList; 944 DateList eventList;
945 return eventList; 945 return eventList;
946} 946}
947 947
948void KOListView::showDates(bool show) 948void KOListView::showDates(bool show)
949{ 949{
950 // Shouldn't we set it to a value greater 0? When showDates is called with 950 // Shouldn't we set it to a value greater 0? When showDates is called with
951 // show == true at first, then the columnwidths are set to zero. 951 // show == true at first, then the columnwidths are set to zero.
952 static int oldColWidth1 = 0; 952 static int oldColWidth1 = 0;
953 static int oldColWidth3 = 0; 953 static int oldColWidth3 = 0;
954 954
955 if (!show) { 955 if (!show) {
956 oldColWidth1 = mListView->columnWidth(1); 956 oldColWidth1 = mListView->columnWidth(1);
957 oldColWidth3 = mListView->columnWidth(3); 957 oldColWidth3 = mListView->columnWidth(3);
958 mListView->setColumnWidth(1, 0); 958 mListView->setColumnWidth(1, 0);
959 mListView->setColumnWidth(3, 0); 959 mListView->setColumnWidth(3, 0);
960 } else { 960 } else {
961 mListView->setColumnWidth(1, oldColWidth1); 961 mListView->setColumnWidth(1, oldColWidth1);
962 mListView->setColumnWidth(3, oldColWidth3); 962 mListView->setColumnWidth(3, oldColWidth3);
963 } 963 }
964 mListView->repaint(); 964 mListView->repaint();
965} 965}
966 966
967void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 967void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
968 const QDate &td) 968 const QDate &td)
969{ 969{
970#ifndef KORG_NOPRINTER 970#ifndef KORG_NOPRINTER
971 calPrinter->preview(CalPrinter::Day, fd, td); 971 calPrinter->preview(CalPrinter::Day, fd, td);
972#endif 972#endif
973} 973}
974 974
975void KOListView::showDates() 975void KOListView::showDates()
976{ 976{
977 showDates(true); 977 showDates(true);
978} 978}
979 979
980void KOListView::hideDates() 980void KOListView::hideDates()
981{ 981{
982 showDates(false); 982 showDates(false);
983} 983}
984 984
985void KOListView::resetFocus() 985void KOListView::resetFocus()
986{ 986{
987 topLevelWidget()->setActiveWindow(); 987 topLevelWidget()->setActiveWindow();
988 topLevelWidget()->raise(); 988 topLevelWidget()->raise();
989 mListView->setFocus(); 989 mListView->setFocus();
990} 990}
991void KOListView::updateView() 991void KOListView::updateView()
992{ 992{
993 mListView->setFocus(); 993 mListView->setFocus();
994 if ( mListView->firstChild () ) 994 if ( mListView->firstChild () )
995 mListView->setCurrentItem( mListView->firstChild () ); 995 mListView->setCurrentItem( mListView->firstChild () );
996} 996}
997void KOListView::updateConfig() 997void KOListView::updateConfig()
998{ 998{
999 999
1000 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1000 mListView->setFont ( KOPrefs::instance()->mListViewFont );
1001 updateView(); 1001 updateView();
1002 1002
1003} 1003}
1004void KOListView::setStartDate(const QDate &start) 1004void KOListView::setStartDate(const QDate &start)
1005{ 1005{
1006 mStartDate = start; 1006 mStartDate = start;
1007} 1007}
1008 1008
1009void KOListView::showDates(const QDate &start, const QDate &end) 1009void KOListView::showDates(const QDate &start, const QDate &end)
1010{ 1010{
1011 clear(); 1011 clear();
1012 mStartDate = start; 1012 mStartDate = start;
1013 QDate date = start; 1013 QDate date = start;
1014 QPtrList<Journal> j_list;
1015 while( date <= end ) { 1014 while( date <= end ) {
1016 addEvents(calendar()->events(date)); 1015 addEvents(calendar()->events(date));
1017 addTodos(calendar()->todos(date)); 1016 addTodos(calendar()->todos(date));
1018 Journal* jo = calendar()->journal(date); 1017 addJournals( calendar()->journals4Date(date) );
1019 if ( jo )
1020 j_list.append( jo );
1021 date = date.addDays( 1 ); 1018 date = date.addDays( 1 );
1022 } 1019 }
1023 addJournals(j_list);
1024 emit incidenceSelected( 0 ); 1020 emit incidenceSelected( 0 );
1025 updateView(); 1021 updateView();
1026 1022
1027} 1023}
1028 1024
1029void KOListView::addEvents(QPtrList<Event> eventList) 1025void KOListView::addEvents(QPtrList<Event> eventList)
1030{ 1026{
1031 1027
1032 Event *ev; 1028 Event *ev;
1033 for(ev = eventList.first(); ev; ev = eventList.next()) { 1029 for(ev = eventList.first(); ev; ev = eventList.next()) {
1034 addIncidence(ev); 1030 addIncidence(ev);
1035 } 1031 }
1036 if ( !mListView->currentItem() ){ 1032 if ( !mListView->currentItem() ){
1037 updateView(); 1033 updateView();
1038 } 1034 }
1039} 1035}
1040 1036
1041void KOListView::addTodos(QPtrList<Todo> eventList) 1037void KOListView::addTodos(QPtrList<Todo> eventList)
1042{ 1038{
1043 Todo *ev; 1039 Todo *ev;
1044 for(ev = eventList.first(); ev; ev = eventList.next()) { 1040 for(ev = eventList.first(); ev; ev = eventList.next()) {
1045 addIncidence(ev); 1041 addIncidence(ev);
1046 } 1042 }
1047 if ( !mListView->currentItem() ){ 1043 if ( !mListView->currentItem() ){
1048 updateView(); 1044 updateView();
1049 } 1045 }
1050} 1046}
1051void KOListView::addJournals(QPtrList<Journal> eventList) 1047void KOListView::addJournals(QPtrList<Journal> eventList)
1052{ 1048{
1053 Journal *ev; 1049 Journal *ev;
1054 for(ev = eventList.first(); ev; ev = eventList.next()) { 1050 for(ev = eventList.first(); ev; ev = eventList.next()) {
1055 addIncidence(ev); 1051 addIncidence(ev);
1056 } 1052 }
1057 if ( !mListView->currentItem() ){ 1053 if ( !mListView->currentItem() ){
1058 updateView(); 1054 updateView();
1059 } 1055 }
1060} 1056}
1061 1057
1062void KOListView::showCompletedTodos() 1058void KOListView::showCompletedTodos()
1063{ 1059{
1064 mForceShowCompletedTodos = true; 1060 mForceShowCompletedTodos = true;
1065} 1061}
1066void KOListView::addIncidence(Incidence *incidence) 1062void KOListView::addIncidence(Incidence *incidence)
1067{ 1063{
1068 if ( mUidDict.find( incidence->uid() ) ) return; 1064 if ( mUidDict.find( incidence->uid() ) ) return;
1069 1065
1070 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1066 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
1071 if ( incidence->typeID() == todoID ) { 1067 if ( incidence->typeID() == todoID ) {
1072 if ( ! mForceShowCompletedTodos ) { 1068 if ( ! mForceShowCompletedTodos ) {
1073 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) 1069 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() )
1074 return; 1070 return;
1075 } 1071 }
1076 } 1072 }
1077 mUidDict.insert( incidence->uid(), incidence ); 1073 mUidDict.insert( incidence->uid(), incidence );
1078 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1074 KOListViewItem *item = new KOListViewItem( incidence, mListView );
1079 ListItemVisitor v(item, mStartDate ); 1075 ListItemVisitor v(item, mStartDate );
1080 if (incidence->accept(v)) { 1076 if (incidence->accept(v)) {
1081 return; 1077 return;
1082 } 1078 }
1083 else delete item; 1079 else delete item;
1084} 1080}
1085 1081
1086void KOListView::showEvents(QPtrList<Event> eventList) 1082void KOListView::showEvents(QPtrList<Event> eventList)
1087{ 1083{
1088 clear(); 1084 clear();
1089 1085
1090 addEvents(eventList); 1086 addEvents(eventList);
1091 1087
1092 // After new creation of list view no events are selected. 1088 // After new creation of list view no events are selected.
1093 emit incidenceSelected( 0 ); 1089 emit incidenceSelected( 0 );
1094} 1090}
1095int KOListView::count() 1091int KOListView::count()
1096{ 1092{
1097 return mListView->childCount(); 1093 return mListView->childCount();
1098} 1094}
1099 1095
1100void KOListView::changeEventDisplay(Event *event, int action) 1096void KOListView::changeEventDisplay(Event *event, int action)
1101{ 1097{
1102 KOListViewItem *item; 1098 KOListViewItem *item;
1103 1099
1104 switch(action) { 1100 switch(action) {
1105 case KOGlobals::EVENTADDED: 1101 case KOGlobals::EVENTADDED:
1106 addIncidence( event ); 1102 addIncidence( event );
1107 break; 1103 break;
1108 case KOGlobals::EVENTEDITED: 1104 case KOGlobals::EVENTEDITED:
1109 item = getItemForEvent(event); 1105 item = getItemForEvent(event);
1110 if (item) { 1106 if (item) {
1111 mUidDict.remove( event->uid() ); 1107 mUidDict.remove( event->uid() );
1112 delete item; 1108 delete item;
1113 addIncidence( event ); 1109 addIncidence( event );
1114 } 1110 }
1115 break; 1111 break;
1116 case KOGlobals::EVENTDELETED: 1112 case KOGlobals::EVENTDELETED:
1117 item = getItemForEvent(event); 1113 item = getItemForEvent(event);
1118 if (item) { 1114 if (item) {
1119 mUidDict.remove( event->uid() ); 1115 mUidDict.remove( event->uid() );
1120 delete item; 1116 delete item;
1121 } 1117 }
1122 break; 1118 break;
1123 default: 1119 default:
1124 ; 1120 ;
1125 } 1121 }
1126} 1122}
1127 1123
1128KOListViewItem *KOListView::getItemForEvent(Incidence *event) 1124KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1129{ 1125{
1130 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1126 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1131 while (item) { 1127 while (item) {
1132 if (item->data() == event) return item; 1128 if (item->data() == event) return item;
1133 item = (KOListViewItem *)item->nextSibling(); 1129 item = (KOListViewItem *)item->nextSibling();
1134 } 1130 }
1135 return 0; 1131 return 0;
1136} 1132}
1137 1133
1138void KOListView::defaultItemAction(QListViewItem *i) 1134void KOListView::defaultItemAction(QListViewItem *i)
1139{ 1135{
1140 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1136 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1141 if ( item ) defaultAction( item->data() ); 1137 if ( item ) defaultAction( item->data() );
1142 1138
1143} 1139}
1144 1140
1145void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1141void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1146{ 1142{
1147 mActiveItem = (KOListViewItem *)item; 1143 mActiveItem = (KOListViewItem *)item;
1148 if (mActiveItem) { 1144 if (mActiveItem) {
1149 Incidence *incidence = mActiveItem->data(); 1145 Incidence *incidence = mActiveItem->data();
1150 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1146 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1151 mPopupMenu->showIncidencePopup(incidence); 1147 mPopupMenu->showIncidencePopup(incidence);
1152 1148
1153 /* 1149 /*
1154 if ( incidence && incidence->type() == "Event" ) { 1150 if ( incidence && incidence->type() == "Event" ) {
1155 Event *event = static_cast<Event *>( incidence ); 1151 Event *event = static_cast<Event *>( incidence );
1156 mPopupMenu->showEventPopup(event); 1152 mPopupMenu->showEventPopup(event);
1157 } 1153 }
1158 */ 1154 */
1159 } 1155 }
1160} 1156}
1161 1157
1162void KOListView::readSettings(KConfig *config, QString setting) 1158void KOListView::readSettings(KConfig *config, QString setting)
1163{ 1159{
1164 // qDebug("KOListView::readSettings "); 1160 // qDebug("KOListView::readSettings ");
1165 mListView->restoreLayout(config,setting); 1161 mListView->restoreLayout(config,setting);
1166} 1162}
1167 1163
1168void KOListView::writeSettings(KConfig *config, QString setting) 1164void KOListView::writeSettings(KConfig *config, QString setting)
1169{ 1165{
1170 // qDebug("KOListView::writeSettings "); 1166 // qDebug("KOListView::writeSettings ");
1171 mListView->saveLayout(config, setting); 1167 mListView->saveLayout(config, setting);
1172} 1168}
1173 1169
1174void KOListView::processSelectionChange(QListViewItem *) 1170void KOListView::processSelectionChange(QListViewItem *)
1175{ 1171{
1176 1172
1177 KOListViewItem *item = 1173 KOListViewItem *item =
1178 static_cast<KOListViewItem *>( mListView->currentItem() ); 1174 static_cast<KOListViewItem *>( mListView->currentItem() );
1179 1175
1180 if ( !item ) { 1176 if ( !item ) {
1181 emit incidenceSelected( 0 ); 1177 emit incidenceSelected( 0 );
1182 } else { 1178 } else {
1183 emit incidenceSelected( item->data() ); 1179 emit incidenceSelected( item->data() );
1184 } 1180 }
1185} 1181}
1186 1182
1187void KOListView::clearSelection() 1183void KOListView::clearSelection()
1188{ 1184{
1189 mListView->selectAll( false ); 1185 mListView->selectAll( false );
1190} 1186}
1191void KOListView::allSelection() 1187void KOListView::allSelection()
1192{ 1188{
1193 mListView->selectAll( true ); 1189 mListView->selectAll( true );
1194} 1190}
1195 1191
1196void KOListView::clear() 1192void KOListView::clear()
1197{ 1193{
1198 mListView->clear(); 1194 mListView->clear();
1199 mUidDict.clear(); 1195 mUidDict.clear();
1200} 1196}
1201 1197
1202Incidence* KOListView::currentItem() 1198Incidence* KOListView::currentItem()
1203{ 1199{
1204 if ( mListView->currentItem() ) 1200 if ( mListView->currentItem() )
1205 return ((KOListViewItem*) mListView->currentItem())->data(); 1201 return ((KOListViewItem*) mListView->currentItem())->data();
1206 return 0; 1202 return 0;
1207} 1203}
1208void KOListView::keyPressEvent ( QKeyEvent *e) 1204void KOListView::keyPressEvent ( QKeyEvent *e)
1209{ 1205{
1210 1206
1211 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1207 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1212 deleteAll(); 1208 deleteAll();
1213 return; 1209 return;
1214 } 1210 }
1215 1211