summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-16 11:47:11 (UTC)
committer zautrix <zautrix>2005-03-16 11:47:11 (UTC)
commitb90787b3fd6cf859c80ddce0f1a2272c7565eec3 (patch) (side-by-side diff)
treeca87e708078cea9180a8a5123b4d068a2a06a714 /korganizer
parent2a92f30dbb2a2bfcee223d949a1672060b76f6ab (diff)
downloadkdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.zip
kdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.tar.gz
kdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.tar.bz2
drag fix in agenda
Diffstat (limited to 'korganizer') (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
@@ -395,20 +395,26 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
}
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 ) {
@@ -426,20 +432,13 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
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);
}
@@ -447,101 +446,94 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
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 );
}
@@ -569,7 +561,6 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
default:
break;
}
-
return true;
}
@@ -686,8 +677,10 @@ void KOAgenda::endSelectAction( bool emitNewEvent )
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)
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 2069b22..f3f1772 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -210,7 +210,6 @@ class KOAgenda : public QScrollView
virtual void contentsMousePressEvent ( QMouseEvent * );
private:
- bool blockNewEvent;
void init();
void marcus_bains();
bool mAllDayMode;