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 /korganizer | |
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 | 179 | ||||
-rw-r--r-- | korganizer/koagenda.h | 1 |
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 @@ -390,30 +390,36 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) QPoint viewportPos; if (object != viewport()) { viewportPos = ((QWidget *)object)->mapToParent(me->pos()); } else { viewportPos = me->pos(); } static int startX = 0; 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()) { if (me->button() == RightButton) { mClickedItem = (KOAgendaItem *)object; if (mClickedItem) { selectItem(mClickedItem); - // emit showIncidencePopupSignal(mClickedItem->incidence()); } - //mItemPopup->popup(QCursor::pos()); - } else { + } else if (me->button() == LeftButton) { mActionItem = (KOAgendaItem *)object; if (mActionItem) { if ( mSelectionHeight > 0 ) { int selectionCellX = mSelectionCellX * mGridSpacingX; int selectionYTop = mSelectionYTop; int gridSpacingX = mGridSpacingX; int selectionHeight = mSelectionHeight; clearSelection(); @@ -421,132 +427,118 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) gridSpacingX, selectionHeight,false ); } selectItem(mActionItem); Incidence *incidence = mActionItem->incidence(); if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { mActionItem = 0; } else { startItemAction(viewportPos); - startX = viewportPos.x(); - startY = viewportPos.y(); - block = true; } } } - } else { + } else { // ---------- viewport() selectItem(0); mActionItem = 0; - if (me->button() == RightButton ) { - blockNewEvent = true; - block = false; - } else { - blockNewEvent = false; + if (me->button() == LeftButton ) { setCursor(arrowCursor); startSelectAction(viewportPos); } } break; 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); + if (object != viewport()) { + if (me->button() == RightButton) { + if ( blockMoving ) { + mClickedItem = (KOAgendaItem *)object; + if (mActionItem ) { + endItemAction(); + } + leftMouseDown = false; // no more leftMouse computation + if (mClickedItem) { + selectItem(mClickedItem); + emit showIncidencePopupSignal(mClickedItem->incidence()); + } + } + } else if (me->button() == LeftButton && leftMouseDown) { + if (mActionItem) { + QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); + //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); + if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { + mScrollUpTimer.stop(); + mScrollDownTimer.stop(); + mActionItem->resetMove(); + placeSubCells( mActionItem ); + // emit startDragSignal( mActionItem->incidence() ); + setCursor( arrowCursor ); + mActionItem = 0; + mActionType = NOP; + mItemMoved = 0; + return true; + } + endItemAction(); + } + } + + } 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() ) ); - 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()) { - mClickedItem = (KOAgendaItem *)object; - if (mActionItem ) { - endItemAction(); - } - if (mClickedItem) { - selectItem(mClickedItem); - emit showIncidencePopupSignal(mClickedItem->incidence()); - } - } - break; - } - block = true; - if (mActionItem) { - QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); - //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); - if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { - mScrollUpTimer.stop(); - mScrollDownTimer.stop(); - mActionItem->resetMove(); - placeSubCells( mActionItem ); - // emit startDragSignal( mActionItem->incidence() ); - setCursor( arrowCursor ); - mActionItem = 0; - mActionType = NOP; - mItemMoved = 0; - return true; } - endItemAction(); - } else if ( mActionType == SELECT ) { - if (me->button() == RightButton ) { - } else { - endSelectAction( !blockNewEvent ); + 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; case QEvent::MouseMove: + if ( !rightMouseDown && !leftMouseDown ) + return true; + if ( blockMoving ) { + int dX, dY; + dX = startX - viewportPos.x(); + if ( dX < 0 ) + dX = -dX; + dY = viewportPos.y() - startY; + if ( dY < 0 ) + dY = -dY; + //qDebug("%d %d %d ", dX, dY , blockmoveDist ); + if ( dX > blockmoveDist || dY > blockmoveDist ) { + blockMoving = false; + } + } if (object != viewport()) { KOAgendaItem *moveItem = (KOAgendaItem *)object; - //qDebug("moveItem %d ",moveItem ); - if (!moveItem->incidence()->isReadOnly() /*&& - !moveItem->incidence()->recurrence()->doesRecur()*/ ) + if (!moveItem->incidence()->isReadOnly() ) { if (!mActionItem) setNoActionCursor(moveItem,viewportPos); else { - if ( block ) { - int dX, dY; - dX = startX - viewportPos.x(); - if ( dX < 0 ) - dX = -dX; - dY = viewportPos.y() - startY; - if ( dY < 0 ) - dY = -dY; - int diff = 30; - if ( QApplication::desktop()->width() < 480 ) - diff = 15; - // qDebug(" %d %d ",dX, dY ); - if ( dX > diff || dY > diff ) { - block = false; - } - } - if ( !block ) + if ( !blockMoving ) performItemAction(viewportPos); } - } else { + } + } else { // ---------- viewport() if ( mActionType == SELECT ) { performSelectAction( viewportPos ); } } break; case QEvent::MouseButtonDblClick: if (object == viewport()) { @@ -564,17 +556,16 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) else emit showIncidenceSignal(doubleClickedItem->incidence()); } break; default: break; } - return true; } void KOAgenda::newItem( int item ) { if ( item == 1 ) { //new event newEventSignal(mStartCellX ,mStartCellY ); } else @@ -681,18 +672,20 @@ void KOAgenda::performSelectAction(QPoint viewportPos) void KOAgenda::endSelectAction( bool emitNewEvent ) { mActionType = NOP; mScrollUpTimer.stop(); mScrollDownTimer.stop(); emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); - if ( emitNewEvent && mStartCellY < mCurrentCellY ) + if ( emitNewEvent && mStartCellY < mCurrentCellY ) { + qDebug("ew event signal "); emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); + } } void KOAgenda::startItemAction(QPoint viewportPos) { int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; contentsToGrid(x,y,gx,gy); diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 2069b22..f3f1772 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -205,17 +205,16 @@ class KOAgenda : public QScrollView */ void keyPressEvent( QKeyEvent * ); void calculateWorkingHours(); virtual void contentsMousePressEvent ( QMouseEvent * ); private: - bool blockNewEvent; void init(); void marcus_bains(); bool mAllDayMode; bool blockResize; QTimer mResizeTimer; double mContentPosition; // Width and height of agenda cells |