summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp179
-rw-r--r--korganizer/koagenda.h1
2 files changed, 86 insertions, 94 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ec81d44..e8b7c94 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -206,677 +206,670 @@ KOAgenda::~KOAgenda()
206{ 206{
207 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
208 208
209} 209}
210 210
211Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
212{ 212{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 214}
215 215
216 216
217QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
218{ 218{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 220}
221 221
222 222
223void KOAgenda::init() 223void KOAgenda::init()
224{ 224{
225 mNewItemPopup = new QPopupMenu( this ); 225 mNewItemPopup = new QPopupMenu( this );
226 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 226 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
227 QString pathString = ""; 227 QString pathString = "";
228 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 228 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
229 if ( QApplication::desktop()->width() < 480 ) 229 if ( QApplication::desktop()->width() < 480 )
230 pathString += "icons16/"; 230 pathString += "icons16/";
231 } else 231 } else
232 pathString += "iconsmini/"; 232 pathString += "iconsmini/";
233 233
234 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 234 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
235 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 235 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
236 mNewItemPopup->insertSeparator ( ); 236 mNewItemPopup->insertSeparator ( );
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
243#ifndef _WIN32_ 243#ifndef _WIN32_
244 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 244 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
245 viewport()->setWFlags ( wflags); 245 viewport()->setWFlags ( wflags);
246#endif 246#endif
247 mGridSpacingX = 80; 247 mGridSpacingX = 80;
248 mResizeBorderWidth = 8; 248 mResizeBorderWidth = 8;
249 mScrollBorderWidth = 8; 249 mScrollBorderWidth = 8;
250 mScrollDelay = 30; 250 mScrollDelay = 30;
251 mScrollOffset = 10; 251 mScrollOffset = 10;
252 mPaintPixmap.resize( 20,20); 252 mPaintPixmap.resize( 20,20);
253 //enableClipper(true); 253 //enableClipper(true);
254 254
255 // Grab key strokes for keyboard navigation of agenda. Seems to have no 255 // Grab key strokes for keyboard navigation of agenda. Seems to have no
256 // effect. Has to be fixed. 256 // effect. Has to be fixed.
257 setFocusPolicy(WheelFocus); 257 setFocusPolicy(WheelFocus);
258 258
259 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 259 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
260 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 260 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
261 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 261 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
262 262
263 mStartCellX = 0; 263 mStartCellX = 0;
264 mStartCellY = 0; 264 mStartCellY = 0;
265 mCurrentCellX = 0; 265 mCurrentCellX = 0;
266 mCurrentCellY = 0; 266 mCurrentCellY = 0;
267 267
268 mSelectionCellX = 0; 268 mSelectionCellX = 0;
269 mSelectionYTop = 0; 269 mSelectionYTop = 0;
270 mSelectionHeight = 0; 270 mSelectionHeight = 0;
271 271
272 mOldLowerScrollValue = -1; 272 mOldLowerScrollValue = -1;
273 mOldUpperScrollValue = -1; 273 mOldUpperScrollValue = -1;
274 274
275 mClickedItem = 0; 275 mClickedItem = 0;
276 276
277 mActionItem = 0; 277 mActionItem = 0;
278 mActionType = NOP; 278 mActionType = NOP;
279 mItemMoved = false; 279 mItemMoved = false;
280 280
281 mSelectedItem = 0; 281 mSelectedItem = 0;
282 282
283 // mItems.setAutoDelete(true); 283 // mItems.setAutoDelete(true);
284 284
285 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 285 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
286 286
287 viewport()->update(); 287 viewport()->update();
288 288
289 setMinimumSize(30, 1); 289 setMinimumSize(30, 1);
290// setMaximumHeight(mGridSpacingY * mRows + 5); 290// setMaximumHeight(mGridSpacingY * mRows + 5);
291 291
292 // Disable horizontal scrollbar. This is a hack. The geometry should be 292 // Disable horizontal scrollbar. This is a hack. The geometry should be
293 // controlled in a way that the contents horizontally always fits. Then it is 293 // controlled in a way that the contents horizontally always fits. Then it is
294 // not necessary to turn off the scrollbar. 294 // not necessary to turn off the scrollbar.
295 setHScrollBarMode(AlwaysOff); 295 setHScrollBarMode(AlwaysOff);
296 if ( ! mAllDayMode ) 296 if ( ! mAllDayMode )
297 setVScrollBarMode(AlwaysOn); 297 setVScrollBarMode(AlwaysOn);
298 else 298 else
299 setVScrollBarMode(AlwaysOff); 299 setVScrollBarMode(AlwaysOff);
300 300
301 setStartHour(KOPrefs::instance()->mDayBegins); 301 setStartHour(KOPrefs::instance()->mDayBegins);
302 302
303 calculateWorkingHours(); 303 calculateWorkingHours();
304 304
305 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 305 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
306 SLOT(checkScrollBoundaries(int))); 306 SLOT(checkScrollBoundaries(int)));
307 307
308 // Create the Marcus Bains line. 308 // Create the Marcus Bains line.
309 if(mAllDayMode) 309 if(mAllDayMode)
310 mMarcusBains = 0; 310 mMarcusBains = 0;
311 else { 311 else {
312 mMarcusBains = new MarcusBains(this); 312 mMarcusBains = new MarcusBains(this);
313 addChild(mMarcusBains); 313 addChild(mMarcusBains);
314 } 314 }
315} 315}
316 316
317void KOAgenda::clear() 317void KOAgenda::clear()
318{ 318{
319 KOAgendaItem *item; 319 KOAgendaItem *item;
320 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 320 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
321 mUnusedItems.append( item ); 321 mUnusedItems.append( item );
322 //item->hide(); 322 //item->hide();
323 } 323 }
324 mItems.clear(); 324 mItems.clear();
325 mSelectedItem = 0; 325 mSelectedItem = 0;
326 clearSelection(); 326 clearSelection();
327} 327}
328 328
329void KOAgenda::clearSelection() 329void KOAgenda::clearSelection()
330{ 330{
331 mSelectionCellX = 0; 331 mSelectionCellX = 0;
332 mSelectionYTop = 0; 332 mSelectionYTop = 0;
333 mSelectionHeight = 0; 333 mSelectionHeight = 0;
334} 334}
335 335
336void KOAgenda::marcus_bains() 336void KOAgenda::marcus_bains()
337{ 337{
338 if(mMarcusBains) mMarcusBains->updateLocation(true); 338 if(mMarcusBains) mMarcusBains->updateLocation(true);
339} 339}
340 340
341 341
342void KOAgenda::changeColumns(int columns) 342void KOAgenda::changeColumns(int columns)
343{ 343{
344 if (columns == 0) { 344 if (columns == 0) {
345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; 345 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
346 return; 346 return;
347 } 347 }
348 348
349 clear(); 349 clear();
350 350
351 mColumns = columns; 351 mColumns = columns;
352// setMinimumSize(mColumns * 10, mGridSpacingY + 1); 352// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
353// init(); 353// init();
354// update(); 354// update();
355 //qDebug("KOAgenda::changeColumns "); 355 //qDebug("KOAgenda::changeColumns ");
356 computeSizes(); 356 computeSizes();
357 // QResizeEvent event( size(), size() ); 357 // QResizeEvent event( size(), size() );
358 358
359 //QApplication::sendEvent( this, &event ); 359 //QApplication::sendEvent( this, &event );
360} 360}
361 361
362/* 362/*
363 This is the eventFilter function, which gets all events from the KOAgendaItems 363 This is the eventFilter function, which gets all events from the KOAgendaItems
364 contained in the agenda. It has to handle moving and resizing for all items. 364 contained in the agenda. It has to handle moving and resizing for all items.
365*/ 365*/
366bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 366bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
367{ 367{
368// kdDebug() << "KOAgenda::eventFilter" << endl; 368// kdDebug() << "KOAgenda::eventFilter" << endl;
369 switch(event->type()) { 369 switch(event->type()) {
370 case QEvent::MouseButtonPress: 370 case QEvent::MouseButtonPress:
371 case QEvent::MouseButtonDblClick: 371 case QEvent::MouseButtonDblClick:
372 case QEvent::MouseButtonRelease: 372 case QEvent::MouseButtonRelease:
373 case QEvent::MouseMove: 373 case QEvent::MouseMove:
374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 374 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
375 375
376 case (QEvent::Leave): 376 case (QEvent::Leave):
377 if (!mActionItem) 377 if (!mActionItem)
378 setCursor(arrowCursor); 378 setCursor(arrowCursor);
379 return true; 379 return true;
380 380
381 default: 381 default:
382 return QScrollView::eventFilter(object,event); 382 return QScrollView::eventFilter(object,event);
383 } 383 }
384} 384}
385 385
386 386
387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 387bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
388{ 388{
389 //qDebug("KOAgenda::eventFilter_mous "); 389 //qDebug("KOAgenda::eventFilter_mous ");
390 QPoint viewportPos; 390 QPoint viewportPos;
391 if (object != viewport()) { 391 if (object != viewport()) {
392 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 392 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
393 } else { 393 } else {
394 viewportPos = me->pos(); 394 viewportPos = me->pos();
395 } 395 }
396 static int startX = 0; 396 static int startX = 0;
397 static int startY = 0; 397 static int startY = 0;
398 static bool block = true; 398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
399 static bool blockMoving = true;
400 static bool leftMouseDown = false;
401 static bool rightMouseDown = false;
399 switch (me->type()) { 402 switch (me->type()) {
400 case QEvent::MouseButtonPress: 403 case QEvent::MouseButtonPress:
401 //qDebug("QEvent::MouseButtonPress: "); 404 if (me->button() == LeftButton)
402 // kdDebug() << "koagenda: filtered button press" << endl; 405 leftMouseDown = true;
406 else if (me->button() == RightButton)
407 rightMouseDown = true;
408 blockMoving = true;
409 startX = viewportPos.x();
410 startY = viewportPos.y();
403 if (object != viewport()) { 411 if (object != viewport()) {
404 if (me->button() == RightButton) { 412 if (me->button() == RightButton) {
405 mClickedItem = (KOAgendaItem *)object; 413 mClickedItem = (KOAgendaItem *)object;
406 if (mClickedItem) { 414 if (mClickedItem) {
407 selectItem(mClickedItem); 415 selectItem(mClickedItem);
408 // emit showIncidencePopupSignal(mClickedItem->incidence());
409 } 416 }
410 //mItemPopup->popup(QCursor::pos()); 417 } else if (me->button() == LeftButton) {
411 } else {
412 mActionItem = (KOAgendaItem *)object; 418 mActionItem = (KOAgendaItem *)object;
413 if (mActionItem) { 419 if (mActionItem) {
414 if ( mSelectionHeight > 0 ) { 420 if ( mSelectionHeight > 0 ) {
415 int selectionCellX = mSelectionCellX * mGridSpacingX; 421 int selectionCellX = mSelectionCellX * mGridSpacingX;
416 int selectionYTop = mSelectionYTop; 422 int selectionYTop = mSelectionYTop;
417 int gridSpacingX = mGridSpacingX; 423 int gridSpacingX = mGridSpacingX;
418 int selectionHeight = mSelectionHeight; 424 int selectionHeight = mSelectionHeight;
419 clearSelection(); 425 clearSelection();
420 repaintContents( selectionCellX, selectionYTop, 426 repaintContents( selectionCellX, selectionYTop,
421 gridSpacingX, selectionHeight,false ); 427 gridSpacingX, selectionHeight,false );
422 } 428 }
423 selectItem(mActionItem); 429 selectItem(mActionItem);
424 Incidence *incidence = mActionItem->incidence(); 430 Incidence *incidence = mActionItem->incidence();
425 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 431 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
426 mActionItem = 0; 432 mActionItem = 0;
427 } else { 433 } else {
428 startItemAction(viewportPos); 434 startItemAction(viewportPos);
429 startX = viewportPos.x();
430 startY = viewportPos.y();
431 block = true;
432 } 435 }
433 } 436 }
434 } 437 }
435 } else { 438 } else { // ---------- viewport()
436 selectItem(0); 439 selectItem(0);
437 mActionItem = 0; 440 mActionItem = 0;
438 if (me->button() == RightButton ) { 441 if (me->button() == LeftButton ) {
439 blockNewEvent = true;
440 block = false;
441 } else {
442 blockNewEvent = false;
443 setCursor(arrowCursor); 442 setCursor(arrowCursor);
444 startSelectAction(viewportPos); 443 startSelectAction(viewportPos);
445 } 444 }
446 } 445 }
447 break; 446 break;
448 447
449 case QEvent::MouseButtonRelease: 448 case QEvent::MouseButtonRelease:
450 //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); 449 if (object != viewport()) {
451 if (me->button() == RightButton && blockNewEvent && !block) { 450 if (me->button() == RightButton) {
452 int x,y; 451 if ( blockMoving ) {
453 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 452 mClickedItem = (KOAgendaItem *)object;
454 int gx,gy; 453 if (mActionItem ) {
455 contentsToGrid(x,y,gx,gy); 454 endItemAction();
456 if ( object == viewport() ) { 455 }
457 if ( mCurrentCellY < mStartCellY +1 ) { 456 leftMouseDown = false; // no more leftMouse computation
458 //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); 457 if (mClickedItem) {
458 selectItem(mClickedItem);
459 emit showIncidencePopupSignal(mClickedItem->incidence());
460 }
461 }
462 } else if (me->button() == LeftButton && leftMouseDown) {
463 if (mActionItem) {
464 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
465 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
466 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
467 mScrollUpTimer.stop();
468 mScrollDownTimer.stop();
469 mActionItem->resetMove();
470 placeSubCells( mActionItem );
471 // emit startDragSignal( mActionItem->incidence() );
472 setCursor( arrowCursor );
473 mActionItem = 0;
474 mActionType = NOP;
475 mItemMoved = 0;
476 return true;
477 }
478 endItemAction();
479 }
480 }
481
482 } else { // ---------- viewport()
483 if (me->button() == RightButton) { //right click
484 if ( blockMoving ) { // we did mot moved the mouse much - popup menu
485 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
486 endSelectAction( false ); // do not emit new event signal
487 leftMouseDown = false; // no more leftMouse computation
488 }
489 int x,y;
490 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
491 int gx,gy;
492 contentsToGrid(x,y,gx,gy);
459 mCurrentCellX = gx; 493 mCurrentCellX = gx;
460 mCurrentCellY = gy; 494 mCurrentCellY = gy;
461 mStartCellX = gx; 495 mStartCellX = gx;
462 mStartCellY = gy; 496 mStartCellY = gy;
463 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 497 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
464 break;
465 } else {
466 blockNewEvent = false;
467 } 498 }
468 } else {
469 mClickedItem = (KOAgendaItem *)object;
470 if (mActionItem ) {
471 endItemAction();
472 }
473 if (mClickedItem) {
474 selectItem(mClickedItem);
475 emit showIncidencePopupSignal(mClickedItem->incidence());
476 }
477 }
478 } else if (me->button() == RightButton && block ) {
479 if (object != viewport()) {
480 mClickedItem = (KOAgendaItem *)object;
481 if (mActionItem ) {
482 endItemAction();
483 }
484 if (mClickedItem) {
485 selectItem(mClickedItem);
486 emit showIncidencePopupSignal(mClickedItem->incidence());
487 }
488 }
489 break;
490 }
491 block = true;
492 if (mActionItem) {
493 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
494 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
495 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
496 mScrollUpTimer.stop();
497 mScrollDownTimer.stop();
498 mActionItem->resetMove();
499 placeSubCells( mActionItem );
500 // emit startDragSignal( mActionItem->incidence() );
501 setCursor( arrowCursor );
502 mActionItem = 0;
503 mActionType = NOP;
504 mItemMoved = 0;
505 return true;
506 } 499 }
507 endItemAction(); 500 else if (me->button() == LeftButton && leftMouseDown ) { //left click
508 } else if ( mActionType == SELECT ) { 501 endSelectAction( true ); // emit new event signal
509 if (me->button() == RightButton ) {
510 } else {
511 endSelectAction( !blockNewEvent );
512 } 502 }
513 } 503 }
504 if (me->button() == LeftButton)
505 leftMouseDown = false;
506 else if (me->button() == RightButton)
507 rightMouseDown = false;
514 break; 508 break;
515 509
516 case QEvent::MouseMove: 510 case QEvent::MouseMove:
511 if ( !rightMouseDown && !leftMouseDown )
512 return true;
513 if ( blockMoving ) {
514 int dX, dY;
515 dX = startX - viewportPos.x();
516 if ( dX < 0 )
517 dX = -dX;
518 dY = viewportPos.y() - startY;
519 if ( dY < 0 )
520 dY = -dY;
521 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
522 if ( dX > blockmoveDist || dY > blockmoveDist ) {
523 blockMoving = false;
524 }
525 }
517 if (object != viewport()) { 526 if (object != viewport()) {
518 KOAgendaItem *moveItem = (KOAgendaItem *)object; 527 KOAgendaItem *moveItem = (KOAgendaItem *)object;
519 //qDebug("moveItem %d ",moveItem ); 528 if (!moveItem->incidence()->isReadOnly() ) {
520 if (!moveItem->incidence()->isReadOnly() /*&&
521 !moveItem->incidence()->recurrence()->doesRecur()*/ )
522 if (!mActionItem) 529 if (!mActionItem)
523 setNoActionCursor(moveItem,viewportPos); 530 setNoActionCursor(moveItem,viewportPos);
524 else { 531 else {
525 if ( block ) { 532 if ( !blockMoving )
526 int dX, dY;
527 dX = startX - viewportPos.x();
528 if ( dX < 0 )
529 dX = -dX;
530 dY = viewportPos.y() - startY;
531 if ( dY < 0 )
532 dY = -dY;
533 int diff = 30;
534 if ( QApplication::desktop()->width() < 480 )
535 diff = 15;
536 // qDebug(" %d %d ",dX, dY );
537 if ( dX > diff || dY > diff ) {
538 block = false;
539 }
540 }
541 if ( !block )
542 performItemAction(viewportPos); 533 performItemAction(viewportPos);
543 } 534 }
544 } else { 535 }
536 } else { // ---------- viewport()
545 if ( mActionType == SELECT ) { 537 if ( mActionType == SELECT ) {
546 performSelectAction( viewportPos ); 538 performSelectAction( viewportPos );
547 } 539 }
548 } 540 }
549 break; 541 break;
550 542
551 case QEvent::MouseButtonDblClick: 543 case QEvent::MouseButtonDblClick:
552 if (object == viewport()) { 544 if (object == viewport()) {
553 selectItem(0); 545 selectItem(0);
554 int x,y; 546 int x,y;
555 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 547 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
556 int gx,gy; 548 int gx,gy;
557 contentsToGrid(x,y,gx,gy); 549 contentsToGrid(x,y,gx,gy);
558 emit newEventSignal(gx,gy); 550 emit newEventSignal(gx,gy);
559 } else { 551 } else {
560 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 552 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
561 selectItem(doubleClickedItem); 553 selectItem(doubleClickedItem);
562 if ( KOPrefs::instance()->mEditOnDoubleClick ) 554 if ( KOPrefs::instance()->mEditOnDoubleClick )
563 emit editIncidenceSignal(doubleClickedItem->incidence()); 555 emit editIncidenceSignal(doubleClickedItem->incidence());
564 else 556 else
565 emit showIncidenceSignal(doubleClickedItem->incidence()); 557 emit showIncidenceSignal(doubleClickedItem->incidence());
566 } 558 }
567 break; 559 break;
568 560
569 default: 561 default:
570 break; 562 break;
571 } 563 }
572
573 return true; 564 return true;
574} 565}
575 566
576void KOAgenda::newItem( int item ) 567void KOAgenda::newItem( int item )
577{ 568{
578 if ( item == 1 ) { //new event 569 if ( item == 1 ) { //new event
579 newEventSignal(mStartCellX ,mStartCellY ); 570 newEventSignal(mStartCellX ,mStartCellY );
580 } else 571 } else
581 if ( item == 2 ) { //new event 572 if ( item == 2 ) { //new event
582 newTodoSignal(mStartCellX ,mStartCellY ); 573 newTodoSignal(mStartCellX ,mStartCellY );
583 } else 574 } else
584 { 575 {
585 QDate day = mSelectedDates[mStartCellX]; 576 QDate day = mSelectedDates[mStartCellX];
586 emit showDateView( item, day ); 577 emit showDateView( item, day );
587 // 3Day view 578 // 3Day view
588 // 4Week view 579 // 4Week view
589 // 5Month view 580 // 5Month view
590 // 6Journal view 581 // 6Journal view
591 } 582 }
592} 583}
593void KOAgenda::startSelectAction(QPoint viewportPos) 584void KOAgenda::startSelectAction(QPoint viewportPos)
594{ 585{
595 //emit newStartSelectSignal(); 586 //emit newStartSelectSignal();
596 587
597 mActionType = SELECT; 588 mActionType = SELECT;
598 589
599 int x,y; 590 int x,y;
600 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 591 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
601 int gx,gy; 592 int gx,gy;
602 contentsToGrid(x,y,gx,gy); 593 contentsToGrid(x,y,gx,gy);
603 594
604 mStartCellX = gx; 595 mStartCellX = gx;
605 mStartCellY = gy; 596 mStartCellY = gy;
606 mCurrentCellX = gx; 597 mCurrentCellX = gx;
607 mCurrentCellY = gy; 598 mCurrentCellY = gy;
608 599
609 // Store coordinates of old selection 600 // Store coordinates of old selection
610 int selectionX = mSelectionCellX * mGridSpacingX; 601 int selectionX = mSelectionCellX * mGridSpacingX;
611 int selectionYTop = mSelectionYTop; 602 int selectionYTop = mSelectionYTop;
612 int selectionHeight = mSelectionHeight; 603 int selectionHeight = mSelectionHeight;
613 604
614 // Store new selection 605 // Store new selection
615 mSelectionCellX = gx; 606 mSelectionCellX = gx;
616 mSelectionYTop = gy * mGridSpacingY; 607 mSelectionYTop = gy * mGridSpacingY;
617 mSelectionHeight = mGridSpacingY; 608 mSelectionHeight = mGridSpacingY;
618 609
619 // Clear old selection 610 // Clear old selection
620 repaintContents( selectionX, selectionYTop, 611 repaintContents( selectionX, selectionYTop,
621 mGridSpacingX, selectionHeight,false ); 612 mGridSpacingX, selectionHeight,false );
622 613
623 // Paint new selection 614 // Paint new selection
624 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 615 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
625 // mGridSpacingX, mSelectionHeight ); 616 // mGridSpacingX, mSelectionHeight );
626} 617}
627 618
628void KOAgenda::performSelectAction(QPoint viewportPos) 619void KOAgenda::performSelectAction(QPoint viewportPos)
629{ 620{
630 int x,y; 621 int x,y;
631 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 622 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
632 int gx,gy; 623 int gx,gy;
633 contentsToGrid(x,y,gx,gy); 624 contentsToGrid(x,y,gx,gy);
634 625
635 QPoint clipperPos = clipper()-> 626 QPoint clipperPos = clipper()->
636 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 627 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
637 628
638 // Scroll if cursor was moved to upper or lower end of agenda. 629 // Scroll if cursor was moved to upper or lower end of agenda.
639 if (clipperPos.y() < mScrollBorderWidth) { 630 if (clipperPos.y() < mScrollBorderWidth) {
640 mScrollUpTimer.start(mScrollDelay); 631 mScrollUpTimer.start(mScrollDelay);
641 } else if (visibleHeight() - clipperPos.y() < 632 } else if (visibleHeight() - clipperPos.y() <
642 mScrollBorderWidth) { 633 mScrollBorderWidth) {
643 mScrollDownTimer.start(mScrollDelay); 634 mScrollDownTimer.start(mScrollDelay);
644 } else { 635 } else {
645 mScrollUpTimer.stop(); 636 mScrollUpTimer.stop();
646 mScrollDownTimer.stop(); 637 mScrollDownTimer.stop();
647 } 638 }
648 639
649 if ( gy > mCurrentCellY ) { 640 if ( gy > mCurrentCellY ) {
650 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 641 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
651 642
652#if 0 643#if 0
653 // FIXME: Repaint only the newly selected region 644 // FIXME: Repaint only the newly selected region
654 repaintContents( mSelectionCellX * mGridSpacingX, 645 repaintContents( mSelectionCellX * mGridSpacingX,
655 mCurrentCellY + mGridSpacingY, 646 mCurrentCellY + mGridSpacingY,
656 mGridSpacingX, 647 mGridSpacingX,
657 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 648 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
658#else 649#else
659 repaintContents( (KOGlobals::self()->reverseLayout() ? 650 repaintContents( (KOGlobals::self()->reverseLayout() ?
660 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 651 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
661 mGridSpacingX, mSelectionYTop, 652 mGridSpacingX, mSelectionYTop,
662 mGridSpacingX, mSelectionHeight , false); 653 mGridSpacingX, mSelectionHeight , false);
663#endif 654#endif
664 655
665 mCurrentCellY = gy; 656 mCurrentCellY = gy;
666 } else if ( gy < mCurrentCellY ) { 657 } else if ( gy < mCurrentCellY ) {
667 if ( gy >= mStartCellY ) { 658 if ( gy >= mStartCellY ) {
668 int selectionHeight = mSelectionHeight; 659 int selectionHeight = mSelectionHeight;
669 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 660 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
670 661
671 repaintContents( (KOGlobals::self()->reverseLayout() ? 662 repaintContents( (KOGlobals::self()->reverseLayout() ?
672 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 663 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
673 mGridSpacingX, mSelectionYTop, 664 mGridSpacingX, mSelectionYTop,
674 mGridSpacingX, selectionHeight,false ); 665 mGridSpacingX, selectionHeight,false );
675 666
676 mCurrentCellY = gy; 667 mCurrentCellY = gy;
677 } else { 668 } else {
678 } 669 }
679 } 670 }
680} 671}
681 672
682void KOAgenda::endSelectAction( bool emitNewEvent ) 673void KOAgenda::endSelectAction( bool emitNewEvent )
683{ 674{
684 mActionType = NOP; 675 mActionType = NOP;
685 mScrollUpTimer.stop(); 676 mScrollUpTimer.stop();
686 mScrollDownTimer.stop(); 677 mScrollDownTimer.stop();
687 678
688 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 679 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
689 if ( emitNewEvent && mStartCellY < mCurrentCellY ) 680 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
681 qDebug("ew event signal ");
690 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 682 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
683 }
691} 684}
692 685
693void KOAgenda::startItemAction(QPoint viewportPos) 686void KOAgenda::startItemAction(QPoint viewportPos)
694{ 687{
695 int x,y; 688 int x,y;
696 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 689 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
697 int gx,gy; 690 int gx,gy;
698 contentsToGrid(x,y,gx,gy); 691 contentsToGrid(x,y,gx,gy);
699 692
700 mStartCellX = gx; 693 mStartCellX = gx;
701 mStartCellY = gy; 694 mStartCellY = gy;
702 mCurrentCellX = gx; 695 mCurrentCellX = gx;
703 mCurrentCellY = gy; 696 mCurrentCellY = gy;
704 697
705 if (mAllDayMode) { 698 if (mAllDayMode) {
706 int gridDistanceX = (x - gx * mGridSpacingX); 699 int gridDistanceX = (x - gx * mGridSpacingX);
707 if (gridDistanceX < mResizeBorderWidth && 700 if (gridDistanceX < mResizeBorderWidth &&
708 mActionItem->cellX() == mCurrentCellX) { 701 mActionItem->cellX() == mCurrentCellX) {
709 mActionType = RESIZELEFT; 702 mActionType = RESIZELEFT;
710 setCursor(sizeHorCursor); 703 setCursor(sizeHorCursor);
711 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 704 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
712 mActionItem->cellXWidth() == mCurrentCellX) { 705 mActionItem->cellXWidth() == mCurrentCellX) {
713 mActionType = RESIZERIGHT; 706 mActionType = RESIZERIGHT;
714 setCursor(sizeHorCursor); 707 setCursor(sizeHorCursor);
715 } else { 708 } else {
716 mActionType = MOVE; 709 mActionType = MOVE;
717 mActionItem->startMove(); 710 mActionItem->startMove();
718 setCursor(sizeAllCursor); 711 setCursor(sizeAllCursor);
719 } 712 }
720 } else { 713 } else {
721 int gridDistanceY = (y - gy * mGridSpacingY); 714 int gridDistanceY = (y - gy * mGridSpacingY);
722 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 715 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
723 if (allowResize && gridDistanceY < mResizeBorderWidth && 716 if (allowResize && gridDistanceY < mResizeBorderWidth &&
724 mActionItem->cellYTop() == mCurrentCellY && 717 mActionItem->cellYTop() == mCurrentCellY &&
725 !mActionItem->firstMultiItem()) { 718 !mActionItem->firstMultiItem()) {
726 mActionType = RESIZETOP; 719 mActionType = RESIZETOP;
727 setCursor(sizeVerCursor); 720 setCursor(sizeVerCursor);
728 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 721 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
729 mActionItem->cellYBottom() == mCurrentCellY && 722 mActionItem->cellYBottom() == mCurrentCellY &&
730 !mActionItem->lastMultiItem()) { 723 !mActionItem->lastMultiItem()) {
731 mActionType = RESIZEBOTTOM; 724 mActionType = RESIZEBOTTOM;
732 setCursor(sizeVerCursor); 725 setCursor(sizeVerCursor);
733 } else { 726 } else {
734 mActionType = MOVE; 727 mActionType = MOVE;
735 mActionItem->startMove(); 728 mActionItem->startMove();
736 setCursor(sizeAllCursor); 729 setCursor(sizeAllCursor);
737 } 730 }
738 } 731 }
739} 732}
740 733
741void KOAgenda::performItemAction(QPoint viewportPos) 734void KOAgenda::performItemAction(QPoint viewportPos)
742{ 735{
743// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 736// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
744// QPoint point = viewport()->mapToGlobal(viewportPos); 737// QPoint point = viewport()->mapToGlobal(viewportPos);
745// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 738// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
746// point = clipper()->mapFromGlobal(point); 739// point = clipper()->mapFromGlobal(point);
747// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 740// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
748// kdDebug() << "visible height: " << visibleHeight() << endl; 741// kdDebug() << "visible height: " << visibleHeight() << endl;
749 int x,y; 742 int x,y;
750 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 743 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
751// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 744// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
752 int gx,gy; 745 int gx,gy;
753 contentsToGrid(x,y,gx,gy); 746 contentsToGrid(x,y,gx,gy);
754 QPoint clipperPos = clipper()-> 747 QPoint clipperPos = clipper()->
755 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 748 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
756 749
757 // Cursor left active agenda area. 750 // Cursor left active agenda area.
758 // This starts a drag. 751 // This starts a drag.
759 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 752 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
760 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 753 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
761 if ( mActionType == MOVE ) { 754 if ( mActionType == MOVE ) {
762 mScrollUpTimer.stop(); 755 mScrollUpTimer.stop();
763 mScrollDownTimer.stop(); 756 mScrollDownTimer.stop();
764 mActionItem->resetMove(); 757 mActionItem->resetMove();
765 placeSubCells( mActionItem ); 758 placeSubCells( mActionItem );
766 // emit startDragSignal( mActionItem->incidence() ); 759 // emit startDragSignal( mActionItem->incidence() );
767 setCursor( arrowCursor ); 760 setCursor( arrowCursor );
768 mActionItem = 0; 761 mActionItem = 0;
769 mActionType = NOP; 762 mActionType = NOP;
770 mItemMoved = 0; 763 mItemMoved = 0;
771 return; 764 return;
772 } 765 }
773 } else { 766 } else {
774 switch ( mActionType ) { 767 switch ( mActionType ) {
775 case MOVE: 768 case MOVE:
776 setCursor( sizeAllCursor ); 769 setCursor( sizeAllCursor );
777 break; 770 break;
778 case RESIZETOP: 771 case RESIZETOP:
779 case RESIZEBOTTOM: 772 case RESIZEBOTTOM:
780 setCursor( sizeVerCursor ); 773 setCursor( sizeVerCursor );
781 break; 774 break;
782 case RESIZELEFT: 775 case RESIZELEFT:
783 case RESIZERIGHT: 776 case RESIZERIGHT:
784 setCursor( sizeHorCursor ); 777 setCursor( sizeHorCursor );
785 break; 778 break;
786 default: 779 default:
787 setCursor( arrowCursor ); 780 setCursor( arrowCursor );
788 } 781 }
789 } 782 }
790 783
791 // Scroll if item was moved to upper or lower end of agenda. 784 // Scroll if item was moved to upper or lower end of agenda.
792 if (clipperPos.y() < mScrollBorderWidth) { 785 if (clipperPos.y() < mScrollBorderWidth) {
793 mScrollUpTimer.start(mScrollDelay); 786 mScrollUpTimer.start(mScrollDelay);
794 } else if (visibleHeight() - clipperPos.y() < 787 } else if (visibleHeight() - clipperPos.y() <
795 mScrollBorderWidth) { 788 mScrollBorderWidth) {
796 mScrollDownTimer.start(mScrollDelay); 789 mScrollDownTimer.start(mScrollDelay);
797 } else { 790 } else {
798 mScrollUpTimer.stop(); 791 mScrollUpTimer.stop();
799 mScrollDownTimer.stop(); 792 mScrollDownTimer.stop();
800 } 793 }
801 794
802 // Move or resize item if necessary 795 // Move or resize item if necessary
803 if (mCurrentCellX != gx || mCurrentCellY != gy) { 796 if (mCurrentCellX != gx || mCurrentCellY != gy) {
804 mItemMoved = true; 797 mItemMoved = true;
805 mActionItem->raise(); 798 mActionItem->raise();
806 if (mActionType == MOVE) { 799 if (mActionType == MOVE) {
807 // Move all items belonging to a multi item 800 // Move all items belonging to a multi item
808 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 801 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
809 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 802 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
810 if (!moveItem) moveItem = mActionItem; 803 if (!moveItem) moveItem = mActionItem;
811 while (moveItem) { 804 while (moveItem) {
812 int dy; 805 int dy;
813 if (isMultiItem) dy = 0; 806 if (isMultiItem) dy = 0;
814 else dy = gy - mCurrentCellY; 807 else dy = gy - mCurrentCellY;
815 moveItem->moveRelative(gx - mCurrentCellX,dy); 808 moveItem->moveRelative(gx - mCurrentCellX,dy);
816 int x,y; 809 int x,y;
817 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 810 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
818 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 811 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
819 mGridSpacingY * moveItem->cellHeight()); 812 mGridSpacingY * moveItem->cellHeight());
820 moveChild(moveItem,x,y); 813 moveChild(moveItem,x,y);
821 moveItem = moveItem->nextMultiItem(); 814 moveItem = moveItem->nextMultiItem();
822 } 815 }
823 } else if (mActionType == RESIZETOP) { 816 } else if (mActionType == RESIZETOP) {
824 if (mCurrentCellY <= mActionItem->cellYBottom()) { 817 if (mCurrentCellY <= mActionItem->cellYBottom()) {
825 mActionItem->expandTop(gy - mCurrentCellY); 818 mActionItem->expandTop(gy - mCurrentCellY);
826 mActionItem->resize(mActionItem->width(), 819 mActionItem->resize(mActionItem->width(),
827 mGridSpacingY * mActionItem->cellHeight()); 820 mGridSpacingY * mActionItem->cellHeight());
828 int x,y; 821 int x,y;
829 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 822 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
830 //moveChild(mActionItem,childX(mActionItem),y); 823 //moveChild(mActionItem,childX(mActionItem),y);
831 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 824 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
832 } 825 }
833 } else if (mActionType == RESIZEBOTTOM) { 826 } else if (mActionType == RESIZEBOTTOM) {
834 if (mCurrentCellY >= mActionItem->cellYTop()) { 827 if (mCurrentCellY >= mActionItem->cellYTop()) {
835 mActionItem->expandBottom(gy - mCurrentCellY); 828 mActionItem->expandBottom(gy - mCurrentCellY);
836 mActionItem->resize(mActionItem->width(), 829 mActionItem->resize(mActionItem->width(),
837 mGridSpacingY * mActionItem->cellHeight()); 830 mGridSpacingY * mActionItem->cellHeight());
838 } 831 }
839 } else if (mActionType == RESIZELEFT) { 832 } else if (mActionType == RESIZELEFT) {
840 if (mCurrentCellX <= mActionItem->cellXWidth()) { 833 if (mCurrentCellX <= mActionItem->cellXWidth()) {
841 mActionItem->expandLeft(gx - mCurrentCellX); 834 mActionItem->expandLeft(gx - mCurrentCellX);
842 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 835 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
843 mActionItem->height()); 836 mActionItem->height());
844 int x,y; 837 int x,y;
845 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 838 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
846 moveChild(mActionItem,x,childY(mActionItem)); 839 moveChild(mActionItem,x,childY(mActionItem));
847 } 840 }
848 } else if (mActionType == RESIZERIGHT) { 841 } else if (mActionType == RESIZERIGHT) {
849 if (mCurrentCellX >= mActionItem->cellX()) { 842 if (mCurrentCellX >= mActionItem->cellX()) {
850 mActionItem->expandRight(gx - mCurrentCellX); 843 mActionItem->expandRight(gx - mCurrentCellX);
851 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 844 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
852 mActionItem->height()); 845 mActionItem->height());
853 } 846 }
854 } 847 }
855 mCurrentCellX = gx; 848 mCurrentCellX = gx;
856 mCurrentCellY = gy; 849 mCurrentCellY = gy;
857 } 850 }
858} 851}
859 852
860void KOAgenda::endItemAction() 853void KOAgenda::endItemAction()
861{ 854{
862 855
863 if ( mItemMoved ) { 856 if ( mItemMoved ) {
864 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 857 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
865 if ( !placeItem ) { 858 if ( !placeItem ) {
866 placeItem = mActionItem; 859 placeItem = mActionItem;
867 } 860 }
868 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 861 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
869 Incidence* oldInc = placeItem->incidence(); 862 Incidence* oldInc = placeItem->incidence();
870 placeItem->recreateIncidence(); 863 placeItem->recreateIncidence();
871 emit addToCalSignal(placeItem->incidence(), oldInc ); 864 emit addToCalSignal(placeItem->incidence(), oldInc );
872 } 865 }
873 int type = mActionType; 866 int type = mActionType;
874 if ( mAllDayMode ) 867 if ( mAllDayMode )
875 type = -1; 868 type = -1;
876 KOAgendaItem *modifiedItem = placeItem; 869 KOAgendaItem *modifiedItem = placeItem;
877 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 870 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
878 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 871 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
879 KOAgendaItem *item; 872 KOAgendaItem *item;
880 873
881 if ( placeItem->incidence()->type() == "Todo" ) { 874 if ( placeItem->incidence()->type() == "Todo" ) {
882 mSelectedItem = 0; 875 mSelectedItem = 0;
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 2069b22..f3f1772 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -21,271 +21,270 @@
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 34
35class QPopupMenu; 35class QPopupMenu;
36class QTime; 36class QTime;
37class KConfig; 37class KConfig;
38class QFrame; 38class QFrame;
39class KOAgenda; 39class KOAgenda;
40class KCal::Event; 40class KCal::Event;
41class KCal::Todo; 41class KCal::Todo;
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45class MarcusBains : public QFrame { 45class MarcusBains : public QFrame {
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 MarcusBains(KOAgenda *agenda=0,const char *name=0); 48 MarcusBains(KOAgenda *agenda=0,const char *name=0);
49 virtual ~MarcusBains(); 49 virtual ~MarcusBains();
50 50
51 public slots: 51 public slots:
52 void updateLocation(bool recalculate=false); 52 void updateLocation(bool recalculate=false);
53 void updateLoc(); 53 void updateLoc();
54 54
55 private: 55 private:
56 int todayColumn(); 56 int todayColumn();
57 QTimer *minutes; 57 QTimer *minutes;
58 QLabel *mTimeBox; 58 QLabel *mTimeBox;
59 KOAgenda *agenda; 59 KOAgenda *agenda;
60 QTime oldTime; 60 QTime oldTime;
61 int oldToday; 61 int oldToday;
62}; 62};
63 63
64 64
65class KOAgenda : public QScrollView 65class KOAgenda : public QScrollView
66{ 66{
67 Q_OBJECT 67 Q_OBJECT
68 public: 68 public:
69 enum MouseActionType { NOP, MOVE, SELECT, 69 enum MouseActionType { NOP, MOVE, SELECT,
70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
71 71
72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
73 const char * name=0, WFlags f=0 ); 73 const char * name=0, WFlags f=0 );
74 KOAgenda ( int columns, QWidget * parent=0, 74 KOAgenda ( int columns, QWidget * parent=0,
75 const char * name=0, WFlags f=0 ); 75 const char * name=0, WFlags f=0 );
76 virtual ~KOAgenda(); 76 virtual ~KOAgenda();
77 77
78 Incidence *selectedIncidence() const; 78 Incidence *selectedIncidence() const;
79 QDate selectedIncidenceDate() const; 79 QDate selectedIncidenceDate() const;
80 80
81 virtual bool eventFilter ( QObject *, QEvent * ); 81 virtual bool eventFilter ( QObject *, QEvent * );
82 82
83 void contentsToGrid (int x, int y, int& gx, int& gy); 83 void contentsToGrid (int x, int y, int& gx, int& gy);
84 void gridToContents (int gx, int gy, int& x, int& y); 84 void gridToContents (int gx, int gy, int& x, int& y);
85 85
86 int timeToY (const QTime &time); 86 int timeToY (const QTime &time);
87 QTime gyToTime (int y); 87 QTime gyToTime (int y);
88 88
89 void setStartHour(int startHour); 89 void setStartHour(int startHour);
90 90
91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
94 int YTop,int YBottom); 94 int YTop,int YBottom);
95 95
96 void changeColumns(int columns); 96 void changeColumns(int columns);
97 97
98 int columns() { return mColumns; } 98 int columns() { return mColumns; }
99 int rows() { return mRows; } 99 int rows() { return mRows; }
100 100
101 int gridSpacingX() const { return mGridSpacingX; } 101 int gridSpacingX() const { return mGridSpacingX; }
102 int gridSpacingY() const { return mGridSpacingY; } 102 int gridSpacingY() const { return mGridSpacingY; }
103 103
104// virtual QSizePolicy sizePolicy() const; 104// virtual QSizePolicy sizePolicy() const;
105 105
106 void clear(); 106 void clear();
107 107
108 void clearSelection(); 108 void clearSelection();
109 void hideUnused(); 109 void hideUnused();
110 110
111 /** Calculates the minimum width */ 111 /** Calculates the minimum width */
112 virtual int minimumWidth() const; 112 virtual int minimumWidth() const;
113 /** Update configuration from preference settings */ 113 /** Update configuration from preference settings */
114 void updateConfig(); 114 void updateConfig();
115 115
116 void checkScrollBoundaries(); 116 void checkScrollBoundaries();
117 117
118 void setHolidayMask(QMemArray<bool> *); 118 void setHolidayMask(QMemArray<bool> *);
119 void setDateList(const DateList &selectedDates); 119 void setDateList(const DateList &selectedDates);
120 DateList dateList() const; 120 DateList dateList() const;
121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
122 void finishUpdate(); 122 void finishUpdate();
123 void printSelection(); 123 void printSelection();
124 void storePosition(); 124 void storePosition();
125 void restorePosition(); 125 void restorePosition();
126 126
127 127
128 public slots: 128 public slots:
129 void newItem( int ); 129 void newItem( int );
130 void moveChild( QWidget *, int, int ); 130 void moveChild( QWidget *, int, int );
131 void scrollUp(); 131 void scrollUp();
132 void scrollDown(); 132 void scrollDown();
133 void updateTodo( Todo * t, int , bool ); 133 void updateTodo( Todo * t, int , bool );
134 void popupAlarm(); 134 void popupAlarm();
135 135
136 void checkScrollBoundaries(int); 136 void checkScrollBoundaries(int);
137 137
138 /** Deselect selected items. This function does not emit any signals. */ 138 /** Deselect selected items. This function does not emit any signals. */
139 void deselectItem(); 139 void deselectItem();
140 /** Select item. If the argument is 0, the currently selected item gets 140 /** Select item. If the argument is 0, the currently selected item gets
141 deselected. This function emits the itemSelected(bool) signal to inform 141 deselected. This function emits the itemSelected(bool) signal to inform
142 about selection/deseelction of events. */ 142 about selection/deseelction of events. */
143 void selectItem(KOAgendaItem *); 143 void selectItem(KOAgendaItem *);
144 void finishResize(); 144 void finishResize();
145 145
146 signals: 146 signals:
147 void showDateView( int, QDate ); 147 void showDateView( int, QDate );
148 void newEventSignal(); 148 void newEventSignal();
149 void newEventSignal(int gx,int gy); 149 void newEventSignal(int gx,int gy);
150 void newTodoSignal(int gx,int gy); 150 void newTodoSignal(int gx,int gy);
151 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 151 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
152 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 152 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
153 void newStartSelectSignal(); 153 void newStartSelectSignal();
154 void showIncidenceSignal(Incidence *); 154 void showIncidenceSignal(Incidence *);
155 void editIncidenceSignal(Incidence *); 155 void editIncidenceSignal(Incidence *);
156 void deleteIncidenceSignal(Incidence *); 156 void deleteIncidenceSignal(Incidence *);
157 void showIncidencePopupSignal(Incidence *); 157 void showIncidencePopupSignal(Incidence *);
158 158
159 void itemModified(KOAgendaItem *item, int ); 159 void itemModified(KOAgendaItem *item, int );
160 void incidenceSelected(Incidence *); 160 void incidenceSelected(Incidence *);
161 161
162 void lowerYChanged(int); 162 void lowerYChanged(int);
163 void upperYChanged(int); 163 void upperYChanged(int);
164 164
165 void startDragSignal(Incidence *); 165 void startDragSignal(Incidence *);
166 void addToCalSignal(Incidence *, Incidence *); 166 void addToCalSignal(Incidence *, Incidence *);
167 void resizedSignal(); 167 void resizedSignal();
168 168
169 protected: 169 protected:
170 QPainter mPixPainter; 170 QPainter mPixPainter;
171 QPixmap mPaintPixmap; 171 QPixmap mPaintPixmap;
172 QPixmap mHighlightPixmap; 172 QPixmap mHighlightPixmap;
173 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 173 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
174 virtual void resizeEvent ( QResizeEvent * ); 174 virtual void resizeEvent ( QResizeEvent * );
175 175
176 /** Handles mouse events. Called from eventFilter */ 176 /** Handles mouse events. Called from eventFilter */
177 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 177 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
178 178
179 /** Start selecting time span. */ 179 /** Start selecting time span. */
180 void startSelectAction(QPoint viewportPos); 180 void startSelectAction(QPoint viewportPos);
181 181
182 /** Select time span. */ 182 /** Select time span. */
183 void performSelectAction(QPoint viewportPos); 183 void performSelectAction(QPoint viewportPos);
184 184
185 /** Emd selecting time span. */ 185 /** Emd selecting time span. */
186 void endSelectAction( bool emitNewEvent = false ); 186 void endSelectAction( bool emitNewEvent = false );
187 187
188 /** Start moving/resizing agenda item */ 188 /** Start moving/resizing agenda item */
189 void startItemAction(QPoint viewportPos); 189 void startItemAction(QPoint viewportPos);
190 190
191 /** Move/resize agenda item */ 191 /** Move/resize agenda item */
192 void performItemAction(QPoint viewportPos); 192 void performItemAction(QPoint viewportPos);
193 193
194 /** End moving/resizing agenda item */ 194 /** End moving/resizing agenda item */
195 void endItemAction(); 195 void endItemAction();
196 196
197 /** Set cursor, when no item action is in progress */ 197 /** Set cursor, when no item action is in progress */
198 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 198 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
199 199
200 /** Place agenda item in agenda and adjust other cells if necessary */ 200 /** Place agenda item in agenda and adjust other cells if necessary */
201 void placeSubCells(KOAgendaItem *placeItem); 201 void placeSubCells(KOAgendaItem *placeItem);
202 202
203 /** Process the keyevent, including the ignored keyevents of eventwidgets. 203 /** Process the keyevent, including the ignored keyevents of eventwidgets.
204 * Implements pgup/pgdn and cursor key navigation in the view. 204 * Implements pgup/pgdn and cursor key navigation in the view.
205 */ 205 */
206 void keyPressEvent( QKeyEvent * ); 206 void keyPressEvent( QKeyEvent * );
207 207
208 void calculateWorkingHours(); 208 void calculateWorkingHours();
209 209
210 virtual void contentsMousePressEvent ( QMouseEvent * ); 210 virtual void contentsMousePressEvent ( QMouseEvent * );
211 211
212 private: 212 private:
213 bool blockNewEvent;
214 void init(); 213 void init();
215 void marcus_bains(); 214 void marcus_bains();
216 bool mAllDayMode; 215 bool mAllDayMode;
217 bool blockResize; 216 bool blockResize;
218 QTimer mResizeTimer; 217 QTimer mResizeTimer;
219 double mContentPosition; 218 double mContentPosition;
220 219
221 // Width and height of agenda cells 220 // Width and height of agenda cells
222 int mGridSpacingX; 221 int mGridSpacingX;
223 int mGridSpacingY; 222 int mGridSpacingY;
224 223
225 // size of border, where mouse action will resize the KOAgendaItem 224 // size of border, where mouse action will resize the KOAgendaItem
226 int mResizeBorderWidth; 225 int mResizeBorderWidth;
227 226
228 // size of border, where mouse mve will cause a scroll of the agenda 227 // size of border, where mouse mve will cause a scroll of the agenda
229 int mScrollBorderWidth; 228 int mScrollBorderWidth;
230 int mScrollDelay; 229 int mScrollDelay;
231 int mScrollOffset; 230 int mScrollOffset;
232 231
233 QTimer mScrollUpTimer; 232 QTimer mScrollUpTimer;
234 QTimer mScrollDownTimer; 233 QTimer mScrollDownTimer;
235 234
236 // Number of Columns/Rows of agenda grid 235 // Number of Columns/Rows of agenda grid
237 int mColumns; 236 int mColumns;
238 int mRows; 237 int mRows;
239 238
240 // Cells to store Move and Resize coordiantes 239 // Cells to store Move and Resize coordiantes
241 int mStartCellX; 240 int mStartCellX;
242 int mStartCellY; 241 int mStartCellY;
243 int mCurrentCellX; 242 int mCurrentCellX;
244 int mCurrentCellY; 243 int mCurrentCellY;
245 244
246 // Working Hour coordiantes 245 // Working Hour coordiantes
247 bool mWorkingHoursEnable; 246 bool mWorkingHoursEnable;
248 int mWorkingHoursYTop; 247 int mWorkingHoursYTop;
249 int mWorkingHoursYBottom; 248 int mWorkingHoursYBottom;
250 249
251 // Selection 250 // Selection
252 int mSelectionCellX; 251 int mSelectionCellX;
253 int mSelectionYTop; 252 int mSelectionYTop;
254 int mSelectionHeight; 253 int mSelectionHeight;
255 254
256 // List of dates to be displayed 255 // List of dates to be displayed
257 DateList mSelectedDates; 256 DateList mSelectedDates;
258 257
259 // The KOAgendaItem, which has been right-clicked last 258 // The KOAgendaItem, which has been right-clicked last
260 KOAgendaItem *mClickedItem; 259 KOAgendaItem *mClickedItem;
261 260
262 // The KOAgendaItem, which is being moved/resized 261 // The KOAgendaItem, which is being moved/resized
263 QGuardedPtr<KOAgendaItem> mActionItem; 262 QGuardedPtr<KOAgendaItem> mActionItem;
264 263
265 // Currently selected item 264 // Currently selected item
266 QGuardedPtr<KOAgendaItem> mSelectedItem; 265 QGuardedPtr<KOAgendaItem> mSelectedItem;
267 266
268 // The Marcus Bains Line widget. 267 // The Marcus Bains Line widget.
269 MarcusBains *mMarcusBains; 268 MarcusBains *mMarcusBains;
270 void computeSizes(); 269 void computeSizes();
271 270
272 MouseActionType mActionType; 271 MouseActionType mActionType;
273 272
274 bool mItemMoved; 273 bool mItemMoved;
275 274
276 // List of all Items contained in agenda 275 // List of all Items contained in agenda
277 QPtrList<KOAgendaItem> mItems; 276 QPtrList<KOAgendaItem> mItems;
278 QPtrList<KOAgendaItem> mUnusedItems; 277 QPtrList<KOAgendaItem> mUnusedItems;
279 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 278 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
280 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 279 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
281 QPopupMenu *mNewItemPopup; 280 QPopupMenu *mNewItemPopup;
282 281
283 int mOldLowerScrollValue; 282 int mOldLowerScrollValue;
284 int mOldUpperScrollValue; 283 int mOldUpperScrollValue;
285 KOAgendaItem * getItemForTodo ( Todo * todo ); 284 KOAgendaItem * getItemForTodo ( Todo * todo );
286 QMemArray<bool> *mHolidayMask; 285 QMemArray<bool> *mHolidayMask;
287 int mCurPixWid; 286 int mCurPixWid;
288 int mCurPixHei; 287 int mCurPixHei;
289}; 288};
290 289
291#endif // KOAGENDA_H 290#endif // KOAGENDA_H