summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index dcb46a8..5420822 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -357,193 +357,193 @@ void KOAgenda::changeColumns(int columns)
// QResizeEvent event( size(), size() );
//QApplication::sendEvent( this, &event );
}
/*
This is the eventFilter function, which gets all events from the KOAgendaItems
contained in the agenda. It has to handle moving and resizing for all items.
*/
bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
{
// kdDebug() << "KOAgenda::eventFilter" << endl;
switch(event->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
case (QEvent::Leave):
if (!mActionItem)
setCursor(arrowCursor);
return true;
default:
return QScrollView::eventFilter(object,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 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
static bool blockMoving = true;
static bool leftMouseDown = false;
static bool rightMouseDown = false;
static QTime rightClickTime;
bool rightButtonPressed = false;
switch (me->type()) {
case QEvent::MouseButtonPress:
rightClickTime.restart();
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);
}
} 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);
}
}
}
} else { // ---------- viewport()
selectItem(0);
mActionItem = 0;
if (me->button() == LeftButton ) {
setCursor(arrowCursor);
startSelectAction(viewportPos);
}
}
break;
case QEvent::MouseButtonRelease:
- if ( rightClickTime.elapsed() > 700 && blockMoving )
+ if ( rightClickTime.elapsed() > 500 && blockMoving )
rightButtonPressed = true;
if (object != viewport()) {
if (me->button() == RightButton || rightButtonPressed ) {
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;
leftMouseDown = false;
return true;
}
endItemAction();
}
}
} else { // ---------- viewport()
if (me->button() == RightButton || rightButtonPressed ) { //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 ( !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;
if (!moveItem->incidence()->isReadOnly() ) {
if (!mActionItem)
setNoActionCursor(moveItem,viewportPos);
else {
if ( !blockMoving )
performItemAction(viewportPos);
}
}
} else { // ---------- viewport()
if ( mActionType == SELECT ) {
performSelectAction( viewportPos );
}
}
break;