author | zautrix <zautrix> | 2005-03-16 11:47:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-16 11:47:11 (UTC) |
commit | b90787b3fd6cf859c80ddce0f1a2272c7565eec3 (patch) (side-by-side diff) | |
tree | ca87e708078cea9180a8a5123b4d068a2a06a714 | |
parent | 2a92f30dbb2a2bfcee223d949a1672060b76f6ab (diff) | |
download | kdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.zip kdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.tar.gz kdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.tar.bz2 |
drag fix in agenda
-rw-r--r-- | korganizer/koagenda.cpp | 133 | ||||
-rw-r--r-- | korganizer/koagenda.h | 1 |
2 files changed, 63 insertions, 71 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index ec81d44..e8b7c94 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -397,7 +397,15 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) static int startY = 0; - static bool block = true; + static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); + static bool blockMoving = true; + static bool leftMouseDown = false; + static bool rightMouseDown = false; switch (me->type()) { case QEvent::MouseButtonPress: - //qDebug("QEvent::MouseButtonPress: "); - // kdDebug() << "koagenda: filtered button press" << endl; + if (me->button() == LeftButton) + leftMouseDown = true; + else if (me->button() == RightButton) + rightMouseDown = true; + blockMoving = true; + startX = viewportPos.x(); + startY = viewportPos.y(); if (object != viewport()) { @@ -407,6 +415,4 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) selectItem(mClickedItem); - // emit showIncidencePopupSignal(mClickedItem->incidence()); } - //mItemPopup->popup(QCursor::pos()); - } else { + } else if (me->button() == LeftButton) { mActionItem = (KOAgendaItem *)object; @@ -428,5 +434,2 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) startItemAction(viewportPos); - startX = viewportPos.x(); - startY = viewportPos.y(); - block = true; } @@ -434,10 +437,6 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) } - } else { + } else { // ---------- viewport() selectItem(0); mActionItem = 0; - if (me->button() == RightButton ) { - blockNewEvent = true; - block = false; - } else { - blockNewEvent = false; + if (me->button() == LeftButton ) { setCursor(arrowCursor); @@ -449,32 +448,5 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) case QEvent::MouseButtonRelease: - //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); - if (me->button() == RightButton && blockNewEvent && !block) { - int x,y; - viewportToContents(viewportPos.x(),viewportPos.y(),x,y); - int gx,gy; - contentsToGrid(x,y,gx,gy); - if ( object == viewport() ) { - if ( mCurrentCellY < mStartCellY +1 ) { - //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); - mCurrentCellX = gx; - mCurrentCellY = gy; - mStartCellX = gx; - mStartCellY = gy; - mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); - break; - } else { - blockNewEvent = false; - } - } else { - mClickedItem = (KOAgendaItem *)object; - if (mActionItem ) { - endItemAction(); - } - if (mClickedItem) { - selectItem(mClickedItem); - emit showIncidencePopupSignal(mClickedItem->incidence()); - } - } - } else if (me->button() == RightButton && block ) { if (object != viewport()) { + if (me->button() == RightButton) { + if ( blockMoving ) { mClickedItem = (KOAgendaItem *)object; @@ -483,2 +455,3 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) } + leftMouseDown = false; // no more leftMouse computation if (mClickedItem) { @@ -488,5 +461,3 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) } - break; - } - block = true; + } else if (me->button() == LeftButton && leftMouseDown) { if (mActionItem) { @@ -507,8 +478,31 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) endItemAction(); - } else if ( mActionType == SELECT ) { - if (me->button() == RightButton ) { - } else { - endSelectAction( !blockNewEvent ); } } + + } else { // ---------- viewport() + if (me->button() == RightButton) { //right click + if ( blockMoving ) { // we did mot moved the mouse much - popup menu + if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action + endSelectAction( false ); // do not emit new event signal + leftMouseDown = false; // no more leftMouse computation + } + int x,y; + viewportToContents(viewportPos.x(),viewportPos.y(),x,y); + int gx,gy; + contentsToGrid(x,y,gx,gy); + mCurrentCellX = gx; + mCurrentCellY = gy; + mStartCellX = gx; + mStartCellY = gy; + mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); + } + } + else if (me->button() == LeftButton && leftMouseDown ) { //left click + endSelectAction( true ); // emit new event signal + } + } + if (me->button() == LeftButton) + leftMouseDown = false; + else if (me->button() == RightButton) + rightMouseDown = false; break; @@ -516,11 +510,5 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) case QEvent::MouseMove: - if (object != viewport()) { - KOAgendaItem *moveItem = (KOAgendaItem *)object; - //qDebug("moveItem %d ",moveItem ); - if (!moveItem->incidence()->isReadOnly() /*&& - !moveItem->incidence()->recurrence()->doesRecur()*/ ) - if (!mActionItem) - setNoActionCursor(moveItem,viewportPos); - else { - if ( block ) { + if ( !rightMouseDown && !leftMouseDown ) + return true; + if ( blockMoving ) { int dX, dY; @@ -532,14 +520,18 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) dY = -dY; - int diff = 30; - if ( QApplication::desktop()->width() < 480 ) - diff = 15; - // qDebug(" %d %d ",dX, dY ); - if ( dX > diff || dY > diff ) { - block = false; + //qDebug("%d %d %d ", dX, dY , blockmoveDist ); + if ( dX > blockmoveDist || dY > blockmoveDist ) { + blockMoving = false; } } - if ( !block ) + if (object != viewport()) { + KOAgendaItem *moveItem = (KOAgendaItem *)object; + if (!moveItem->incidence()->isReadOnly() ) { + if (!mActionItem) + setNoActionCursor(moveItem,viewportPos); + else { + if ( !blockMoving ) performItemAction(viewportPos); } - } else { + } + } else { // ---------- viewport() if ( mActionType == SELECT ) { @@ -571,3 +563,2 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) } - return true; @@ -688,5 +679,7 @@ void KOAgenda::endSelectAction( bool emitNewEvent ) emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); - if ( emitNewEvent && mStartCellY < mCurrentCellY ) + if ( emitNewEvent && mStartCellY < mCurrentCellY ) { + qDebug("ew event signal "); emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); } +} diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 2069b22..f3f1772 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -212,3 +212,2 @@ class KOAgenda : public QScrollView private: - bool blockNewEvent; void init(); |