[Gnucash-changes] r13548 - gnucash/trunk - Define and emit two new events when splits are added/removed from accounts.

Derek Atkins warlord at cvs.gnucash.org
Wed Mar 8 22:58:00 EST 2006


Author: warlord
Date: 2006-03-08 22:58:00 -0500 (Wed, 08 Mar 2006)
New Revision: 13548
Trac: http://svn.gnucash.org/trac/changeset/13548

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/configure.in
   gnucash/trunk/src/engine/Split.c
   gnucash/trunk/src/engine/gnc-event.h
Log:
Define and emit two new events when splits are added/removed from accounts.

	* 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.



Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-09 03:48:49 UTC (rev 13547)
+++ gnucash/trunk/ChangeLog	2006-03-09 03:58:00 UTC (rev 13548)
@@ -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 <stimming at tuhh.de>
 
 	* src/gnc-module/gnc-module.c, src/backend/file/sixtp-utils.c:

Modified: gnucash/trunk/configure.in
===================================================================
--- gnucash/trunk/configure.in	2006-03-09 03:48:49 UTC (rev 13547)
+++ gnucash/trunk/configure.in	2006-03-09 03:58:00 UTC (rev 13548)
@@ -433,8 +433,8 @@
 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

Modified: gnucash/trunk/src/engine/Split.c
===================================================================
--- gnucash/trunk/src/engine/Split.c	2006-03-09 03:48:49 UTC (rev 13547)
+++ gnucash/trunk/src/engine/Split.c	2006-03-09 03:58:00 UTC (rev 13548)
@@ -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 @@
             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 @@
             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));

Modified: gnucash/trunk/src/engine/gnc-event.h
===================================================================
--- gnucash/trunk/src/engine/gnc-event.h	2006-03-09 03:48:49 UTC (rev 13547)
+++ gnucash/trunk/src/engine/gnc-event.h	2006-03-09 03:58:00 UTC (rev 13548)
@@ -24,11 +24,17 @@
 #define GNC_EVENT_H
 
 #include <glib.h>
+#include <qof.h>
 
 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



More information about the gnucash-changes mailing list