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 @@ -386,171 +386,163 @@ bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) { //qDebug("KOAgenda::eventFilter_mous "); 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(); repaintContents( selectionCellX, selectionYTop, 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); - 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; if (mActionItem ) { endItemAction(); } + leftMouseDown = false; // no more leftMouse computation if (mClickedItem) { selectItem(mClickedItem); emit showIncidencePopupSignal(mClickedItem->incidence()); } } - break; - } - block = true; + } 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 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; 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; 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; + //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 ) { performSelectAction( viewportPos ); } } break; case QEvent::MouseButtonDblClick: if (object == viewport()) { selectItem(0); int x,y; viewportToContents(viewportPos.x(),viewportPos.y(),x,y); int gx,gy; @@ -560,25 +552,24 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; selectItem(doubleClickedItem); if ( KOPrefs::instance()->mEditOnDoubleClick ) emit editIncidenceSignal(doubleClickedItem->incidence()); else emit showIncidenceSignal(doubleClickedItem->incidence()); } break; default: break; } - return true; } void KOAgenda::newItem( int item ) { if ( item == 1 ) { //new event newEventSignal(mStartCellX ,mStartCellY ); } else if ( item == 2 ) { //new event newTodoSignal(mStartCellX ,mStartCellY ); } else { @@ -677,27 +668,29 @@ void KOAgenda::performSelectAction(QPoint viewportPos) } else { } } } 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); mStartCellX = gx; mStartCellY = gy; mCurrentCellX = gx; mCurrentCellY = gy; diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 2069b22..f3f1772 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h @@ -201,25 +201,24 @@ class KOAgenda : public QScrollView void placeSubCells(KOAgendaItem *placeItem); /** Process the keyevent, including the ignored keyevents of eventwidgets. * Implements pgup/pgdn and cursor key navigation in the view. */ 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 int mGridSpacingX; int mGridSpacingY; // size of border, where mouse action will resize the KOAgendaItem |