summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-17 09:44:18 (UTC)
committer zautrix <zautrix>2005-02-17 09:44:18 (UTC)
commitd9565b4258279d70fa651e7e6ebe072c0f3755d6 (patch) (side-by-side diff)
tree3d4aeffd7983b34f9e32392a7e855feb6ce52dde
parent311181f1415625529db49ae73c6ee0b86e3ce86b (diff)
downloadkdepimpi-d9565b4258279d70fa651e7e6ebe072c0f3755d6.zip
kdepimpi-d9565b4258279d70fa651e7e6ebe072c0f3755d6.tar.gz
kdepimpi-d9565b4258279d70fa651e7e6ebe072c0f3755d6.tar.bz2
popup agenda fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagenda.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ffa2678..a72e470 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -309,255 +309,265 @@ void KOAgenda::init()
if(mAllDayMode)
mMarcusBains = 0;
else {
mMarcusBains = new MarcusBains(this);
addChild(mMarcusBains);
}
}
void KOAgenda::clear()
{
KOAgendaItem *item;
for ( item=mItems.first(); item != 0; item=mItems.next() ) {
mUnusedItems.append( item );
//item->hide();
}
mItems.clear();
mSelectedItem = 0;
clearSelection();
}
void KOAgenda::clearSelection()
{
mSelectionCellX = 0;
mSelectionYTop = 0;
mSelectionHeight = 0;
}
void KOAgenda::marcus_bains()
{
if(mMarcusBains) mMarcusBains->updateLocation(true);
}
void KOAgenda::changeColumns(int columns)
{
if (columns == 0) {
kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
return;
}
clear();
mColumns = columns;
// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
// init();
// update();
//qDebug("KOAgenda::changeColumns ");
computeSizes();
// 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 bool block = true;
switch (me->type()) {
case QEvent::MouseButtonPress:
//qDebug("QEvent::MouseButtonPress: ");
// kdDebug() << "koagenda: filtered button press" << endl;
if (object != viewport()) {
if (me->button() == RightButton) {
-
mClickedItem = (KOAgendaItem *)object;
if (mClickedItem) {
selectItem(mClickedItem);
// emit showIncidencePopupSignal(mClickedItem->incidence());
}
//mItemPopup->popup(QCursor::pos());
} else {
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 {
selectItem(0);
mActionItem = 0;
if (me->button() == RightButton ) {
blockNewEvent = true;
block = false;
} else {
blockNewEvent = false;
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()) {
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 );
}
}
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 ) {
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 )
performItemAction(viewportPos);
}
} else {
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;
contentsToGrid(x,y,gx,gy);
emit newEventSignal(gx,gy);
} else {
KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
selectItem(doubleClickedItem);
if ( KOPrefs::instance()->mEditOnDoubleClick )
emit editIncidenceSignal(doubleClickedItem->incidence());
else
emit showIncidenceSignal(doubleClickedItem->incidence());
}
break;
default:
break;
}
return true;