summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
authorzautrix <zautrix>2005-03-25 18:26:36 (UTC)
committer zautrix <zautrix>2005-03-25 18:26:36 (UTC)
commit89a72c007045dcfa5dbf57012b4cf0c2aebd1495 (patch) (unidiff)
tree6accbe5706b724e307d1590152fa2d2c78cdef70 /korganizer/koagenda.cpp
parent3326831dbf6f962e97a978781361db5198f6a035 (diff)
downloadkdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.zip
kdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.tar.gz
kdepimpi-89a72c007045dcfa5dbf57012b4cf0c2aebd1495.tar.bz2
layout fixes
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp77
1 files changed, 32 insertions, 45 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 2820ca2..66ad4ec 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -172,13 +172,13 @@ KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
172 172
173 mColumns = columns; 173 mColumns = columns;
174 mRows = rows; 174 mRows = rows;
175 mGridSpacingY = rowSize; 175 mGridSpacingY = rowSize;
176 mAllDayMode = false; 176 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 177#ifndef DESKTOP_VERSION
178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 178 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 179#endif
180 mHolidayMask = 0; 180 mHolidayMask = 0;
181 init(); 181 init();
182} 182}
183 183
184/* 184/*
@@ -395,32 +395,36 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
395 } 395 }
396 static int startX = 0; 396 static int startX = 0;
397 static int startY = 0; 397 static int startY = 0;
398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 398 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
399 static bool blockMoving = true; 399 static bool blockMoving = true;
400 static bool leftMouseDown = false; 400 static bool leftMouseDown = false;
401 static bool rightMouseDown = false;
402 static QTime rightClickTime;
403 bool rightButtonPressed = false; 401 bool rightButtonPressed = false;
404 switch (me->type()) { 402 switch (me->type()) {
405 case QEvent::MouseButtonPress: 403 case QEvent::MouseButtonPress:
406 rightClickTime.restart();
407 if (me->button() == LeftButton) { 404 if (me->button() == LeftButton) {
408 leftMouseDown = true; 405 leftMouseDown = true;
409 } 406 }
410 else if (me->button() == RightButton) 407 else if (me->button() == RightButton) {
411 rightMouseDown = true; 408 leftMouseDown = false;
409 }
412 blockMoving = true; 410 blockMoving = true;
413 startX = viewportPos.x(); 411 startX = viewportPos.x();
414 startY = viewportPos.y(); 412 startY = viewportPos.y();
415 if (object != viewport()) { 413 if (object != viewport()) { // item clicked **************
416 if (me->button() == RightButton) { 414 if (me->button() == RightButton) {
415 leftMouseDown = false;
417 mClickedItem = (KOAgendaItem *)object; 416 mClickedItem = (KOAgendaItem *)object;
417 if (mActionItem ) {
418 endItemAction();
419 }
418 if (mClickedItem) { 420 if (mClickedItem) {
419 selectItem(mClickedItem); 421 selectItem(mClickedItem);
420 } 422 emit showIncidencePopupSignal(mClickedItem->incidence());
423 }
424 return true;
421 } else if (me->button() == LeftButton) { 425 } else if (me->button() == LeftButton) {
422 mActionItem = (KOAgendaItem *)object; 426 mActionItem = (KOAgendaItem *)object;
423 if (mActionItem) { 427 if (mActionItem) {
424 if ( mSelectionHeight > 0 ) { 428 if ( mSelectionHeight > 0 ) {
425 int selectionCellX = mSelectionCellX * mGridSpacingX; 429 int selectionCellX = mSelectionCellX * mGridSpacingX;
426 int selectionYTop = mSelectionYTop; 430 int selectionYTop = mSelectionYTop;
@@ -442,33 +446,35 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
442 } else { // ---------- viewport() 446 } else { // ---------- viewport()
443 selectItem(0); 447 selectItem(0);
444 mActionItem = 0; 448 mActionItem = 0;
445 if (me->button() == LeftButton ) { 449 if (me->button() == LeftButton ) {
446 setCursor(arrowCursor); 450 setCursor(arrowCursor);
447 startSelectAction(viewportPos); 451 startSelectAction(viewportPos);
452 } else if (me->button() == RightButton ) {
453 setCursor(arrowCursor);
454 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
455 endSelectAction( false ); // do not emit new event signal
456 leftMouseDown = false; // no more leftMouse computation
457 }
458 int x,y;
459 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
460 int gx,gy;
461 contentsToGrid(x,y,gx,gy);
462 mCurrentCellX = gx;
463 mCurrentCellY = gy;
464 mStartCellX = gx;
465 mStartCellY = gy;
466 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
448 } 467 }
449 } 468 }
450 break; 469 break;
451 470
452 case QEvent::MouseButtonRelease: 471 case QEvent::MouseButtonRelease:
453 if ( rightClickTime.elapsed() > 500 && blockMoving ) 472
454 rightButtonPressed = true;
455 if (object != viewport()) { 473 if (object != viewport()) {
456 if (me->button() == RightButton || rightButtonPressed ) { 474 if (me->button() == LeftButton && leftMouseDown) {
457 if ( blockMoving ) {
458 mClickedItem = (KOAgendaItem *)object;
459 if (mActionItem ) {
460 endItemAction();
461 }
462 leftMouseDown = false; // no more leftMouse computation
463 if (mClickedItem) {
464 selectItem(mClickedItem);
465 emit showIncidencePopupSignal(mClickedItem->incidence());
466 }
467 }
468 } else if (me->button() == LeftButton && leftMouseDown) {
469 if (mActionItem) { 475 if (mActionItem) {
470 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 476 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
471 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 477 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
472 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 478 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
473 mScrollUpTimer.stop(); 479 mScrollUpTimer.stop();
474 mScrollDownTimer.stop(); 480 mScrollDownTimer.stop();
@@ -484,41 +490,23 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
484 } 490 }
485 endItemAction(); 491 endItemAction();
486 } 492 }
487 } 493 }
488 494
489 } else { // ---------- viewport() 495 } else { // ---------- viewport()
490 if (me->button() == RightButton || rightButtonPressed ) { //right click 496 if (me->button() == LeftButton && leftMouseDown ) { //left click
491 if ( blockMoving ) { // we did mot moved the mouse much - popup menu
492 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
493 endSelectAction( false ); // do not emit new event signal
494 leftMouseDown = false; // no more leftMouse computation
495 }
496 int x,y;
497 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
498 int gx,gy;
499 contentsToGrid(x,y,gx,gy);
500 mCurrentCellX = gx;
501 mCurrentCellY = gy;
502 mStartCellX = gx;
503 mStartCellY = gy;
504 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
505 }
506 }
507 else if (me->button() == LeftButton && leftMouseDown ) { //left click
508 endSelectAction( true ); // emit new event signal 497 endSelectAction( true ); // emit new event signal
509 } 498 }
510 } 499 }
511 if (me->button() == LeftButton) 500 if (me->button() == LeftButton)
512 leftMouseDown = false; 501 leftMouseDown = false;
513 else if (me->button() == RightButton) 502
514 rightMouseDown = false;
515 break; 503 break;
516 504
517 case QEvent::MouseMove: 505 case QEvent::MouseMove:
518 if ( !rightMouseDown && !leftMouseDown ) 506 if ( !leftMouseDown )
519 return true; 507 return true;
520 if ( blockMoving ) { 508 if ( blockMoving ) {
521 int dX, dY; 509 int dX, dY;
522 dX = startX - viewportPos.x(); 510 dX = startX - viewportPos.x();
523 if ( dX < 0 ) 511 if ( dX < 0 )
524 dX = -dX; 512 dX = -dX;
@@ -547,13 +535,12 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
547 } 535 }
548 break; 536 break;
549 537
550 case QEvent::MouseButtonDblClick: 538 case QEvent::MouseButtonDblClick:
551 blockMoving = false; 539 blockMoving = false;
552 leftMouseDown = false; 540 leftMouseDown = false;
553 rightMouseDown = false;
554 if (object == viewport()) { 541 if (object == viewport()) {
555 selectItem(0); 542 selectItem(0);
556 int x,y; 543 int x,y;
557 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 544 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
558 int gx,gy; 545 int gx,gy;
559 contentsToGrid(x,y,gx,gy); 546 contentsToGrid(x,y,gx,gy);