diff --git a/ChangeLog b/ChangeLog index bbee9d6e75..28be41b127 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,13 @@ * lib/libqof/qof/qofevent.[ch]: Fix the definition of QOF_EVENT_BASE; use QOF_EVENT__LAST for tests. + * src/engine/gnc-event.h: + Add GNC_EVENT_ITEM_ADDED and GNC_EVENT_ITEM_REMOVED event definitions + * src/engine/Split.c: + Emit GNC_EVENT_ITEM_ADDED and GNC_EVENT_ITEM_REMOVED events + when a split is added or removed from an account. + * configure.in: depend on QOF 0.6.3 for proper event handling. + 2006-03-08 Christian Stimming * src/gnc-module/gnc-module.c, src/backend/file/sixtp-utils.c: diff --git a/configure.in b/configure.in index d58d111bfb..767d4ed3af 100644 --- a/configure.in +++ b/configure.in @@ -433,8 +433,8 @@ AC_ARG_ENABLE(qof, AC_ARG_WITH(qof, [ --with-qof=path prefix for Query Object Framework - QOF (auto)], [gnc_with_qof=$withval], [gnc_with_qof=yes]) -# bug fixes between 0.6.1 and 0.6.2 mean gnucash runs best with 0.6.2 -QOF_REQUIRED=0.6.2 +# bug fixes in QOF mean gnucash runs best with 0.6.3 +QOF_REQUIRED=0.6.3 if test "$gnc_enable_qof" = true ; then AC_MSG_CHECKING([for QOF, version >= $QOF_REQUIRED]) if test "$gnc_with_qof" != "yes"; then diff --git a/src/engine/Split.c b/src/engine/Split.c index 07061b51ab..83184ce138 100644 --- a/src/engine/Split.c +++ b/src/engine/Split.c @@ -46,6 +46,7 @@ #include "gnc-engine.h" #include "gnc-lot-p.h" #include "gnc-lot.h" +#include "gnc-event.h" const char *void_former_amt_str = "void-former-amount"; const char *void_former_val_str = "void-former-value"; @@ -517,6 +518,8 @@ xaccSplitCommitEdit(Split *s) xaccGroupMarkNotSaved (orig_acc->parent); //FIXME: find better event type qof_event_gen (&orig_acc->inst.entity, QOF_EVENT_MODIFY, NULL); + // And send the account-based event, too + qof_event_gen(&orig_acc->inst.entity, GNC_EVENT_ITEM_REMOVED, s); } else PERR("Account lost track of moved or deleted split."); orig_acc->balance_dirty = TRUE; xaccAccountRecomputeBalance(orig_acc); @@ -541,6 +544,9 @@ xaccSplitCommitEdit(Split *s) xaccGroupMarkNotSaved (acc->parent); //FIXME: probably not needed. //FIXME: find better event qof_event_gen (&acc->inst.entity, QOF_EVENT_MODIFY, NULL); + + /* Also send an event based on the account */ + qof_event_gen(&acc->inst.entity, GNC_EVENT_ITEM_ADDED, s); } else PERR("Account grabbed split prematurely."); acc->balance_dirty = TRUE; xaccSplitSetAmount(s, xaccSplitGetAmount(s)); diff --git a/src/engine/gnc-event.h b/src/engine/gnc-event.h index c5b925740c..8b17c20630 100644 --- a/src/engine/gnc-event.h +++ b/src/engine/gnc-event.h @@ -24,11 +24,17 @@ #define GNC_EVENT_H #include +#include typedef struct { gpointer node; gint idx; } GncEventData; +/* These events are used when a split is added to an account. + * The event subject is the Account, the Object is the Split. + */ +#define GNC_EVENT_ITEM_ADDED QOF_MAKE_EVENT(QOF_EVENT_BASE+0) +#define GNC_EVENT_ITEM_REMOVED QOF_MAKE_EVENT(QOF_EVENT_BASE+1) #endif