summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
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/koagenda.cpp
parent2a92f30dbb2a2bfcee223d949a1672060b76f6ab (diff)
downloadkdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.zip
kdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.tar.gz
kdepimpi-b90787b3fd6cf859c80ddce0f1a2272c7565eec3.tar.bz2
drag fix in agenda
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp179
1 files changed, 86 insertions, 93 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ec81d44..e8b7c94 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -394,22 +394,28 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
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;
@@ -425,124 +431,110 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
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 );
}
}
@@ -568,9 +560,8 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
default:
break;
}
-
return true;
}
void KOAgenda::newItem( int item )
@@ -685,10 +676,12 @@ void KOAgenda::endSelectAction( bool emitNewEvent )
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)
{