-rw-r--r-- | korganizer/koagenda.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index fc213d8..b99625c 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -411,108 +411,158 @@ void KOAgenda::popupMenu() bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) { static int startX = 0; static int startY = 0; int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); static bool blockMoving = true; //qDebug("KOAgenda::eventFilter_mous "); if ( object == mNewItemPopup ) { //qDebug("mNewItemPopup "); if ( me->type() == QEvent::MouseButtonRelease ) { mNewItemPopup->removeEventFilter( this ); int dX = me->globalPos().x() - mPopupPos.x();; if ( dX < 0 ) dX = -dX; int dY = me->globalPos().y() - mPopupPos.y(); if ( dY < 0 ) dY = -dY; if ( dX > blockmoveDist || dY > blockmoveDist ) { mNewItemPopup->hide(); } } return true; } if ( object == mAllAgendaPopup ) { //qDebug(" mAllAgendaPopup "); if ( me->type() == QEvent::MouseButtonRelease ) { mAllAgendaPopup->removeEventFilter( this ); int dX = me->globalPos().x() - mPopupPos.x();; if ( dX < 0 ) dX = -dX; int dY = me->globalPos().y() - mPopupPos.y(); if ( dY < 0 ) dY = -dY; if ( dX > blockmoveDist || dY > blockmoveDist ) { mAllAgendaPopup->hide(); } } return true; } QPoint viewportPos; if (object != viewport()) { blockmoveDist = blockmoveDist*2; viewportPos = ((QWidget *)object)->mapToParent(me->pos()); } else { viewportPos = me->pos(); } - + bool objIsNotViewport = (object != viewport()); switch (me->type()) { case QEvent::MouseButtonPress: if (me->button() == LeftButton) { mPopupTimer->start( 600 ); mLeftMouseDown = true; } blockMoving = true; startX = viewportPos.x(); startY = viewportPos.y(); mPopupPos = me->globalPos(); - if (object != viewport()) { + if ( objIsNotViewport ) { + KOAgendaItem * tempItem = (KOAgendaItem *)object; + if (mAllDayMode) { + if ( tempItem->height() > 10 ) { + int minV = tempItem->height()/4; + if ( minV > (blockmoveDist/2)-2 ) + minV = (blockmoveDist/2)-2; + bool border = false; + int diff = tempItem->y() - viewportPos.y(); + if ( diff < 0 ) + diff *= -1; + if ( diff < minV ) { + border = true; + objIsNotViewport = false; + } + if ( ! border ) { + diff = tempItem->y() + tempItem->height()- viewportPos.y(); + if ( diff < 0 ) + diff *= -1; + if ( diff < minV ) { + border = true; + objIsNotViewport = false; + } + } + } + } else { // not allday + if ( tempItem->width() > 10 ) { + int minH = tempItem->width()/4; + if ( minH > (blockmoveDist/2)-2 ) + minH = (blockmoveDist/2)-2; + bool border = false; + int diff = tempItem->x() - viewportPos.x(); + if ( diff < 0 ) + diff *= -1; + if ( diff < minH ) { + border = true; + objIsNotViewport = false; + } + if ( ! border ) { + diff = tempItem->x() + tempItem->width() - viewportPos.x(); + if ( diff < 0 ) + diff *= -1; + if ( diff < minH ) { + border = true; + objIsNotViewport = false; + } + } + } + } + } + if ( objIsNotViewport ) { mPopupItem = (KOAgendaItem *)object; mPopupKind = 1; if (me->button() == RightButton) { mPopupKind = 3; popupMenu(); } else if (me->button() == LeftButton) { mActionItem = (KOAgendaItem *)object; if (mActionItem) { emit signalClearSelection(); slotClearSelection(); selectItem(mActionItem); Incidence *incidence = mActionItem->incidence(); if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { mActionItem = 0; } else { startItemAction(viewportPos); } } } } else { // ---------- viewport() mPopupItem = 0; mPopupKind = 2; selectItem(0); mActionItem = 0; if (me->button() == RightButton) { 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; mPopupKind = 4; popupMenu(); } else if (me->button() == LeftButton) { setCursor(arrowCursor); startSelectAction(viewportPos); } } break; case QEvent::MouseButtonRelease: if (me->button() == LeftButton ) { mPopupTimer->stop(); } if (object != viewport()) { if (me->button() == LeftButton && mLeftMouseDown) { |