[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: [Kde-pim] [PATCH] Group schedulling when an event is moved in the
From: Mario Teijeiro Otero <emeteo () escomposlinux ! org>
Date: 2004-12-23 0:37:17
Message-ID: 200412230137.27260.emeteo () escomposlinux ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi,
It was not easy make it. The blame is the $%&·$%%/
sendIcalMessage in IncidenceChanger::changeIncidence.
Problem: the MessageBox has not parent widget => the agenda
recives the move events and KOAgenda->performItemAction and
KOAgenda->endItemAction has not ready to be reentrant. I fixed this.
We don't have enough control when show the MessageBox to ask the user
if wants to send a status update, This control is required because when We
move a recurrente event with "Only this item", mChanger->changeIncidence and
mChanger->addIncidence are called, this calls fire a "ask user update event"
each one.
I don't like very much this patch because looks a "patch".
I wait comments.
I hope I was able to explain me right.
["korganizer_drag.patch" (text/x-diff)]
? cscope.files
? cscope.out
? koagenda_new.cpp
? plugins/holidays/holidays/Makefile.in
Index: koagenda.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koagenda.cpp,v
retrieving revision 1.155
diff -u -p -r1.155 koagenda.cpp
--- koagenda.cpp 17 Nov 2004 12:42:58 -0000 1.155
+++ koagenda.cpp 23 Dec 2004 00:26:44 -0000
@@ -580,20 +580,22 @@ bool KOAgenda::eventFilter_mouse(QObject
mClickedItem->itemDate() );
}
} else {
- KOAgendaItem* item = dynamic_cast<KOAgendaItem *>(object);
- if (item) {
- Incidence *incidence = item->incidence();
- if ( incidence->isReadOnly() ) {
- mActionItem = 0;
- } else {
- mActionItem = item;
- startItemAction(viewportPos);
+ if( mActionType == NOP ) {
+ KOAgendaItem* item = dynamic_cast<KOAgendaItem *>(object);
+ if (item) {
+ Incidence *incidence = item->incidence();
+ if ( incidence->isReadOnly() ) {
+ mActionItem = 0;
+ } else {
+ mActionItem = item;
+ startItemAction(viewportPos);
+ }
+ // Warning: do selectItem() as late as possible, since all
+ // sorts of things happen during this call. Some can lead to
+ // this filter being run again and mActionItem being set to
+ // null.
+ selectItem(mActionItem);
}
- // Warning: do selectItem() as late as possible, since all
- // sorts of things happen during this call. Some can lead to
- // this filter being run again and mActionItem being set to
- // null.
- selectItem(mActionItem);
}
}
} else {
@@ -626,7 +628,10 @@ bool KOAgenda::eventFilter_mouse(QObject
break;
case QEvent::MouseButtonRelease:
- if (mActionItem) {
+ kdDebug(5850) << "eventFilter_mouse:: MouseButtonRelease " << endl;
+ if (mActionItem && mActionType != NOP &&
+ mActionType != SELECT && mActionType != END ) {
+ mActionType = END;
endItemAction();
} else if ( mActionType == SELECT ) {
endSelectAction( viewportPos );
@@ -639,8 +644,12 @@ bool KOAgenda::eventFilter_mouse(QObject
if (moveItem && !moveItem->incidence()->isReadOnly() )
if (!mActionItem)
setNoActionCursor(moveItem,viewportPos);
- else
+ else {
+ if ( mActionType == MOVE || mActionType == RESIZETOP ||
+ mActionType == RESIZEBOTTOM || mActionType == RESIZELEFT
+ || mActionType == RESIZERIGHT )
performItemAction(viewportPos);
+ }
} else {
if ( mActionType == SELECT ) {
performSelectAction( viewportPos );
@@ -841,7 +850,7 @@ void KOAgenda::performItemAction(const Q
QPoint gpos = contentsToGrid( pos );
QPoint clipperPos = clipper()->
mapFromGlobal(viewport()->mapToGlobal(viewportPos));
-
+ kdDebug(5850) << "KOAgenda::performItemAction" << endl;
// Cursor left active agenda area.
// This starts a drag.
if ( clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||
@@ -1022,7 +1031,10 @@ void KOAgenda::endItemAction()
// FIXME: do the cloning here...
if ( mItemMoved ) {
+ Incidence *newIncidence;
+ newIncidence=0;
bool modify = true;
+
if ( mActionItem->incidence()->doesRecur() ) {
int res = KOMessageBox::fourBtnMsgBox( this, QMessageBox::Question,
i18n("The item you try to change is a recurring item. Shall the changes "
@@ -1032,6 +1044,7 @@ void KOAgenda::endItemAction()
i18n("Only &this item"), i18n("Only &future items"), i18n("&All occurrences") );
switch ( res ) {
case KMessageBox::Ok: // All occurences
+ kdDebug(5850) << "Moving all occurrences" << endl;
// Moving the whole sequene of events is handled by the itemModified below.
modify = true;
break;
@@ -1044,24 +1057,34 @@ void KOAgenda::endItemAction()
// care of the new time!
modify = true;
multiModify = true;
- emit startMultiModify( i18n("Dissociate event from recurrence") );
- Incidence* oldInc = mActionItem->incidence();
- Incidence* oldIncSaved = mActionItem->incidence()->clone();
- Incidence* newInc = mCalendar->dissociateOccurrence(
- oldInc, mActionItem->itemDate() );
- if ( newInc ) {
+
+ kdDebug(5850) << "Moving only this ocurrence" << endl;
+
+ Incidence* incidence = mActionItem->incidence();
+ Incidence* oldIncidence = mActionItem->incidence()->clone();
+ //We get the single item, recurrence item is in incidence
+ newIncidence = mCalendar->dissociateOccurrence( incidence,
+ mActionItem->itemDate(), true );
+
+ if ( newIncidence ) {
+
+ emit startMultiModify( i18n("Dissociate event from recurrence") );
+
// don't recreate items, they already have the correct position
emit enableAgendaUpdate( false );
- mChanger->changeIncidence( oldIncSaved, oldInc );
- mActionItem->setIncidence( newInc );
+
+ mChanger->changeIncidence( oldIncidence, incidence );
+ mActionItem->setIncidence( newIncidence );
mActionItem->dissociateFromMultiItem();
- mChanger->addIncidence( newInc );
+
emit enableAgendaUpdate( true );
+
} else {
KMessageBox::sorry( this, i18n("Unable to add the exception item to the "
"calendar. No change will be done."), i18n("Error Occurred") );
}
- delete oldIncSaved;
+ delete oldIncidence;
+
break; }
case KMessageBox::No/*Future*/: { // All future occurences
// Dissociate this occurence:
@@ -1070,27 +1093,33 @@ void KOAgenda::endItemAction()
// for the old event, adjust the recurrence for the new copy and then just
// go on with the newly adjusted mActionItem and let the usual code take
// care of the new time!
+ kdDebug(5850) << "Moving only future ocurrences" << endl;
modify = true;
multiModify = true;
emit startMultiModify( i18n("Split future recurrences") );
- Incidence* oldInc = mActionItem->incidence();
- Incidence* oldIncSaved = mActionItem->incidence()->clone();
- Incidence* newInc = mCalendar->dissociateOccurrence(
- oldInc, mActionItem->itemDate(), false );
- if ( newInc ) {
+ Incidence* incidence = mActionItem->incidence();
+ Incidence* oldIncidence = mActionItem->incidence()->clone();
+
+ //We get the recurrent incidence, in incidence is the single
+ newIncidence = mCalendar->dissociateOccurrence(incidence,
+ mActionItem->itemDate(), false );
+
+ if ( newIncidence ) {
emit enableAgendaUpdate( false );
+
mActionItem->dissociateFromMultiItem();
- mActionItem->setIncidence( newInc );
- mChanger->addIncidence( newInc );
+ mActionItem->setIncidence( newIncidence );
+
emit enableAgendaUpdate( true );
- mChanger->changeIncidence( oldIncSaved, oldInc );
+ mChanger->changeIncidence( oldIncidence, incidence );
} else {
KMessageBox::sorry( this, i18n("Unable to add the future items to the "
"calendar. No change will be done."), i18n("Error Occurred") );
}
- delete oldIncSaved;
+ delete oldIncidence;
break; }
default:
+ kdDebug(5850) << "Reset" << endl;
modify = false;
mActionItem->resetMove();
placeSubCells( mActionItem );
@@ -1098,9 +1127,10 @@ void KOAgenda::endItemAction()
}
if ( modify ) {
+
mActionItem->endMove();
+
KOAgendaItem *placeItem = mActionItem->firstMultiItem();
- // FIXME: A mChanger->changeIncidence is missing here!
if ( !placeItem ) {
placeItem = mActionItem;
}
@@ -1119,16 +1149,33 @@ void KOAgenda::endItemAction()
}
// Notify about change, so that agenda view can update the event data
+ Incidence* oldIncidence = modif->incidence()->clone();
emit itemModified( modif );
+
+ kdDebug(5850) << " emitting updateItem " << endl;
+ emit updateItem( modif );
+
+ if( newIncidence ) {
+ emit enableAgendaUpdate( false );
+ mChanger->addIncidence( newIncidence );
+ emit enableAgendaUpdate( true );
+
+ } else {
+ newIncidence = mActionItem->incidence();
+ mChanger->changeIncidence( oldIncidence, newIncidence );
+ }
+
+ delete oldIncidence;
}
+
+ mActionItem = 0;
// FIXME: If the change failed, we need to update the view!
- mChanger->endChange( mActionItem->incidence() );
+ mChanger->endChange( newIncidence );
}
-
mActionItem = 0;
mActionType = NOP;
mItemMoved = false;
-
+
if ( multiModify ) emit endMultiModify();
kdDebug(5850) << "KOAgenda::endItemAction() done" << endl;
Index: koagenda.h
===================================================================
RCS file: /home/kde/kdepim/korganizer/koagenda.h,v
retrieving revision 1.72
diff -u -p -r1.72 koagenda.h
--- koagenda.h 14 Nov 2004 12:56:00 -0000 1.72
+++ koagenda.h 23 Dec 2004 00:26:44 -0000
@@ -179,6 +179,7 @@ class KOAgenda : public QScrollView
void showNewEventPopupSignal();
void itemModified( KOAgendaItem *item );
+ void updateItem( KOAgendaItem * );
void incidenceSelected( Incidence * );
void startMultiModify( const QString & );
void endMultiModify();
@@ -198,7 +199,7 @@ class KOAgenda : public QScrollView
private:
enum MouseActionType { NOP, MOVE, SELECT,
- RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
+ RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT, END };
protected:
void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
Index: koagendaview.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koagendaview.cpp,v
retrieving revision 1.188
diff -u -p -r1.188 koagendaview.cpp
--- koagendaview.cpp 14 Nov 2004 12:56:00 -0000 1.188
+++ koagendaview.cpp 23 Dec 2004 00:26:45 -0000
@@ -555,6 +555,8 @@ void KOAgendaView::connectAgenda( KOAgen
connect( agenda, SIGNAL( itemModified( KOAgendaItem * ) ),
SLOT( updateEventDates( KOAgendaItem * ) ) );
+ connect( agenda, SIGNAL( updateItem(KOAgendaItem*) ),
+ SLOT( doUpdateItem(KOAgendaItem*) ) );
connect( agenda, SIGNAL( enableAgendaUpdate( bool ) ),
SLOT( enableAgendaUpdate( bool ) ) );
@@ -1147,6 +1149,14 @@ void KOAgendaView::doUpdateItem()
}
}
+void KOAgendaView::doUpdateItem( KOAgendaItem * item )
+{
+ kdDebug(5850 ) << "doUpdateItem" << endl;
+ if (item ) {
+ changeIncidenceDisplay( inc->incidence(), KOGlobals::INCIDENCEEDITED );
+ }
+}
+
void KOAgendaView::showDates( const QDate &start, const QDate &end )
@@ -1294,7 +1304,8 @@ void KOAgendaView::changeIncidenceDispla
// recreating everything even causes troubles: dropping to the day matrix
// recreates the agenda items, but the evaluation is still in an agendaItems' code,
// which was deleted in the mean time. Thus KOrg crashes...
- changeIncidenceDisplayAdded( incidence );
+ if( mAllowAgendaUpdate )
+ changeIncidenceDisplayAdded( incidence );
break;
}
case KOGlobals::INCIDENCEEDITED: {
Index: koagendaview.h
===================================================================
RCS file: /home/kde/kdepim/korganizer/koagendaview.h,v
retrieving revision 1.82
diff -u -p -r1.82 koagendaview.h
--- koagendaview.h 14 Nov 2004 12:56:01 -0000 1.82
+++ koagendaview.h 23 Dec 2004 00:26:45 -0000
@@ -251,6 +251,7 @@ class KOAgendaView : public KOEventView
void updateEventDates( KOAgendaItem *item );
/** update just the display of the given incidence, called by a single-shot timer */
void doUpdateItem();
+ void doUpdateItem( KOAgendaItem * );
void updateEventIndicatorTop( int newY );
void updateEventIndicatorBottom( int newY );
[Attachment #8 (application/pgp-signature)]
_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic