Generate appropriate engine events for changes.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3345 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-12-22 12:40:52 +00:00
parent 461ed1695c
commit 30e728d81f

View File

@ -44,6 +44,8 @@
#include "gnc-commodity.h" #include "gnc-commodity.h"
#include "gnc-engine-util.h" #include "gnc-engine-util.h"
#include "gnc-engine.h" #include "gnc-engine.h"
#include "gnc-event-p.h"
/* /*
* The "force_double_entry" flag determines how * The "force_double_entry" flag determines how
@ -292,11 +294,13 @@ xaccConfigGetForceDoubleEntry (void)
/********************************************************************\ /********************************************************************\
\********************************************************************/ \********************************************************************/
G_INLINE_FUNC void mark_split (Split *split); G_INLINE_FUNC void mark_split_internal (Split *split,
gboolean generate_events);
G_INLINE_FUNC void G_INLINE_FUNC void
mark_split (Split *split) mark_split_internal (Split *split, gboolean generate_events)
{ {
Account *account = split->acc; Account *account = split->acc;
Transaction *trans;
if (account) if (account)
{ {
@ -304,7 +308,21 @@ mark_split (Split *split)
account->sort_dirty = TRUE; account->sort_dirty = TRUE;
xaccGroupMarkNotSaved (account->parent); xaccGroupMarkNotSaved (account->parent);
if (generate_events)
gnc_engine_generate_event (&account->guid, GNC_EVENT_MODIFY);
} }
trans = split->parent;
if (trans && generate_events)
gnc_engine_generate_event (&trans->guid, GNC_EVENT_MODIFY);
}
G_INLINE_FUNC void mark_split (Split *split);
G_INLINE_FUNC void
mark_split (Split *split)
{
mark_split_internal (split, TRUE);
} }
G_INLINE_FUNC void mark_trans (Transaction *trans); G_INLINE_FUNC void mark_trans (Transaction *trans);
@ -314,7 +332,9 @@ mark_trans (Transaction *trans)
GList *node; GList *node;
for (node = trans->splits; node; node = node->next) for (node = trans->splits; node; node = node->next)
mark_split (node->data); mark_split_internal (node->data, FALSE);
gnc_engine_generate_event (&trans->guid, GNC_EVENT_MODIFY);
} }
/********************************************************************\ /********************************************************************\
@ -560,7 +580,11 @@ Transaction *
xaccMallocTransaction (void) xaccMallocTransaction (void)
{ {
Transaction *trans = g_new(Transaction, 1); Transaction *trans = g_new(Transaction, 1);
xaccInitTransaction (trans); xaccInitTransaction (trans);
gnc_engine_generate_event (&trans->guid, GNC_EVENT_CREATE);
return trans; return trans;
} }
@ -1457,6 +1481,8 @@ xaccTransDestroy (Transaction *trans)
g_list_free (trans->splits); g_list_free (trans->splits);
trans->splits = NULL; trans->splits = NULL;
gnc_engine_generate_event (&trans->guid, GNC_EVENT_DESTROY);
xaccRemoveEntity(&trans->guid); xaccRemoveEntity(&trans->guid);
/* the actual free is done with the commit call, else its rolled back */ /* the actual free is done with the commit call, else its rolled back */
@ -1690,13 +1716,13 @@ xaccTransSetDateInternal(Transaction *trans, int which, time_t secs,
dadate->tv_nsec = nsecs; dadate->tv_nsec = nsecs;
mark_trans(trans); mark_trans(trans);
/* Because the date has changed, we need to make sure that each of the /* Because the date has changed, we need to make sure that each of
* splits is properly ordered in each of their accounts. We could do that * the splits is properly ordered in each of their accounts. We
* here, simply by reinserting each split into its account. However, in * could do that here, simply by reinserting each split into its
* some ways this is bad behaviour, and it seems much better/nicer to defer * account. However, in some ways this is bad behaviour, and it
* that until the commit phase, i.e. until the user has called the * seems much better/nicer to defer that until the commit phase,
* xaccTransCommitEdit() routine. So, for now, we are done. * i.e. until the user has called the xaccTransCommitEdit()
*/ * routine. So, for now, we are done. */
} }
void void